From 55624026468f2ad7132ebe28e9a47a0953230128 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:37:23 +0200 Subject: [PATCH] hotkey number from config --- client/battle/BattleInterfaceClasses.cpp | 6 ++++- client/battle/BattleWindow.cpp | 2 +- config/shortcutsConfig.json | 32 ++++++++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/client/battle/BattleInterfaceClasses.cpp b/client/battle/BattleInterfaceClasses.cpp index 1ae1acd44..62d37c989 100644 --- a/client/battle/BattleInterfaceClasses.cpp +++ b/client/battle/BattleInterfaceClasses.cpp @@ -57,6 +57,8 @@ #include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/networkPacks/PacksForClientBattle.h" #include "../../lib/TextOperations.h" +#include "../../lib/json/JsonUtils.h" + void BattleConsole::showAll(Canvas & to) { @@ -437,6 +439,8 @@ void QuickSpellPanel::create() { OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); + const JsonNode config = JsonUtils::assembleFromFiles("config/shortcutsConfig"); + labels.clear(); buttons.clear(); buttonsDisabled.clear(); @@ -476,7 +480,7 @@ void QuickSpellPanel::create() { buttonsDisabled.push_back(std::make_shared(Rect(2, 5 + 37 * i, 48, 36), ColorRGBA(0, 0, 0, 172))); } - labels.push_back(std::make_shared(7, 8 + 37 * i, EFonts::FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, std::to_string(i))); + labels.push_back(std::make_shared(7, 8 + 37 * i, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, config["keyboard"]["battleSpellShortcut" + std::to_string(i)].String())); buttons.push_back(button); } diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index f641a516a..67e416502 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -204,7 +204,7 @@ void BattleWindow::createQuickSpellWindow() OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; quickSpellWindow = std::make_shared(owner); - quickSpellWindow->moveTo(Point(pos.x - 67, pos.y - 1)); + quickSpellWindow->moveTo(Point(pos.x - 67, pos.y)); if(settings["battle"]["enableQuickSpellPanel"].Bool()) showStickyQuickSpellWindow(); diff --git a/config/shortcutsConfig.json b/config/shortcutsConfig.json index f637e6b52..caf62161d 100644 --- a/config/shortcutsConfig.json +++ b/config/shortcutsConfig.json @@ -65,22 +65,22 @@ "battleRetreat": "R", "battleSelectAction": "S", "battleToggleQuickSpell": "T", - "battleSpellShortcut0": "0", - "battleSpellShortcut1": "1", - "battleSpellShortcut2": "2", - "battleSpellShortcut3": "3", - "battleSpellShortcut4": "4", - "battleSpellShortcut5": "5", - "battleSpellShortcut6": "6", - "battleSpellShortcut7": "7", - "battleSpellShortcut8": "8", - "battleSpellShortcut9": "9", - "battleSpellShortcut10": "Shift+0", - "battleSpellShortcut11": "Shift+1", - "battleSpellShortcut12": "Shift+2", - "battleSpellShortcut13": "Shift+3", - "battleSpellShortcut14": "Shift+4", - "battleSpellShortcut15": "Shift+5", + "battleSpellShortcut0": "1", + "battleSpellShortcut1": "2", + "battleSpellShortcut2": "3", + "battleSpellShortcut3": "4", + "battleSpellShortcut4": "5", + "battleSpellShortcut5": "6", + "battleSpellShortcut6": "7", + "battleSpellShortcut7": "8", + "battleSpellShortcut8": "Shift+1", + "battleSpellShortcut9": "Shift+2", + "battleSpellShortcut10": "Shift+3", + "battleSpellShortcut11": "Shift+4", + "battleSpellShortcut12": "Shift+5", + "battleSpellShortcut13": "Shift+6", + "battleSpellShortcut14": "Shift+7", + "battleSpellShortcut15": "Shift+8", "battleSurrender": "S", "battleTacticsEnd": [ "Return", "Keypad Enter"], "battleTacticsNext": "Space",