diff --git a/include/dusk/action_bindings.h b/include/dusk/action_bindings.h index 7eba412fe8..45883cebab 100644 --- a/include/dusk/action_bindings.h +++ b/include/dusk/action_bindings.h @@ -11,12 +11,19 @@ enum class ActionBinds { CALL_MIDNA, OPEN_DUSKLIGHT_MENU, TURBO_SPEED_BUTTON, + TOGGLE_TEXTURE_PACK, COUNT, }; +enum class ActionBindType { + GAMEPLAY, + INTERFACE, +}; + struct ActionBindData { std::array* configVars{}; std::string actionName{}; + ActionBindType type{}; }; struct ActionBindPressData { @@ -40,4 +47,6 @@ bool getActionBindHoldAnyPort(ActionBinds action); int getActionBindButton(ActionBinds action, u32 port); +ActionBindType getActionBindType(ActionBinds action); + } diff --git a/include/dusk/settings.h b/include/dusk/settings.h index 923a1e9fc6..948c909fad 100644 --- a/include/dusk/settings.h +++ b/include/dusk/settings.h @@ -263,6 +263,7 @@ struct UserSettings { std::array callMidna; std::array openDusklightMenu; std::array turboSpeedButton; + std::array toggleTexturePack; } actionBindings; }; diff --git a/src/dusk/action_bindings.cpp b/src/dusk/action_bindings.cpp index 204f219558..c85acc8f8c 100644 --- a/src/dusk/action_bindings.cpp +++ b/src/dusk/action_bindings.cpp @@ -1,6 +1,8 @@ #include "dusk/action_bindings.h" +#include "aurora/gfx.h" #include "aurora/lib/input.hpp" +#include "dusk/config.hpp" #include "dusk/settings.h" #include "dusk/ui/ui.hpp" @@ -10,10 +12,11 @@ static std::array(ActionBinds:: ActionBindsMap& getActionBinds() { static ActionBindsMap actionBinds = { - {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera"}}, - {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna"}}, - {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu"}}, - {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button"}}, + {ActionBinds::FIRST_PERSON_CAMERA, {&getSettings().actionBindings.firstPersonCamera, "First Person Camera", ActionBindType::GAMEPLAY}}, + {ActionBinds::CALL_MIDNA, {&getSettings().actionBindings.callMidna, "Call Midna", ActionBindType::GAMEPLAY}}, + {ActionBinds::TURBO_SPEED_BUTTON, {&getSettings().actionBindings.turboSpeedButton, "Turbo Speed Button", ActionBindType::GAMEPLAY}}, + {ActionBinds::OPEN_DUSKLIGHT_MENU, {&getSettings().actionBindings.openDusklightMenu, "Open Dusklight Menu", ActionBindType::INTERFACE}}, + {ActionBinds::TOGGLE_TEXTURE_PACK, {&getSettings().actionBindings.toggleTexturePack, "Toggle Texture Pack", ActionBindType::INTERFACE}}, }; return actionBinds; } @@ -65,6 +68,15 @@ void updateActionBindings() { } } } + + // Interface-specific triggers + if (getActionBindTrig(ActionBinds::TOGGLE_TEXTURE_PACK, port)) { + const bool enabled = !getSettings().game.enableTextureReplacements.getValue(); + getSettings().game.enableTextureReplacements.setValue(enabled); + aurora_set_texture_replacements_enabled(enabled); + config::Save(); + break; + } } } } diff --git a/src/dusk/settings.cpp b/src/dusk/settings.cpp index ef639e2b05..ab7a58f810 100644 --- a/src/dusk/settings.cpp +++ b/src/dusk/settings.cpp @@ -171,6 +171,12 @@ UserSettings g_userSettings = { ActionBindConfigVar{"actionBindings.turboButton_port2", PAD_NATIVE_BUTTON_INVALID}, ActionBindConfigVar{"actionBindings.turboButton_port3", PAD_NATIVE_BUTTON_INVALID}, }, + .toggleTexturePack { + ActionBindConfigVar{"actionBindings.toggleTexturePack_port0", PAD_NATIVE_BUTTON_INVALID}, + ActionBindConfigVar{"actionBindings.toggleTexturePack_port1", PAD_NATIVE_BUTTON_INVALID}, + ActionBindConfigVar{"actionBindings.toggleTexturePack_port2", PAD_NATIVE_BUTTON_INVALID}, + ActionBindConfigVar{"actionBindings.toggleTexturePack_port3", PAD_NATIVE_BUTTON_INVALID}, + }, } }; @@ -313,6 +319,10 @@ void registerSettings() { Register(g_userSettings.actionBindings.turboSpeedButton[1]); Register(g_userSettings.actionBindings.turboSpeedButton[2]); Register(g_userSettings.actionBindings.turboSpeedButton[3]); + Register(g_userSettings.actionBindings.toggleTexturePack[0]); + Register(g_userSettings.actionBindings.toggleTexturePack[1]); + Register(g_userSettings.actionBindings.toggleTexturePack[2]); + Register(g_userSettings.actionBindings.toggleTexturePack[3]); } // Transient settings diff --git a/src/dusk/ui/controller_config.cpp b/src/dusk/ui/controller_config.cpp index 20c599ecfd..eead7e8287 100644 --- a/src/dusk/ui/controller_config.cpp +++ b/src/dusk/ui/controller_config.cpp @@ -937,9 +937,21 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { pane.add_section("Custom Action Bindings"); pane.add_text("A key bound to any action here will REPLACE the default control for" " that action. Only bind buttons here that aren't used anywhere else."); - for (auto& [configVars, actionName] : getActionBinds() | std::views::values) { - addActionBinding(&configVars->at(port), actionName); + + pane.add_section("Gameplay"); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == ActionBindType::GAMEPLAY) { + addActionBinding(&configVars->at(port), actionName); + } } + + pane.add_section("Interface"); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == ActionBindType::INTERFACE) { + addActionBinding(&configVars->at(port), actionName); + } + } + break; } @@ -952,10 +964,11 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { SDL_Gamepad* gamepad = gamepad_for_port(port); pane.add_section("Custom Action Bindings"); - pane.add_text("A button bound to any action here will REPLACE the default control for" - " that action. Only bind buttons here that aren't used anywhere else. The glyphs" - " shown for in game actions will not change. This is not recommended for " - " regular Gamecube controllers."); + pane.add_rml("A button bound to any action here will REPLACE the default control for" + " that action. Only bind buttons here that aren't used anywhere else." + "

Note: The glyphs shown for in-game actions will not change." + " This is not recommended for regular Gamecube controllers."); + auto addActionBinding = [&](auto actionBind, const std::string& key) { pane.add_select_button({ .key = key, @@ -978,8 +991,18 @@ void ControllerConfigWindow::render_page(Pane& pane, int port, Page page) { }); }; - for (auto& [configVars, actionName] : getActionBinds() | std::views::values) { - addActionBinding(&configVars->at(port), actionName); + pane.add_section("Gameplay"); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == ActionBindType::GAMEPLAY) { + addActionBinding(&configVars->at(port), actionName); + } + } + + pane.add_section("Interface"); + for (auto& [configVars, actionName, type] : getActionBinds() | std::views::values) { + if (type == ActionBindType::INTERFACE) { + addActionBinding(&configVars->at(port), actionName); + } } break; }