Skip to content

Commit 4cd2d1c

Browse files
Implement parsing .csf files from .big archives
1 parent dc998b2 commit 4cd2d1c

File tree

7 files changed

+169
-199
lines changed

7 files changed

+169
-199
lines changed

src/GUI/LoadFromTheFileWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LoadFromTheFileWindow::LoadFromTheFileWindow(QWidget* parent) : QWidget(parent)
1717
QPushButton* btnCancel = new QPushButton(tr("BACK"));
1818
QHBoxLayout* ltBtnOk = new QHBoxLayout();
1919
QHBoxLayout* ltBtnCancel = new QHBoxLayout();
20-
QLabel* lblSelectFile = new QLabel(tr("Select .csf file:"));
20+
QLabel* lblSelectFile = new QLabel(tr("Select .csf or .big file:"));
2121

2222
btnOk->setObjectName(nameof(btnOk));
2323
btnOk->setFixedWidth(80);
@@ -47,7 +47,7 @@ LoadFromTheFileWindow::LoadFromTheFileWindow(QWidget* parent) : QWidget(parent)
4747
QFileDialog* fileDialog = new QFileDialog(); // dialog for selecting the path to the file
4848
fileDialog->setFileMode(QFileDialog::FileMode::ExistingFile);
4949
fileDialog->setAcceptMode(QFileDialog::AcceptMode::AcceptOpen);
50-
fileDialog->setNameFilters({tr("Binary files") + " (*.csf)",
50+
fileDialog->setNameFilters({tr("Binary files") + " (*.csf, *.big)",
5151
tr("Any files") + " (*)"});
5252
connect(fileDialog, &QFileDialog::fileSelected, lneFilePath, &QLineEdit::setText);
5353

src/GUI/SetUpWindowsWrapper.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,22 @@ void SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration()
125125
// TODO: Make it load vanila Generals
126126
// Also as work with non-ascii paths
127127
// Also as search in big-archives (see more at GZH source code)
128-
QString path = QString::fromStdString(Registry::GetPathToGame(Registry::Games::GeneralsZeroHour)) + "Data\\English\\generals.csf";
129-
130-
if (!QFile::exists(path))
128+
QString gamePath = QString::fromStdString(Registry::GetPathToGame(Registry::Games::GeneralsZeroHour));
129+
QString pathDataEngGenCsf = gamePath + "Data\\English\\generals.csf";
130+
QString pathEngBig = gamePath + "\\EnglishZH.big";
131+
132+
if (!QFile::exists(pathDataEngGenCsf) && !QFile::exists(pathEngBig))
131133
{
132-
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->CSF_ERROR_HEADER),
133-
L10N(PROGRAM_CONSTANTS->CSF_EMPTY_DATA_ENGLISH));
134+
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->GMFILES_SRCH_ERR_HEADER),
135+
L10N(PROGRAM_CONSTANTS->BIG_NO_ENGLISH_ZH).arg(pathEngBig));
134136
return;
135137
}
138+
139+
if (QFile::exists(pathDataEngGenCsf))
140+
WINDOW_MANAGER->SetCSFFilePath(pathDataEngGenCsf);
141+
else
142+
WINDOW_MANAGER->SetCSFFilePath(pathEngBig);
136143

137-
WINDOW_MANAGER->SetCSFFilePath(path);
138144
WINDOW_MANAGER->StartUpWindow_AcceptConfiguration();
139145
}
140146

src/GUI/Translations/ru.ts

