Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ GameplayOptions::GameplayOptions()
, showItemGraphicsInStores("Show Item Graphics in Stores", OptionEntryFlags::None, N_("Show Item Graphics in Stores"), N_("Show item graphics to the left of item descriptions in store menus."), false)
, 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)
, showRemainingCharges("Show Remaining Staff Charges", OptionEntryFlags::None, N_("Show Remaining Staff Charges"), N_("Displays remaining Staff Charges on Staff Spell Icon."), false)
, enemyHealthBar("Enemy Health Bar", OptionEntryFlags::None, N_("Enemy Health Bar"), N_("Enemy Health Bar is displayed at the top of the screen."), false)
, autoGoldPickup("Auto Gold Pickup", OptionEntryFlags::None, N_("Auto Gold Pickup"), N_("Gold is automatically collected when in close proximity to the player."), false)
, autoElixirPickup("Auto Elixir Pickup", OptionEntryFlags::None, N_("Auto Elixir Pickup"), N_("Elixirs are automatically collected when in close proximity to the player."), false)
Expand Down Expand Up @@ -786,6 +787,7 @@ std::vector<OptionEntryBase *> GameplayOptions::GetEntries()
&showItemGraphicsInStores,
&showHealthValues,
&showManaValues,
&showRemainingCharges,
&enemyHealthBar,
&showMonsterType,
&showItemLabels,
Expand Down
2 changes: 2 additions & 0 deletions Source/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ struct GameplayOptions : OptionCategoryBase {
OptionEntryBoolean showHealthValues;
/** @brief Display current/max mana values on mana globe. */
OptionEntryBoolean showManaValues;
/** @brief Display remaining staff charges on staff spell icon. */
OptionEntryBoolean showRemainingCharges;
/** @brief Show enemy health at the top of the screen. */
OptionEntryBoolean enemyHealthBar;
/** @brief Automatically pick up gold when walking over it. */
Expand Down
26 changes: 26 additions & 0 deletions Source/panels/spell_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ std::optional<std::string_view> GetHotkeyName(SpellID spellId, SpellType spellTy
return {};
}

void PrintSBookRemainingCharges(const Surface &out, Point pos)
{
const Player &myPlayer = *MyPlayer;

if (myPlayer._pRSplType != SpellType::Charges)
return;

const Item &staff = myPlayer.InvBody[INVLOC_HAND_LEFT];

UiFlags color = (staff._iCharges == staff._iMaxCharges ? UiFlags::ColorGold : UiFlags::ColorBlue);

auto drawStringWithShadow = [out, color](std::string_view text, Point pos) {
DrawString(out, text, pos + Displacement { -1, -1 },
{ .flags = UiFlags::ColorBlack | UiFlags::KerningFitSpacing, .spacing = 0 });
DrawString(out, text, pos,
{ .flags = color | UiFlags::KerningFitSpacing, .spacing = 0 });
};

std::string currText = StrCat(staff._iCharges);
drawStringWithShadow(currText, pos + Displacement { 2, -12 });
}

} // namespace

void DrawSpell(const Surface &out)
Expand Down Expand Up @@ -111,6 +133,10 @@ void DrawSpell(const Surface &out)
std::optional<std::string_view> hotkeyName = GetHotkeyName(spl, myPlayer._pRSplType, true);
if (hotkeyName)
PrintSBookHotkey(out, position, *hotkeyName);

if (*GetOptions().Gameplay.showRemainingCharges) {
PrintSBookRemainingCharges(out, position);
}
}

void DrawSpellList(const Surface &out)
Expand Down
Loading