diff --git a/Mods/vcmi/Content/config/english.json b/Mods/vcmi/Content/config/english.json index 74281e3bc..5253930d1 100644 --- a/Mods/vcmi/Content/config/english.json +++ b/Mods/vcmi/Content/config/english.json @@ -97,6 +97,9 @@ "vcmi.randomMap.description.monster.normal" : "normal", "vcmi.randomMap.description.monster.strong" : "strong", + "vcmi.overlay.battery" : "Battery", + "vcmi.overlay.charging" : "Charging", + "vcmi.spellBook.search" : "search...", "vcmi.spellBook.tab.hover" : "%s Spells", "vcmi.spellBook.tab.help" : "Turn to view %s spells", @@ -313,8 +316,8 @@ "vcmi.systemOptions.longTouchMenu.hover" : "Select Long Touch Interval", "vcmi.systemOptions.longTouchMenu.help" : "Change duration of long touch interval.", "vcmi.systemOptions.longTouchMenu.entry" : "%d milliseconds", - "vcmi.systemOptions.infoboxButton.hover" : "Show Infobox (with FPS)", - "vcmi.systemOptions.infoboxButton.help" : "{Show Infobox}\n\nToggle the visibility of the infobox with additional information like frames per second, time and battery charge level (if available) in the corner of the game window.", + "vcmi.systemOptions.performanceOverlayButton.hover" : "Show Performance Overlay", + "vcmi.systemOptions.performanceOverlayButton.help" : "{Show Performance Overlay}\n\nToggle the visibility of the overlay with additional information like frames per second, time and battery charge level (if available) in the corner of the game window.", "vcmi.systemOptions.hapticFeedbackButton.hover" : "Haptic feedback", "vcmi.systemOptions.hapticFeedbackButton.help" : "{Haptic feedback}\n\nToggle the haptic feedback on touch inputs.", "vcmi.systemOptions.enableUiEnhancementsButton.hover" : "Interface Enhancements", diff --git a/Mods/vcmi/Content/config/german.json b/Mods/vcmi/Content/config/german.json index 8f6ba2957..0b013ec78 100644 --- a/Mods/vcmi/Content/config/german.json +++ b/Mods/vcmi/Content/config/german.json @@ -97,6 +97,9 @@ "vcmi.randomMap.description.monster.normal" : "Normal", "vcmi.randomMap.description.monster.strong" : "Stark", + "vcmi.overlay.battery" : "Batterie", + "vcmi.overlay.charging" : "Lädt", + "vcmi.spellBook.search" : "suchen...", "vcmi.spellBook.tab.hover" : "%szauber", "vcmi.spellBook.tab.help" : "Zu %szaubersprüchen blättern", @@ -313,8 +316,8 @@ "vcmi.systemOptions.longTouchMenu.hover" : "Wähle Dauer für Touch", "vcmi.systemOptions.longTouchMenu.help" : "Ändere die Dauer für den langen Touch", "vcmi.systemOptions.longTouchMenu.entry" : "%d Millisekunden", - "vcmi.systemOptions.infoboxButton.hover" : "Infobox anzeigen (mit FPS)", - "vcmi.systemOptions.infoboxButton.help" : "{Infobox anzeigen}\n\n Schaltet die Sichtbarkeit einer Infobox für zusätzliche Informationen, wie eines Zählers für die Bilder pro Sekunde, der Uhrzeit oder des Batterieladezustands (wenn verfügbar) in der Ecke des Spielfensters um.", + "vcmi.systemOptions.performanceOverlayButton.hover" : "Leistungs-Overlay anzeigen", + "vcmi.systemOptions.performanceOverlayButton.help" : "{Leistungs-Overlay anzeigen}\n\n Schaltet die Sichtbarkeit eines Overlays für zusätzliche Informationen, wie eines Zählers für die Bilder pro Sekunde, der Uhrzeit oder des Batterieladezustands (wenn verfügbar) in der Ecke des Spielfensters um.", "vcmi.systemOptions.hapticFeedbackButton.hover" : "Haptisches Feedback", "vcmi.systemOptions.hapticFeedbackButton.help" : "{Haptisches Feedback}\n\nHaptisches Feedback bei Touch-Eingaben.", "vcmi.systemOptions.enableUiEnhancementsButton.hover" : "Interface Verbesserungen", diff --git a/client/GameEngine.cpp b/client/GameEngine.cpp index 771d26759..283e611af 100644 --- a/client/GameEngine.cpp +++ b/client/GameEngine.cpp @@ -9,6 +9,7 @@ */ #include "StdInc.h" #include "GameEngine.h" +#include "GameLibrary.h" #include "gui/CIntObject.h" #include "gui/CursorHandler.h" @@ -36,6 +37,7 @@ #include "../lib/AsyncRunner.h" #include "../lib/CConfigHandler.h" #include "../lib/texts/TextOperations.h" +#include "../lib/texts/CGeneralTextHandler.h" #include @@ -126,8 +128,8 @@ void GameEngine::updateFrame() handleEvents(); windows().simpleRedraw(); - if (settings["video"]["infobox"]["show"].Bool()) - drawInfoBox(); + if (settings["video"]["performanceOverlay"]["show"].Bool()) + drawPerformanceOverlay(); screenHandlerInstance->updateScreenTexture(); @@ -185,7 +187,7 @@ Point GameEngine::screenDimensions() const return screenHandlerInstance->getLogicalResolution(); } -void GameEngine::drawInfoBox() +void GameEngine::drawPerformanceOverlay() { auto font = EFonts::FONT_SMALL; const auto & fontPtr = ENGINE->renderHandler().loadFont(font); @@ -194,10 +196,10 @@ void GameEngine::drawInfoBox() auto powerState = ENGINE->input().getPowerState(); std::string powerSymbol = ""; // add symbol if emoji are supported (e.g. VCMI extras) - if(fontPtr->canRepresentCharacter("🔋") && powerState.powerState == PowerStateMode::ON_BATTERY) - powerSymbol = "🔋 "; - else if(fontPtr->canRepresentCharacter("🔌") && powerState.powerState == PowerStateMode::CHARGING) - powerSymbol = "🔌 "; + if(powerState.powerState == PowerStateMode::ON_BATTERY) + powerSymbol = fontPtr->canRepresentCharacter("🔋") ? "🔋 " : (LIBRARY->generaltexth->translate("vcmi.overlay.battery") + " "); + else if(powerState.powerState == PowerStateMode::CHARGING) + powerSymbol = fontPtr->canRepresentCharacter("🔌") ? "🔌 " : (LIBRARY->generaltexth->translate("vcmi.overlay.charging") + " "); std::string fps = std::to_string(framerate().getFramerate())+" FPS"; std::string time = TextOperations::getFormattedTimeLocal(std::time(nullptr)); @@ -205,23 +207,23 @@ void GameEngine::drawInfoBox() std::string textToDisplay = time + (power.empty() ? "" : " | " + power) + " | " + fps; - maxInfoBoxTextWidth = std::max(maxInfoBoxTextWidth, static_cast(fontPtr->getStringWidth(textToDisplay))); // do not get smaller (can cause graphical glitches) + maxPerformanceOverlayTextWidth = std::max(maxPerformanceOverlayTextWidth, static_cast(fontPtr->getStringWidth(textToDisplay))); // do not get smaller (can cause graphical glitches) Rect targetArea; - std::string edge = settings["video"]["infobox"]["edge"].String(); - int pos1 = settings["video"]["infobox"]["pos1"].Integer(); - int pos2 = settings["video"]["infobox"]["pos2"].Integer(); + std::string edge = settings["video"]["performanceOverlay"]["edge"].String(); + int marginTopBottom = settings["video"]["performanceOverlay"]["marginTopBottom"].Integer(); + int marginLeftRight = settings["video"]["performanceOverlay"]["marginLeftRight"].Integer(); - Point boxSize(maxInfoBoxTextWidth + 4, fontPtr->getLineHeight() + 2); + Point boxSize(maxPerformanceOverlayTextWidth + 6, fontPtr->getLineHeight() + 2); if (edge == "topleft") - targetArea = Rect(pos2, pos1, boxSize.x, boxSize.y); + targetArea = Rect(marginLeftRight, marginTopBottom, boxSize.x, boxSize.y); else if (edge == "topright") - targetArea = Rect(screenDimensions().x - pos2 - boxSize.x, pos1, boxSize.x, boxSize.y); + targetArea = Rect(screenDimensions().x - marginLeftRight - boxSize.x, marginTopBottom, boxSize.x, boxSize.y); else if (edge == "bottomleft") - targetArea = Rect(pos2, screenDimensions().y - pos1 - boxSize.y, boxSize.x, boxSize.y); + targetArea = Rect(marginLeftRight, screenDimensions().y - marginTopBottom - boxSize.y, boxSize.x, boxSize.y); else if (edge == "bottomright") - targetArea = Rect(screenDimensions().x - pos2 - boxSize.x, screenDimensions().y - pos1 - boxSize.y, boxSize.x, boxSize.y); + targetArea = Rect(screenDimensions().x - marginLeftRight - boxSize.x, screenDimensions().y - marginTopBottom - boxSize.y, boxSize.x, boxSize.y); target.drawColor(targetArea.resize(1), Colors::BRIGHT_YELLOW); target.drawColor(targetArea, ColorRGBA(0, 0, 0)); diff --git a/client/GameEngine.h b/client/GameEngine.h index 177eed215..339032a31 100644 --- a/client/GameEngine.h +++ b/client/GameEngine.h @@ -57,11 +57,11 @@ private: IGameEngineUser *engineUser = nullptr; - int maxInfoBoxTextWidth = 0; + int maxPerformanceOverlayTextWidth = 0; void updateFrame(); void handleEvents(); //takes events from queue and calls interested objects - void drawInfoBox(); // draws box with additional infos (e.g. fps) + void drawPerformanceOverlay(); // draws box with additional infos (e.g. fps) public: std::mutex interfaceMutex; diff --git a/client/windows/settings/GeneralOptionsTab.cpp b/client/windows/settings/GeneralOptionsTab.cpp index 201ae31f1..c00ef1be2 100644 --- a/client/windows/settings/GeneralOptionsTab.cpp +++ b/client/windows/settings/GeneralOptionsTab.cpp @@ -152,9 +152,9 @@ GeneralOptionsTab::GeneralOptionsTab() { selectLongTouchDuration(); }); - addCallback("infoboxChanged", [](bool value) + addCallback("performanceOverlayChanged", [](bool value) { - Settings gameRes = settings.write["video"]["infobox"]; + Settings gameRes = settings.write["video"]["performanceOverlay"]; gameRes["show"].Bool() = value; }); addCallback("hapticFeedbackChanged", [](bool value) @@ -226,8 +226,8 @@ GeneralOptionsTab::GeneralOptionsTab() if (fullscreenExclusiveCheckbox) fullscreenExclusiveCheckbox->setSelected(settings["video"]["fullscreen"].Bool() && settings["video"]["realFullscreen"].Bool()); - std::shared_ptr infoboxCheckbox = widget("infoboxCheckbox"); - infoboxCheckbox->setSelected(settings["video"]["infobox"]["show"].Bool()); + std::shared_ptr infoboxCheckbox = widget("performanceOverlayCheckbox"); + infoboxCheckbox->setSelected(settings["video"]["performanceOverlay"]["show"].Bool()); std::shared_ptr hapticFeedbackCheckbox = widget("hapticFeedbackCheckbox"); if (hapticFeedbackCheckbox) diff --git a/config/schemas/settings.json b/config/schemas/settings.json index 20689116c..e62b9ef40 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -210,7 +210,7 @@ "spellbookAnimation", "driver", "displayIndex", - "infobox", + "performanceOverlay", "targetfps", "vsync", "fontsType", @@ -270,15 +270,15 @@ "type" : "number", "default" : 0 }, - "infobox" : { + "performanceOverlay" : { "type" : "object", "additionalProperties" : false, - "required" : [ "show", "edge", "pos1", "pos2" ], + "required" : [ "show", "edge", "marginTopBottom", "marginLeftRight" ], "properties" : { "show" : { "type" : "boolean", "default" : false }, "edge" : { "type" : "string", "enum" : [ "topleft", "topright", "bottomleft", "bottomright" ], "default" : "bottomleft" }, - "pos1" : { "type" : "number", "default" : 5 }, - "pos2" : { "type" : "number", "default" : 7 } + "marginTopBottom" : { "type" : "number", "default" : 5 }, + "marginLeftRight" : { "type" : "number", "default" : 7 } } }, "targetfps" : { diff --git a/config/widgets/settings/generalOptionsTab.json b/config/widgets/settings/generalOptionsTab.json index 9e2a07ad7..63f188f62 100644 --- a/config/widgets/settings/generalOptionsTab.json +++ b/config/widgets/settings/generalOptionsTab.json @@ -50,7 +50,7 @@ "created" : "desktop" }, { - "text": "vcmi.systemOptions.infoboxButton.hover" + "text": "vcmi.systemOptions.performanceOverlayButton.hover" }, { "text": "vcmi.systemOptions.enableLargeSpellbookButton.hover" @@ -136,9 +136,9 @@ "created" : "desktop" }, { - "name": "infoboxCheckbox", - "help": "vcmi.systemOptions.infoboxButton", - "callback": "infoboxChanged" + "name": "performanceOverlayCheckbox", + "help": "vcmi.systemOptions.performanceOverlayButton", + "callback": "performanceOverlayChanged" }, { "name": "enableLargeSpellbookCheckbox",