Skip to content

Commit 5de6b54

Browse files
Add saving as generals.csf if big archive has been loaded and there attempt to save changes
1 parent 9849d77 commit 5de6b54

File tree

4 files changed

+35
-27
lines changed

4 files changed

+35
-27
lines changed

src/GUI/EditorWindow.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <QComboBox>
99
#include <QFileDialog>
1010

11+
#include "../Windows/Registry.hpp"
1112
#include "../Windows/Locale.hpp"
1213
#include "../Parsers/CSFParser.hpp"
1314
#include "../Info.hpp"
@@ -532,6 +533,15 @@ void EditorWindow::ActSettings_Triggered()
532533
void EditorWindow::ActSave_Triggered()
533534
{
534535
LOGMSG("Saving changes to .csf file...");
536+
537+
if (CSF_PARSER->Path.ends_with(L".big") || CSF_PARSER->Path.ends_with(L".BIG"))
538+
{
539+
CSF_PARSER->Path = (QString::fromStdWString(
540+
Windows::Registry::GetPathToGame(
541+
Windows::Registry::Games::GeneralsZeroHour))
542+
+ "Data\\English\\generals.csf"q).toStdWString();
543+
}
544+
535545
CSF_PARSER->Save();
536546
LOGMSG("Changes has been saved");
537547
}

src/GUI/Translations/ru.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,99 +22,99 @@
2222
<context>
2323
<name>EditorWindow</name>
2424
<message>
25-
<location filename="../EditorWindow.cpp" line="178"/>
25+
<location filename="../EditorWindow.cpp" line="179"/>
2626
<source>File</source>
2727
<translation>Файл</translation>
2828
</message>
2929
<message>
30-
<location filename="../EditorWindow.cpp" line="179"/>
30+
<location filename="../EditorWindow.cpp" line="180"/>
3131
<source>Open</source>
3232
<translation>Открыть</translation>
3333
</message>
3434
<message>
35-
<location filename="../EditorWindow.cpp" line="180"/>
35+
<location filename="../EditorWindow.cpp" line="181"/>
3636
<source>Save</source>
3737
<translation>Сохранить</translation>
3838
</message>
3939
<message>
40-
<location filename="../EditorWindow.cpp" line="181"/>
40+
<location filename="../EditorWindow.cpp" line="182"/>
4141
<source>Save As...</source>
4242
<translation>Сохранить как...</translation>
4343
</message>
4444
<message>
45-
<location filename="../EditorWindow.cpp" line="182"/>
45+
<location filename="../EditorWindow.cpp" line="183"/>
4646
<source>Special</source>
4747
<translation>Дополнительно</translation>
4848
</message>
4949
<message>
50-
<location filename="../EditorWindow.cpp" line="198"/>
50+
<location filename="../EditorWindow.cpp" line="199"/>
5151
<source>View</source>
5252
<translation>Вид</translation>
5353
</message>
5454
<message>
55-
<location filename="../EditorWindow.cpp" line="199"/>
55+
<location filename="../EditorWindow.cpp" line="200"/>
5656
<source>Status Bar</source>
5757
<translation>Строка состояния</translation>
5858
</message>
5959
<message>
60-
<location filename="../EditorWindow.cpp" line="200"/>
60+
<location filename="../EditorWindow.cpp" line="201"/>
6161
<source>Enable</source>
6262
<translation>Включить</translation>
6363
</message>
6464
<message>
65-
<location filename="../EditorWindow.cpp" line="201"/>
65+
<location filename="../EditorWindow.cpp" line="202"/>
6666
<source>Disable</source>
6767
<translation>Отключить</translation>
6868
</message>
6969
<message>
70-
<location filename="../EditorWindow.cpp" line="205"/>
71-
<location filename="../EditorWindow.cpp" line="517"/>
70+
<location filename="../EditorWindow.cpp" line="206"/>
71+
<location filename="../EditorWindow.cpp" line="518"/>
7272
<source>Settings</source>
7373
<translation>Настройки</translation>
7474
</message>
7575
<message>
76-
<location filename="../EditorWindow.cpp" line="209"/>
77-
<location filename="../EditorWindow.cpp" line="482"/>
76+
<location filename="../EditorWindow.cpp" line="210"/>
77+
<location filename="../EditorWindow.cpp" line="483"/>
7878
<source>About</source>
7979
<translation>О программе</translation>
8080
</message>
8181
<message>
82-
<location filename="../EditorWindow.cpp" line="343"/>
82+
<location filename="../EditorWindow.cpp" line="344"/>
8383
<source>Layout %1</source>
8484
<translation>Раскладка %1</translation>
8585
</message>
8686
<message>
87-
<location filename="../EditorWindow.cpp" line="462"/>
87+
<location filename="../EditorWindow.cpp" line="463"/>
8888
<source>Authors: </source>
8989
<translation>Авторы: </translation>
9090
</message>
9191
<message>
92-
<location filename="../EditorWindow.cpp" line="463"/>
92+
<location filename="../EditorWindow.cpp" line="464"/>
9393
<source>Version: </source>
9494
<translation>Версия: </translation>
9595
</message>
9696
<message>
97-
<location filename="../EditorWindow.cpp" line="464"/>
97+
<location filename="../EditorWindow.cpp" line="465"/>
9898
<source>Program licensed with </source>
9999
<translation>Программа лицензирована под </translation>
100100
</message>
101101
<message>
102-
<location filename="../EditorWindow.cpp" line="465"/>
102+
<location filename="../EditorWindow.cpp" line="466"/>
103103
<source>GitHub repository:</source>
104104
<translation>Репозиторий на GitHub:</translation>
105105
</message>
106106
<message>
107-
<location filename="../EditorWindow.cpp" line="467"/>
107+
<location filename="../EditorWindow.cpp" line="468"/>
108108
<source>Support development:</source>
109109
<translation>Поддержать разработку:</translation>
110110
</message>
111111
<message>
112-
<location filename="../EditorWindow.cpp" line="557"/>
112+
<location filename="../EditorWindow.cpp" line="568"/>
113113
<source>Binary files</source>
114114
<translation>Двоичные файлы</translation>
115115
</message>
116116
<message>
117-
<location filename="../EditorWindow.cpp" line="558"/>
117+
<location filename="../EditorWindow.cpp" line="569"/>
118118
<source>Any files</source>
119119
<translation>Все файлы</translation>
120120
</message>

