From 64ea43d538a95ab4fb250a3af435b1b1a3e2b31c Mon Sep 17 00:00:00 2001 From: Trihedraf Date: Sat, 23 Apr 2022 18:30:59 +0000 Subject: [PATCH] show item labels toggle in menu Co-Authored-By: obligaron <25415264+obligaron@users.noreply.github.com> --- Source/options.cpp | 2 ++ Source/options.h | 2 ++ Source/qol/itemlabels.cpp | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/options.cpp b/Source/options.cpp index a416cf28d..2f5272818 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -833,6 +833,7 @@ GameplayOptions::GameplayOptions() , autoEquipJewelry("Auto Equip Jewelry", OptionEntryFlags::None, N_("Auto Equip Jewelry"), N_("Jewelry will be automatically equipped on pickup or purchase if enabled."), false) , randomizeQuests("Randomize Quests", OptionEntryFlags::CantChangeInGame, N_("Randomize Quests"), N_("Randomly selecting available quests for new games."), true) , showMonsterType("Show Monster Type", OptionEntryFlags::None, N_("Show Monster Type"), N_("Hovering over a monster will display the type of monster in the description box in the UI."), false) + , showItemLabels("Show Item Labels", OptionEntryFlags::None, N_("Show Item Labels"), N_("Show labels for items on the ground when enabled."), false) , autoRefillBelt("Auto Refill Belt", OptionEntryFlags::None, N_("Auto Refill Belt"), N_("Refill belt from inventory when belt item is consumed."), false) , disableCripplingShrines("Disable Crippling Shrines", OptionEntryFlags::None, N_("Disable Crippling Shrines"), N_("When enabled Cauldrons, Fascinating Shrines, Goat Shrines, Ornate Shrines and Sacred Shrines are not able to be clicked on and labeled as disabled."), false) , quickCast("Quick Cast", OptionEntryFlags::None, N_("Quick Cast"), N_("Spell hotkeys instantly cast the spell, rather than switching the readied spell."), false) @@ -863,6 +864,7 @@ std::vector GameplayOptions::GetEntries() &experienceBar, &enemyHealthBar, &showMonsterType, + &showItemLabels, &disableCripplingShrines, &quickCast, &autoRefillBelt, diff --git a/Source/options.h b/Source/options.h index 1aff4be83..23bb4cda6 100644 --- a/Source/options.h +++ b/Source/options.h @@ -466,6 +466,8 @@ struct GameplayOptions : OptionCategoryBase { OptionEntryBoolean randomizeQuests; /** @brief Indicates whether or not monster type (Animal, Demon, Undead) is shown along with other monster information. */ OptionEntryBoolean showMonsterType; + /** @brief Displays item labels for items on the ground. */ + OptionEntryBoolean showItemLabels; /** @brief Refill belt from inventory, or rather, use potions/scrolls from inventory first when belt item is consumed. */ OptionEntryBoolean autoRefillBelt; /** @brief Locally disable clicking on shrines which permanently cripple character. */ diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index e7ff4e354..e4c6c290a 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -13,6 +13,7 @@ #include "gmenu.h" #include "inv.h" #include "itemlabels.h" +#include "options.h" #include "qol/stash.h" #include "utils/language.h" #include "utils/stdcompat/string_view.hpp" @@ -32,7 +33,6 @@ std::vector labelQueue; bool altPressed = false; bool isLabelHighlighted = false; std::array, ITEMTYPES> labelCenterOffsets; -bool invertHighlightToggle = false; const int BorderX = 4; // minimal horizontal space between labels const int BorderY = 2; // minimal vertical space between labels @@ -44,7 +44,7 @@ const int Height = 11 + MarginY * 2; // going above 13 scatters labels of items void ToggleItemLabelHighlight() { - invertHighlightToggle = !invertHighlightToggle; + sgOptions.Gameplay.showItemLabels.SetValue(!*sgOptions.Gameplay.showItemLabels); } void AltPressed(bool pressed) @@ -59,7 +59,7 @@ bool IsItemLabelHighlighted() bool IsHighlightingLabelsEnabled() { - return altPressed != invertHighlightToggle; + return altPressed != *sgOptions.Gameplay.showItemLabels; } void AddItemToLabelQueue(int id, int x, int y)