1+ #include < QDir>
12#include < QLineEdit>
2- #include < QFile>
33#include < QMessageBox>
44
5+ #include " ../Parsers/CSFParser.hpp"
56#include " ../Windows/Registry.hpp"
67#include " ../Logger.hpp"
8+ #include " ../Exception.hpp"
79#include " WindowManager.hpp"
810#include " ImageManager.hpp"
911#include " LoadFromTheGameWindow.hpp"
@@ -122,18 +124,8 @@ void SetUpWindowsWrapper::BtnBack_Clicked() { WINDOW_MANAGER->SetCSFFile
122124
123125void SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration ()
124126{
125- // TODO: Make it load vanila Generals
126- // Also as search in all big-archives (see more at GZH source code)
127127 const QString gamePath = QString::fromStdWString (Windows::Registry::GetPathToGame (Windows::Registry::Games::GeneralsZeroHour));
128128 const QString pathDataEngGenCsf = gamePath + " Data\\ English\\ generals.csf" ;
129- const QString pathEngBig = gamePath + " \\ EnglishZH.big" ;
130-
131- if (!QFile::exists (pathDataEngGenCsf) && !QFile::exists (pathEngBig))
132- {
133- QMessageBox::critical (nullptr , L10N (PROGRAM_CONSTANTS->GMFILES_SRCH_ERR_HEADER ),
134- L10N (PROGRAM_CONSTANTS->BIG_NO_ENGLISH_ZH ).arg (pathEngBig));
135- return ;
136- }
137129
138130 if (QFile::exists (pathDataEngGenCsf))
139131 {
@@ -142,8 +134,31 @@ void SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration()
142134 else
143135 {
144136 LOGMSG (" Unable to find " + pathDataEngGenCsf);
145- LOGMSG (" Loading " + pathEngBig + " ..." );
146- WINDOW_MANAGER->SetCSFFilePath (pathEngBig);
137+ LOGMSG (" Searching generals.csf in all archives" );
138+
139+ QDir gameDir (gamePath);
140+ QFileInfoList fileList = gameDir.entryInfoList (QDir::Filter::Files
141+ | QDir::Filter::NoDotAndDotDot
142+ | QDir::Filter::Readable,
143+ QDir::SortFlag::Name);
144+ for (const QFileInfo& elem : fileList)
145+ {
146+ if (elem.suffix ().toUpper () != " BIG" )
147+ continue ;
148+
149+ LOGMSG (" Processing " + elem.absoluteFilePath () + " ..." );
150+ try
151+ {
152+ CSFParser parser (elem.absoluteFilePath ());
153+ WINDOW_MANAGER->SetCSFFilePath (elem.absoluteFilePath ());
154+ break ;
155+ }
156+ catch (...)
157+ {
158+ LOGMSG (" String table doesn't exist in archive" );
159+ continue ;
160+ }
161+ }
147162 }
148163
149164 WINDOW_MANAGER->StartUpWindow_AcceptConfiguration ();
0 commit comments