Skip to content

Commit 2397664

Browse files
Clearing ru.ts and implement simple hotkeys load from the game
1 parent 0952c81 commit 2397664

File tree

4 files changed

+64
-112
lines changed

4 files changed

+64
-112
lines changed

src/GUI/SetUpWindowsWrapper.cpp

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include <QLineEdit>
2+
#include <QFile>
3+
#include <QMessageBox>
24

35
#include "../Logger.hpp"
6+
#include "../Registry.hpp"
47
#include "WindowManager.hpp"
58
#include "ImageManager.hpp"
69
#include "LoadFromTheGameWindow.hpp"
@@ -42,8 +45,8 @@ void SetUpWindowsWrapper::AttachConnections()
4245
connect(pLoadFromTheGameWindow, &LoadFromTheGameWindow::btnBackClicked,
4346
this, &SetUpWindowsWrapper::BtnBack_Clicked);
4447

45-
// connect(pLoadFromTheGameWindow, &LoadFromTheGameWindow::btnStartClicked,
46-
// this, &SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration);
48+
connect(pLoadFromTheGameWindow, &LoadFromTheGameWindow::btnStartClicked,
49+
this, &SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration);
4750

4851
connect(pSettingsWindow, &SettingsWindow::btnBackClicked,
4952
this, &SetUpWindowsWrapper::BtnBack_Clicked);
@@ -72,8 +75,8 @@ void SetUpWindowsWrapper::DetachConnections()
7275
disconnect(pLoadFromTheGameWindow, &LoadFromTheGameWindow::btnBackClicked,
7376
this, &SetUpWindowsWrapper::BtnBack_Clicked);
7477

75-
// disconnect(pLoadFromTheGameWindow, &LoadFromTheGameWindow::btnStartClicked,
76-
// this, &SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration);
78+
disconnect(pLoadFromTheGameWindow, &LoadFromTheGameWindow::btnStartClicked,
79+
this, &SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration);
7780

7881
disconnect(pSettingsWindow, &SettingsWindow::btnBackClicked,
7982
this, &SetUpWindowsWrapper::BtnBack_Clicked);
@@ -114,14 +117,32 @@ void SetUpWindowsWrapper::GreetingWidget_LanguageChanged(int intLngIndex)
114117
setCurrentWidget(pGreetingWidget);
115118
}
116119

120+
void SetUpWindowsWrapper::BtnLoadFromFile_Clicked() { setCurrentWidget(pLoadFromTheFileWindow); }
121+
void SetUpWindowsWrapper::BtnLoadFromGame_Clicked() { setCurrentWidget(pLoadFromTheGameWindow); }
122+
void SetUpWindowsWrapper::BtnSettings_Clicked() { setCurrentWidget(pSettingsWindow); }
123+
void SetUpWindowsWrapper::BtnBack_Clicked() { WINDOW_MANAGER->SetCSFFilePath(""); setCurrentWidget(pGreetingWidget); }
124+
125+
void SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration()
126+
{
127+
// TODO: Make it load vanila Generals
128+
// Also as work with non-ascii paths
129+
// Also as search in big-archives (see more at GZH source code)
130+
// Also as if-protection when `Game\English` doesnt have `generals.csf`
131+
QString path = QString::fromStdString(Registry::GetPathToGame(Registry::Games::GeneralsZeroHour)) + "\\Data\\English\\generals.csf";
132+
133+
if (!QFile::exists(path))
134+
{
135+
QMessageBox::critical(nullptr, L10N(PROGRAM_CONSTANTS->CSF_ERROR_HEADER),
136+
L10N(PROGRAM_CONSTANTS->CSF_EMPTY_DATA_ENGLISH));
137+
return;
138+
}
139+
140+
WINDOW_MANAGER->SetCSFFilePath(path);
141+
WINDOW_MANAGER->LaunchWidget_AcceptConfiguration();
142+
}
143+
117144
void SetUpWindowsWrapper::LoadFromTheFileWindow_AcceptConfiguration()
118145
{
119146
WINDOW_MANAGER->SetCSFFilePath(pLoadFromTheFileWindow->findChild<QLineEdit*>("lneFilePath", Qt::FindChildrenRecursively)->text());
120147
WINDOW_MANAGER->LaunchWidget_AcceptConfiguration();
121148
}
122-
123-
void SetUpWindowsWrapper::BtnLoadFromFile_Clicked() { setCurrentWidget(pLoadFromTheFileWindow); }
124-
void SetUpWindowsWrapper::BtnLoadFromGame_Clicked() { setCurrentWidget(pLoadFromTheGameWindow); }
125-
void SetUpWindowsWrapper::BtnSettings_Clicked() { setCurrentWidget(pSettingsWindow); }
126-
void SetUpWindowsWrapper::BtnBack_Clicked() { WINDOW_MANAGER->SetCSFFilePath(""); setCurrentWidget(pGreetingWidget); }
127-
void SetUpWindowsWrapper::LoadFromTheGameWindow_AcceptConfiguration() { WINDOW_MANAGER->LaunchWidget_AcceptConfiguration(); }

