Working more on translations, fixing tree bugs
This commit is contained in:
1 parent
e7dc3279ae
commit
cdaebc3c0c
23 files changed
+542
-487
No files matched your search
+42
-11
@@ -84,6 +84,13 @@ namespace ZL {
|
||||
result += digits[i];
|
||||
}
|
||||
if (negative) result = "-" + result;
|
||||
|
||||
|
||||
|
||||
if (g_currentLanguage == Language::English)
|
||||
{
|
||||
return result + " som";
|
||||
}
|
||||
return result + " сом";
|
||||
}
|
||||
|
||||
@@ -124,6 +131,20 @@ namespace ZL {
|
||||
return loadUiFromFile(basePath, renderer, zipFile);
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> MenuManager::loadLocalizedTexture(const std::string& basePath, const std::string& zipFile) {
|
||||
static const std::string marker = "resources/w/ui/";
|
||||
if (basePath.rfind(marker, 0) == 0) {
|
||||
const std::string localizedPath = "resources/w/ui_" + languageToCode(g_currentLanguage) + "/" + basePath.substr(marker.size());
|
||||
try {
|
||||
return renderer.textureManager.LoadFromPng(localizedPath, zipFile, true);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
// Localized screen not available — fall back to the base path below.
|
||||
}
|
||||
}
|
||||
return renderer.textureManager.LoadFromPng(basePath, zipFile, true);
|
||||
}
|
||||
|
||||
void MenuManager::loadUiRoots(const std::string& zipFile) {
|
||||
hudRoot = loadLocalizedUi("resources/w/ui/hud_step0.json", zipFile);
|
||||
hudStep1Root = loadLocalizedUi("resources/w/ui/hud_step1.json", zipFile);
|
||||
@@ -197,26 +218,29 @@ namespace ZL {
|
||||
|
||||
texObjectiveCompleted_ = renderer.textureManager.LoadFromPng("resources/w/ui/img/journal/quest_objective_completed.png", zipFile, true);
|
||||
texObjectiveBlank_ = renderer.textureManager.LoadFromPng("resources/w/ui/img/journal/quest_objective_blank.png", zipFile, true);
|
||||
|
||||
texItemSelected_ = renderer.textureManager.LoadFromPng("resources/w/ui/img/journal/ButtonBkg001.png", zipFile, true);
|
||||
texItemTransparent_ = renderer.textureManager.LoadFromPng("resources/w/ui/img/journal/ButtonBkgTransparent001.png", zipFile, true);
|
||||
|
||||
gameState_.questJournal.loadFromFile("resources/config/quests.json", zipFile);
|
||||
|
||||
renderer.textureManager.LoadFromPng("resources/w/ui/img/toast/quest_new001.png", zipFile, true);
|
||||
renderer.textureManager.LoadFromPng("resources/w/ui/img/toast/quest_completed001.png", zipFile, true);
|
||||
renderer.textureManager.LoadFromPng("resources/w/ui/img/toast/quest_failed001.png", zipFile, true);
|
||||
toastTextureQuestNew = loadLocalizedTexture("resources/w/ui/img/toast/quest_new001.png", zipFile);
|
||||
toastTextureQuestCompleted = loadLocalizedTexture("resources/w/ui/img/toast/quest_completed001.png", zipFile);
|
||||
toastTextureQuestFailed = loadLocalizedTexture("resources/w/ui/img/toast/quest_failed001.png", zipFile);
|
||||
toastTextureItemAdded = loadLocalizedTexture("resources/w/ui/img/toast/item_received001.png", zipFile);
|
||||
toastTextureItemRemoved = loadLocalizedTexture("resources/w/ui/img/toast/item_removed001.png", zipFile);
|
||||
|
||||
gameState_.questJournal.onQuestUnlocked = [this](const std::string& id) {
|
||||
const Quest::QuestState* q = gameState_.questJournal.findQuest(id);
|
||||
if (q) showToast("resources/w/ui/img/toast/quest_new001.png", q->definition.title);
|
||||
if (q) showToast(toastTextureQuestNew, q->definition.title);
|
||||
};
|
||||
gameState_.questJournal.onQuestCompleted = [this](const std::string& id) {
|
||||
const Quest::QuestState* q = gameState_.questJournal.findQuest(id);
|
||||
if (q) showToast("resources/w/ui/img/toast/quest_completed001.png", q->definition.title);
|
||||
if (q) showToast(toastTextureQuestCompleted, q->definition.title);
|
||||
};
|
||||
gameState_.questJournal.onQuestFailed = [this](const std::string& id) {
|
||||
const Quest::QuestState* q = gameState_.questJournal.findQuest(id);
|
||||
if (q) showToast("resources/w/ui/img/toast/quest_failed001.png", q->definition.title);
|
||||
if (q) showToast(toastTextureQuestFailed, q->definition.title);
|
||||
};
|
||||
|
||||
const std::string imgDir = "resources/w/ui/img/phone/";
|
||||
@@ -465,6 +489,13 @@ namespace ZL {
|
||||
|
||||
loadUiRoots(CONST_ZIP_FILE);
|
||||
|
||||
toastTextureQuestNew = loadLocalizedTexture("resources/w/ui/img/toast/quest_new001.png", CONST_ZIP_FILE);
|
||||
toastTextureQuestCompleted = loadLocalizedTexture("resources/w/ui/img/toast/quest_completed001.png", CONST_ZIP_FILE);
|
||||
toastTextureQuestFailed = loadLocalizedTexture("resources/w/ui/img/toast/quest_failed001.png", CONST_ZIP_FILE);
|
||||
toastTextureItemAdded = loadLocalizedTexture("resources/w/ui/img/toast/item_received001.png", CONST_ZIP_FILE);
|
||||
toastTextureItemRemoved = loadLocalizedTexture("resources/w/ui/img/toast/item_removed001.png", CONST_ZIP_FILE);
|
||||
|
||||
|
||||
showMainMenu();
|
||||
}
|
||||
|
||||
@@ -1722,14 +1753,14 @@ namespace ZL {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void MenuManager::showToast(const std::string& iconPath, const std::string& text) {
|
||||
void MenuManager::showToast(std::shared_ptr<Texture> toastTexture, const std::string& text) {
|
||||
if (activeToasts_.size() < 3) {
|
||||
ToastEntry e;
|
||||
e.iconPath = iconPath;
|
||||
e.toastTexture = toastTexture;
|
||||
e.text = text;
|
||||
activeToasts_.push_back(std::move(e));
|
||||
} else {
|
||||
toastQueue_.push_back({ iconPath, text });
|
||||
toastQueue_.push_back({ toastTexture, text });
|
||||
}
|
||||
applyToastsToUi();
|
||||
}
|
||||
@@ -1758,7 +1789,7 @@ namespace ZL {
|
||||
// Promote queued messages into free slots
|
||||
while (!toastQueue_.empty() && activeToasts_.size() < 3) {
|
||||
ToastEntry e;
|
||||
e.iconPath = toastQueue_.front().iconPath;
|
||||
e.toastTexture = toastQueue_.front().toastTexture;
|
||||
e.text = toastQueue_.front().text;
|
||||
toastQueue_.pop_front();
|
||||
activeToasts_.push_back(std::move(e));
|
||||
@@ -1782,7 +1813,7 @@ namespace ZL {
|
||||
auto tv = uiManager.findTextView(txtNames[i]);
|
||||
|
||||
if (img) {
|
||||
img->texture = renderer.textureManager.LoadFromPng(e.iconPath, CONST_ZIP_FILE, true);
|
||||
img->texture = e.toastTexture;
|
||||
img->alpha = a;
|
||||
}
|
||||
if (tv) {
|
||||
|
||||
Reference in new issue
Block a user