Fixing lots of UI bugs
This commit is contained in:
1 parent
8e745ce0cd
commit
79413e7319
33 files changed
+1740
-1342
No files matched your search
+20
-1
@@ -823,7 +823,26 @@ namespace ZL
|
||||
renderer.PushMatrix();
|
||||
renderer.LoadIdentity();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, loadingTexture->getTexID());
|
||||
if (showLoadingProgressBar == false) // Loading language screen
|
||||
{
|
||||
if (ZL::g_currentLanguage == ZL::Language::English)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, menuManager.languageLoadingEn->getTexID());
|
||||
}
|
||||
else if (ZL::g_currentLanguage == ZL::Language::Russian)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, menuManager.languageLoadingRu->getTexID());
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, loadingTexture->getTexID());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, loadingTexture->getTexID());
|
||||
}
|
||||
|
||||
renderer.DrawVertexRenderStruct(loadingMesh);
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
+67
-26
@@ -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");
|
||||
}
|
||||
|
||||
@@ -123,6 +123,9 @@ namespace ZL {
|
||||
std::shared_ptr<Texture> toastTextureItemAdded;
|
||||
std::shared_ptr<Texture> toastTextureItemRemoved;
|
||||
|
||||
std::shared_ptr<Texture> languageLoadingRu;
|
||||
std::shared_ptr<Texture> languageLoadingEn;
|
||||
|
||||
protected:
|
||||
Renderer& renderer;
|
||||
|
||||
@@ -316,6 +319,15 @@ namespace ZL {
|
||||
float chatFboQuadLastProjH_ = -1.0f;
|
||||
bool chatFboQuadLastPortrait_ = false;
|
||||
|
||||
std::string musicVolumePrefix;
|
||||
std::string soundVolumePrefix;
|
||||
std::string musicToggleOn;
|
||||
std::string musicToggleOff;
|
||||
std::string soundToggleOn;
|
||||
std::string soundToggleOff;
|
||||
std::string fullScreenToggleOn;
|
||||
std::string fullScreenToggleOff;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ZL
|
||||
+18
-10
@@ -50,19 +50,27 @@ bool TextRenderer::init(Renderer& renderer, const std::string& ttfPath, int pixe
|
||||
|
||||
r = &renderer;
|
||||
|
||||
static bool shaderAlreadyAdded = false;
|
||||
|
||||
if (shaderAlreadyAdded == false)
|
||||
{
|
||||
shaderAlreadyAdded = true;
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
r->shaderManager.AddShaderFromFiles(shaderName,
|
||||
"resources/shaders/text2d.vertex",
|
||||
"resources/shaders/text2d_web.fragment",
|
||||
zipfilename
|
||||
);
|
||||
r->shaderManager.AddShaderFromFiles(shaderName,
|
||||
"resources/shaders/text2d.vertex",
|
||||
"resources/shaders/text2d_web.fragment",
|
||||
zipfilename
|
||||
);
|
||||
#else
|
||||
r->shaderManager.AddShaderFromFiles(shaderName,
|
||||
"resources/shaders/text2d.vertex",
|
||||
"resources/shaders/text2d_desktop.fragment",
|
||||
zipfilename
|
||||
);
|
||||
r->shaderManager.AddShaderFromFiles(shaderName,
|
||||
"resources/shaders/text2d.vertex",
|
||||
"resources/shaders/text2d_desktop.fragment",
|
||||
zipfilename
|
||||
);
|
||||
#endif
|
||||
|
||||
}
|
||||
ZL::CheckGlError(__FILE__, __LINE__);
|
||||
if (!loadGlyphs(ttfPath, pixelSize, zipfilename)) return false;
|
||||
ZL::CheckGlError(__FILE__, __LINE__);
|
||||
|
||||
Reference in new issue
Block a user