Skip to content

Commit

Permalink
serialize config in cmain
Browse files Browse the repository at this point in the history
ambiennt committed Oct 23, 2022
1 parent 24001b1 commit 40a9394
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/cApp.cpp
Original file line number Diff line number Diff line change
@@ -8,11 +8,6 @@ bool cApp::OnInit() {
char* shut_up_VS = _getcwd(Globals::WORKING_DIR, FILENAME_MAX);

CMAIN_INSTANCE = new cMain();

if (!CMAIN_INSTANCE->cfg.serializeConfig()) { //if error
CMAIN_INSTANCE->cfg.updateConfigFile();
}

CMAIN_INSTANCE->Show();
return true;
}
11 changes: 8 additions & 3 deletions src/cMain.cpp
Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ wxEND_EVENT_TABLE();
cMain::cMain() : wxFrame(nullptr, wxID_ANY, "MCBE DLL Injector", wxDefaultPosition, wxSize(297.5, 162.5),
wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) {

if (!this->cfg.serializeConfig()) { // if error
this->cfg.updateConfigFile();
}

wxIcon icon(icon_xpm);
this->SetIcon(icon);

@@ -40,8 +44,6 @@ cMain::cMain() : wxFrame(nullptr, wxID_ANY, "MCBE DLL Injector", wxDefaultPositi
this->check_CustomTarget->SetValue(false);
this->txt_ProcName->Disable();
}

this->txt_ProcName->SetLabel(Globals::PROC_NAME);

this->openDialog = new wxFileDialog(this, "Select the .dll file", Globals::WORKING_DIR, "*.dll" ,"Dynamic link library (*.dll)|*.dll", wxFD_OPEN);
}
@@ -51,8 +53,11 @@ cMain::~cMain() {
}

void cMain::updateGlobalVars() {
static const std::wstring EMPTY_WSTR = std::wstring{};
auto pathStr = this->txt_DllPath->GetValue();

Globals::USE_CUSTOM_PROC_NAME = this->check_CustomTarget->GetValue();
Globals::DLL_PATH = this->txt_DllPath->GetValue();
Globals::DLL_PATH = ((pathStr == Globals::NO_DLL_PATH_SELECTED_MSG) ? EMPTY_WSTR : pathStr); // so we done save this to config later on
Globals::PROC_NAME = this->txt_ProcName->GetValue();
}

0 comments on commit 40a9394

Please sign in to comment.