diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 41a31f8be..ee59665c5 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1,7 +1,7 @@ #include "SohInputEditorWindow.h" #include #include "soh/OTRGlobals.h" -#include "soh/SohGui/UIWidgets.hpp" +#include "soh/SohGui/SohMenu.h" #include "soh/SohGui/SohGui.hpp" #include "z64.h" #include "soh/cvar_prefixes.h" @@ -13,6 +13,17 @@ using namespace UIWidgets; +static WidgetInfo freeLook; +static WidgetInfo mouseControl; +static WidgetInfo rightStickOcarina; +static WidgetInfo dpadOcarina; +static WidgetInfo dpadPause; +static WidgetInfo dpadText; + +namespace SohGui { +extern std::shared_ptr mSohMenu; +} + SohInputEditorWindow::~SohInputEditorWindow() { } @@ -1321,8 +1332,8 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { ImGui::SetCursorPos(ImVec2(cursor.x, cursor.y + 5)); CheckboxOptions checkOpt = CheckboxOptions().Color(THEME_COLOR); - CVarCheckbox("Dpad Ocarina Playback", CVAR_SETTING("CustomOcarina.Dpad"), checkOpt); - CVarCheckbox("Right Stick Ocarina Playback", CVAR_SETTING("CustomOcarina.RightStick"), checkOpt); + SohGui::mSohMenu->MenuDrawItem(dpadOcarina, ImGui::GetContentRegionAvail().x, THEME_COLOR); + SohGui::mSohMenu->MenuDrawItem(rightStickOcarina, ImGui::GetContentRegionAvail().x, THEME_COLOR); CVarCheckbox("Customize Ocarina Controls", CVAR_SETTING("CustomOcarina.Enabled"), checkOpt); if (!CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) { @@ -1354,12 +1365,8 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() { void SohInputEditorWindow::DrawCameraControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - CVarCheckbox( - "Enable Mouse Controls", CVAR_SETTING("EnableMouse"), - CheckboxOptions() - .Color(THEME_COLOR) - .Tooltip("Allows for using the mouse to control the camera (must enable Free Look), " - "aim with the shield, and perform quickspin attacks (quickly rotate the mouse then press B)")); + SohGui::mSohMenu->MenuDrawItem(mouseControl, ImGui::GetContentRegionAvail().x, THEME_COLOR); + Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail()); CVarCheckbox("Right Stick Aiming", CVAR_SETTING("Controls.RightStickAim"), CheckboxOptions() @@ -1427,14 +1434,7 @@ void SohInputEditorWindow::DrawCameraControlPanel() { ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); Ship::GuiWindow::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail()); - CVarCheckbox( - "Free Look", CVAR_SETTING("FreeLook.Enabled"), - CheckboxOptions() - .Color(THEME_COLOR) - .Tooltip("Enables free look camera control\nNote: You must remap C buttons off of the right stick in the " - "controller config menu, and map the camera stick to the right stick.\n" - "Doesn't work in areas were the game locks the camera.\n" - "Scene reload may be necessary to enable.")); + SohGui::mSohMenu->MenuDrawItem(freeLook, ImGui::GetContentRegionAvail().x, THEME_COLOR); CVarCheckbox("Invert Camera X Axis", CVAR_SETTING("FreeLook.InvertXAxis"), CheckboxOptions().Color(THEME_COLOR).Tooltip("Inverts the Camera X Axis in:\n-Free look")); CVarCheckbox( @@ -1467,16 +1467,8 @@ void SohInputEditorWindow::DrawDpadControlPanel() { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); Ship::GuiWindow::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail()); - CVarCheckbox("D-pad Support on Pause Screen", CVAR_SETTING("DPadOnPause"), - CheckboxOptions() - .Color(THEME_COLOR) - .Tooltip("Navigate Pause with the D-pad\nIf used with \"D-pad as Equip Items\", you must hold " - "C-Up to equip instead of navigate")); - CVarCheckbox("D-pad Support in Text Boxes", CVAR_SETTING("DpadInText"), - CheckboxOptions() - .Color(THEME_COLOR) - .Tooltip("Navigate choices in text boxes, shop item selection, and the file select / name entry " - "screens with the D-pad")); + SohGui::mSohMenu->MenuDrawItem(dpadPause, ImGui::GetContentRegionAvail().x, THEME_COLOR); + SohGui::mSohMenu->MenuDrawItem(dpadText, ImGui::GetContentRegionAvail().x, THEME_COLOR); if (!CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) && !CVarGetInteger(CVAR_SETTING("DpadInText"), 0)) { ImGui::BeginDisabled(); @@ -1902,3 +1894,52 @@ void SohInputEditorWindow::DrawElement() { ImGui::PopStyleColor(3); ImGui::PopFont(); } + +void RegisterInputWidgets() { + dpadOcarina = { .name = "Dpad Ocarina Playback", .type = WidgetType::WIDGET_CVAR_CHECKBOX }; + dpadOcarina.CVar(CVAR_SETTING("CustomOcarina.Dpad")).Options(CheckboxOptions().Color(THEME_COLOR)); + SohGui::mSohMenu->AddSearchWidget({ dpadOcarina, "Settings", "Controls", "Ocarina Controls", "" }); + + freeLook = { .name = "Free Look", .type = WidgetType::WIDGET_CVAR_CHECKBOX }; + freeLook.CVar(CVAR_SETTING("FreeLook.Enabled")) + .Options( + CheckboxOptions() + .Color(THEME_COLOR) + .Tooltip( + "Enables free look camera control\nNote: You must remap C buttons off of the right stick in the " + "controller config menu, and map the camera stick to the right stick.\n" + "Doesn't work in areas were the game locks the camera.\n" + "Scene reload may be necessary to enable.")); + SohGui::mSohMenu->AddSearchWidget({ freeLook, "Settings", "Controls", "Camera Controls" }); + + mouseControl = { .name = "Enable Mouse Controls", .type = WidgetType::WIDGET_CVAR_CHECKBOX }; + mouseControl.CVar(CVAR_SETTING("EnableMouse")) + .Options( + CheckboxOptions() + .Color(THEME_COLOR) + .Tooltip("Allows for using the mouse to control the camera (must enable Free Look), " + "aim with the shield, and perform quickspin attacks (quickly rotate the mouse then press B)")); + SohGui::mSohMenu->AddSearchWidget({ mouseControl, "Settings", "Controls", "Camera Controls" }); + + rightStickOcarina = { .name = "Right Stick Ocarina Playback", .type = WidgetType::WIDGET_CVAR_CHECKBOX }; + rightStickOcarina.CVar(CVAR_SETTING("CustomOcarina.RightStick")).Options(CheckboxOptions().Color(THEME_COLOR)); + SohGui::mSohMenu->AddSearchWidget({ rightStickOcarina, "Settings", "Controls", "Ocarina Controls" }); + + dpadPause = { .name = "D-pad Support on Pause Screen", .type = WidgetType::WIDGET_CVAR_CHECKBOX }; + dpadPause.CVar(CVAR_SETTING("DPadOnPause")) + .Options(CheckboxOptions() + .Color(THEME_COLOR) + .Tooltip("Navigate Pause with the D-pad\nIf used with \"D-pad as Equip Items\", you must hold " + "C-Up to equip instead of navigate")); + SohGui::mSohMenu->AddSearchWidget({ dpadPause, "Settings", "Controls", "Dpad Controls" }); + + dpadText = { .name = "D-pad Support in Text Boxes", .type = WidgetType::WIDGET_CVAR_CHECKBOX }; + dpadText.CVar(CVAR_SETTING("DpadInText")) + .Options(CheckboxOptions() + .Color(THEME_COLOR) + .Tooltip("Navigate choices in text boxes, shop item selection, and the file select / name entry " + "screens with the D-pad")); + SohGui::mSohMenu->AddSearchWidget({ dpadText, "Settings", "Controls", "Dpad Controls" }); +} + +static RegisterMenuInitFunc initFunc(RegisterInputWidgets); diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index e7f59f38c..a0d105da9 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -25,6 +25,7 @@ extern std::shared_ptr mModalWindow; } std::vector extraSearches = {}; +std::vector extraSearchWidgets = {}; namespace Ship { std::string disabledTempTooltip; @@ -235,6 +236,24 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y }); if (ImGui::BeginChild("Search Results Col 2", { ImGui::GetContentRegionAvail().x, 0 }, ImGuiChildFlags_AutoResizeY, ImGuiWindowFlags_NoTitleBar)) { + for (auto& entry : extraSearchWidgets) { + if (entry.info.type == WIDGET_SEARCH || entry.info.type == WIDGET_SEPARATOR || + entry.info.type == WIDGET_SEPARATOR_TEXT || entry.info.isHidden || entry.info.hideInSearch) { + continue; + } + std::string widgetStr = + entry.info.name + entry.info.options->tooltip + entry.extraTerms + entry.sidebarName; + std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower); + widgetStr.erase(std::remove(widgetStr.begin(), widgetStr.end(), ' '), widgetStr.end()); + if (widgetStr.find(menuSearchText) != std::string::npos) { + MenuDrawItem(entry.info, 400, menuThemeIndex); + ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(UIWidgets::Colors::Gray)); + std::string origin = fmt::format(" ({} -> {}, {})", entry.menuName, entry.sidebarName, entry.location); + ImGui::Text("%s", origin.c_str()); + ImGui::PopStyleColor(); + searchCount++; + } + } for (auto& entry : extraSearches) { std::string widgetStr = entry.widgetName + entry.extraTerms + entry.sidebarName; std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower); @@ -277,6 +296,10 @@ void Menu::AddSearchEntry(SearchEntry entry) { extraSearches.push_back(entry); } +void Menu::AddSearchWidget(SearchWidget widget) { + extraSearchWidgets.push_back(widget); +} + std::unordered_map& Menu::GetDisabledMap() { return disabledMap; } diff --git a/soh/soh/SohGui/Menu.h b/soh/soh/SohGui/Menu.h index a6f030356..8a88272af 100644 --- a/soh/soh/SohGui/Menu.h +++ b/soh/soh/SohGui/Menu.h @@ -27,6 +27,7 @@ class Menu : public GuiWindow { void MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors menuThemeIndex); void AddMenuEntry(std::string entryName, const char* entryCvar); void AddSearchEntry(SearchEntry entry); + void AddSearchWidget(SearchWidget widget); std::unordered_map& GetDisabledMap(); protected: diff --git a/soh/soh/SohGui/MenuTypes.h b/soh/soh/SohGui/MenuTypes.h index 990d98d36..e86f475f9 100644 --- a/soh/soh/SohGui/MenuTypes.h +++ b/soh/soh/SohGui/MenuTypes.h @@ -295,6 +295,15 @@ struct SearchEntry { std::string extraTerms = ""; }; +struct SearchWidget { + // First four required + WidgetInfo& info; + std::string menuName; + std::string sidebarName; + std::string location; + std::string extraTerms = ""; +}; + struct RegisterMenuInitFunc { RegisterMenuInitFunc(std::function initFunc) { auto& menuInitFuncs = MenuInit::GetInitFuncs(); diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index cdd8435fd..52d1a53c4 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -487,13 +487,6 @@ void SohMenu::AddMenuSettings() { }); }) .Options(ButtonOptions().Tooltip("Displays a test notification.")); - - AddSearchEntry({ "Free Look", "Settings", "Controls", "Camera Controls" }); - AddSearchEntry({ "Enable Mouse Controls", "Settings", "Controls", "Camera Controls" }); - AddSearchEntry({ "Right Stick Ocarina Playback", "Settings", "Controls", "Ocarina Controls" }); - AddSearchEntry({ "Dpad Ocarina Playback", "Settings", "Controls", "Ocarina Controls" }); - AddSearchEntry({ "Dpad Support on Pause Menu", "Settings", "Controls", "Dpad Controls" }); - AddSearchEntry({ "Dpad Support in Text Boxes", "Settings", "Controls", "Dpad Controls" }); } } // namespace SohGui