Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows default to non-portable + Reworked MLC handling and related UI #1252

Merged
merged 6 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions src/config/ActiveSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,47 @@
#include "config/LaunchSettings.h"
#include "util/helpers/helpers.h"

std::set<fs::path>
ActiveSettings::LoadOnce(
const fs::path& executablePath,
const fs::path& userDataPath,
const fs::path& configPath,
const fs::path& cachePath,
const fs::path& dataPath)
void ActiveSettings::SetPaths(bool isPortableMode,
const fs::path& executablePath,
const fs::path& userDataPath,
const fs::path& configPath,
const fs::path& cachePath,
const fs::path& dataPath,
std::set<fs::path>& failedWriteAccess)
{
cemu_assert_debug(!s_setPathsCalled); // can only change paths before loading
s_isPortableMode = isPortableMode;
s_executable_path = executablePath;
s_user_data_path = userDataPath;
s_config_path = configPath;
s_cache_path = cachePath;
s_data_path = dataPath;
std::set<fs::path> failed_write_access;
failedWriteAccess.clear();
for (auto&& path : {userDataPath, configPath, cachePath})
{
if (!fs::exists(path))
{
std::error_code ec;
std::error_code ec;
if (!fs::exists(path, ec))
fs::create_directories(path, ec);
}
if (!TestWriteAccess(path))
{
cemuLog_log(LogType::Force, "Failed to write to {}", _pathToUtf8(path));
failed_write_access.insert(path);
failedWriteAccess.insert(path);
}
}

s_executable_filename = s_executable_path.filename();
s_setPathsCalled = true;
}

[[nodiscard]] bool ActiveSettings::IsPortableMode()
{
return s_isPortableMode;
}

g_config.SetFilename(GetConfigPath("settings.xml").generic_wstring());
g_config.Load();
void ActiveSettings::Init()
{
cemu_assert_debug(s_setPathsCalled);
std::string additionalErrorInfo;
s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK;
return failed_write_access;
}

bool ActiveSettings::LoadSharedLibrariesEnabled()
Expand Down Expand Up @@ -229,6 +235,7 @@ bool ActiveSettings::ForceSamplerRoundToPrecision()

fs::path ActiveSettings::GetMlcPath()
{
cemu_assert_debug(s_setPathsCalled);
if(const auto launch_mlc = LaunchSettings::GetMLCPath(); launch_mlc.has_value())
return launch_mlc.value();

Expand All @@ -238,6 +245,17 @@ fs::path ActiveSettings::GetMlcPath()
return GetDefaultMLCPath();
}

bool ActiveSettings::IsCustomMlcPath()
{
cemu_assert_debug(s_setPathsCalled);
return !GetConfig().mlc_path.GetValue().empty();
}

bool ActiveSettings::IsCommandLineMlcPath()
{
return LaunchSettings::GetMLCPath().has_value();
}

fs::path ActiveSettings::GetDefaultMLCPath()
{
return GetUserDataPath("mlc01");
Expand Down
23 changes: 17 additions & 6 deletions src/config/ActiveSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ class ActiveSettings

public:
// Set directories and return all directories that failed write access test
static std::set<fs::path>
LoadOnce(const fs::path& executablePath,
const fs::path& userDataPath,
const fs::path& configPath,
const fs::path& cachePath,
const fs::path& dataPath);
static void
SetPaths(bool isPortableMode,
const fs::path& executablePath,
const fs::path& userDataPath,
const fs::path& configPath,
const fs::path& cachePath,
const fs::path& dataPath,
std::set<fs::path>& failedWriteAccess);

static void Init();

[[nodiscard]] static fs::path GetExecutablePath() { return s_executable_path; }
[[nodiscard]] static fs::path GetExecutableFilename() { return s_executable_filename; }
Expand All @@ -56,11 +60,14 @@ class ActiveSettings

template <typename ...TArgs>
[[nodiscard]] static fs::path GetMlcPath(TArgs&&... args){ return GetPath(GetMlcPath(), std::forward<TArgs>(args)...); };
static bool IsCustomMlcPath();
static bool IsCommandLineMlcPath();

// get mlc path to default cemu root dir/mlc01
[[nodiscard]] static fs::path GetDefaultMLCPath();

private:
inline static bool s_isPortableMode{false};
inline static fs::path s_executable_path;
inline static fs::path s_user_data_path;
inline static fs::path s_config_path;
Expand All @@ -70,6 +77,9 @@ class ActiveSettings
inline static fs::path s_mlc_path;

public:
// can be called before Init
[[nodiscard]] static bool IsPortableMode();

// general
[[nodiscard]] static bool LoadSharedLibrariesEnabled();
[[nodiscard]] static bool DisplayDRCEnabled();
Expand Down Expand Up @@ -111,6 +121,7 @@ class ActiveSettings
[[nodiscard]] static bool ForceSamplerRoundToPrecision();

private:
inline static bool s_setPathsCalled = false;
// dump options
inline static bool s_dump_shaders = false;
inline static bool s_dump_textures = false;
Expand Down
4 changes: 0 additions & 4 deletions src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ add_library(CemuConfig
LaunchSettings.h
NetworkSettings.cpp
NetworkSettings.h
PermanentConfig.cpp
PermanentConfig.h
PermanentStorage.cpp
PermanentStorage.h
XMLConfig.h
)

Expand Down
18 changes: 0 additions & 18 deletions src/config/CemuConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <wx/language.h>

#include "PermanentConfig.h"
#include "ActiveSettings.h"

XMLCemuConfig_t g_config(L"settings.xml");
Expand All @@ -15,23 +14,6 @@ void CemuConfig::SetMLCPath(fs::path path, bool save)
mlc_path.SetValue(_pathToUtf8(path));
if(save)
g_config.Save();

// if custom mlc path has been selected, store it in permanent config
if (path != ActiveSettings::GetDefaultMLCPath())
{
try
{
auto pconfig = PermanentConfig::Load();
pconfig.custom_mlc_path = _pathToUtf8(path);
pconfig.Store();
}
catch (const PSDisabledException&) {}
catch (const std::exception& ex)
{
cemuLog_log(LogType::Force, "can't store custom mlc path in permanent storage: {}", ex.what());
}
}

Account::RefreshAccounts();
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/CemuConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ struct CemuConfig
ConfigValue<bool> save_screenshot{true};

ConfigValue<bool> did_show_vulkan_warning{false};
ConfigValue<bool> did_show_graphic_pack_download{false};
ConfigValue<bool> did_show_graphic_pack_download{false}; // no longer used but we keep the config value around in case people downgrade Cemu. Despite the name this was used for the Getting Started dialog
ConfigValue<bool> did_show_macos_disclaimer{false};

ConfigValue<bool> show_icon_column{ true };
Expand Down
65 changes: 0 additions & 65 deletions src/config/PermanentConfig.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions src/config/PermanentConfig.h

This file was deleted.

76 changes: 0 additions & 76 deletions src/config/PermanentStorage.cpp

This file was deleted.

27 changes: 0 additions & 27 deletions src/config/PermanentStorage.h

This file was deleted.

Loading
Loading