Fixing lots of UI bugs

This commit is contained in:
Vladislav Khorev committed 2026-07-10 21:30:59 +03:00
1 parent 8e745ce0cd
commit 79413e7319
33 files changed
+1740 -1342

No files matched your search

+67 -26
View File
@@ -12,6 +12,10 @@
namespace ZL {
static const std::string EMPTY_LANGUAGE_RU = "(пусто)";
static const std::string EMPTY_LANGUAGE_EN = "(empty)";
static int questStatusPriority(Quest::QuestStatus status) {
switch (status) {
case Quest::QuestStatus::Available: return 0;
@@ -234,6 +238,9 @@ namespace ZL {
toastTextureItemAdded = loadLocalizedTexture("resources/w/ui/img/toast/item_received001.png", zipFile);
toastTextureItemRemoved = loadLocalizedTexture("resources/w/ui/img/toast/item_removed001.png", zipFile);
languageLoadingRu = renderer.textureManager.LoadFromPng("resources/loading_land003_ru.png", zipFile);
languageLoadingEn = renderer.textureManager.LoadFromPng("resources/loading_land003_en.png", zipFile);
gameState_.questJournal.onQuestUnlocked = [this](const std::string& id) {
const Quest::QuestState* q = gameState_.questJournal.findQuest(id);
if (q) showToast(toastTextureQuestNew, q->definition.title);
@@ -393,16 +400,6 @@ namespace ZL {
uiManager.setSliderValue("musicVolumeSlider", musicFrac);
uiManager.setSliderValue("soundVolumeSlider", soundFrac);
static std::string musicVolumePrefix = "Громкость музыки: ";
static std::string soundVolumePrefix = "Громкость звука: ";
static std::string musicToggleOn = "Музыка: ВКЛ";
static std::string musicToggleOff = "Музыка: ВЫКЛ";
static std::string soundToggleOn = "Звук: ВКЛ";
static std::string soundToggleOff = "Звук: ВЫКЛ";
static std::string fullScreenToggleOn = "Полноэкранный режим: ВКЛ";
static std::string fullScreenToggleOff = "Полноэкранный режим: ВЫКЛ";
if (g_currentLanguage == Language::English)
{
musicVolumePrefix = "Music volume: ";
@@ -414,6 +411,17 @@ namespace ZL {
fullScreenToggleOn = "Full Screen: ON";
fullScreenToggleOff = "Full Screen: OFF";
}
else if (g_currentLanguage == Language::Russian)
{
musicVolumePrefix = "Громкость музыки: ";
soundVolumePrefix = "Громкость звука: ";
musicToggleOn = "Музыка: ВКЛ";
musicToggleOff = "Музыка: ВЫКЛ";
soundToggleOn = "Звук: ВКЛ";
soundToggleOff = "Звук: ВЫКЛ";
fullScreenToggleOn = "Полноэкранный режим: ВКЛ";
fullScreenToggleOff = "Полноэкранный режим: ВЫКЛ";
}
uiManager.setText("musicVolumeText",
musicVolumePrefix + std::to_string(audioPlayer_.getMusicVolume()));
@@ -439,23 +447,23 @@ namespace ZL {
auto refreshMusicToggle = [this]() {
const bool on = audioPlayer_.isMusicEnabled();
uiManager.setTextButtonText("musicToggleButton", on ? musicToggleOn : musicToggleOff);
uiManager.setTextButtonColor("musicToggleButton", on
/*uiManager.setTextButtonColor("musicToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
};
auto refreshSoundToggle = [this]() {
const bool on = audioPlayer_.isSoundEnabled();
uiManager.setTextButtonText("soundToggleButton", on ? soundToggleOn : soundToggleOff);
uiManager.setTextButtonColor("soundToggleButton", on
/*uiManager.setTextButtonColor("soundToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
};
auto refreshFullscreenToggle = [this]() {
const bool on = Environment::isFullscreen;
uiManager.setTextButtonText("fullScreenToggleButton", on ? fullScreenToggleOn : fullScreenToggleOff);
uiManager.setTextButtonColor("fullScreenToggleButton", on
/*uiManager.setTextButtonColor("fullScreenToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
};
refreshMusicToggle();
@@ -466,18 +474,18 @@ namespace ZL {
audioPlayer_.setMusicEnabled(!audioPlayer_.isMusicEnabled());
const bool on = audioPlayer_.isMusicEnabled();
uiManager.setTextButtonText("musicToggleButton", on ? musicToggleOn : musicToggleOff);
uiManager.setTextButtonColor("musicToggleButton", on
/*uiManager.setTextButtonColor("musicToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("soundToggleButton", [this](const std::string&) {
audioPlayer_.setSoundEnabled(!audioPlayer_.isSoundEnabled());
const bool on = audioPlayer_.isSoundEnabled();
uiManager.setTextButtonText("soundToggleButton", on ? soundToggleOn : soundToggleOff);
uiManager.setTextButtonColor("soundToggleButton", on
/*uiManager.setTextButtonColor("soundToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });*/
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("fullScreenToggleButton", [this, refreshFullscreenToggle](const std::string&) {
@@ -575,9 +583,20 @@ namespace ZL {
int slot = i + 1;
if (getSlotInfoFunc) {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string emptyText;
if (ZL::g_currentLanguage == ZL::Language::Russian)
{
emptyText = EMPTY_LANGUAGE_RU;
}
else if (ZL::g_currentLanguage == ZL::Language::English)
{
emptyText = EMPTY_LANGUAGE_EN;
}
std::string label = info.empty
? "Empty"
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
? emptyText
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(kSlotButtons[i], label);
}
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
@@ -605,18 +624,40 @@ namespace ZL {
const char* buttonName = kSlotButtons[i];
if (getSlotInfoFunc) {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string emptyText;
if (ZL::g_currentLanguage == ZL::Language::Russian)
{
emptyText = EMPTY_LANGUAGE_RU;
}
else if (ZL::g_currentLanguage == ZL::Language::English)
{
emptyText = EMPTY_LANGUAGE_EN;
}
std::string label = info.empty
? "Empty"
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
? emptyText
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
}
uiManager.setTextButtonCallback(buttonName, [this, slot, buttonName](const std::string&) {
if (onSaveGame) onSaveGame(slot);
if (getSlotInfoFunc) {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string emptyText;
if (ZL::g_currentLanguage == ZL::Language::Russian)
{
emptyText = EMPTY_LANGUAGE_RU;
}
else if (ZL::g_currentLanguage == ZL::Language::English)
{
emptyText = EMPTY_LANGUAGE_EN;
}
std::string label = info.empty
? "Empty"
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
? emptyText
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
}