diff --git a/Source/control.cpp b/Source/control.cpp index 56ac49a3..1d344dba 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -484,6 +484,21 @@ void DrawManaFlaskLower(const Surface &out) DrawFlaskLower(out, *pManaBuff, ManaFlaskLowerOffeset, Players[MyPlayerId]._pManaPer); } +void DrawFlaskValues(const Surface &out, Point pos, int currValue, int maxValue) +{ + UiFlags color = (currValue > 0 ? (currValue == maxValue ? UiFlags::ColorGold : UiFlags::ColorWhite) : UiFlags::ColorRed); + + auto drawStringWithShadow = [out, color](string_view text, Point pos) { + DrawString(out, text, pos + Displacement { -1, -1 }, UiFlags::ColorBlack | UiFlags::KerningFitSpacing, 0); + DrawString(out, text, pos, color | UiFlags::KerningFitSpacing, 0); + }; + + std::string currText = fmt::format("{:d}", currValue); + drawStringWithShadow(currText, pos - Displacement { GetLineWidth(currText, GameFont12) + 1, 0 }); + drawStringWithShadow("/", pos); + drawStringWithShadow(fmt::format("{:d}", maxValue), pos + Displacement { GetLineWidth("/", GameFont12) + 1, 0 }); +} + void control_update_life_mana() { Players[MyPlayerId].UpdateManaPercentage(); diff --git a/Source/control.h b/Source/control.h index eac77975..a7ed18a1 100644 --- a/Source/control.h +++ b/Source/control.h @@ -105,6 +105,11 @@ void DrawManaFlaskUpper(const Surface &out); */ void DrawManaFlaskLower(const Surface &out); +/** + * Controls drawing of current / max values (health, mana) within the control panel. + */ +void DrawFlaskValues(const Surface &out, Point pos, int currValue, int maxValue); + /** * @brief calls on the active player object to update HP/Mana percentage variables * diff --git a/Source/options.cpp b/Source/options.cpp index c0a0bc65..2c6a19bf 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -765,6 +765,8 @@ GraphicsOptions::GraphicsOptions() #endif , limitFPS("FPS Limiter", OptionEntryFlags::None, N_("FPS Limiter"), N_("FPS is limited to avoid high CPU load. Limit considers refresh rate."), true) , showFPS("Show FPS", OptionEntryFlags::None, N_("Show FPS"), N_("Displays the FPS in the upper left corner of the screen."), true) + , showHealthValues("Show health values", OptionEntryFlags::None, N_("Show health values"), N_("Displays current / max health value on health globe."), false) + , showManaValues("Show mana values", OptionEntryFlags::None, N_("Show mana values"), N_("Displays current / max mana value on mana globe."), false) { resolution.SetValueChangedCallback(ResizeWindow); fullscreen.SetValueChangedCallback(SetFullscreenMode); @@ -798,6 +800,8 @@ std::vector GraphicsOptions::GetEntries() #endif &limitFPS, &showFPS, + &showHealthValues, + &showManaValues, &colorCycling, #if SDL_VERSION_ATLEAST(2, 0, 0) &hardwareCursor, diff --git a/Source/options.h b/Source/options.h index 03e8a6e6..16f0d187 100644 --- a/Source/options.h +++ b/Source/options.h @@ -408,6 +408,10 @@ struct GraphicsOptions : OptionCategoryBase { OptionEntryBoolean limitFPS; /** @brief Show FPS, even without the -f command line flag. */ OptionEntryBoolean showFPS; + /** @brief Display current/max health values on health globe. */ + OptionEntryBoolean showHealthValues; + /** @brief Display current/max mana values on mana globe. */ + OptionEntryBoolean showManaValues; }; struct GameplayOptions : OptionCategoryBase { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 36cef563..afb6d268 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1739,6 +1739,10 @@ void DrawAndBlit() hgt = gnScreenHeight; } DrawXPBar(out); + if (*sgOptions.Graphics.showHealthValues) + DrawFlaskValues(out, { PANEL_X + 134, PANEL_Y + 28 }, MyPlayer->_pHitPoints >> 6, MyPlayer->_pMaxHP >> 6); + if (*sgOptions.Graphics.showManaValues) + DrawFlaskValues(out, { PANEL_X + PANEL_WIDTH - 138, PANEL_Y + 28 }, MyPlayer->_pMana >> 6, MyPlayer->_pMaxMana >> 6); if (IsHardwareCursor()) { SetHardwareCursorVisible(ShouldShowCursor());