mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 13:23:45 -07:00
Add extraSearchWidgets for searching through non-menu widgets.
Convert Controls extraSearches to widgets. Used to display in-window, as well as provide reference to extraSearchWidgets.
This commit is contained in:
parent
1ffa08dac5
commit
b767d89e26
5 changed files with 101 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
||||||
#include "SohInputEditorWindow.h"
|
#include "SohInputEditorWindow.h"
|
||||||
#include <utils/StringHelper.h>
|
#include <utils/StringHelper.h>
|
||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
#include "soh/SohGui/UIWidgets.hpp"
|
#include "soh/SohGui/SohMenu.h"
|
||||||
#include "soh/SohGui/SohGui.hpp"
|
#include "soh/SohGui/SohGui.hpp"
|
||||||
#include "z64.h"
|
#include "z64.h"
|
||||||
#include "soh/cvar_prefixes.h"
|
#include "soh/cvar_prefixes.h"
|
||||||
|
@ -13,6 +13,17 @@
|
||||||
|
|
||||||
using namespace UIWidgets;
|
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<SohMenu> mSohMenu;
|
||||||
|
}
|
||||||
|
|
||||||
SohInputEditorWindow::~SohInputEditorWindow() {
|
SohInputEditorWindow::~SohInputEditorWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1321,8 +1332,8 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() {
|
||||||
ImGui::SetCursorPos(ImVec2(cursor.x, cursor.y + 5));
|
ImGui::SetCursorPos(ImVec2(cursor.x, cursor.y + 5));
|
||||||
|
|
||||||
CheckboxOptions checkOpt = CheckboxOptions().Color(THEME_COLOR);
|
CheckboxOptions checkOpt = CheckboxOptions().Color(THEME_COLOR);
|
||||||
CVarCheckbox("Dpad Ocarina Playback", CVAR_SETTING("CustomOcarina.Dpad"), checkOpt);
|
SohGui::mSohMenu->MenuDrawItem(dpadOcarina, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
CVarCheckbox("Right Stick Ocarina Playback", CVAR_SETTING("CustomOcarina.RightStick"), checkOpt);
|
SohGui::mSohMenu->MenuDrawItem(rightStickOcarina, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
CVarCheckbox("Customize Ocarina Controls", CVAR_SETTING("CustomOcarina.Enabled"), checkOpt);
|
CVarCheckbox("Customize Ocarina Controls", CVAR_SETTING("CustomOcarina.Enabled"), checkOpt);
|
||||||
|
|
||||||
if (!CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) {
|
if (!CVarGetInteger(CVAR_SETTING("CustomOcarina.Enabled"), 0)) {
|
||||||
|
@ -1354,12 +1365,8 @@ void SohInputEditorWindow::DrawOcarinaControlPanel() {
|
||||||
void SohInputEditorWindow::DrawCameraControlPanel() {
|
void SohInputEditorWindow::DrawCameraControlPanel() {
|
||||||
ImVec2 cursor = ImGui::GetCursorPos();
|
ImVec2 cursor = ImGui::GetCursorPos();
|
||||||
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||||
CVarCheckbox(
|
SohGui::mSohMenu->MenuDrawItem(mouseControl, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
"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)"));
|
|
||||||
Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail());
|
Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail());
|
||||||
CVarCheckbox("Right Stick Aiming", CVAR_SETTING("Controls.RightStickAim"),
|
CVarCheckbox("Right Stick Aiming", CVAR_SETTING("Controls.RightStickAim"),
|
||||||
CheckboxOptions()
|
CheckboxOptions()
|
||||||
|
@ -1427,14 +1434,7 @@ void SohInputEditorWindow::DrawCameraControlPanel() {
|
||||||
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||||
Ship::GuiWindow::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail());
|
Ship::GuiWindow::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail());
|
||||||
|
|
||||||
CVarCheckbox(
|
SohGui::mSohMenu->MenuDrawItem(freeLook, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
"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."));
|
|
||||||
CVarCheckbox("Invert Camera X Axis", CVAR_SETTING("FreeLook.InvertXAxis"),
|
CVarCheckbox("Invert Camera X Axis", CVAR_SETTING("FreeLook.InvertXAxis"),
|
||||||
CheckboxOptions().Color(THEME_COLOR).Tooltip("Inverts the Camera X Axis in:\n-Free look"));
|
CheckboxOptions().Color(THEME_COLOR).Tooltip("Inverts the Camera X Axis in:\n-Free look"));
|
||||||
CVarCheckbox(
|
CVarCheckbox(
|
||||||
|
@ -1467,16 +1467,8 @@ void SohInputEditorWindow::DrawDpadControlPanel() {
|
||||||
ImVec2 cursor = ImGui::GetCursorPos();
|
ImVec2 cursor = ImGui::GetCursorPos();
|
||||||
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||||
Ship::GuiWindow::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail());
|
Ship::GuiWindow::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail());
|
||||||
CVarCheckbox("D-pad Support on Pause Screen", CVAR_SETTING("DPadOnPause"),
|
SohGui::mSohMenu->MenuDrawItem(dpadPause, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
CheckboxOptions()
|
SohGui::mSohMenu->MenuDrawItem(dpadText, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
.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"));
|
|
||||||
|
|
||||||
if (!CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) && !CVarGetInteger(CVAR_SETTING("DpadInText"), 0)) {
|
if (!CVarGetInteger(CVAR_SETTING("DPadOnPause"), 0) && !CVarGetInteger(CVAR_SETTING("DpadInText"), 0)) {
|
||||||
ImGui::BeginDisabled();
|
ImGui::BeginDisabled();
|
||||||
|
@ -1902,3 +1894,52 @@ void SohInputEditorWindow::DrawElement() {
|
||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
ImGui::PopFont();
|
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);
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern std::shared_ptr<SohModalWindow> mModalWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SearchEntry> extraSearches = {};
|
std::vector<SearchEntry> extraSearches = {};
|
||||||
|
std::vector<SearchWidget> extraSearchWidgets = {};
|
||||||
|
|
||||||
namespace Ship {
|
namespace Ship {
|
||||||
std::string disabledTempTooltip;
|
std::string disabledTempTooltip;
|
||||||
|
@ -235,6 +236,24 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
|
||||||
{ ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
|
{ ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
|
||||||
if (ImGui::BeginChild("Search Results Col 2", { ImGui::GetContentRegionAvail().x, 0 }, ImGuiChildFlags_AutoResizeY,
|
if (ImGui::BeginChild("Search Results Col 2", { ImGui::GetContentRegionAvail().x, 0 }, ImGuiChildFlags_AutoResizeY,
|
||||||
ImGuiWindowFlags_NoTitleBar)) {
|
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) {
|
for (auto& entry : extraSearches) {
|
||||||
std::string widgetStr = entry.widgetName + entry.extraTerms + entry.sidebarName;
|
std::string widgetStr = entry.widgetName + entry.extraTerms + entry.sidebarName;
|
||||||
std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower);
|
std::transform(widgetStr.begin(), widgetStr.end(), widgetStr.begin(), ::tolower);
|
||||||
|
@ -277,6 +296,10 @@ void Menu::AddSearchEntry(SearchEntry entry) {
|
||||||
extraSearches.push_back(entry);
|
extraSearches.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::AddSearchWidget(SearchWidget widget) {
|
||||||
|
extraSearchWidgets.push_back(widget);
|
||||||
|
}
|
||||||
|
|
||||||
std::unordered_map<uint32_t, disabledInfo>& Menu::GetDisabledMap() {
|
std::unordered_map<uint32_t, disabledInfo>& Menu::GetDisabledMap() {
|
||||||
return disabledMap;
|
return disabledMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Menu : public GuiWindow {
|
||||||
void MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors menuThemeIndex);
|
void MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors menuThemeIndex);
|
||||||
void AddMenuEntry(std::string entryName, const char* entryCvar);
|
void AddMenuEntry(std::string entryName, const char* entryCvar);
|
||||||
void AddSearchEntry(SearchEntry entry);
|
void AddSearchEntry(SearchEntry entry);
|
||||||
|
void AddSearchWidget(SearchWidget widget);
|
||||||
std::unordered_map<uint32_t, disabledInfo>& GetDisabledMap();
|
std::unordered_map<uint32_t, disabledInfo>& GetDisabledMap();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -295,6 +295,15 @@ struct SearchEntry {
|
||||||
std::string extraTerms = "";
|
std::string extraTerms = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SearchWidget {
|
||||||
|
// First four required
|
||||||
|
WidgetInfo& info;
|
||||||
|
std::string menuName;
|
||||||
|
std::string sidebarName;
|
||||||
|
std::string location;
|
||||||
|
std::string extraTerms = "";
|
||||||
|
};
|
||||||
|
|
||||||
struct RegisterMenuInitFunc {
|
struct RegisterMenuInitFunc {
|
||||||
RegisterMenuInitFunc(std::function<void()> initFunc) {
|
RegisterMenuInitFunc(std::function<void()> initFunc) {
|
||||||
auto& menuInitFuncs = MenuInit::GetInitFuncs();
|
auto& menuInitFuncs = MenuInit::GetInitFuncs();
|
||||||
|
|
|
@ -487,13 +487,6 @@ void SohMenu::AddMenuSettings() {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.Options(ButtonOptions().Tooltip("Displays a test notification."));
|
.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
|
} // namespace SohGui
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue