From 98edf6b9107408f1ace7b058b57c5896170125fb Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Fri, 2 Aug 2024 11:16:02 -0400 Subject: [PATCH] fixed startup configuration handling issue . --- MissionEditor/FinalSun.cpp | 21 +++++++++------------ MissionEditor/FinalSunDlg.cpp | 5 ++--- MissionEditor/TSOptions.cpp | 11 ++++++++--- MissionEditor/functions.cpp | 28 +++++++++++++++------------- MissionEditor/functions.h | 2 +- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/MissionEditor/FinalSun.cpp b/MissionEditor/FinalSun.cpp index 6c17c2a..0176588 100644 --- a/MissionEditor/FinalSun.cpp +++ b/MissionEditor/FinalSun.cpp @@ -265,27 +265,24 @@ BOOL CFinalSunApp::InitInstance() opts.TSExe = optini.GetString(game, "Exe"); } - auto const& appSec = optini[app]; + // settings incomplete if (copiedDefaultFile || optini.Size() == 0 || opts.TSExe.IsEmpty() || - appSec.GetString("Language").IsEmpty() || - !appSec.GetBool("FileSearchLikeGame") || - !appSec.GetBool("PreferLocalTheaterFiles")) { + optini[app].GetString("Language").IsEmpty() || + !optini[app].GetBool("FileSearchLikeGame") || + !optini[app].GetBool("PreferLocalTheaterFiles")) { opts.bSearchLikeTS = TRUE; - bOptionsStartup = TRUE; - ShowOptionsDialog(); + ShowOptionsDialog(optini); bOptionsStartup = FALSE; } else { - opts.LanguageName = appSec.GetString("Language"); - if (appSec.GetBool("FileSearchLikeGame")) { - opts.bSearchLikeTS = TRUE; - } else { - opts.bSearchLikeTS = FALSE; - } + opts.LanguageName = optini[app].GetString("Language"); + opts.bSearchLikeTS = optini[app].GetBool("FileSearchLikeGame"); } + + auto const& appSec = optini[app]; opts.bPreferLocalTheaterFiles = appSec.GetBool("PreferLocalTheaterFiles", opts.bPreferLocalTheaterFiles); auto const& graphSec = optini["Graphics"]; opts.bDoNotLoadAircraftGraphics = graphSec.GetBool("NoAircraftGraphics"); diff --git a/MissionEditor/FinalSunDlg.cpp b/MissionEditor/FinalSunDlg.cpp index 9026069..2eeaa71 100644 --- a/MissionEditor/FinalSunDlg.cpp +++ b/MissionEditor/FinalSunDlg.cpp @@ -485,9 +485,8 @@ void CFinalSunDlg::OnCancel() void CFinalSunDlg::OnOptionsTiberiansunoptions() { - - ShowOptionsDialog(); - + CIniFile optini; + ShowOptionsDialog(optini); } void CFinalSunDlg::OnFileOpenmap() diff --git a/MissionEditor/TSOptions.cpp b/MissionEditor/TSOptions.cpp index 4e8cd87..2f6df88 100644 --- a/MissionEditor/TSOptions.cpp +++ b/MissionEditor/TSOptions.cpp @@ -74,12 +74,17 @@ END_MESSAGE_MAP() void CTSOptions::OnChoose() { -#ifndef RA2_MODE - CFileDialog fd(TRUE, NULL, "Sun.exe", OFN_FILEMUSTEXIST, "Tiberian Sun EXE|Sun.exe|"); + const char* pFileName = "game.exe"; + const char* pFileSearchPattern = "C&C EXE|game.exe|"; +#if defined(RA2_MODE) + pFileName = yuri_mode? "ra2md.exe":"ra2.exe"; + pFileSearchPattern = yuri_mode ? "Yuri's Revenge EXE|ra2md.exe|": "Red Alert 2 EXE|ra2.exe|"; #else - CFileDialog fd(TRUE, NULL, "ra2.exe", OFN_FILEMUSTEXIST, "Red Alert 2 EXE|ra2.exe|"); + pFileName = "Sun.exe"; + pFileSearchPattern = "Tiberian Sun EXE|Sun.exe|"; #endif + CFileDialog fd(TRUE, NULL, pFileName, OFN_FILEMUSTEXIST, pFileSearchPattern); fd.DoModal(); this->GetDlgItem(IDC_EDIT1)->SetWindowText((LPCTSTR)fd.GetPathName()); diff --git a/MissionEditor/functions.cpp b/MissionEditor/functions.cpp index 263ed5d..374b010 100644 --- a/MissionEditor/functions.cpp +++ b/MissionEditor/functions.cpp @@ -311,7 +311,7 @@ void HandleParamList(CComboBox& cb, int type) } } -void ShowOptionsDialog() +void ShowOptionsDialog(CIniFile& optIni) { // show the options dialog, and save the options. @@ -324,49 +324,51 @@ void ShowOptionsDialog() #endif std::string iniFile = ""; - CIniFile optini; iniFile = u8AppDataPath; #ifndef RA2_MODE iniFile += "\\FinalSun.ini"; #else iniFile += "\\FinalAlert.ini"; #endif - optini.LoadFile(iniFile); + optIni.LoadFile(iniFile); CTSOptions opt; opt.m_TSEXE = theApp.m_Options.TSExe; - if (opt.DoModal() == IDCANCEL) return; + if (opt.DoModal() == IDCANCEL) { + return; + } theApp.m_Options.TSExe = opt.m_TSEXE; - optini.SetString(game, "Exe", theApp.m_Options.TSExe); - optini.SetString(app, "Language", opt.m_LanguageName); + optIni.SetString(game, "Exe", theApp.m_Options.TSExe); + optIni.SetString(app, "Language", opt.m_LanguageName); BOOL bOldSearch = theApp.m_Options.bSearchLikeTS; if (!(opt.m_LikeTS == 1)) { - optini.SetString(app, "FileSearchLikeGame", "yes"); + optIni.SetString(app, "FileSearchLikeGame", "yes"); theApp.m_Options.bSearchLikeTS = TRUE; } else { theApp.m_Options.bSearchLikeTS = FALSE; - optini.SetString(app, "FileSearchLikeGame", "no"); + optIni.SetString(app, "FileSearchLikeGame", "no"); } auto bOldPreferLocalTheaterFiles = theApp.m_Options.bPreferLocalTheaterFiles; theApp.m_Options.bPreferLocalTheaterFiles = opt.m_PreferLocalTheaterFiles ? true : false; - optini.SetString(app, "PreferLocalTheaterFiles", theApp.m_Options.bPreferLocalTheaterFiles ? "1" : "0"); + optIni.SetString(app, "PreferLocalTheaterFiles", theApp.m_Options.bPreferLocalTheaterFiles ? "1" : "0"); if ( ( (bOldPreferLocalTheaterFiles != theApp.m_Options.bPreferLocalTheaterFiles) || (bOldSearch != theApp.m_Options.bSearchLikeTS) - ) && bOptionsStartup == FALSE) + ) && bOptionsStartup == FALSE) { MessageBox(0, GetLanguageStringACP("RestartNeeded"), "Restart", 0); + } CString oldLang = theApp.m_Options.LanguageName; theApp.m_Options.LanguageName = opt.m_LanguageName; - if (oldLang != theApp.m_Options.LanguageName && theApp.m_pMainWnd != NULL && theApp.m_pMainWnd->m_hWnd != NULL) + if (oldLang != theApp.m_Options.LanguageName && theApp.m_pMainWnd != NULL && theApp.m_pMainWnd->m_hWnd != NULL) { ((CFinalSunDlg*)theApp.m_pMainWnd)->UpdateStrings(); - - optini.SaveFile(iniFile); + } + optIni.SaveFile(iniFile); } diff --git a/MissionEditor/functions.h b/MissionEditor/functions.h index da7ed88..1a88026 100644 --- a/MissionEditor/functions.h +++ b/MissionEditor/functions.h @@ -41,7 +41,7 @@ CString TranslateStringVariables(int n, const char* originaltext, const char* in CString TranslateHouse(CString original, BOOL bToUI = FALSE); // show options dialog -void ShowOptionsDialog(); +void ShowOptionsDialog(CIniFile& optIni); // repairs a trigger (sets flags correctly) bool RepairTrigger(CString& triggerdata);