Added simple localizations for locations

This commit is contained in:
Vladislav Khorev 2026-07-07 12:11:34 +03:00
parent e2d9105b02
commit ef5b142425
4 changed files with 16 additions and 5 deletions

View File

@ -317,7 +317,7 @@ namespace ZL
gameState.chatHistory[i].clear();
}
gameState.inventory.clear();
gameState.questJournal.loadFromFile("resources/config/quests.json", CONST_ZIP_FILE);
gameState.questJournal.loadFromFile(localizedConfigPath("resources/config/quests.json", g_currentLanguage), CONST_ZIP_FILE);
createLocations();
};

View File

@ -15,7 +15,7 @@ void GameState::save(nlohmann::json& out) const
out["savedAt"] = ts.str();
// --- World ---
out["currentLocationName"] = currentLocationName;
out["currentLocationName"] = currentLocationName;
out["isDarklands"] = isDarklands;
out["isNight"] = isNight;
out["isDawn"] = isDawn;

View File

@ -101,6 +101,14 @@ namespace ZL {
gameState_(gameState),
audioPlayer_(audioPlayer)
{
localizedLocationName["uni_interior"][Language::Russian] = "Университет, 3 этаж";
localizedLocationName["uni_interior"][Language::English] = "University, 3rd floor";
localizedLocationName["uni_exterior"][Language::Russian] = "Университет, двор";
localizedLocationName["uni_exterior"][Language::English] = "University, exterior";
localizedLocationName["location_dorm"][Language::Russian] = "Общежитие, 1 этаж";
localizedLocationName["location_dorm"][Language::English] = "Dormitory, 1st floor";
}
void MenuManager::setup(Inventory& inv, const std::string& zipFile) {
@ -445,7 +453,7 @@ namespace ZL {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string label = info.empty
? "Empty"
: info.locationName + "\n" + info.savedAt;
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
uiManager.setTextButtonText(kSlotButtons[i], label);
}
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
@ -473,7 +481,7 @@ namespace ZL {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string label = info.empty
? "Empty"
: info.locationName + "\n" + info.savedAt;
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
}
uiManager.setTextButtonCallback(buttonName, [this, slot, buttonName](const std::string&) {
@ -482,7 +490,7 @@ namespace ZL {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string label = info.empty
? "Empty"
: info.locationName + "\n" + info.savedAt;
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
}
});

View File

@ -34,6 +34,9 @@ namespace ZL {
UiManager topUiManager;
UiManager chatUiManager;
std::unordered_map<std::string,
std::unordered_map<Language, std::string>> localizedLocationName;
MenuManager(Renderer& iRenderer, GameState& gameState, AudioPlayerAsync& audioPlayer);
void setup(Inventory& inv, const std::string& zipFile);