fix build state not saving

This commit is contained in:
Sam39 2022-08-18 16:18:39 +03:00
parent e9608e0f7e
commit 53fffdb802
2 changed files with 8 additions and 3 deletions

View File

@ -102,7 +102,7 @@ class ShutdownException : public std::runtime_error {
};
struct UIData {
static inline std::string GamePath, ProfilePath, CachePath, PublicKey, UserRole, Username;
static inline std::string GamePath, ProfilePath, CachePath, Build, PublicKey, UserRole, Username;
static inline bool LoginAuth{false}, Console{false};

View File

@ -169,6 +169,7 @@ void MySettingsFrame::UpdateInfo() {
ctrlProfileDirectory->SetPath(UIData::ProfilePath);
ctrlCacheDirectory->SetPath(UIData::CachePath);
checkConsole->SetValue(UIData::Console);
choiceController->SetStringSelection(UIData::Build);
}
/////////// Update Game Directory Function ///////////
@ -195,7 +196,7 @@ void LoadConfig() {
if (fs::exists("Launcher.toml")) {
toml::parse_result config = toml::parse_file("Launcher.toml");
auto ui = config["UI"];
auto build = config["Build"];
auto Build = config["Build"];
auto GamePath = config["GamePath"];
auto ProfilePath = config["ProfilePath"];
auto CachePath = config["CachePath"];
@ -215,9 +216,12 @@ void LoadConfig() {
if (Console.is_boolean()) {
UIData::Console = Console.as_boolean()->get();
wxMessageBox(std::to_string(UIData::Console), "DEBUG");
} else wxMessageBox("Unable to retrieve console state!", "Error");
if (Build.is_string()) {
UIData::Build = Build.as_string()->get();
} else wxMessageBox("Unable to retrieve build state!", "Error");
} else {
std::ofstream tml("Launcher.toml");
if (tml.is_open()) {
@ -792,6 +796,7 @@ void MySettingsFrame::OnChangedCacheDir(wxFileDirPickerEvent& event) {
void MySettingsFrame::OnChangedBuild(wxCommandEvent& event) {
std::string key = reinterpret_cast<wxChoice*> (event.GetEventObject())->GetString(event.GetSelection());
UpdateConfig("Build", key);
UIData::Build = key;
}
/////////// AutoDetect Game Function ///////////