refactor: use keybinding manager for spellbook and talents toggles instead of hardcoded keys

This commit is contained in:
Kelsi 2026-03-11 08:58:20 -07:00
parent 46365f4738
commit 7220737d48
2 changed files with 14 additions and 10 deletions

View file

@ -1,4 +1,5 @@
#include "ui/spellbook_screen.hpp" #include "ui/spellbook_screen.hpp"
#include "ui/keybinding_manager.hpp"
#include "core/input.hpp" #include "core/input.hpp"
#include "core/application.hpp" #include "core/application.hpp"
#include "rendering/vk_context.hpp" #include "rendering/vk_context.hpp"
@ -563,13 +564,14 @@ void SpellbookScreen::renderSpellTooltip(const SpellInfo* info, game::GameHandle
} }
void SpellbookScreen::render(game::GameHandler& gameHandler, pipeline::AssetManager* assetManager) { void SpellbookScreen::render(game::GameHandler& gameHandler, pipeline::AssetManager* assetManager) {
// P key toggle (edge-triggered) // Spellbook toggle via keybinding (edge-triggered)
bool wantsTextInput = ImGui::GetIO().WantTextInput; // Customizable key (default: P) from KeybindingManager
bool pDown = !wantsTextInput && core::Input::getInstance().isKeyPressed(SDL_SCANCODE_P); bool spellbookDown = KeybindingManager::getInstance().isActionPressed(
if (pDown && !pKeyWasDown) { KeybindingManager::Action::TOGGLE_SPELLBOOK, false);
if (spellbookDown && !pKeyWasDown) {
open = !open; open = !open;
} }
pKeyWasDown = pDown; pKeyWasDown = spellbookDown;
if (!open) return; if (!open) return;

View file

@ -1,4 +1,5 @@
#include "ui/talent_screen.hpp" #include "ui/talent_screen.hpp"
#include "ui/keybinding_manager.hpp"
#include "core/input.hpp" #include "core/input.hpp"
#include "core/application.hpp" #include "core/application.hpp"
#include "core/logger.hpp" #include "core/logger.hpp"
@ -22,13 +23,14 @@ static const char* getClassName(uint8_t classId) {
} }
void TalentScreen::render(game::GameHandler& gameHandler) { void TalentScreen::render(game::GameHandler& gameHandler) {
// N key toggle (edge-triggered) // Talents toggle via keybinding (edge-triggered)
bool wantsTextInput = ImGui::GetIO().WantTextInput; // Customizable key (default: N) from KeybindingManager
bool nDown = !wantsTextInput && core::Input::getInstance().isKeyPressed(SDL_SCANCODE_N); bool talentsDown = KeybindingManager::getInstance().isActionPressed(
if (nDown && !nKeyWasDown) { KeybindingManager::Action::TOGGLE_TALENTS, false);
if (talentsDown && !nKeyWasDown) {
open = !open; open = !open;
} }
nKeyWasDown = nDown; nKeyWasDown = talentsDown;
if (!open) return; if (!open) return;