src/GUI/Translations/ru.ts

Lines changed: 23 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -35,79 +35,6 @@
3535
<translation>Нажмите клавишу...</translation>
3636
</message>
3737
</context>
38-
<context>
39-
<name>BaseConfigurationDialog</name>
40-
<message>
41-
<source>Configure</source>
42-
<translation type="vanished">Настройка</translation>
43-
</message>
44-
<message>
45-
<source>Back</source>
46-
<translation type="vanished">Назад</translation>
47-
</message>
48-
<message>
49-
<source>CONFIGURE</source>
50-
<translation type="vanished">НАСТРОЙКА</translation>
51-
</message>
52-
<message>
53-
<source>BACK</source>
54-
<translation type="vanished">НАЗАД</translation>
55-
</message>
56-
</context>
57-
<context>
58-
<name>CreationDialog</name>
59-
<message>
60-
<source>START</source>
61-
<translation type="vanished">НАЧАТЬ</translation>
62-
</message>
63-
<message>
64-
<source>BACK</source>
65-
<translation type="vanished">НАЗАД</translation>
66-
</message>
67-
<message>
68-
<source>Save hotkeys dirrectly to the game.</source>
69-
<translation type="vanished">Сохранять горячие клавиши в игре.</translation>
70-
</message>
71-
</context>
72-
<context>
73-
<name>GreetingWidget</name>
74-
<message>
75-
<source>Load Project</source>
76-
<translation type="vanished">Загрузить проект</translation>
77-
</message>
78-
<message>
79-
<source>Language</source>
80-
<translation type="vanished">Язык</translation>
81-
</message>
82-
<message>
83-
<source>NEW PROJECT</source>
84-
<translation type="vanished">НОВЫЙ ПРОЕКТ</translation>
85-
</message>
86-
<message>
87-
<source>LOAD PROJECT</source>
88-
<translation type="vanished">ЗАГРУЗИТЬ ПРОЕКТ</translation>
89-
</message>
90-
<message>
91-
<source>NEW</source>
92-
<translation type="vanished">НОВЫЙ</translation>
93-
</message>
94-
<message>
95-
<source>PROJECT</source>
96-
<translation type="vanished">ПРОЕКТ</translation>
97-
</message>
98-
<message>
99-
<source>LOAD</source>
100-
<translation type="vanished">ЗАГРУЗИТЬ</translation>
101-
</message>
102-
<message>
103-
<source>LANGUAGE</source>
104-
<translation type="vanished">ЯЗЫК</translation>
105-
</message>
106-
<message>
107-
<source>Greetings, %username%. You have launched the hotkey editing program for the game Command and Conquer: Generals and Command and Conquer: Generals — Zero Hour. At the moment, the program supports in test mode only the creation of hotkey maps based on pre-prepared hotkeys. We hope that you will like the program.</source>
108-
<translation type="vanished">Приветствую тебя, %username%. Ты запустил программу редактирования горячих клавиш для игры Command and Conquer: Generals и Command and Conquer: Generals — Zero Hour. На текущий момент программа поддерживает в тестовом режиме только создание карт горячих клавиш на основе заранее подготовленных горячих клавиш. Надеемся, что программа тебе понравится.</translation>
109-
</message>
110-
</context>
11138
<context>
11239
<name>GreetingWindow</name>
11340
<message>
@@ -144,21 +71,6 @@
14471
<translation>ЯЗЫК</translation>
14572
</message>
14673
</context>
147-
<context>
148-
<name>HotkeyElement</name>
149-
<message>
150-
<source>Press any key...</source>
151-
<translation type="vanished">Нажмите любую клавишу...</translation>
152-
</message>
153-
<message>
154-
<source>It isn&apos;t latin key...</source>
155-
<translation type="vanished">Это не латинская клавиша...</translation>
156-
</message>
157-
<message>
158-
<source>Press latin key...</source>
159-
<translation type="vanished">Нажмите латинскую клавишу...</translation>
160-
</message>
161-
</context>
16274
<context>
16375
<name>HotkeysMainWindow</name>
16476
<message>
@@ -386,29 +298,46 @@
386298
<translation>Невозможно найти указанный CSF файл.</translation>
387299
</message>
388300
<message>
389-
<location filename="../../ProgramConstants.hpp" line="82"/>
390301
<source>Choosen CSF file doesn&apos;t have CONTROLBAR category.
391302
Make sure that you are load correct file.</source>
392-
<translation>У выбранного CSF файла отсутствует категория CONTROLBAR
303+
<translation type="vanished">У выбранного CSF файла отсутствует категория CONTROLBAR
393304
Проверьте, что вы загружаете правильный файл.</translation>
394305
</message>
395306
<message>
396-
<location filename="../../ProgramConstants.hpp" line="112"/>
307+
<location filename="../../ProgramConstants.hpp" line="82"/>
308+
<source>Choosen CSF file doesn&apos;t have CONTROLBAR category. Make sure that you are load correct file.</source>
309+
<translation>У выбранного CSF файла отсутствует категория CONTROLBAR. Проверьте, что вы загружаете правильный файл.</translation>
310+
</message>
311+
<message>
312+
<source>Unable find CSF file in &quot;Game\Data\English\&quot; folder.</source>
313+
<translation type="vanished">Невозможно найти &quot;generals.csf&quot; в папке &quot;Game\Data\English\&quot;.</translation>
314+
</message>
315+
<message>
316+
<source>Unable find &quot;generals.csf&quot; file in &quot;Game\Data\English\&quot; folder.</source>
317+
<translation type="vanished">Невозможно найти &quot;generals.csf&quot; в папке &quot;Game/Data/English&quot;.</translation>
318+
</message>
319+
<message>
320+
<location filename="../../ProgramConstants.hpp" line="83"/>
321+
<source>Unable find &quot;generals.csf&quot; file in &quot;Game/Data/English&quot; folder.</source>
322+
<translation>Невозможно найти &quot;generals.csf&quot; в папке &quot;Game/Data/English&quot;.</translation>
323+
</message>
324+
<message>
325+
<location filename="../../ProgramConstants.hpp" line="113"/>
397326
<source>Buildings</source>
398327
<translation>Здания</translation>
399328
</message>
400329
<message>
401-
<location filename="../../ProgramConstants.hpp" line="113"/>
330+
<location filename="../../ProgramConstants.hpp" line="114"/>
402331
<source>Infantry</source>
403332
<translation>Пехота</translation>
404333
</message>
405334
<message>
406-
<location filename="../../ProgramConstants.hpp" line="114"/>
335+
<location filename="../../ProgramConstants.hpp" line="115"/>
407336
<source>Vehicles</source>
408337
<translation>Техника</translation>
409338
</message>
410339
<message>
411-
<location filename="../../ProgramConstants.hpp" line="115"/>
340+
<location filename="../../ProgramConstants.hpp" line="116"/>
412341
<source>Aircrafts</source>
413342
<translation>Авиация</translation>
414343
</message>

