Skip to content

Commit 64232ff

Browse files
authored
Windows default to non-portable + Reworked MLC handling and related UI (#1252)
1 parent 7522c84 commit 64232ff

18 files changed

+514
-650
lines changed

src/config/ActiveSettings.cpp

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,47 @@
77
#include "config/LaunchSettings.h"
88
#include "util/helpers/helpers.h"
99

10-
std::set<fs::path>
11-
ActiveSettings::LoadOnce(
12-
const fs::path& executablePath,
13-
const fs::path& userDataPath,
14-
const fs::path& configPath,
15-
const fs::path& cachePath,
16-
const fs::path& dataPath)
10+
void ActiveSettings::SetPaths(bool isPortableMode,
11+
const fs::path& executablePath,
12+
const fs::path& userDataPath,
13+
const fs::path& configPath,
14+
const fs::path& cachePath,
15+
const fs::path& dataPath,
16+
std::set<fs::path>& failedWriteAccess)
1717
{
18+
cemu_assert_debug(!s_setPathsCalled); // can only change paths before loading
19+
s_isPortableMode = isPortableMode;
1820
s_executable_path = executablePath;
1921
s_user_data_path = userDataPath;
2022
s_config_path = configPath;
2123
s_cache_path = cachePath;
2224
s_data_path = dataPath;
23-
std::set<fs::path> failed_write_access;
25+
failedWriteAccess.clear();
2426
for (auto&& path : {userDataPath, configPath, cachePath})
2527
{
26-
if (!fs::exists(path))
27-
{
28-
std::error_code ec;
28+
std::error_code ec;
29+
if (!fs::exists(path, ec))
2930
fs::create_directories(path, ec);
30-
}
3131
if (!TestWriteAccess(path))
3232
{
3333
cemuLog_log(LogType::Force, "Failed to write to {}", _pathToUtf8(path));
34-
failed_write_access.insert(path);
34+
failedWriteAccess.insert(path);
3535
}
3636
}
37-
3837
s_executable_filename = s_executable_path.filename();
38+
s_setPathsCalled = true;
39+
}
40+
41+
[[nodiscard]] bool ActiveSettings::IsPortableMode()
42+
{
43+
return s_isPortableMode;
44+
}
3945

40-
g_config.SetFilename(GetConfigPath("settings.xml").generic_wstring());
41-
g_config.Load();
46+
void ActiveSettings::Init()
47+
{
48+
cemu_assert_debug(s_setPathsCalled);
4249
std::string additionalErrorInfo;
4350
s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK;
44-
return failed_write_access;
4551
}
4652

4753
bool ActiveSettings::LoadSharedLibrariesEnabled()
@@ -229,6 +235,7 @@ bool ActiveSettings::ForceSamplerRoundToPrecision()
229235

230236
fs::path ActiveSettings::GetMlcPath()
231237
{
238+
cemu_assert_debug(s_setPathsCalled);
232239
if(const auto launch_mlc = LaunchSettings::GetMLCPath(); launch_mlc.has_value())
233240
return launch_mlc.value();
234241

@@ -238,6 +245,17 @@ fs::path ActiveSettings::GetMlcPath()
238245
return GetDefaultMLCPath();
239246
}
240247

248+
bool ActiveSettings::IsCustomMlcPath()
249+
{
250+
cemu_assert_debug(s_setPathsCalled);
251+
return !GetConfig().mlc_path.GetValue().empty();
252+
}
253+
254+
bool ActiveSettings::IsCommandLineMlcPath()
255+
{
256+
return LaunchSettings::GetMLCPath().has_value();
257+
}
258+
241259
fs::path ActiveSettings::GetDefaultMLCPath()
242260
{
243261
return GetUserDataPath("mlc01");

src/config/ActiveSettings.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ class ActiveSettings
3434

3535
public:
3636
// Set directories and return all directories that failed write access test
37-
static std::set<fs::path>
38-
LoadOnce(const fs::path& executablePath,
39-
const fs::path& userDataPath,
40-
const fs::path& configPath,
41-
const fs::path& cachePath,
42-
const fs::path& dataPath);
37+
static void
38+
SetPaths(bool isPortableMode,
39+
const fs::path& executablePath,
40+
const fs::path& userDataPath,
41+
const fs::path& configPath,
42+
const fs::path& cachePath,
43+
const fs::path& dataPath,
44+
std::set<fs::path>& failedWriteAccess);
45+
46+
static void Init();
4347

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

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

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

6369
private:
70+
inline static bool s_isPortableMode{false};
6471
inline static fs::path s_executable_path;
6572
inline static fs::path s_user_data_path;
6673
inline static fs::path s_config_path;
@@ -70,6 +77,9 @@ class ActiveSettings
7077
inline static fs::path s_mlc_path;
7178

7279
public:
80+
// can be called before Init
81+
[[nodiscard]] static bool IsPortableMode();
82+
7383
// general
7484
[[nodiscard]] static bool LoadSharedLibrariesEnabled();
7585
[[nodiscard]] static bool DisplayDRCEnabled();
@@ -111,6 +121,7 @@ class ActiveSettings
111121
[[nodiscard]] static bool ForceSamplerRoundToPrecision();
112122

113123
private:
124+
inline static bool s_setPathsCalled = false;
114125
// dump options
115126
inline static bool s_dump_shaders = false;
116127
inline static bool s_dump_textures = false;

src/config/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ add_library(CemuConfig
88
LaunchSettings.h
99
NetworkSettings.cpp
1010
NetworkSettings.h
11-
PermanentConfig.cpp
12-
PermanentConfig.h
13-
PermanentStorage.cpp
14-
PermanentStorage.h
1511
XMLConfig.h
1612
)
1713

src/config/CemuConfig.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include <wx/language.h>
77

8-
#include "PermanentConfig.h"
98
#include "ActiveSettings.h"
109

1110
XMLCemuConfig_t g_config(L"settings.xml");
@@ -15,23 +14,6 @@ void CemuConfig::SetMLCPath(fs::path path, bool save)
1514
mlc_path.SetValue(_pathToUtf8(path));
1615
if(save)
1716
g_config.Save();
18-
19-
// if custom mlc path has been selected, store it in permanent config
20-
if (path != ActiveSettings::GetDefaultMLCPath())
21-
{
22-
try
23-
{
24-
auto pconfig = PermanentConfig::Load();
25-
pconfig.custom_mlc_path = _pathToUtf8(path);
26-
pconfig.Store();
27-
}
28-
catch (const PSDisabledException&) {}
29-
catch (const std::exception& ex)
30-
{
31-
cemuLog_log(LogType::Force, "can't store custom mlc path in permanent storage: {}", ex.what());
32-
}
33-
}
34-
3517
Account::RefreshAccounts();
3618
}
3719

src/config/CemuConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ struct CemuConfig
417417
ConfigValue<bool> save_screenshot{true};
418418

419419
ConfigValue<bool> did_show_vulkan_warning{false};
420-
ConfigValue<bool> did_show_graphic_pack_download{false};
420+
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
421421
ConfigValue<bool> did_show_macos_disclaimer{false};
422422

423423
ConfigValue<bool> show_icon_column{ true };

src/config/PermanentConfig.cpp

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/config/PermanentConfig.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/config/PermanentStorage.cpp

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/config/PermanentStorage.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)