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/keybinding_manager.hpp"
#include "core/input.hpp"
#include "core/application.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) {
// P key toggle (edge-triggered)
bool wantsTextInput = ImGui::GetIO().WantTextInput;
bool pDown = !wantsTextInput && core::Input::getInstance().isKeyPressed(SDL_SCANCODE_P);
if (pDown && !pKeyWasDown) {
// Spellbook toggle via keybinding (edge-triggered)
// Customizable key (default: P) from KeybindingManager
bool spellbookDown = KeybindingManager::getInstance().isActionPressed(
KeybindingManager::Action::TOGGLE_SPELLBOOK, false);
if (spellbookDown && !pKeyWasDown) {
open = !open;
}
pKeyWasDown = pDown;
pKeyWasDown = spellbookDown;
if (!open) return;

View file

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