Lines changed: 53 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -40,89 +40,89 @@
4040
<message>
4141
<location filename="../EditorWindow.cpp" line="168"/>
4242
<source>File</source>
43-
<translation type="unfinished">Файл</translation>
43+
<translation>Файл</translation>
4444
</message>
4545
<message>
4646
<location filename="../EditorWindow.cpp" line="169"/>
4747
<source>Open</source>
48-
<translation type="unfinished">Открыть</translation>
48+
<translation>Открыть</translation>
4949
</message>
5050
<message>
5151
<location filename="../EditorWindow.cpp" line="170"/>
5252
<source>Save</source>
53-
<translation type="unfinished">Сохранить</translation>
53+
<translation>Сохранить</translation>
5454
</message>
5555
<message>
5656
<location filename="../EditorWindow.cpp" line="171"/>
5757
<source>Save As...</source>
58-
<translation type="unfinished">Сохранить как...</translation>
58+
<translation>Сохранить как...</translation>
5959
</message>
6060
<message>
6161
<location filename="../EditorWindow.cpp" line="172"/>
6262
<source>Special</source>
63-
<translation type="unfinished">Дополнительно</translation>
63+
<translation>Дополнительно</translation>
6464
</message>
6565
<message>
6666
<location filename="../EditorWindow.cpp" line="183"/>
6767
<source>View</source>
68-
<translation type="unfinished">Вид</translation>
68+
<translation>Вид</translation>
6969
</message>
7070
<message>
7171
<location filename="../EditorWindow.cpp" line="184"/>
7272
<source>Status Bar</source>
73-
<translation type="unfinished">Строка состояния</translation>
73+
<translation>Строка состояния</translation>
7474
</message>
7575
<message>
7676
<location filename="../EditorWindow.cpp" line="185"/>
7777
<source>Enable</source>
78-
<translation type="unfinished">Включить</translation>
78+
<translation>Включить</translation>
7979
</message>
8080
<message>
8181
<location filename="../EditorWindow.cpp" line="186"/>
8282
<source>Disable</source>
83-
<translation type="unfinished">Отключить</translation>
83+
<translation>Отключить</translation>
8484
</message>
8585
<message>
8686
<location filename="../EditorWindow.cpp" line="190"/>
8787
<location filename="../EditorWindow.cpp" line="510"/>
8888
<source>Settings</source>
89-
<translation type="unfinished">Настройки</translation>
89+
<translation>Настройки</translation>
9090
</message>
9191
<message>
9292
<location filename="../EditorWindow.cpp" line="194"/>
9393
<location filename="../EditorWindow.cpp" line="475"/>
9494
<source>About</source>
95-
<translation type="unfinished">О программе</translation>
95+
<translation>О программе</translation>
9696
</message>
9797
<message>
9898
<location filename="../EditorWindow.cpp" line="325"/>
9999
<source>Layout %1</source>
100-
<translation type="unfinished">Раскладка %1</translation>
100+
<translation>Раскладка %1</translation>
101101
</message>
102102
<message>
103103
<location filename="../EditorWindow.cpp" line="455"/>
104104
<source>Authors: </source>
105-
<translation type="unfinished">Авторы: </translation>
105+
<translation>Авторы: </translation>
106106
</message>
107107
<message>
108108
<location filename="../EditorWindow.cpp" line="456"/>
109109
<source>Version: </source>
110-
<translation type="unfinished">Версия: </translation>
110+
<translation>Версия: </translation>
111111
</message>
112112
<message>
113113
<location filename="../EditorWindow.cpp" line="457"/>
114114
<source>Program licensed with </source>
115-
<translation type="unfinished">Программа лицензирована под </translation>
115+
<translation>Программа лицензирована под </translation>
116116
</message>
117117
<message>
118118
<location filename="../EditorWindow.cpp" line="458"/>
119119
<source>GitHub repository:</source>
120-
<translation type="unfinished">Репозиторий на GitHub:</translation>
120+
<translation>Репозиторий на GitHub:</translation>
121121
</message>
122122
<message>
123123
<location filename="../EditorWindow.cpp" line="460"/>
124124
<source>Support development:</source>
125-
<translation type="unfinished">Поддержать разработку:</translation>
125+
<translation>Поддержать разработку:</translation>
126126
</message>
127127
</context>
128128
<context>
@@ -160,109 +160,6 @@
160160
<translation type="vanished">ЯЗЫК</translation>
161161
</message>
162162
</context>
163-
<context>
164-
<name>HotkeysMainWindow</name>
165-
<message>
166-
<source>File</source>
167-
<translation type="vanished">Файл</translation>
168-
</message>
169-
<message>
170-
<source>Open</source>
171-
<translation type="vanished">Открыть</translation>
172-
</message>
173-
<message>
174-
<source>Save</source>
175-
<translation type="vanished">Сохранить</translation>
176-
</message>
177-
<message>
178-
<source>Save As...</source>
179-
<translation type="vanished">Сохранить как...</translation>
180-
</message>
181-
<message>
182-
<source>Special</source>
183-
<translation type="vanished">Дополнительно</translation>
184-
</message>
185-
<message>
186-
<source>View</source>
187-
<translation type="vanished">Вид</translation>
188-
</message>
189-
<message>
190-
<source>Status Bar</source>
191-
<translation type="vanished">Строка состояния</translation>
192-
</message>
193-
<message>
194-
<source>Enable</source>
195-
<translation type="vanished">Включить</translation>
196-
</message>
197-
<message>
198-
<source>Disable</source>
199-
<translation type="vanished">Отключить</translation>
200-
</message>
201-
<message>
202-
<source>Settings</source>
203-
<translation type="vanished">Настройки</translation>
204-
</message>
205-
<message>
206-
<source>Language</source>
207-
<translation type="vanished">Язык</translation>
208-
</message>
209-
<message>
210-
<source>About</source>
211-
<translation type="vanished">О программе</translation>
212-
</message>
213-
<message>
214-
<source>Layout %1</source>
215-
<translation type="vanished">Раскладка %1</translation>
216-
</message>
217-
<message>
218-
<source>Authors: </source>
219-
<translation type="vanished">Авторы: </translation>
220-
</message>
221-
<message>
222-
<source>Version: </source>
223-
<translation type="vanished">Версия: </translation>
224-
</message>
225-
<message>
226-
<source>Program licensed with </source>
227-
<translation type="vanished">Программа лицензирована под </translation>
228-
</message>
229-
<message>
230-
<source>GitHub repository:</source>
231-
<translation type="vanished">Репозиторий на GitHub:</translation>
232-
</message>
233-
<message>
234-
<source>Support development:</source>
235-
<translation type="vanished">Поддержать разработку:</translation>
236-
</message>
237-
<message>
238-
<source>Lanugage</source>
239-
<translation type="vanished">Язык</translation>
240-
</message>
241-
<message>
242-
<source>LANGUAGE</source>
243-
<translation type="vanished">ЯЗЫК</translation>
244-
</message>
245-
<message>
246-
<source>OK</source>
247-
<translation type="vanished">Ок</translation>
248-
</message>
249-
<message>
250-
<source>Cancel</source>
251-
<translation type="vanished">Отмена</translation>
252-
</message>
253-
<message>
254-
<source>Program licensed by GNU GPL v3</source>
255-
<translation type="vanished">Программа лицензирована под лицензией GNU GPL v3</translation>
256-
</message>
257-
<message>
258-
<source>GitHub Repository</source>
259-
<translation type="vanished">Репозиторий на GitHub</translation>
260-
</message>
261-
<message>
262-
<source>&lt;a href=&quot;https://github.com/MahBoiDeveloper/GZHHotkeysEditor&quot;&gt;GitHub Repository&lt;/a&gt;</source>
263-
<translation type="vanished">&lt;a href=&quot;https://github.com/MahBoiDeveloper/GZHHotkeysEditor&quot;&gt;Репозиторий на GitHub&lt;/a&gt;</translation>
264-
</message>
265-
</context>
266163
<context>
267164
<name>LoadFromTheFileWindow</name>
268165
<message>
@@ -280,9 +177,13 @@
280177
<translation type="obsolete">Текстовые файлы</translation>
281178
</message>
282179
<message>
283-
<location filename="../LoadFromTheFileWindow.cpp" line="20"/>
284180
<source>Select .csf file:</source>
285-
<translation>Выберите .csf файл:</translation>
181+
<translation type="vanished">Выберите .csf файл:</translation>
182+
</message>
183+
<message>
184+
<location filename="../LoadFromTheFileWindow.cpp" line="20"/>
185+
<source>Select .csf or .big file:</source>
186+
<translation>Выберите .csf или .big файл:</translation>
286187
</message>
287188
<message>
288189
<location filename="../LoadFromTheFileWindow.cpp" line="50"/>
@@ -352,17 +253,17 @@
352253
<translation type="vanished">Возникла неизвестная ошибка</translation>
353254
</message>
354255
<message>
355-
<location filename="../../ProgramConstants.hpp" line="72"/>
256+
<location filename="../../ProgramConstants.hpp" line="73"/>
356257
<source>Error with CSF file</source>
357258
<translation>Ошибка с CSF файлом</translation>
358259
</message>
359260
<message>
360-
<location filename="../../ProgramConstants.hpp" line="73"/>
261+
<location filename="../../ProgramConstants.hpp" line="74"/>
361262
<source>Cannot process the empty file.</source>
362263
<translation>Невозможно обработать пустой файл.</translation>
363264
</message>
364265
<message>
365-
<location filename="../../ProgramConstants.hpp" line="74"/>
266+
<location filename="../../ProgramConstants.hpp" line="75"/>
366267
<source>Unable to find selected CSF file.</source>
367268
<translation>Невозможно найти указанный CSF файл.</translation>
368269
</message>
@@ -373,7 +274,7 @@ Make sure that you are load correct file.</source>
373274
Проверьте, что вы загружаете правильный файл.</translation>
374275
</message>
375276
<message>
376-
<location filename="../../ProgramConstants.hpp" line="75"/>
277+
<location filename="../../ProgramConstants.hpp" line="76"/>
377278
<source>Choosen CSF file doesn&apos;t have CONTROLBAR category. Make sure that you are load correct file.</source>
378279
<translation>У выбранного CSF файла отсутствует категория CONTROLBAR. Проверьте, что вы загружаете правильный файл.</translation>
379280
</message>
@@ -386,32 +287,51 @@ Make sure that you are load correct file.</source>
386287
<translation type="vanished">Невозможно найти &quot;generals.csf&quot; в папке &quot;Game/Data/English&quot;.</translation>
387288
</message>
388289
<message>
389-
<location filename="../../ProgramConstants.hpp" line="76"/>
290+
<location filename="../../ProgramConstants.hpp" line="77"/>
390291
<source>Choosen CSF file doesn&apos;t have OBJECT category. Make sure that you are load correct file.</source>
391292
<translation>У выбранного CSF файла отсутствует категория OBJECT. Проверьте, что вы загружаете правильный файл.</translation>
392293
</message>
393294
<message>
394-
<location filename="../../ProgramConstants.hpp" line="77"/>
395295
<source>Unable find &quot;generals.csf&quot; file in &quot;Game/Data/English&quot; folder.</source>
396-
<translation>Невозможно найти &quot;generals.csf&quot; в папке &quot;Game/Data/English&quot;.</translation>
296+
<translation type="vanished">Невозможно найти &quot;generals.csf&quot; в папке &quot;Game/Data/English&quot;.</translation>
297+
</message>
298+
<message>
299+
<location filename="../../ProgramConstants.hpp" line="78"/>
300+
<source>Unable to find &quot;generals.csf&quot; file in &quot;%1&quot; folder.</source>
301+
<translation>Невозможно найти &quot;generals.csf&quot; в папке &quot;%1&quot;.</translation>
302+
</message>
303+
<message>
304+
<location filename="../../ProgramConstants.hpp" line="79"/>
305+
<source>Unable to find CSF file inside BIG archive &quot;%1&quot;</source>
306+
<translation>Невозможно найти CSF файл внутри BIG архива &quot;%1&quot;</translation>
307+
</message>
308+
<message>
309+
<location filename="../../ProgramConstants.hpp" line="80"/>
310+
<source>Game files search error</source>
311+
<translation>Ошибка поиска по игровым файлам</translation>
312+
</message>
313+
<message>
314+
<location filename="../../ProgramConstants.hpp" line="81"/>
315+
<source>Unable to find &quot;EnglishZH.big&quot; archive in &quot;%1&quot; folder.</source>
316+
<translation>Невозможно найти &quot;EnglishZH.big&quot; в папке &quot;%1&quot;.</translation>
397317
</message>
398318
<message>
399-
<location filename="../../ProgramConstants.hpp" line="108"/>
319+
<location filename="../../ProgramConstants.hpp" line="114"/>
400320
<source>Buildings</source>
401321
<translation>Здания</translation>
402322
</message>
403323
<message>
404-
<location filename="../../ProgramConstants.hpp" line="109"/>
324+
<location filename="../../ProgramConstants.hpp" line="115"/>
405325
<source>Infantry</source>
406326
<translation>Пехота</translation>
407327
</message>
408328
<message>
409-
<location filename="../../ProgramConstants.hpp" line="110"/>
329+
<location filename="../../ProgramConstants.hpp" line="116"/>
410330
<source>Vehicles</source>
411331
<translation>Техника</translation>
412332
</message>
413333
<message>
414-
<location filename="../../ProgramConstants.hpp" line="111"/>
334+
<location filename="../../ProgramConstants.hpp" line="117"/>
415335
<source>Aircrafts</source>
416336
<translation>Авиация</translation>
417337
</message>

src/GUI/WindowManager.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "../Unsorted.hpp"
88
#include "../Convert.hpp"
99
#include "../Registry.hpp"
10+
#include "../Exception.hpp"
1011

1112
#include "ImageManager.hpp"
1213
#include "WindowManager.hpp"
@@ -56,7 +57,17 @@ void WindowManager::StartUpWindow_AcceptConfiguration()
5657
return;
5758
}
5859

59-
CSF_PARSER = std::make_unique<CSFParser>(strCSFFilePath);
60+
try
61+
{
62+
CSF_PARSER = std::make_unique<CSFParser>(strCSFFilePath);
63+
}
64+
catch(const Exception& e)
65+
{
66+
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->CSF_ERROR_HEADER),
67+
e.what());
68+
return;
69+
}
70+
6071

6172
if (!CSF_PARSER->ExistCategory(PROGRAM_CONSTANTS->HOTKEY_CSF_CATEGORY))
6273
{

0 commit comments

Comments
 (0)