|
@@ -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 <SDL_render.h>
|
|
|
|
|
@@ -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<int>(fontPtr->getStringWidth(textToDisplay))); // do not get smaller (can cause graphical glitches)
|
|
|
+ maxPerformanceOverlayTextWidth = std::max(maxPerformanceOverlayTextWidth, static_cast<int>(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));
|