src/Parsers/CSFParser.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <sstream>
22
#include <QStringList>
33

4-
#include "../Windows/Locale.hpp"
54
#include "../Logger.hpp"
65
#include "../Convert.hpp"
76
#include "../Exception.hpp"
@@ -31,7 +30,6 @@ using namespace StringExt;
3130
LOGMSG("BIG archive detected. Try to find CSF file inside...");
3231
streampos offset = SetOffsetAtTheStringStart(file, " FSC"s);
3332
LOGMSG("CSF file data found at offset : " + static_cast<const uint64_t&>(offset));
34-
Path = Path.substr(0, Path.find_last_of('\\') + 1) + PROGRAM_CONSTANTS->BIG_ARCHIVE_CSF_PATH.toStdWString();
3533
}
3634

3735
LOGMSG("Attempt to read string table from \"" + Path.c_str() + "\" file...");
@@ -44,9 +42,9 @@ using namespace StringExt;
4442
throw Exception("Bad file name error. Unable to open file \""q + Path + "\"");
4543
}
4644
}
47-
void CSFParser::Parse(const wstring& filePath) { Parse(filePath.c_str()); }
48-
void CSFParser::Parse(const std::string& strFilePath) { Parse(strFilePath.c_str()); }
49-
void CSFParser::Parse(const QString& strFilePath) { Parse(strFilePath.toStdString().c_str()); }
45+
void CSFParser::Parse(const wstring& filePath) { Parse(QString::fromStdWString(filePath)); }
46+
void CSFParser::Parse(const string& filePath) { Parse(QString::fromStdString(filePath)); }
47+
void CSFParser::Parse(const QString& filePath) { Parse(filePath.toStdString().c_str()); }
5048

5149
streampos CSFParser::SetOffsetAtTheStringStart(ifstream& file, const string& searchStr)
5250
{

src/Parsers/CSFParser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class CSFParser final
3838
const uint8_t WRTS[4] {'W', 'R', 'T', 'S'}; // Begining of any string with extra value
3939
const uint32_t CNC_CSF_VERSION = 3; // Standart file format. Legacy by WW
4040

41-
std::wstring Path;
4241
CSFHeader Header;
4342
std::list<CompiledString> Table;
4443

4544
public:
4645
inline static std::unique_ptr<CSFParser> Instance = nullptr;
46+
std::wstring Path;
4747

4848
private: // Methods
4949
void ReadHeader(std::ifstream* csfFile);

0 commit comments

Comments
 (0)