src/ProgramConstants.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ class ProgramConstants
6969
const int EMPTY_KEY_WIDTH = 25;
7070

7171
// Errors
72-
const char* SETTINGS_NO_FOUND = "Unable to find Settings.json in Resource folder.";
73-
const char* TECH_TREE_NO_FOUND = "Unable to find TechTree.json in Resource folder.";
74-
const char* THEME_FOLDER_NO_FOUND = "Unable to find Resource/Theme folder.";
75-
const char* ICONS_FOLDER_NO_FOUND = "Unable to find Resource/Icons folder.";
76-
const char* TRANSLATIONS_NO_FOUND = "Unable to find Resource/Translations folder.";
72+
const char* SETTINGS_NO_FOUND = "Unable to find \"Settings.json\" in \"Resource\" folder.";
73+
const char* TECH_TREE_NO_FOUND = "Unable to find \"TechTree.json\" in \"Resource\" folder.";
74+
const char* THEME_FOLDER_NO_FOUND = "Unable to find \"Resource/Theme\" folder.";
75+
const char* ICONS_FOLDER_NO_FOUND = "Unable to find \"Resource/Icons\" folder.";
76+
const char* TRANSLATIONS_NO_FOUND = "Unable to find \"Resource/Translations\" folder.";
7777
const char* UNKNOWN_ERROR = "Unknown error has been occured.";
7878

7979
const QString CSF_ERROR_HEADER = QObject::tr("Error with CSF file");
8080
const QString CSF_EMPTY_STRING_ERROR = QObject::tr("Cannot process the empty file.");
8181
const QString CSF_DOESNT_EXIST_ERROR = QObject::tr("Unable to find selected CSF file.");
82-
const QString CSF_NO_CTLBAR_ERROR = QObject::tr("Choosen CSF file doesn't have CONTROLBAR category.\nMake sure that you are load correct file.");
82+
const QString CSF_NO_CTLBAR_ERROR = QObject::tr("Choosen CSF file doesn't have CONTROLBAR category. Make sure that you are load correct file.");
83+
const QString CSF_EMPTY_DATA_ENGLISH = QObject::tr("Unable find \"generals.csf\" file in \"Game/Data/English\" folder.");
8384

8485
// Other constants
8586
const QString HOTKEY_CSF_CATEGORY = "CONTROLBAR";

src/Settings.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ Settings::~Settings()
2020

2121
void Settings::SetToDefault()
2222
{
23-
allowedKeys = PROGRAM_CONSTANTS->DEFAULT_ALLOWED_KEYS;
24-
enabledConsole = false;
23+
allowedKeys = PROGRAM_CONSTANTS->DEFAULT_ALLOWED_KEYS;
24+
enabledConsole = false;
25+
enabledDiscordRPC = true;
2526
}
2627

2728
void Settings::Parse()

0 commit comments

Comments
 (0)