Skip to content

Commit bd15b9e

Browse files
author
Andrej Redeky
committed
Bugfixes and improvements
- Updated localization system from another project (fixes glyphs not being displayed for Japanese for example) - Added extra fonts which have glyphs base one was missing (in case newly added language or system folder has unexpected glyphs) - Fixed import sample rate conversion crashing the program
1 parent 38fa6b7 commit bd15b9e

22 files changed

+610
-422
lines changed
File renamed without changes.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* New localizations can be added by copying `data/localization/English.toml`, translating the entries and placing the copied file back into `data/localization`
1616
* For example, you could create Deutsch.toml which would contain translations to German language and place it in the mentioned folder
1717
* New option would then appear in the Options tab under Language
18+
* If newly added language is missing glyphs in fonts used by the tool, you may add additional font defining them into `data/fonts` folder (note that fonts are currently being read in alphabetical order)
1819

1920
### Future
2021
* Definitely some more cleanup/refactor of the source code

data/fonts/NotoSansJP-Regular.otf

4.34 MB
Binary file not shown.

data/fonts/NotoSansKR-Regular.otf

4.52 MB
Binary file not shown.

data/fonts/NotoSansSC-Regular.otf

8.09 MB
Binary file not shown.

data/fonts/NotoSansTC-Regular.otf

5.5 MB
Binary file not shown.
46.3 KB
Binary file not shown.

src/ArchiveDialog.cpp

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ bool ArchiveDialog::Load(const std::filesystem::path &loadPath)
166166
if (loadPath.empty())
167167
return false;
168168

169-
progressMessage = LocalizationManager.Localize("ARCHIVE_DIALOG_LOAD_PROGRESS_READING_ARCHIVE");
169+
UTFGlyphRangesBuilder::Get().AddText(loadPath.native());
170+
171+
progressMessage = LocalizationManager::Get().Localize("ARCHIVE_DIALOG_LOAD_PROGRESS_READING_ARCHIVE");
170172
progressNext = 0;
171173
progressNextTotal = 1;
172174
progressNextActive = true;
@@ -191,7 +193,14 @@ bool ArchiveDialog::Load(const std::filesystem::path &loadPath)
191193
}
192194

193195
if (LoadImpl(loadPath))
196+
{
197+
// TODO - this is causing a lot of synchronizations at the end of loading
198+
// best would be to do this on the main thread
199+
for (const auto& archivePath : archivePaths)
200+
UTFGlyphRangesBuilder::Get().AddText(archivePath.native());
201+
194202
path = loadPath;
203+
}
195204
else
196205
Clear();
197206

@@ -213,7 +222,7 @@ bool ArchiveDialog::Import(const std::filesystem::path &importFolderPath)
213222
if (importFolderPath.empty())
214223
return false;
215224

