From b2567844fc473b01d9179c844c585faa36d062e2 Mon Sep 17 00:00:00 2001 From: zulianc Date: Tue, 25 Mar 2025 20:06:02 +0100 Subject: [PATCH] fini menu keybinds --- src/GraphicalUI/AppMenus/AppMenu.h | 9 +- .../AppMenus/GameSettingsAppMenu.cpp | 18 +- src/GraphicalUI/AppMenus/MainAppMenu.cpp | 8 +- .../AppMenus/SettingsControlsAppMenu.cpp | 8 +- .../AppMenus/SettingsKeybindsAppMenu.cpp | 76 ++++-- .../AppMenus/SettingsKeybindsAppMenu.h | 2 + .../AppMenus/SettingsMainAppMenu.cpp | 10 +- src/GraphicalUI/Keybinds.cpp | 2 +- src/GraphicalUI/Keybinds.h | 225 +++++++++--------- src/GraphicalUI/Settings.cpp | 2 + 10 files changed, 199 insertions(+), 161 deletions(-) diff --git a/src/GraphicalUI/AppMenus/AppMenu.h b/src/GraphicalUI/AppMenus/AppMenu.h index 4862cb8..5feab5e 100644 --- a/src/GraphicalUI/AppMenus/AppMenu.h +++ b/src/GraphicalUI/AppMenus/AppMenu.h @@ -57,11 +57,16 @@ class AppMenu { } } - void placeText(sf::Text& text, const PlayerCursor& playerCursor, const sf::String& string, float xPos, float yPos, const sf::Vector2u& cursorPos) const { + void placeText(sf::Text& text, const std::optional& playerCursor, const sf::String& string, float xPos, float yPos, const std::optional& cursorPos) const { float sizeMultiplier = this->settings->getWindowSizeMultiplier(); text.setString(string); - text.setOutlineThickness((playerCursor.getPosition() == cursorPos) ? (sizeMultiplier / 2) : 0); + if (playerCursor.has_value() && cursorPos.has_value()) { + text.setOutlineThickness((playerCursor.value().getPosition() == cursorPos.value()) ? (sizeMultiplier / 2) : 0); + } + else { + text.setOutlineThickness(0); + } text.setOrigin(sf::Vector2f({0, text.getLocalBounds().size.y / 2})); text.setPosition(sf::Vector2f({sizeMultiplier * xPos, sizeMultiplier * yPos})); this->renderWindow->draw(text); diff --git a/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp b/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp index b4fdfb8..fe6e5c3 100644 --- a/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/GameSettingsAppMenu.cpp @@ -60,17 +60,17 @@ void GameSettingsAppMenu::drawFrame() const { text.setFillColor(sf::Color(0, 0, 0)); text.setOutlineColor(sf::Color(255, 255, 255)); - this->placeTitle(text, std::optional(), "GAME SETTINGS", 5.f, std::optional()); + this->placeTitle(text, {}, "GAME SETTINGS", 5.f, {}); - this->placeText(text, this->playerCursor, "PIECES SELECT (TODO)", 5.f, 15.f, {0, 0}); - this->placeText(text, this->playerCursor, "BOARD SELECT (TODO)", 40.f, 15.f, {1, 0}); + this->placeText(text, this->playerCursor, "PIECES SELECT (TODO)", 5.f, 15.f, sf::Vector2u{0, 0}); + this->placeText(text, this->playerCursor, "BOARD SELECT (TODO)", 40.f, 15.f, sf::Vector2u{1, 0}); - this->placeText(text, this->playerCursor, "SPRINT", 5.f, 25.f, {0, 1}); - this->placeText(text, this->playerCursor, "MARATHON", 25.f, 25.f, {1, 1}); - this->placeText(text, this->playerCursor, "ULTRA", 50.f, 25.f, {2, 1}); - this->placeText(text, this->playerCursor, "MASTER", 5.f, 35.f, {0, 2}); - this->placeText(text, this->playerCursor, "??? (TODO)", 25.f, 35.f, {1, 2}); - this->placeText(text, this->playerCursor, "??? (TODO)", 50.f, 35.f, {2, 2}); + this->placeText(text, this->playerCursor, "SPRINT", 5.f, 25.f, sf::Vector2u{0, 1}); + this->placeText(text, this->playerCursor, "MARATHON", 25.f, 25.f, sf::Vector2u{1, 1}); + this->placeText(text, this->playerCursor, "ULTRA", 50.f, 25.f, sf::Vector2u{2, 1}); + this->placeText(text, this->playerCursor, "MASTER", 5.f, 35.f, sf::Vector2u{0, 2}); + this->placeText(text, this->playerCursor, "??? (TODO)", 25.f, 35.f, sf::Vector2u{1, 2}); + this->placeText(text, this->playerCursor, "??? (TODO)", 50.f, 35.f, sf::Vector2u{2, 2}); this->renderWindow->display(); } diff --git a/src/GraphicalUI/AppMenus/MainAppMenu.cpp b/src/GraphicalUI/AppMenus/MainAppMenu.cpp index 8847ba4..14cafa7 100644 --- a/src/GraphicalUI/AppMenus/MainAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/MainAppMenu.cpp @@ -47,11 +47,11 @@ void MainAppMenu::drawFrame() const { text.setFillColor(sf::Color(0, 0, 0)); text.setOutlineColor(sf::Color(255, 255, 255)); - this->placeTitle(text, std::optional(), "JMINOS", 10.f, std::optional()); + this->placeTitle(text, {}, "JMINOS", 10.f, {}); - this->placeTitle(text, this->playerCursor, "PLAY", 20.f, sf::Vector2u({0, 0})); - this->placeTitle(text, this->playerCursor, "SETTINGS", 30.f, sf::Vector2u({0, 1})); - this->placeTitle(text, this->playerCursor, "INFO (TODO)", 40.f, sf::Vector2u({0, 2})); + this->placeTitle(text, this->playerCursor, "PLAY", 20.f, sf::Vector2u{0, 0}); + this->placeTitle(text, this->playerCursor, "SETTINGS", 30.f, sf::Vector2u{0, 1}); + this->placeTitle(text, this->playerCursor, "INFO (TODO)", 40.f, sf::Vector2u{0, 2}); this->renderWindow->display(); } diff --git a/src/GraphicalUI/AppMenus/SettingsControlsAppMenu.cpp b/src/GraphicalUI/AppMenus/SettingsControlsAppMenu.cpp index 2d4be51..7f35deb 100644 --- a/src/GraphicalUI/AppMenus/SettingsControlsAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/SettingsControlsAppMenu.cpp @@ -65,13 +65,13 @@ void SettingsControlsAppMenu::drawFrame() const { text.setFillColor(sf::Color(0, 0, 0)); text.setOutlineColor(sf::Color(255, 255, 255)); - this->placeTitle(text, std::optional(), "CONTROLS SETTINGS", 5.f, std::optional()); + this->placeTitle(text, {}, "CONTROLS SETTINGS", 5.f, {}); sf::Vector2u windowSize = this->renderWindow->getSize(); - this->placeText(text, this->playerCursor, "< DAS: " + std::to_string(playerControls.getDAS()) + " >", 5.f, 15.f, {0, 0}); - this->placeText(text, this->playerCursor, "< ARR: " + std::to_string(playerControls.getARR()) + " >", 5.f, 25.f, {0, 1}); - this->placeText(text, this->playerCursor, "< SDR: " + std::to_string(playerControls.getSDR()) + " >", 5.f, 35.f, {0, 2}); + this->placeText(text, this->playerCursor, "< DAS: " + std::to_string(playerControls.getDAS()) + " >", 5.f, 15.f, sf::Vector2u{0, 0}); + this->placeText(text, this->playerCursor, "< ARR: " + std::to_string(playerControls.getARR()) + " >", 5.f, 25.f, sf::Vector2u{0, 1}); + this->placeText(text, this->playerCursor, "< SDR: " + std::to_string(playerControls.getSDR()) + " >", 5.f, 35.f, sf::Vector2u{0, 2}); this->renderWindow->display(); } diff --git a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp index 8fb4a20..0e32ff9 100644 --- a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -16,6 +17,8 @@ SettingsKeybindsAppMenu::SettingsKeybindsAppMenu(std::shared_ptr menu AppMenu(menuStack, settings, renderWindow), playerCursor(std::vector(12, 1)) { + this->selectedAnAction = false; + for (Action action : ACTION_LIST_IN_ORDER) { std::string textureName = ACTION_NAMES[action]; textureName = std::regex_replace(textureName, std::regex(" "), ""); @@ -27,20 +30,44 @@ SettingsKeybindsAppMenu::SettingsKeybindsAppMenu(std::shared_ptr menu void SettingsKeybindsAppMenu::computeFrame() { this->updateMetaBinds(); - this->playerCursor.updatePosition(); - if (this->playerCursor.movedLeft()) { - this->settings->selectPreviousKeybinds(); + if (!this->selectedAnAction) { + this->playerCursor.updatePosition(); + + if (this->playerCursor.movedLeft()) { + this->settings->selectPreviousKeybinds(); + } + if (this->playerCursor.movedRight()) { + this->settings->selectNextKeybinds(); + } } - if (this->playerCursor.movedRight()) { - this->settings->selectNextKeybinds(); + else { + bool addedKeybind = false; + for (const auto& [key, string] : KEYS_TO_STRING) { + if (sf::Keyboard::isKeyPressed(key) && (key != sfKey::Enter) && (key != sfKey::Escape)) { + this->settings->getKeybinds().addKey(this->actionSelected, key); + addedKeybind = true; + } + + if (addedKeybind) { + this->selectedAnAction = false; + break; + } + } } - if (this->enterReleased) { - //TODO + if (this->enterReleased && this->settings->getKeybinds().isModifiable()) { + this->selectedAnAction = !selectedAnAction; + this->actionSelected = ACTION_LIST_IN_ORDER[this->playerCursor.getPosition().y - 1]; } if (this->escReleased) { - this->menuStack->pop(); + if (this->selectedAnAction) { + this->settings->getKeybinds().clearKeys(this->actionSelected); + this->selectedAnAction = false; + } + else { + this->menuStack->pop(); + } } } @@ -51,32 +78,45 @@ void SettingsKeybindsAppMenu::drawFrame() const { text.setFillColor(sf::Color(0, 0, 0)); text.setOutlineColor(sf::Color(255, 255, 255)); - this->placeTitle(text, std::optional(), "KEYBINDS SETTINGS", 5.f, std::optional()); + this->placeTitle(text, {}, "KEYBINDS SETTINGS", 5.f, {}); if (this->settings->getKeybindsLayout() == CUSTOMIZABLE_KEYBINDS) { - this->placeText(text, this->playerCursor, "< CUSTOM >", 5.f, 15.f, {0, 0}); + this->placeText(text, this->playerCursor, "< CUSTOM >", 5.f, 15.f, sf::Vector2u{0, 0}); } else { - this->placeText(text, this->playerCursor, "< DEFAULT " + std::to_string(this->settings->getKeybindsLayout() + 1) + " >", 5.f, 15.f, {0, 0}); + this->placeText(text, this->playerCursor, "< DEFAULT " + std::to_string(this->settings->getKeybindsLayout() + 1) + " >", 5.f, 15.f, sf::Vector2u{0, 0}); + } + + if (this->selectedAnAction) { + text.setOutlineColor(sf::Color(255, 0, 0)); } int i = 0; - int firstElem = (this->playerCursor.getPosition().y == 0) ? (unsigned int) 0 : (this->playerCursor.getPosition().y - 1); + int firstElem = std::clamp(((int) this->playerCursor.getPosition().y) - 1, 0, 8); + for (Action action : ACTION_LIST_IN_ORDER) { if (i >= firstElem && i < (firstElem + 3)) { sf::String string; + bool firstKey = true; for (sfKey key : this->settings->getKeybinds().getKeybinds(action)) { - auto keyString = getKeyStringRepresentation(key); - if (keyString.has_value()) { - string += keyString.value() + " "; + if (KEYS_TO_STRING.contains(key)) { + std::string keyString = KEYS_TO_STRING.at(key); + if (firstKey) { + string += keyString; + firstKey = false; + } + else { + string += ", " + keyString; + } } } - this->placeText(text, this->playerCursor, setStringToUpperCase(ACTION_NAMES[action]), 20.f, ((i - firstElem) * 10) + 25.f, {0, (unsigned int) i + 1}); - this->placeText(text, this->playerCursor, string, 50.f, ((i - firstElem) * 10) + 25.f, {0, (unsigned int) i + 1}); + + this->placeText(text, this->playerCursor, setStringToUpperCase(ACTION_NAMES[action]), 15.f, ((i - firstElem) * 10) + 25.f, sf::Vector2u{0, (unsigned int) i + 1}); + this->placeText(text, {}, string, 40.f, ((i - firstElem) * 10) + 25.f, {}); sf::Sprite sprite(this->iconTextures[action]); sprite.setOrigin(sprite.getLocalBounds().getCenter()); - sprite.setPosition(sf::Vector2f(10.f, ((i - firstElem) * 10) + 25.f) * (float) this->settings->getWindowSizeMultiplier()); + sprite.setPosition(sf::Vector2f(8.f, ((i - firstElem) * 10) + 25.f) * (float) this->settings->getWindowSizeMultiplier()); sprite.setScale(sprite.getScale() * ((float) this->settings->getWindowSizeMultiplier() / 2)); this->renderWindow->draw(sprite); } diff --git a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.h b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.h index d27dfd7..13b6eaf 100644 --- a/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.h +++ b/src/GraphicalUI/AppMenus/SettingsKeybindsAppMenu.h @@ -12,6 +12,8 @@ class SettingsKeybindsAppMenu : public AppMenu { private: PlayerCursor playerCursor; sf::Texture iconTextures[11]; + bool selectedAnAction; + Action actionSelected; public: SettingsKeybindsAppMenu(std::shared_ptr menuStack, std::shared_ptr settings, std::shared_ptr renderWindow); diff --git a/src/GraphicalUI/AppMenus/SettingsMainAppMenu.cpp b/src/GraphicalUI/AppMenus/SettingsMainAppMenu.cpp index a2dc2fe..6dbf1fe 100644 --- a/src/GraphicalUI/AppMenus/SettingsMainAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/SettingsMainAppMenu.cpp @@ -66,14 +66,14 @@ void SettingsMainAppMenu::drawFrame() const { text.setFillColor(sf::Color(0, 0, 0)); text.setOutlineColor(sf::Color(255, 255, 255)); - this->placeTitle(text, std::optional(), "SETTINGS", 5.f, std::optional()); + this->placeTitle(text, {}, "SETTINGS", 5.f, {}); sf::Vector2u windowSize = this->renderWindow->getSize(); - this->placeText(text, this->playerCursor, "CHANGE KEYBINDS", 5.f, 15.f, {0, 0}); - this->placeText(text, this->playerCursor, "CHANGE CONTROLS", 5.f, 25.f, {0, 1}); - this->placeText(text, this->playerCursor, "< WINDOW SIZE: " + std::to_string(windowSize.x) + "x" + std::to_string(windowSize.y) + " >", 5.f, 35.f, {0, 2}); - this->placeText(text, this->playerCursor, "< VOLUME: " + std::to_string(this->settings->getMasterVolume()) + "% >", 5.f, 45.f, {0, 3}); + this->placeText(text, this->playerCursor, "CHANGE KEYBINDS", 5.f, 15.f, sf::Vector2u{0, 0}); + this->placeText(text, this->playerCursor, "CHANGE CONTROLS", 5.f, 25.f, sf::Vector2u{0, 1}); + this->placeText(text, this->playerCursor, "< WINDOW SIZE: " + std::to_string(windowSize.x) + "x" + std::to_string(windowSize.y) + " >", 5.f, 35.f, sf::Vector2u{0, 2}); + this->placeText(text, this->playerCursor, "< VOLUME: " + std::to_string(this->settings->getMasterVolume()) + "% >", 5.f, 45.f, sf::Vector2u{0, 3}); this->renderWindow->display(); } diff --git a/src/GraphicalUI/Keybinds.cpp b/src/GraphicalUI/Keybinds.cpp index 98a34ee..f4a1c67 100644 --- a/src/GraphicalUI/Keybinds.cpp +++ b/src/GraphicalUI/Keybinds.cpp @@ -66,7 +66,7 @@ void Keybinds::saveKeybindsToFile() const { void Keybinds::addKey(Action action, sfKey key) { if (!this->modifiable) return; - if (!getKeyStringRepresentation(key).has_value()) return; + if (!KEYS_TO_STRING.contains(key)) return; this->keybinds.at(action).insert(key); } diff --git a/src/GraphicalUI/Keybinds.h b/src/GraphicalUI/Keybinds.h index 2043a28..92a8271 100644 --- a/src/GraphicalUI/Keybinds.h +++ b/src/GraphicalUI/Keybinds.h @@ -18,7 +18,7 @@ class Keybinds { std::map> keybinds; int layoutNumber; bool modifiable; - + public: Keybinds(int layoutNumber); @@ -45,123 +45,112 @@ inline std::string setStringToUpperCase(std::string&& str) { inline std::string setStringToUpperCase(const std::string& str) { std::string result = str; - std::transform(str.begin(), str.end(), result.begin(), ::toupper); + std::transform(result.begin(), result.end(), result.begin(), ::toupper); return result; } -inline const std::optional getKeyStringRepresentation(sfKey key) { - #define INSERT_MAPPING(identifier) {sfKey::identifier, setStringToUpperCase(#identifier)} - - static const std::map keysRepresentation { - INSERT_MAPPING(A), - INSERT_MAPPING(B), - INSERT_MAPPING(C), - INSERT_MAPPING(D), - INSERT_MAPPING(E), - INSERT_MAPPING(F), - INSERT_MAPPING(G), - INSERT_MAPPING(H), - INSERT_MAPPING(I), - INSERT_MAPPING(J), - INSERT_MAPPING(K), - INSERT_MAPPING(L), - INSERT_MAPPING(M), - INSERT_MAPPING(N), - INSERT_MAPPING(O), - INSERT_MAPPING(P), - INSERT_MAPPING(Q), - INSERT_MAPPING(R), - INSERT_MAPPING(S), - INSERT_MAPPING(T), - INSERT_MAPPING(U), - INSERT_MAPPING(V), - INSERT_MAPPING(W), - INSERT_MAPPING(X), - INSERT_MAPPING(Y), - INSERT_MAPPING(Z), - INSERT_MAPPING(Num0), - INSERT_MAPPING(Num1), - INSERT_MAPPING(Num2), - INSERT_MAPPING(Num3), - INSERT_MAPPING(Num4), - INSERT_MAPPING(Num5), - INSERT_MAPPING(Num6), - INSERT_MAPPING(Num7), - INSERT_MAPPING(Num8), - INSERT_MAPPING(Num9), - INSERT_MAPPING(Escape), - INSERT_MAPPING(LControl), - INSERT_MAPPING(LShift), - INSERT_MAPPING(LAlt), - INSERT_MAPPING(LSystem), - INSERT_MAPPING(RControl), - INSERT_MAPPING(RShift), - INSERT_MAPPING(RAlt), - INSERT_MAPPING(RSystem), - INSERT_MAPPING(Menu), - INSERT_MAPPING(LBracket), - INSERT_MAPPING(RBracket), - INSERT_MAPPING(Semicolon), - INSERT_MAPPING(Comma), - INSERT_MAPPING(Period), - INSERT_MAPPING(Apostrophe), - INSERT_MAPPING(Slash), - INSERT_MAPPING(Backslash), - INSERT_MAPPING(Grave), - INSERT_MAPPING(Equal), - INSERT_MAPPING(Hyphen), - INSERT_MAPPING(Space), - INSERT_MAPPING(Enter), - INSERT_MAPPING(Backspace), - INSERT_MAPPING(Tab), - INSERT_MAPPING(PageUp), - INSERT_MAPPING(PageDown), - INSERT_MAPPING(End), - INSERT_MAPPING(Home), - INSERT_MAPPING(Insert), - INSERT_MAPPING(Delete), - INSERT_MAPPING(Add), - INSERT_MAPPING(Subtract), - INSERT_MAPPING(Multiply), - INSERT_MAPPING(Divide), - INSERT_MAPPING(Left), - INSERT_MAPPING(Right), - INSERT_MAPPING(Up), - INSERT_MAPPING(Down), - INSERT_MAPPING(Numpad0), - INSERT_MAPPING(Numpad1), - INSERT_MAPPING(Numpad2), - INSERT_MAPPING(Numpad3), - INSERT_MAPPING(Numpad4), - INSERT_MAPPING(Numpad5), - INSERT_MAPPING(Numpad6), - INSERT_MAPPING(Numpad7), - INSERT_MAPPING(Numpad8), - INSERT_MAPPING(Numpad9), - INSERT_MAPPING(F1), - INSERT_MAPPING(F2), - INSERT_MAPPING(F3), - INSERT_MAPPING(F4), - INSERT_MAPPING(F5), - INSERT_MAPPING(F6), - INSERT_MAPPING(F7), - INSERT_MAPPING(F8), - INSERT_MAPPING(F9), - INSERT_MAPPING(F10), - INSERT_MAPPING(F11), - INSERT_MAPPING(F12), - INSERT_MAPPING(F13), - INSERT_MAPPING(F14), - INSERT_MAPPING(F15), - INSERT_MAPPING(Pause) - }; - - #undef INSERT_MAPPING - - if (keysRepresentation.contains(key)) { - return keysRepresentation.at(key); - } - else { - return {}; - } -} +#define INSERT_MAPPING(identifier) {sfKey::identifier, setStringToUpperCase(#identifier)} +static const std::map KEYS_TO_STRING = { + INSERT_MAPPING(A), + INSERT_MAPPING(B), + INSERT_MAPPING(C), + INSERT_MAPPING(D), + INSERT_MAPPING(E), + INSERT_MAPPING(F), + INSERT_MAPPING(G), + INSERT_MAPPING(H), + INSERT_MAPPING(I), + INSERT_MAPPING(J), + INSERT_MAPPING(K), + INSERT_MAPPING(L), + INSERT_MAPPING(M), + INSERT_MAPPING(N), + INSERT_MAPPING(O), + INSERT_MAPPING(P), + INSERT_MAPPING(Q), + INSERT_MAPPING(R), + INSERT_MAPPING(S), + INSERT_MAPPING(T), + INSERT_MAPPING(U), + INSERT_MAPPING(V), + INSERT_MAPPING(W), + INSERT_MAPPING(X), + INSERT_MAPPING(Y), + INSERT_MAPPING(Z), + INSERT_MAPPING(Num0), + INSERT_MAPPING(Num1), + INSERT_MAPPING(Num2), + INSERT_MAPPING(Num3), + INSERT_MAPPING(Num4), + INSERT_MAPPING(Num5), + INSERT_MAPPING(Num6), + INSERT_MAPPING(Num7), + INSERT_MAPPING(Num8), + INSERT_MAPPING(Num9), + INSERT_MAPPING(Escape), + INSERT_MAPPING(LControl), + INSERT_MAPPING(LShift), + INSERT_MAPPING(LAlt), + INSERT_MAPPING(LSystem), + INSERT_MAPPING(RControl), + INSERT_MAPPING(RShift), + INSERT_MAPPING(RAlt), + INSERT_MAPPING(RSystem), + INSERT_MAPPING(Menu), + INSERT_MAPPING(LBracket), + INSERT_MAPPING(RBracket), + INSERT_MAPPING(Semicolon), + INSERT_MAPPING(Comma), + INSERT_MAPPING(Period), + INSERT_MAPPING(Apostrophe), + INSERT_MAPPING(Slash), + INSERT_MAPPING(Backslash), + INSERT_MAPPING(Grave), + INSERT_MAPPING(Equal), + INSERT_MAPPING(Hyphen), + INSERT_MAPPING(Space), + INSERT_MAPPING(Enter), + INSERT_MAPPING(Backspace), + INSERT_MAPPING(Tab), + INSERT_MAPPING(PageUp), + INSERT_MAPPING(PageDown), + INSERT_MAPPING(End), + INSERT_MAPPING(Home), + INSERT_MAPPING(Insert), + INSERT_MAPPING(Delete), + INSERT_MAPPING(Add), + INSERT_MAPPING(Subtract), + INSERT_MAPPING(Multiply), + INSERT_MAPPING(Divide), + INSERT_MAPPING(Left), + INSERT_MAPPING(Right), + INSERT_MAPPING(Up), + INSERT_MAPPING(Down), + INSERT_MAPPING(Numpad0), + INSERT_MAPPING(Numpad1), + INSERT_MAPPING(Numpad2), + INSERT_MAPPING(Numpad3), + INSERT_MAPPING(Numpad4), + INSERT_MAPPING(Numpad5), + INSERT_MAPPING(Numpad6), + INSERT_MAPPING(Numpad7), + INSERT_MAPPING(Numpad8), + INSERT_MAPPING(Numpad9), + INSERT_MAPPING(F1), + INSERT_MAPPING(F2), + INSERT_MAPPING(F3), + INSERT_MAPPING(F4), + INSERT_MAPPING(F5), + INSERT_MAPPING(F6), + INSERT_MAPPING(F7), + INSERT_MAPPING(F8), + INSERT_MAPPING(F9), + INSERT_MAPPING(F10), + INSERT_MAPPING(F11), + INSERT_MAPPING(F12), + INSERT_MAPPING(F13), + INSERT_MAPPING(F14), + INSERT_MAPPING(F15), + INSERT_MAPPING(Pause) +}; +#undef INSERT_MAPPING diff --git a/src/GraphicalUI/Settings.cpp b/src/GraphicalUI/Settings.cpp index 4d9afdb..b0ce505 100644 --- a/src/GraphicalUI/Settings.cpp +++ b/src/GraphicalUI/Settings.cpp @@ -89,6 +89,8 @@ void Settings::loadSettingsFromFile() { } void Settings::saveSettingsToFile() const { + this->keybinds.at(CUSTOMIZABLE_KEYBINDS).saveKeybindsToFile(); + std::ofstream settingsFile("data/config/settings.bin", std::ios::trunc | std::ios::binary); char byte;