mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-05-23 06:54:39 -04:00
57c368aa2c
* Bump LUS to include FileDropMgr's new registration system and initial cursor visibility changes. * New LUS ref. * Remove default on for cursor always visible. Add option to camera controls next to enable mouse input for autocapture. Set autocapture on startup. * next LUS * clang again * Add "EnableMouse" CVar check to startup SetAutoCaptureMouse. * Back to LUS main. * lus version with fixes we need * very wip * get it building * soh otr * bump lus before fixing soh side stuff * build * still builds * mac error * bump otrexporter * bump to lus main * upstream otrexporter --------- Co-authored-by: Malkierian <malkierian@gmail.com> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
199 lines
8.0 KiB
C++
199 lines
8.0 KiB
C++
#include "SohMenu.h"
|
|
#include "soh/OTRGlobals.h"
|
|
#include "soh/Enhancements/controls/SohInputEditorWindow.h"
|
|
#include <ship/window/gui/GuiMenuBar.h>
|
|
#include <ship/window/gui/GuiElement.h>
|
|
#include <variant>
|
|
#include <ship/utils/StringHelper.h>
|
|
#include <spdlog/fmt/fmt.h>
|
|
#include <tuple>
|
|
|
|
extern std::unordered_map<s16, const char*> warpPointSceneList;
|
|
|
|
namespace SohGui {
|
|
extern std::shared_ptr<SohMenu> mSohMenu;
|
|
|
|
using namespace UIWidgets;
|
|
|
|
void SohMenu::AddSidebarEntry(std::string sectionName, std::string sidebarName, uint32_t columnCount) {
|
|
assert(!sectionName.empty());
|
|
assert(!sidebarName.empty());
|
|
menuEntries.at(sectionName).sidebars.emplace(sidebarName, SidebarEntry{ .columnCount = columnCount });
|
|
menuEntries.at(sectionName).sidebarOrder.push_back(sidebarName);
|
|
}
|
|
|
|
WidgetInfo& SohMenu::AddWidget(WidgetPath& pathInfo, std::string widgetName, WidgetType widgetType) {
|
|
assert(!widgetName.empty()); // Must be unique
|
|
assert(menuEntries.contains(pathInfo.sectionName)); // Section/header must already exist
|
|
assert(menuEntries.at(pathInfo.sectionName).sidebars.contains(pathInfo.sidebarName)); // Sidebar must already exist
|
|
std::unordered_map<std::string, SidebarEntry>& sidebar = menuEntries.at(pathInfo.sectionName).sidebars;
|
|
uint8_t column = pathInfo.column;
|
|
if (sidebar.contains(pathInfo.sidebarName)) {
|
|
while (sidebar.at(pathInfo.sidebarName).columnWidgets.size() < column + 1) {
|
|
sidebar.at(pathInfo.sidebarName).columnWidgets.push_back({});
|
|
}
|
|
}
|
|
SidebarEntry& entry = sidebar.at(pathInfo.sidebarName);
|
|
entry.columnWidgets.at(column).push_back({ .name = widgetName, .type = widgetType });
|
|
WidgetInfo& widget = entry.columnWidgets.at(column).back();
|
|
switch (widgetType) {
|
|
case WIDGET_CHECKBOX:
|
|
case WIDGET_CVAR_CHECKBOX:
|
|
widget.options = std::make_shared<CheckboxOptions>();
|
|
break;
|
|
case WIDGET_SLIDER_FLOAT:
|
|
case WIDGET_CVAR_SLIDER_FLOAT:
|
|
widget.options = std::make_shared<FloatSliderOptions>();
|
|
break;
|
|
case WIDGET_SLIDER_INT:
|
|
case WIDGET_CVAR_SLIDER_INT:
|
|
widget.options = std::make_shared<IntSliderOptions>();
|
|
break;
|
|
case WIDGET_COMBOBOX:
|
|
case WIDGET_CVAR_COMBOBOX:
|
|
case WIDGET_AUDIO_BACKEND:
|
|
case WIDGET_VIDEO_BACKEND:
|
|
widget.options = std::make_shared<ComboboxOptions>();
|
|
break;
|
|
case WIDGET_BUTTON:
|
|
widget.options = std::make_shared<ButtonOptions>();
|
|
break;
|
|
case WIDGET_WINDOW_BUTTON:
|
|
widget.options = std::make_shared<WindowButtonOptions>();
|
|
break;
|
|
case WIDGET_CVAR_COLOR_PICKER:
|
|
case WIDGET_COLOR_PICKER:
|
|
widget.options = std::make_shared<ColorPickerOptions>();
|
|
break;
|
|
case WIDGET_SEPARATOR_TEXT:
|
|
case WIDGET_TEXT:
|
|
widget.options = std::make_shared<TextOptions>();
|
|
break;
|
|
case WIDGET_SEARCH:
|
|
case WIDGET_SEPARATOR:
|
|
default:
|
|
widget.options = std::make_shared<WidgetOptions>();
|
|
}
|
|
return widget;
|
|
}
|
|
|
|
SohMenu::SohMenu(const std::string& consoleVariable, const std::string& name)
|
|
: Menu(consoleVariable, name, 0, UIWidgets::Colors::LightBlue) {
|
|
}
|
|
|
|
#ifndef ENABLE_REMOTE_CONTROL
|
|
void SohMenu::AddMenuNetwork() {
|
|
#ifndef _DEBUG
|
|
// in release builds, the tab doesn't even show
|
|
return;
|
|
#endif
|
|
|
|
// Add Network Menu
|
|
AddMenuEntry("Network", CVAR_SETTING("Menu.NetworkSidebarSection"));
|
|
|
|
WidgetPath path = { "Network", "Info", SECTION_COLUMN_1 };
|
|
AddSidebarEntry("Network", path.sidebarName, 2);
|
|
|
|
AddWidget(path,
|
|
ICON_FA_EXCLAMATION_TRIANGLE " The Network features are unavailable because SoH was compiled without "
|
|
"network support (\"ENABLE_REMOTE_CONTROL\" build flag).",
|
|
WIDGET_TEXT)
|
|
.Options(TextOptions().Color(Colors::Orange));
|
|
}
|
|
#endif
|
|
|
|
void SohMenu::InitElement() {
|
|
Ship::Menu::InitElement();
|
|
AddMenuSettings();
|
|
AddMenuEnhancements();
|
|
AddMenuRandomizer();
|
|
AddMenuNetwork();
|
|
AddMenuDevTools();
|
|
|
|
if (CVarGetInteger(CVAR_SETTING("Menu.SidebarSearch"), 0)) {
|
|
InsertSidebarSearch();
|
|
}
|
|
|
|
for (auto& initFunc : MenuInit::GetInitFuncs()) {
|
|
initFunc();
|
|
}
|
|
|
|
disabledMap = {
|
|
{ DISABLE_FOR_NO_VSYNC,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return !Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync();
|
|
},
|
|
"Disabling VSync not supported" } },
|
|
{ DISABLE_FOR_NO_WINDOWED_FULLSCREEN,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return !Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen();
|
|
},
|
|
"Windowed Fullscreen not supported" } },
|
|
{ DISABLE_FOR_NO_MULTI_VIEWPORT,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return !Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports();
|
|
},
|
|
"Multi-viewports not supported" } },
|
|
{ DISABLE_FOR_NOT_DIRECTX,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() !=
|
|
Ship::WindowBackend::FAST3D_DXGI_DX11;
|
|
},
|
|
"Available Only on DirectX" } },
|
|
{ DISABLE_FOR_DIRECTX,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() ==
|
|
Ship::WindowBackend::FAST3D_DXGI_DX11;
|
|
},
|
|
"Not Available on DirectX" } },
|
|
{ DISABLE_FOR_MATCH_REFRESH_RATE_ON,
|
|
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0); },
|
|
"Match Refresh Rate is Enabled" } },
|
|
{ DISABLE_FOR_ADVANCED_RESOLUTION_ON,
|
|
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); },
|
|
"Advanced Resolution Enabled" } },
|
|
{ DISABLE_FOR_VERTICAL_RES_TOGGLE_ON,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0);
|
|
},
|
|
"Vertical Resolution Toggle Enabled" } },
|
|
{ DISABLE_FOR_LOW_RES_MODE_ON,
|
|
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_LOW_RES_MODE, 0); }, "N64 Mode Enabled" } },
|
|
{ DISABLE_FOR_NULL_PLAY_STATE,
|
|
{ [](disabledInfo& info) -> bool { return gPlayState == NULL; }, "Save Not Loaded" } },
|
|
{ DISABLE_FOR_DEBUG_MODE_OFF,
|
|
{ [](disabledInfo& info) -> bool { return !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); },
|
|
"Debug Mode is Disabled" } },
|
|
{ DISABLE_FOR_FRAME_ADVANCE_OFF,
|
|
{ [](disabledInfo& info) -> bool { return !(gPlayState != nullptr && gPlayState->frameAdvCtx.enabled); },
|
|
"Frame Advance is Disabled" } },
|
|
{ DISABLE_FOR_ADVANCED_RESOLUTION_OFF,
|
|
{ [](disabledInfo& info) -> bool { return !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); },
|
|
"Advanced Resolution is Disabled" } },
|
|
{ DISABLE_FOR_VERTICAL_RESOLUTION_OFF,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0);
|
|
},
|
|
"Vertical Resolution Toggle is Off" } },
|
|
{ DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON,
|
|
{ [](disabledInfo& info) -> bool {
|
|
return CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) &&
|
|
CVarGetInteger(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"), 0);
|
|
},
|
|
"\"Boot To Debug Warp Screen\" Enabled (see Dev Tools -> General)" } },
|
|
};
|
|
}
|
|
|
|
void SohMenu::UpdateElement() {
|
|
Ship::Menu::UpdateElement();
|
|
}
|
|
|
|
void SohMenu::Draw() {
|
|
Ship::Menu::Draw();
|
|
}
|
|
|
|
void SohMenu::DrawElement() {
|
|
Ship::Menu::DrawElement();
|
|
}
|
|
} // namespace SohGui
|