fixed startup configuration handling issue .

This commit is contained in:
Zero Fanker 2024-08-02 11:16:02 -04:00
parent 1b3bd71676
commit 98edf6b910
5 changed files with 35 additions and 32 deletions

View file

@ -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");

View file

@ -485,9 +485,8 @@ void CFinalSunDlg::OnCancel()
void CFinalSunDlg::OnOptionsTiberiansunoptions()
{
ShowOptionsDialog();
CIniFile optini;
ShowOptionsDialog(optini);
}
void CFinalSunDlg::OnFileOpenmap()

View file

@ -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());

View file

@ -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);
}

View file

@ -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);