Skip to content

Commit d960c11

Browse files
author
Andrej Redeky
committed
Bugfixes and improvements
- Updated localization system from another project - Updated original records data
1 parent bd15b9e commit d960c11

19 files changed

+2102
-893
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.xmake/
33
build/
44
package/
5+
install/
56
vsxmake2015/
67
vsxmake2017/
78
vsxmake2019/

data/records/h2

0 Bytes
Binary file not shown.

data/records/h3

0 Bytes
Binary file not shown.

src/ArchiveDialog.cpp

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

169-
UTFGlyphRangesBuilder::Get().AddText(loadPath.native());
169+
GlyphRangesBuilder::Get().AddText(loadPath.native());
170170

171171
progressMessage = LocalizationManager::Get().Localize("ARCHIVE_DIALOG_LOAD_PROGRESS_READING_ARCHIVE");
172172
progressNext = 0;
@@ -197,7 +197,7 @@ bool ArchiveDialog::Load(const std::filesystem::path &loadPath)
197197
// TODO - this is causing a lot of synchronizations at the end of loading
198198
// best would be to do this on the main thread
199199
for (const auto& archivePath : archivePaths)
200-
UTFGlyphRangesBuilder::Get().AddText(archivePath.native());
200+
GlyphRangesBuilder::Get().AddText(archivePath.native());
201201

202202
path = loadPath;
203203
}
@@ -316,7 +316,7 @@ bool ArchiveDialog::Save(const std::filesystem::path &savePath, bool async)
316316
if (savePath.empty())
317317
return false;
318318

319-
UTFGlyphRangesBuilder::Get().AddText(savePath.native());
319+
GlyphRangesBuilder::Get().AddText(savePath.native());
320320

321321
progressMessage = LocalizationManager::Get().Localize("ARCHIVE_DIALOG_SAVE_PROGRESS_SAVING_ARCHIVE");
322322
progressNext = 0;
@@ -437,11 +437,11 @@ void ArchiveDialog::DrawBaseDialog(std::wstring_view dialogName, std::wstring_vi
437437
{
438438
auto progressCurrent = progressNext.load();
439439

440-
const auto progressSummary = LocalizationManager::Get().LocalizeFormat("ARCHIVE_DIALOG_PROGRESS_SUMMARY", progressCurrent, progressTotal);
440+
const auto& progressSummary = LocalizationManager::Get().LocalizeFormat("ARCHIVE_DIALOG_PROGRESS_SUMMARY", progressCurrent, progressTotal);
441441
if (progressMessage.empty())
442442
ImGui::TextUnformatted(progressSummary.c_str());
443443
else
444-
ImGui::TextUnformatted(std::format("{}\n{}", progressSummary, progressMessage).c_str());
444+
ImGui::TextUnformatted(std::format("{}\n{}", progressSummary.native(), progressMessage.native()).c_str());
445445
}
446446
else if (!progressMessage.empty())
447447
ImGui::TextUnformatted(progressMessage.c_str());

src/ArchiveDialog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ArchiveDialog
7373
ArchiveDirectory archiveRoot;
7474

7575
std::recursive_mutex progressMessageMutex;
76-
std::string progressMessage;
76+
String8 progressMessage;
7777
std::atomic_uint64_t progressNext = 0;
7878
std::atomic_uint64_t progressNextTotal = 0;
7979
std::atomic_bool progressNextActive = false;

src/Localization.hpp

Lines changed: 0 additions & 848 deletions
This file was deleted.

src/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
bool BuildFontAtlas()
1717
{
18-
if (!UTFGlyphRangesBuilder::Get().NeedsBuild())
18+
if (!GlyphRangesBuilder::Get().NeedsBuild())
1919
return true;
2020

2121
std::vector<std::filesystem::path> searchPaths;
@@ -28,7 +28,7 @@ bool BuildFontAtlas()
2828

2929
ImFontGlyphRangesBuilder builder;
3030

31-
const auto glyphRanges = UTFGlyphRangesBuilder::Get().Build();
31+
const auto glyphRanges = GlyphRangesBuilder::Get().Build();
3232
for (const auto& glyphRange : glyphRanges)
3333
{
3434
uint32_t translatedGlyphRange[3]{glyphRange.first, glyphRange.second, 0};

src/Options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void CommonSettings::Load(const toml::table &aInputRoot)
2626
transcodeToOriginalFormat = commonTable["transcode_to_original_format"].value_or(transcodeToOriginalFormat);
2727
directImport = commonTable["direct_import"].value_or(directImport);
2828

29-
LocalizationManager::Get().SetLanguage(commonTable["language"].value_or(LocalizationManager::Get().GetLanguage()));
29+
LocalizationManager::Get().SetLanguage(commonTable["language"].value_or(LocalizationManager::Get().GetLanguage().native()));
3030
}
3131

3232
void CommonSettings::Save(toml::table &aOutputRoot) const
@@ -42,7 +42,7 @@ void CommonSettings::Save(toml::table &aOutputRoot) const
4242
commonTable.emplace("transcode_to_original_format", transcodeToOriginalFormat);
4343
commonTable.emplace("direct_import", directImport);
4444

45-
commonTable.emplace("language", LocalizationManager::Get().GetLanguage());
45+
commonTable.emplace("language", LocalizationManager::Get().GetLanguage().native());
4646

4747
aOutputRoot.emplace("common", std::move(commonTable));
4848
}
@@ -62,7 +62,7 @@ void CommonSettings::DrawDialog()
6262
const auto availableLanguages = LocalizationManager::Get().GetAvailableLanguages();
6363
for (const auto& language : availableLanguages)
6464
{
65-
bool selected = UTFCaseInsensitiveCompare(LocalizationManager::Get().GetLanguage(), language) == 0;
65+
bool selected = (LocalizationManager::Get().GetLanguage() <=> language) == std::strong_ordering::equivalent;
6666
if (ImGui::Selectable(language.c_str(), &selected))
6767
LocalizationManager::Get().SetLanguage(language);
6868
}

src/Options.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
#pragma once
77

8-
struct CommonSettings
8+
class CommonSettings
99
{
10+
public:
1011
void Load(const toml::table &aInputRoot);
1112
void Save(toml::table &aOutputRoot) const;
1213
void ResetToDefaults();
@@ -25,19 +26,14 @@ struct CommonSettings
2526
bool directImport{false};
2627
};
2728

28-
struct Options
29+
class Options : public Singleton<Options>
2930
{
31+
public:
3032
void Load();
3133
void Save() const;
3234
void ResetToDefaults();
3335

3436
void DrawDialog();
3537

36-
static Options &Get()
37-
{
38-
static Options options;
39-
return options;
40-
}
41-
4238
CommonSettings common{};
4339
};

src/Precompiled.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ extern "C"
1414
#include <imgui.h>
1515
#include <scn/scn.h>
1616
#include <sndfile.hh>
17-
18-
#define TOML_EXCEPTIONS 0
1917
#include <toml++/toml.h>
2018

2119
#include <array>
@@ -31,9 +29,10 @@ extern "C"
3129
#include <variant>
3230
#include <vector>
3331

34-
#include "Options.hpp"
35-
#include "Utils.hpp"
32+
#include "Singleton.hpp"
33+
#include "UTF/UTF.hpp"
3634

37-
#include "Localization.hpp"
35+
using namespace UTF;
3836

39-
using LocalizationManager = UTFLocalizationManager<char>;
37+
#include "Options.hpp"
38+
#include "Utils.hpp"

0 commit comments

Comments
 (0)