fix show console state not saving

This commit is contained in:
Sam39 2022-08-18 15:57:52 +03:00
parent ee99246428
commit e9608e0f7e
2 changed files with 16 additions and 2 deletions

View File

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

View File

@ -89,9 +89,10 @@ class MySettingsFrame : public wxFrame {
void UpdateProfileDirectory(const std::string& path);
void UpdateCacheDirectory(const std::string& path);
private:
wxDirPickerCtrl* ctrlGameDirectory, *ctrlProfileDirectory, *ctrlCacheDirectory;
wxCheckBox* checkConsole;
wxDirPickerCtrl* ctrlGameDirectory, *ctrlProfileDirectory, *ctrlCacheDirectory;
wxChoice* choiceController;
bool DarkMode = wxSystemSettings::GetAppearance().IsDark();
@ -167,6 +168,7 @@ void MySettingsFrame::UpdateInfo() {
ctrlGameDirectory->SetPath(UIData::GamePath);
ctrlProfileDirectory->SetPath(UIData::ProfilePath);
ctrlCacheDirectory->SetPath(UIData::CachePath);
checkConsole->SetValue(UIData::Console);
}
/////////// Update Game Directory Function ///////////
@ -197,6 +199,7 @@ void LoadConfig() {
auto GamePath = config["GamePath"];
auto ProfilePath = config["ProfilePath"];
auto CachePath = config["CachePath"];
auto Console = config["Console"];
if (GamePath.is_string()) {
UIData::GamePath = GamePath.as_string()->get();
@ -210,6 +213,11 @@ void LoadConfig() {
UIData::CachePath = CachePath.as_string()->get();
} else wxMessageBox("Cache path not found!", "Error");
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");
} else {
std::ofstream tml("Launcher.toml");
if (tml.is_open()) {
@ -292,11 +300,16 @@ void CheckKey() {
} else UpdateKey("");
}
void WindowsConsole (bool isChecked);
/////////// OnInit Function ///////////
bool MyApp::OnInit() {
Log::Init();
LoadConfig();
CheckKey();
WindowsConsole(UIData::Console);
auto* MainFrame = new MyMainFrame();
MyMainFrame::MainFrameInstance = MainFrame;
MainFrame->SetIcon(wxIcon("icons/BeamMP_black.png",wxBITMAP_TYPE_PNG));
@ -748,6 +761,7 @@ void MySettingsFrame::OnClickConsole(wxCommandEvent& event) {
WindowsConsole(checkConsole->IsChecked());
bool status = event.IsChecked();
UpdateConfig("Console", status);
UIData::Console = status;
}
/////////// OnChanged Game Path Event ///////////