Loader : Deduplicate code via new CreateSettings()
This commit is contained in:
parent
890a5ffd2f
commit
170b971a8e
|
@ -872,6 +872,22 @@ void ImportLibraries(XbeImportEntry *pImportDirectory)
|
|||
}
|
||||
}
|
||||
|
||||
bool CreateSettings()
|
||||
{
|
||||
g_Settings = new Settings();
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!g_Settings->Init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
log_get_settings();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HandleFirstLaunch()
|
||||
{
|
||||
bool bFirstLaunch;
|
||||
|
@ -879,18 +895,10 @@ bool HandleFirstLaunch()
|
|||
|
||||
/* check if process is launch with elevated access then prompt for continue on or not. */
|
||||
if (!bFirstLaunch) {
|
||||
g_Settings = new Settings();
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
if (!CreateSettings()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!g_Settings->Init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
log_get_settings();
|
||||
|
||||
bool bElevated = CxbxIsElevated();
|
||||
if (bElevated && !g_Settings->m_core.allowAdminPrivilege) {
|
||||
int ret = MessageBox(NULL, "Cxbx-Reloaded has detected that it has been launched with Administrator rights.\n"
|
||||
|
|
|
@ -224,6 +224,8 @@ bool CxbxKrnlVerifyVersion(const char *szVersion);
|
|||
|
||||
extern bool g_bIsDebugKernel;
|
||||
|
||||
bool CreateSettings();
|
||||
|
||||
bool HandleFirstLaunch();
|
||||
|
||||
/*! Cxbx Kernel Entry Point */
|
||||
|
|
|
@ -99,19 +99,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
|
||||
// If 2nd GUI executable is launched, load settings file for GUI for editable support.
|
||||
if (g_Settings == nullptr) {
|
||||
g_Settings = new Settings();
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
if (!CreateSettings()) {
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!g_Settings->Init()) {
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
log_get_settings();
|
||||
}
|
||||
|
||||
// Possible optional output for GUI
|
||||
|
|
Loading…
Reference in New Issue