216-
progressMessage = LocalizationManager.Localize("ARCHIVE_DIALOG_IMPORT_PROGRESS_IMPORTING_DATA");
225+
progressMessage = LocalizationManager::Get().Localize("ARCHIVE_DIALOG_IMPORT_PROGRESS_IMPORTING_DATA");
217226
progressNext = 0;
218227
progressNextTotal = 1;
219228
progressNextActive = true;
@@ -236,7 +245,7 @@ bool ArchiveDialog::Import(const std::filesystem::path &importFolderPath)
236245
{
237246
{
238247
std::unique_lock progressMessageLock(progressMessageMutex);
239-
progressMessage = LocalizationManager.LocalizeFormat("ARCHIVE_DIALOG_IMPORT_PROGRESS_IMPORTING_FILE", ToUTF<char>(relative(importFilePath, importFolderPath).native()));
248+
progressMessage = LocalizationManager::Get().LocalizeFormat("ARCHIVE_DIALOG_IMPORT_PROGRESS_IMPORTING_FILE", ToUTF<char>(relative(importFilePath, importFolderPath).native()));
240249
++progressNext;
241250
}
242251

@@ -260,8 +269,8 @@ bool ArchiveDialog::Export(const std::filesystem::path &exportFolderPath)
260269
{
261270
if (exportFolderPath.empty())
262271
return false;
263-
264-
progressMessage = LocalizationManager.Localize("ARCHIVE_DIALOG_EXPORT_PROGRESS_EXPORTING_DATA");
272+
273+
progressMessage = LocalizationManager::Get().Localize("ARCHIVE_DIALOG_EXPORT_PROGRESS_EXPORTING_DATA");
265274
progressNext = 0;
266275
progressNextTotal = 1;
267276
progressNextActive = true;
@@ -282,7 +291,7 @@ bool ArchiveDialog::Export(const std::filesystem::path &exportFolderPath)
282291
{
283292
{
284293
std::unique_lock progressMessageLock(progressMessageMutex);
285-
progressMessage = LocalizationManager.LocalizeFormat("ARCHIVE_DIALOG_IMPORT_PROGRESS_EXPORTING_FILE", ToUTF<char>(exportFilePath.native()));
294+
progressMessage = LocalizationManager::Get().LocalizeFormat("ARCHIVE_DIALOG_IMPORT_PROGRESS_EXPORTING_FILE", ToUTF<char>(exportFilePath.native()));
286295
++progressNext;
287296
}
288297

@@ -306,8 +315,10 @@ bool ArchiveDialog::Save(const std::filesystem::path &savePath, bool async)
306315
{
307316
if (savePath.empty())
308317
return false;
309-
310-
progressMessage = LocalizationManager.Localize("ARCHIVE_DIALOG_SAVE_PROGRESS_SAVING_ARCHIVE");
318+
319+
UTFGlyphRangesBuilder::Get().AddText(savePath.native());
320+
321+
progressMessage = LocalizationManager::Get().Localize("ARCHIVE_DIALOG_SAVE_PROGRESS_SAVING_ARCHIVE");
311322
progressNext = 0;
312323
progressNextTotal = 1;
313324

@@ -348,8 +359,8 @@ int32_t ArchiveDialog::UnsavedChangesPopup() const
348359
if (!archiveRoot.IsDirty())
349360
return 0;
350361

351-
const auto msgBoxResult = DisplayWarning(LocalizationManager.Localize("ARCHIVE_DIALOG_UNSAVED_CHANGES_MESSAGE"),
352-
LocalizationManager.Localize("ARCHIVE_DIALOG_UNSAVED_CHANGES_TITLE"), true);
362+
const auto msgBoxResult = DisplayWarning(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_UNSAVED_CHANGES_MESSAGE"),
363+
LocalizationManager::Get().Localize("ARCHIVE_DIALOG_UNSAVED_CHANGES_TITLE"), true);
353364

354365
switch (msgBoxResult)
355366
{
@@ -389,30 +400,30 @@ void ArchiveDialog::DrawBaseDialog(std::wstring_view dialogName, std::wstring_vi
389400
if (progressActive)
390401
ImGui::BeginDisabled();
391402

392-
if (ImGui::Button(LocalizationManager.Localize("ARCHIVE_DIALOG_OPEN").c_str(), ImVec2(itemWidth, 0)))
403+
if (ImGui::Button(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_OPEN").c_str(), ImVec2(itemWidth, 0)))
393404
GetAndLoad(filters, defaultFilename);
394405

395406
if (!progressActive && path.empty())
396407
ImGui::BeginDisabled();
397408

398409
ImGui::SameLine();
399410

400-
if (ImGui::Button(LocalizationManager.Localize("ARCHIVE_DIALOG_SAVE").c_str(), ImVec2(itemWidth, 0)))
411+
if (ImGui::Button(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_SAVE").c_str(), ImVec2(itemWidth, 0)))
401412
Save(path, true);
402413

403414
ImGui::SameLine();
404415

405-
if (ImGui::Button(LocalizationManager.Localize("ARCHIVE_DIALOG_SAVE_INTO").c_str(), ImVec2(itemWidth, 0)))
416+
if (ImGui::Button(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_SAVE_INTO").c_str(), ImVec2(itemWidth, 0)))
406417
GetAndSave(filters, defaultFilename);
407418

408419
ImGui::SameLine();
409420

410-
if (ImGui::Button(LocalizationManager.Localize("ARCHIVE_DIALOG_EXPORT_TO").c_str(), ImVec2(itemWidth, 0)))
421+
if (ImGui::Button(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_EXPORT_TO").c_str(), ImVec2(itemWidth, 0)))
411422
GetAndExport();
412423

413424
ImGui::SameLine();
414425

415-
if (ImGui::Button(LocalizationManager.Localize("ARCHIVE_DIALOG_IMPORT_FROM").c_str(), ImVec2(itemWidth, 0)))
426+
if (ImGui::Button(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_IMPORT_FROM").c_str(), ImVec2(itemWidth, 0)))
416427
GetAndImport();
417428

418429
if (progressActive)
@@ -426,7 +437,7 @@ void ArchiveDialog::DrawBaseDialog(std::wstring_view dialogName, std::wstring_vi
426437
{
427438
auto progressCurrent = progressNext.load();
428439

429-
const auto progressSummary = LocalizationManager.LocalizeFormat("ARCHIVE_DIALOG_PROGRESS_SUMMARY", progressCurrent, progressTotal);
440+
const auto progressSummary = LocalizationManager::Get().LocalizeFormat("ARCHIVE_DIALOG_PROGRESS_SUMMARY", progressCurrent, progressTotal);
430441
if (progressMessage.empty())
431442
ImGui::TextUnformatted(progressSummary.c_str());
432443
else
@@ -440,10 +451,10 @@ void ArchiveDialog::DrawBaseDialog(std::wstring_view dialogName, std::wstring_vi
440451
if (path.empty())
441452
{
442453
ImGui::EndDisabled();
443-
ImGui::TextUnformatted(LocalizationManager.Localize("ARCHIVE_DIALOG_NO_ARCHIVE").c_str());
454+
ImGui::TextUnformatted(LocalizationManager::Get().Localize("ARCHIVE_DIALOG_NO_ARCHIVE").c_str());
444455
}
445456
else
446-
ImGui::TextUnformatted(LocalizationManager.LocalizeFormat("ARCHIVE_DIALOG_LOADED_ARCHIVE", ToUTF<char>(path.native()).c_str()).c_str());
457+
ImGui::TextUnformatted(LocalizationManager::Get().LocalizeFormat("ARCHIVE_DIALOG_LOADED_ARCHIVE", ToUTF<char>(path.native()).c_str()).c_str());
447458

448459
ImGui::Separator();
449460

src/Hitman1Dialog.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bool Hitman1Dialog::LoadImpl(const std::filesystem::path &loadPath)
2323
const auto archiveBinFilePath = loadPath.parent_path() / (loadPath.stem().native() + L".bin");
2424
if (!exists(archiveBinFilePath))
2525
{
26-
DisplayError(LocalizationManager.Localize("HITMAN_1_DIALOG_ERROR_MISSING_BIN"));
26+
DisplayError(LocalizationManager::Get().Localize("HITMAN_1_DIALOG_ERROR_MISSING_BIN"));
2727
return false;
2828
}
2929

@@ -86,15 +86,15 @@ bool Hitman1Dialog::LoadImpl(const std::filesystem::path &loadPath)
8686
if (!options.common.checkOriginality)
8787
return true;
8888

89-
std::filesystem::path originalDataPath = GetProgramPath();
89+
originalDataPath = GetProgramPath();
9090
if (originalDataPath.empty())
9191
return Clear(false);
9292

9393
originalDataPath /= L"data";
9494
originalDataPath /= L"records";
9595
originalDataPath /= L"h1";
9696

97-
if (!LoadOriginalData(originalDataPath))
97+
if (!LoadOriginalData())
9898
return Clear(false);
9999

100100
return true;
@@ -112,7 +112,7 @@ bool Hitman1Dialog::ImportSingle(const std::filesystem::path &importFolderPath,
112112
fileIt = fileMap.find(filePath.native());
113113
if (fileIt == fileMap.end())
114114
{
115-
DisplayWarning(LocalizationManager.LocalizeFormat("HITMAN_DIALOG_WARNING_MISSING_FILE", ToUTF<char>(importFilePath.native())));
115+
DisplayWarning(LocalizationManager::Get().LocalizeFormat("HITMAN_DIALOG_WARNING_MISSING_FILE", ToUTF<char>(importFilePath.native())));
116116
return false;
117117
}
118118
}
@@ -163,20 +163,5 @@ bool Hitman1Dialog::SaveImpl(const std::filesystem::path &savePath)
163163

164164
void Hitman1Dialog::DrawDialog()
165165
{
166-
std::filesystem::path originalDataPath;
167-
if (!progressNextActive.load())
168-
{
169-
originalDataPath = GetProgramPath();
170-
171-
if (!originalDataPath.empty() && !fileMap.empty())
172-
{
173-
originalDataPath /= L"data";
174-
originalDataPath /= L"records";
175-
originalDataPath /= L"h1";
176-
}
177-
else
178-
originalDataPath.clear();
179-
}
180-
181-
DrawHitmanDialog(originalDataPath, L"Codename 47", L"Hitman 1 Speech (*.idx)\0*.idx\0", L"English.idx");
166+
DrawHitmanDialog(L"Codename 47", L"Hitman 1 Speech (*.idx)\0*.idx\0", L"English.idx");
182167
}

0 commit comments

Comments
 (0)