diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index c19b186db40..9f78d16feba 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -40,6 +40,7 @@ #include "z64.h" #include "macros.h" #include "Fonts.h" +#include "window/gui/resource/Font.h" #include #include "Enhancements/custom-message/CustomMessageManager.h" #include "Enhancements/presets.h" @@ -400,9 +401,14 @@ OTRGlobals::OTRGlobals() { hasMasterQuest = hasOriginal = false; previousImGuiScale = defaultImGuiScale; - defaultFontSmaller = CreateDefaultFontWithSize(10.0f); - defaultFontLarger = CreateDefaultFontWithSize(16.0f); - defaultFontLargest = CreateDefaultFontWithSize(20.0f); + + fontMono = CreateFontWithSize(16.0f, "fonts/Inconsolata-Regular.ttf"); + fontMonoLarger = CreateFontWithSize(20.0f, "fonts/Inconsolata-Regular.ttf"); + fontMonoLargest = CreateFontWithSize(24.0f, "fonts/Inconsolata-Regular.ttf"); + fontStandard = CreateFontWithSize(16.0f, "fonts/Montserrat-Regular.ttf"); + fontStandardLarger = CreateFontWithSize(20.0f, "fonts/Montserrat-Regular.ttf"); + fontStandardLargest = CreateFontWithSize(24.0f, "fonts/Montserrat-Regular.ttf"); + ImGui::GetIO().FontDefault = fontMono; ScaleImGui(); // Move the camera strings from read only memory onto the heap (writable memory) @@ -1539,6 +1545,37 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { */ } +ImFont* OTRGlobals::CreateFontWithSize(float size, std::string fontPath) { + auto mImGuiIo = &ImGui::GetIO(); + ImFont* font; + if (fontPath == "") { + ImFontConfig fontCfg = ImFontConfig(); + fontCfg.OversampleH = fontCfg.OversampleV = 1; + fontCfg.PixelSnapH = true; + fontCfg.SizePixels = size; + font = mImGuiIo->Fonts->AddFontDefault(&fontCfg); + } else { + auto initData = std::make_shared(); + initData->Format = RESOURCE_FORMAT_BINARY; + initData->Type = static_cast(RESOURCE_TYPE_FONT); + initData->ResourceVersion = 0; + initData->Path = fontPath; + std::shared_ptr fontData = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fontPath, false, initData)); + font = mImGuiIo->Fonts->AddFontFromMemoryTTF(fontData->Data, fontData->DataSize, size); + } + // FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly + float iconFontSize = size * 2.0f / 3.0f; + static const ImWchar sIconsRanges[] = { ICON_MIN_FA, ICON_MAX_16_FA, 0 }; + ImFontConfig iconsConfig; + iconsConfig.MergeMode = true; + iconsConfig.PixelSnapH = true; + iconsConfig.GlyphMinAdvanceX = iconFontSize; + mImGuiIo->Fonts->AddFontFromMemoryCompressedBase85TTF(fontawesome_compressed_data_base85, iconFontSize, + &iconsConfig, sIconsRanges); + return font; +} + std::filesystem::path GetSaveFile(std::shared_ptr Conf) { const std::string fileName = Conf->GetString("Game.SaveName", Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav")); std::filesystem::path saveFile = std::filesystem::absolute(fileName); diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index f056cad5e4a..0a8d6595ea4 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -54,6 +54,13 @@ class OTRGlobals { ImFont* defaultFontLarger; ImFont* defaultFontLargest; + ImFont* fontStandard; + ImFont* fontStandardLarger; + ImFont* fontStandardLargest; + ImFont* fontMono; + ImFont* fontMonoLarger; + ImFont* fontMonoLargest; + OTRGlobals(); ~OTRGlobals(); @@ -69,6 +76,7 @@ class OTRGlobals { bool hasMasterQuest; bool hasOriginal; ImFont* CreateDefaultFontWithSize(float size); + ImFont* CreateFontWithSize(float size, std::string fontPath); }; #endif diff --git a/soh/soh/ShipUtils.cpp b/soh/soh/ShipUtils.cpp index 62f8a09ac6c..5e876892a49 100644 --- a/soh/soh/ShipUtils.cpp +++ b/soh/soh/ShipUtils.cpp @@ -9,7 +9,7 @@ extern "C" { extern float OTRGetAspectRatio(); -extern f32 sNESFontWidths[160]; +//extern f32 sNESFontWidths[160]; extern const char* fontTbl[156]; //extern TexturePtr gItemIcons[131]; //extern TexturePtr gQuestIcons[14]; @@ -80,15 +80,15 @@ extern "C" void Ship_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, vtxList[3].v.tc[1] = height << 5; } -extern "C" f32 Ship_GetCharFontWidthNES(u8 character) { - u8 adjustedChar = character - ' '; - - if (adjustedChar >= ARRAY_COUNTU(sNESFontWidths)) { - return 0.0f; - } - - return sNESFontWidths[adjustedChar]; -} +//extern "C" f32 Ship_GetCharFontWidthNES(u8 character) { +// u8 adjustedChar = character - ' '; +// +// if (adjustedChar >= ARRAY_COUNTU(sNESFontWidths)) { +// return 0.0f; +// } +// +// return sNESFontWidths[adjustedChar]; +//} //extern "C" TexturePtr Ship_GetCharFontTextureNES(u8 character) { // u8 adjustedChar = character - ' '; diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index eabad2953a5..d51fcd0216d 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -87,7 +87,7 @@ void Menu::InsertSidebarSearch() { void Menu::RemoveSidebarSearch() { uint32_t curIndex = - GetVectorIndexOf(menuEntries["Settings"].sidebarOrder, CVarGetString(menuEntries["Settings"].sidebarCvar, "")); + GetVectorIndexOf(menuEntries["Settings"].sidebarOrder, CVarGetString(menuEntries["Settings"].sidebarCvar, "General")); menuEntries["Settings"].sidebars.erase("Search"); std::erase_if(menuEntries["Settings"].sidebarOrder, [](std::string& name) { return name == "Search"; }); if (curIndex > searchSidebarIndex) { @@ -114,7 +114,7 @@ void Menu::UpdateWindowBackendObjects() { } Menu::Menu(const std::string& cVar, const std::string& name, uint8_t searchSidebarIndex_, - UIWidgets::Colors defaultThemeIndex_) + UIWidgets2::Colors defaultThemeIndex_) : GuiWindow(cVar, name), searchSidebarIndex(searchSidebarIndex_), defaultThemeIndex(defaultThemeIndex_) { } @@ -153,7 +153,7 @@ bool ModernMenuSidebarEntry(std::string label) { : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), 3.0f); - UIWidgets::RenderText(pos, label.c_str(), ImGui::FindRenderedTextEnd(label.c_str()), true); + UIWidgets2::RenderText(pos, label.c_str(), ImGui::FindRenderedTextEnd(label.c_str()), true); return pressed; } @@ -175,12 +175,12 @@ bool ModernMenuHeaderEntry(std::string label) { : ImGuiCol_Button), 3.0f); pos += style.FramePadding; - UIWidgets::RenderText(pos, label.c_str(), ImGui::FindRenderedTextEnd(label.c_str()), true); + UIWidgets2::RenderText(pos, label.c_str(), ImGui::FindRenderedTextEnd(label.c_str()), true); return pressed; } uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { - auto menuThemeIndex = static_cast(CVarGetInteger("gSettings.Menu.Theme", defaultThemeIndex)); + auto menuThemeIndex = static_cast(CVarGetInteger("gSettings.Menu.Theme", defaultThemeIndex)); ImGui::BeginChild("Search Results"); int searchCount = 0; for (auto& menuLabel : menuOrder) { @@ -202,7 +202,7 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { widgetStr.erase(std::remove(widgetStr.begin(), widgetStr.end(), ' '), widgetStr.end()); if (widgetStr.find(menuSearchText) != std::string::npos) { MenuDrawItem(info, 90 / sidebar.columnCount, menuThemeIndex); - ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(UIWidgets::Colors::Gray)); + ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets2::ColorValues.at(UIWidgets2::Colors::Gray)); std::string origin = fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, column); ImGui::Text("%s", origin.c_str()); ImGui::PopStyleColor(); @@ -224,7 +224,7 @@ std::unordered_map& Menu::GetDisabledMap() { return disabledMap; } -void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors menuThemeIndex) { +void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets2::Colors menuThemeIndex) { disabledTempTooltip = "This setting is disabled because: \n\n"; disabledValue = false; disabledTooltip = " "; @@ -257,9 +257,9 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me assert(false); return; } - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::Checkbox(UIWidgets::WrappedText(widget.name.c_str(), width).c_str(), pointer, + if (UIWidgets2::Checkbox(UIWidgets2::WrappedText(widget.name.c_str(), width).c_str(), pointer, *options)) { if (widget.callback != nullptr) { widget.callback(widget); @@ -267,9 +267,9 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me } } break; case WIDGET_CVAR_CHECKBOX: { - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::CVarCheckbox(UIWidgets::WrappedText(widget.name.c_str(), width).c_str(), widget.cVar, + if (UIWidgets2::CVarCheckbox(UIWidgets2::WrappedText(widget.name.c_str(), width).c_str(), widget.cVar, *options)) { if (widget.callback != nullptr) { widget.callback(widget); @@ -277,23 +277,23 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me }; } break; case WIDGET_AUDIO_BACKEND: { - auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); - UIWidgets::ComboboxOptions options = {}; + auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend(); + UIWidgets2::ComboboxOptions options = {}; options.color = menuThemeIndex; options.tooltip = "Sets the audio API used by the game. Requires a relaunch to take effect."; options.disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1; options.disabledTooltip = "Only one audio API is available on this platform."; - if (UIWidgets::Combobox("Audio API", ¤tAudioBackend, audioBackendsMap, options)) { - Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(currentAudioBackend); + if (UIWidgets2::Combobox("Audio API", ¤tAudioBackend, audioBackendsMap, options)) { + Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend); } } break; case WIDGET_VIDEO_BACKEND: { - UIWidgets::ComboboxOptions options = {}; + UIWidgets2::ComboboxOptions options = {}; options.color = menuThemeIndex; options.tooltip = "Sets the renderer API used by the game."; options.disabled = availableWindowBackends->size() <= 1; options.disabledTooltip = "Only one renderer API is available on this platform."; - if (UIWidgets::Combobox("Renderer API (Needs reload)", &configWindowBackend, availableWindowBackendsMap, + if (UIWidgets2::Combobox("Renderer API (Needs reload)", &configWindowBackend, availableWindowBackendsMap, options)) { Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", (int32_t)(configWindowBackend)); @@ -307,21 +307,21 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me ImGui::Separator(); } break; case WIDGET_SEPARATOR_TEXT: { - if (widget.options->color != UIWidgets::Colors::NoColor) { - ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(widget.options->color)); + if (widget.options->color != UIWidgets2::Colors::NoColor) { + ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets2::ColorValues.at(widget.options->color)); } ImGui::SeparatorText(widget.name.c_str()); - if (widget.options->color != UIWidgets::Colors::NoColor) { + if (widget.options->color != UIWidgets2::Colors::NoColor) { ImGui::PopStyleColor(); } } break; case WIDGET_TEXT: { - if (widget.options->color != UIWidgets::Colors::NoColor) { - ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(widget.options->color)); + if (widget.options->color != UIWidgets2::Colors::NoColor) { + ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets2::ColorValues.at(widget.options->color)); } ImGui::AlignTextToFramePadding(); ImGui::TextWrapped("%s", widget.name.c_str()); - if (widget.options->color != UIWidgets::Colors::NoColor) { + if (widget.options->color != UIWidgets2::Colors::NoColor) { ImGui::PopStyleColor(); } } break; @@ -332,18 +332,18 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me assert(false); return; } - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::Combobox(widget.name.c_str(), pointer, options->comboMap, *options)) { + if (UIWidgets2::Combobox(widget.name.c_str(), pointer, options->comboMap, *options)) { if (widget.callback != nullptr) { widget.callback(widget); } }; } break; case WIDGET_CVAR_COMBOBOX: { - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::CVarCombobox(widget.name.c_str(), widget.cVar, options->comboMap, *options)) { + if (UIWidgets2::CVarCombobox(widget.name.c_str(), widget.cVar, options->comboMap, *options)) { if (widget.callback != nullptr) { widget.callback(widget); } @@ -356,18 +356,18 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me assert(false); return; } - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::SliderInt(widget.name.c_str(), pointer, *options)) { + if (UIWidgets2::SliderInt(widget.name.c_str(), pointer, *options)) { if (widget.callback != nullptr) { widget.callback(widget); } }; } break; case WIDGET_CVAR_SLIDER_INT: { - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::CVarSliderInt(widget.name.c_str(), widget.cVar, *options)) { + if (UIWidgets2::CVarSliderInt(widget.name.c_str(), widget.cVar, *options)) { if (widget.callback != nullptr) { widget.callback(widget); } @@ -381,27 +381,27 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me assert(false); return; } - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::SliderFloat(widget.name.c_str(), pointer, *options)) { + if (UIWidgets2::SliderFloat(widget.name.c_str(), pointer, *options)) { if (widget.callback != nullptr) { widget.callback(widget); } } } break; case WIDGET_CVAR_SLIDER_FLOAT: { - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::CVarSliderFloat(widget.name.c_str(), widget.cVar, *options)) { + if (UIWidgets2::CVarSliderFloat(widget.name.c_str(), widget.cVar, *options)) { if (widget.callback != nullptr) { widget.callback(widget); } } } break; case WIDGET_BUTTON: { - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - if (UIWidgets::Button(widget.name.c_str(), *options)) { + if (UIWidgets2::Button(widget.name.c_str(), *options)) { if (widget.callback != nullptr) { widget.callback(widget); } @@ -426,15 +426,15 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me SPDLOG_ERROR(msg.c_str()); break; } - auto options = std::static_pointer_cast(widget.options); + auto options = std::static_pointer_cast(widget.options); options->color = menuThemeIndex; - UIWidgets::WindowButton(widget.name.c_str(), widget.cVar, window, *options); + UIWidgets2::WindowButton(widget.name.c_str(), widget.cVar, window, *options); if (!window->IsVisible()) { window->DrawElement(); } } break; case WIDGET_SEARCH: { - UIWidgets::PushStyleButton(menuThemeIndex); + UIWidgets2::PushStyleButton(menuThemeIndex); if (ImGui::Button("Clear")) { menuSearch.Clear(); } @@ -444,12 +444,12 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me !ImGui::IsMouseClicked(0)) { ImGui::SetKeyboardFocusHere(0); } - UIWidgets::PushStyleCombobox(menuThemeIndex); - ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::ColorValues.at(menuThemeIndex)); + UIWidgets2::PushStyleCombobox(menuThemeIndex); + ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets2::ColorValues.at(menuThemeIndex)); menuSearch.Draw(); ImGui::PopStyleColor(); - UIWidgets::PopStyleCombobox(); - UIWidgets::PopStyleButton(); + UIWidgets2::PopStyleCombobox(); + UIWidgets2::PopStyleButton(); std::string menuSearchText(menuSearch.InputBuf); if (menuSearchText == "") { @@ -484,7 +484,7 @@ void Menu::DrawElement() { for (auto& [reason, info] : disabledMap) { info.active = info.evaluation(info); } - auto menuThemeIndex = static_cast(CVarGetInteger("gSettings.Menu.Theme", defaultThemeIndex)); + auto menuThemeIndex = static_cast(CVarGetInteger("gSettings.Menu.Theme", defaultThemeIndex)); windowHeight = ImGui::GetMainViewport()->WorkSize.y; windowWidth = ImGui::GetMainViewport()->WorkSize.x; @@ -574,10 +574,10 @@ void Menu::DrawElement() { headerHeight += style.ScrollbarSize; scrollbar = true; } - UIWidgets::ButtonOptions options = {}; - options.size = UIWidgets::Sizes::Inline; + UIWidgets2::ButtonOptions options = {}; + options.size = UIWidgets2::Sizes::Inline; options.tooltip = "Close Menu (Esc)"; - if (UIWidgets::Button(ICON_FA_TIMES_CIRCLE, options)) { + if (UIWidgets2::Button(ICON_FA_TIMES_CIRCLE, options)) { ToggleVisibility(); // Update gamepad navigation after close based on if other menus are still visible @@ -606,7 +606,7 @@ void Menu::DrawElement() { } auto& entry = menuEntries.at(label); std::string nextIndex = label; - UIWidgets::PushStyleButton(menuThemeIndex); + UIWidgets2::PushStyleButton(menuThemeIndex); if (headerIndex != label) { ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 }); } @@ -621,7 +621,7 @@ void Menu::DrawElement() { if (headerIndex != label) { ImGui::PopStyleColor(); } - UIWidgets::PopStyleButton(); + UIWidgets2::PopStyleButton(); if (headerIndex == label) { sidebar = &entry.sidebars; } @@ -637,7 +637,7 @@ void Menu::DrawElement() { !ImGui::IsMouseClicked(0)) { ImGui::SetKeyboardFocusHere(0); } - auto color = UIWidgets::ColorValues.at(menuThemeIndex); + auto color = UIWidgets2::ColorValues.at(menuThemeIndex); color.w = 0.2f; ImGui::PushStyleColor(ImGuiCol_FrameBg, color); menuSearch.Draw("##search", 200.0f); @@ -651,9 +651,9 @@ void Menu::DrawElement() { } ImGui::EndChild(); ImGui::SameLine(menuSize.x - (buttonSize.x * 2) - style.ItemSpacing.x); - UIWidgets::ButtonOptions options2 = {}; - options2.color = UIWidgets::Colors::Red; - options2.size = UIWidgets::Sizes::Inline; + UIWidgets2::ButtonOptions options2 = {}; + options2.color = UIWidgets2::Colors::Red; + options2.size = UIWidgets2::Sizes::Inline; options2.tooltip = "Reset" #ifdef __APPLE__ " (Command-R)" @@ -663,17 +663,17 @@ void Menu::DrawElement() { "" #endif ; - if (UIWidgets::Button(ICON_FA_UNDO, options2)) { + if (UIWidgets2::Button(ICON_FA_UNDO, options2)) { std::reinterpret_pointer_cast( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); } ImGui::SameLine(); - UIWidgets::ButtonOptions options3 = {}; - options3.color = UIWidgets::Colors::Red; - options3.size = UIWidgets::Sizes::Inline; + UIWidgets2::ButtonOptions options3 = {}; + options3.color = UIWidgets2::Colors::Red; + options3.size = UIWidgets2::Sizes::Inline; options3.tooltip = "Quit 2S2H"; - if (UIWidgets::Button(ICON_FA_POWER_OFF, options3)) { + if (UIWidgets2::Button(ICON_FA_POWER_OFF, options3)) { if (!popped) { ToggleVisibility(); } @@ -704,7 +704,7 @@ void Menu::DrawElement() { ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize, ImGuiWindowFlags_NoTitleBar); for (auto& sidebarLabel : menuEntries.at(headerIndex).sidebarOrder) { std::string nextIndex = ""; - UIWidgets::PushStyleButton(menuThemeIndex); + UIWidgets2::PushStyleButton(menuThemeIndex); if (sectionIndex != sidebarLabel) { ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 }); } @@ -719,7 +719,7 @@ void Menu::DrawElement() { if (sectionIndex != sidebarLabel) { ImGui::PopStyleColor(); } - UIWidgets::PopStyleButton(); + UIWidgets2::PopStyleButton(); if (nextIndex != "") { sectionIndex = nextIndex; } @@ -756,9 +756,9 @@ void Menu::DrawElement() { } ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("Clear Search").x) / 2 - 10.0f); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f); - UIWidgets::ButtonOptions clearBtnOpts = {}; - clearBtnOpts.size = UIWidgets::Sizes::Inline; - if (UIWidgets::Button("Clear Search", clearBtnOpts)) { + UIWidgets2::ButtonOptions clearBtnOpts = {}; + clearBtnOpts.size = UIWidgets2::Sizes::Inline; + if (UIWidgets2::Button("Clear Search", clearBtnOpts)) { menuSearch.Clear(); } diff --git a/soh/soh/SohGui/Menu.h b/soh/soh/SohGui/Menu.h index dc91d8fa5da..92b845b8ea1 100644 --- a/soh/soh/SohGui/Menu.h +++ b/soh/soh/SohGui/Menu.h @@ -14,7 +14,7 @@ class Menu : public GuiWindow { using GuiWindow::GuiWindow; Menu(const std::string& cVar, const std::string& name, uint8_t searchSidebarIndex_ = 0, - UIWidgets::Colors menuThemeIndex_ = UIWidgets::Colors::LightBlue); + UIWidgets2::Colors menuThemeIndex_ = UIWidgets2::Colors::LightBlue); void InitElement() override; void DrawElement() override; @@ -24,7 +24,7 @@ class Menu : public GuiWindow { void RemoveSidebarSearch(); void UpdateWindowBackendObjects(); - void MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors menuThemeIndex); + void MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets2::Colors menuThemeIndex); void AddMenuEntry(std::string entryName, const char* entryCvar); std::unordered_map& GetDisabledMap(); @@ -37,7 +37,7 @@ class Menu : public GuiWindow { uint32_t DrawSearchResults(std::string& menuSearchText); ImGuiTextFilter menuSearch; uint8_t searchSidebarIndex; - UIWidgets::Colors defaultThemeIndex; + UIWidgets2::Colors defaultThemeIndex; std::shared_ptr> availableWindowBackends; std::unordered_map availableWindowBackendsMap; Ship::WindowBackend configWindowBackend; @@ -48,7 +48,7 @@ class Menu : public GuiWindow { .columnCount = 1, .columnWidgets = { { { .name = "Sidebar Search", .type = WIDGET_SEARCH, - .options = std::make_shared(UIWidgets::WidgetOptions{}.Tooltip( + .options = std::make_shared(UIWidgets2::WidgetOptions{}.Tooltip( "Searches all menus for the given text, including tooltips.")) } } } }; diff --git a/soh/soh/SohGui/MenuTypes.h b/soh/soh/SohGui/MenuTypes.h index 00e6400acf6..b1f923bd6dc 100644 --- a/soh/soh/SohGui/MenuTypes.h +++ b/soh/soh/SohGui/MenuTypes.h @@ -74,8 +74,8 @@ typedef enum { // evaluation using CVarVariant = std::variant; using OptionsVariant = - std::variant; + std::variant; // All the info needed for display and search of all widgets in the menu. // `name` is the label displayed, @@ -101,7 +101,7 @@ struct WidgetInfo { std::string name; // Used by all widgets const char* cVar; // Used by all widgets except WidgetType type; - std::shared_ptr options; + std::shared_ptr options; std::variant valuePointer; WidgetFunc callback = nullptr; WidgetFunc preFunc = nullptr; @@ -122,31 +122,31 @@ struct WidgetInfo { case WIDGET_VIDEO_BACKEND: case WIDGET_COMBOBOX: case WIDGET_CVAR_COMBOBOX: - options = std::make_shared(std::get(options_)); + options = std::make_shared(std::get(options_)); break; case WIDGET_CHECKBOX: case WIDGET_CVAR_CHECKBOX: - options = std::make_shared(std::get(options_)); + options = std::make_shared(std::get(options_)); break; case WIDGET_SLIDER_FLOAT: case WIDGET_CVAR_SLIDER_FLOAT: options = - std::make_shared(std::get(options_)); + std::make_shared(std::get(options_)); break; case WIDGET_SLIDER_INT: case WIDGET_CVAR_SLIDER_INT: options = - std::make_shared(std::get(options_)); + std::make_shared(std::get(options_)); break; case WIDGET_BUTTON: case WIDGET_WINDOW_BUTTON: - options = std::make_shared(std::get(options_)); + options = std::make_shared(std::get(options_)); break; case WIDGET_TEXT: case WIDGET_SEPARATOR_TEXT: case WIDGET_SEPARATOR: default: - options = std::make_shared(std::get(options_)); + options = std::make_shared(std::get(options_)); } return *this; } @@ -156,7 +156,7 @@ struct WidgetInfo { options->disabledTooltip = ""; activeDisables.clear(); } - WidgetInfo& Options(std::shared_ptr options_) { + WidgetInfo& Options(std::shared_ptr options_) { options = options_; return *this; } diff --git a/soh/soh/SohGui/SohMenu.cpp b/soh/soh/SohGui/SohMenu.cpp index ff5d09ac91b..c44a60aa1a5 100644 --- a/soh/soh/SohGui/SohMenu.cpp +++ b/soh/soh/SohGui/SohMenu.cpp @@ -22,7 +22,7 @@ extern std::unordered_map warpPointSceneList; extern void Warp(); namespace SohGui { -extern std::shared_ptr mBenMenu; +extern std::shared_ptr mSohMenu; void FreeLookPitchMinMax() { f32 maxY = CVarGetFloat("gEnhancements.Camera.FreeLook.MaxPitch", 72.0f); f32 minY = CVarGetFloat("gEnhancements.Camera.FreeLook.MinPitch", -49.0f); @@ -30,7 +30,7 @@ void FreeLookPitchMinMax() { CVarSetFloat("gEnhancements.Camera.FreeLook.MinPitch", std::min(maxY, minY)); } -using namespace UIWidgets; +using namespace UIWidgets2; void SohMenu::AddSidebarEntry(std::string sectionName, std::string sidebarName, uint32_t columnCount) { assert(!sectionName.empty()); @@ -122,9 +122,9 @@ void SohMenu::AddSettings() { .CVar("gSettings.Menu.SidebarSearch") .Callback([](WidgetInfo& info) { if (CVarGetInteger("gSettings.Menu.SidebarSearch", 0)) { - mBenMenu->InsertSidebarSearch(); + mSohMenu->InsertSidebarSearch(); } else { - mBenMenu->RemoveSidebarSearch(); + mSohMenu->RemoveSidebarSearch(); } }) .Options(CheckboxOptions().Tooltip( @@ -227,11 +227,11 @@ void SohMenu::AddSettings() { CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); }) .PreFunc([](WidgetInfo& info) { - if (mBenMenu->disabledMap.at(DISABLE_FOR_ADVANCED_RESOLUTION_ON).active && - mBenMenu->disabledMap.at(DISABLE_FOR_VERTICAL_RES_TOGGLE_ON).active) { + if (mSohMenu->disabledMap.at(DISABLE_FOR_ADVANCED_RESOLUTION_ON).active && + mSohMenu->disabledMap.at(DISABLE_FOR_VERTICAL_RES_TOGGLE_ON).active) { info.activeDisables.push_back(DISABLE_FOR_ADVANCED_RESOLUTION_ON); info.activeDisables.push_back(DISABLE_FOR_VERTICAL_RES_TOGGLE_ON); - } else if (mBenMenu->disabledMap.at(DISABLE_FOR_LOW_RES_MODE_ON).active) { + } else if (mSohMenu->disabledMap.at(DISABLE_FOR_LOW_RES_MODE_ON).active) { info.activeDisables.push_back(DISABLE_FOR_LOW_RES_MODE_ON); } }) @@ -272,7 +272,7 @@ void SohMenu::AddSettings() { } }) .PreFunc([](WidgetInfo& info) { - if (mBenMenu->disabledMap.at(DISABLE_FOR_MATCH_REFRESH_RATE_ON).active) + if (mSohMenu->disabledMap.at(DISABLE_FOR_MATCH_REFRESH_RATE_ON).active) info.activeDisables.push_back(DISABLE_FOR_MATCH_REFRESH_RATE_ON); }) .Options(IntSliderOptions().Tooltip(tooltip).Min(20).Max(maxFps).DefaultValue(20)); @@ -284,15 +284,15 @@ void SohMenu::AddSettings() { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } }) - .PreFunc([](WidgetInfo& info) { info.isHidden = mBenMenu->disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; }) + .PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; }) .Options(ButtonOptions().Tooltip("Matches interpolation value to the current game's window refresh rate.")); AddWidget(path, "Match Refresh Rate", WIDGET_CVAR_CHECKBOX) .CVar("gMatchRefreshRate") - .PreFunc([](WidgetInfo& info) { info.isHidden = mBenMenu->disabledMap.at(DISABLE_FOR_DIRECTX).active; }) + .PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_DIRECTX).active; }) .Options(CheckboxOptions().Tooltip("Matches interpolation value to the current game's window refresh rate.")); AddWidget(path, "Jitter fix : >= % d FPS", WIDGET_CVAR_SLIDER_INT) .CVar("gExtraLatencyThreshold") - .PreFunc([](WidgetInfo& info) { info.isHidden = mBenMenu->disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; }) + .PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; }) .Options(IntSliderOptions() .Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input " "lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the " @@ -304,18 +304,18 @@ void SohMenu::AddSettings() { AddWidget(path, "Renderer API (Needs reload)", WIDGET_VIDEO_BACKEND); AddWidget(path, "Enable Vsync", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_VSYNC_ENABLED) - .PreFunc([](WidgetInfo& info) { info.isHidden = mBenMenu->disabledMap.at(DISABLE_FOR_NO_VSYNC).active; }) + .PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NO_VSYNC).active; }) .Options(CheckboxOptions().Tooltip("Enables Vsync.")); AddWidget(path, "Windowed Fullscreen", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_SDL_WINDOWED_FULLSCREEN) .PreFunc([](WidgetInfo& info) { - info.isHidden = mBenMenu->disabledMap.at(DISABLE_FOR_NO_WINDOWED_FULLSCREEN).active; + info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NO_WINDOWED_FULLSCREEN).active; }) .Options(CheckboxOptions().Tooltip("Enables Windowed Fullscreen Mode.")); AddWidget(path, "Allow multi-windows", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_ENABLE_MULTI_VIEWPORTS) .PreFunc( - [](WidgetInfo& info) { info.isHidden = mBenMenu->disabledMap.at(DISABLE_FOR_NO_MULTI_VIEWPORT).active; }) + [](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NO_MULTI_VIEWPORT).active; }) .Options(CheckboxOptions().Tooltip( "Allows multiple windows to be opened at once. Requires a reload to take effect.")); AddWidget(path, "Texture Filter (Needs reload)", WIDGET_CVAR_COMBOBOX) @@ -392,6 +392,7 @@ void SohMenu::AddEnhancements() { AddMenuEntry("Enhancements", "gSettings.Menu.EnhancementsSidebarSection"); WidgetPath path = { "Enhancements", "Camera", SECTION_COLUMN_1 }; AddSidebarEntry("Enhancements", "Camera", 3); + AddWidget(path, "Filler1", WIDGET_TEXT); // HUD Editor //path = { "Enhancements", "HUD Editor", SECTION_COLUMN_1 }; @@ -415,66 +416,67 @@ void SohMenu::AddDevTools() { AddMenuEntry("Developer Tools", "gSettings.Menu.DevToolsSidebarSection"); AddSidebarEntry("Developer Tools", "General", 3); WidgetPath path = { "Developer Tools", "General", SECTION_COLUMN_1 }; - AddWidget(path, "Popout Menu", WIDGET_CVAR_CHECKBOX) - .CVar("gSettings.Menu.Popout") - .Options(CheckboxOptions().Tooltip("Changes the menu display from overlay to windowed.")); - - // dev tools windows - path = { "Developer Tools", "Collision Viewer", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Collision Viewer", 1); - AddWidget(path, "Popout Collision Viewer", WIDGET_WINDOW_BUTTON) - .CVar("gWindows.CollisionViewer") - .Options(ButtonOptions().Tooltip("Makes collision visible on screen").Size(Sizes::Inline)) - .WindowName("Collision Viewer"); + AddWidget(path, "Filler1", WIDGET_TEXT); + //AddWidget(path, "Popout Menu", WIDGET_CVAR_CHECKBOX) + // .CVar("gSettings.Menu.Popout") + // .Options(CheckboxOptions().Tooltip("Changes the menu display from overlay to windowed.")); + // + //// dev tools windows + //path = { "Developer Tools", "Collision Viewer", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Collision Viewer", 1); + //AddWidget(path, "Popout Collision Viewer", WIDGET_WINDOW_BUTTON) + // .CVar("gWindows.CollisionViewer") + // .Options(ButtonOptions().Tooltip("Makes collision visible on screen").Size(Sizes::Inline)) + // .WindowName("Collision Viewer"); - path = { "Developer Tools", "Stats", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Stats", 1); - AddWidget(path, "Popout Stats", WIDGET_WINDOW_BUTTON) - .CVar("gOpenWindows.Stats") - .Options(ButtonOptions().Tooltip( - "Shows the stats window, with your FPS and frametimes, and the OS you're playing on")) - .WindowName("Stats"); + //path = { "Developer Tools", "Stats", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Stats", 1); + //AddWidget(path, "Popout Stats", WIDGET_WINDOW_BUTTON) + // .CVar("gOpenWindows.Stats") + // .Options(ButtonOptions().Tooltip( + // "Shows the stats window, with your FPS and frametimes, and the OS you're playing on")) + // .WindowName("Stats"); - path = { "Developer Tools", "Console", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Console", 1); - AddWidget(path, "Popout Console", WIDGET_WINDOW_BUTTON) - .CVar("gOpenWindows.Console") - .Options(ButtonOptions().Tooltip( - "Enables the console window, allowing you to input commands. Type help for some examples")) - .WindowName("Console"); + //path = { "Developer Tools", "Console", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Console", 1); + //AddWidget(path, "Popout Console", WIDGET_WINDOW_BUTTON) + // .CVar("gOpenWindows.Console") + // .Options(ButtonOptions().Tooltip( + // "Enables the console window, allowing you to input commands. Type help for some examples")) + // .WindowName("Console"); - path = { "Developer Tools", "Gfx Debugger", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Gfx Debugger", 1); - AddWidget(path, "Popout Gfx Debugger", WIDGET_WINDOW_BUTTON) - .CVar("gOpenWindows.GfxDebugger") - .Options(ButtonOptions().Tooltip( - "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples")) - .WindowName("GfxDebuggerWindow"); + //path = { "Developer Tools", "Gfx Debugger", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Gfx Debugger", 1); + //AddWidget(path, "Popout Gfx Debugger", WIDGET_WINDOW_BUTTON) + // .CVar("gOpenWindows.GfxDebugger") + // .Options(ButtonOptions().Tooltip( + // "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples")) + // .WindowName("GfxDebuggerWindow"); - path = { "Developer Tools", "Save Editor", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Save Editor", 1); - AddWidget(path, "Popout Save Editor", WIDGET_WINDOW_BUTTON) - .CVar("gWindows.SaveEditor") - .Options(ButtonOptions().Tooltip("Enables the Save Editor window, allowing you to edit your save file")) - .WindowName("Save Editor"); + //path = { "Developer Tools", "Save Editor", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Save Editor", 1); + //AddWidget(path, "Popout Save Editor", WIDGET_WINDOW_BUTTON) + // .CVar("gWindows.SaveEditor") + // .Options(ButtonOptions().Tooltip("Enables the Save Editor window, allowing you to edit your save file")) + // .WindowName("Save Editor"); - path = { "Developer Tools", "Actor Viewer", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Actor Viewer", 1); - AddWidget(path, "Popout Actor Viewer", WIDGET_WINDOW_BUTTON) - .CVar("gWindows.ActorViewer") - .Options(ButtonOptions().Tooltip("Enables the Actor Viewer window, allowing you to view actors in the world.")) - .WindowName("Actor Viewer"); + //path = { "Developer Tools", "Actor Viewer", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Actor Viewer", 1); + //AddWidget(path, "Popout Actor Viewer", WIDGET_WINDOW_BUTTON) + // .CVar("gWindows.ActorViewer") + // .Options(ButtonOptions().Tooltip("Enables the Actor Viewer window, allowing you to view actors in the world.")) + // .WindowName("Actor Viewer"); - path = { "Developer Tools", "Event Log", SECTION_COLUMN_1 }; - AddSidebarEntry("Developer Tools", "Event Log", 1); - AddWidget(path, "Popout Event Log", WIDGET_WINDOW_BUTTON) - .CVar("gWindows.EventLog") - .Options(ButtonOptions().Tooltip("Enables the event log window")) - .WindowName("Event Log"); + //path = { "Developer Tools", "Event Log", SECTION_COLUMN_1 }; + //AddSidebarEntry("Developer Tools", "Event Log", 1); + //AddWidget(path, "Popout Event Log", WIDGET_WINDOW_BUTTON) + // .CVar("gWindows.EventLog") + // .Options(ButtonOptions().Tooltip("Enables the event log window")) + // .WindowName("Event Log"); } SohMenu::SohMenu(const std::string& consoleVariable, const std::string& name) - : Menu(consoleVariable, name, 0, UIWidgets::Colors::LightBlue) { + : Menu(consoleVariable, name, 0, UIWidgets2::Colors::LightBlue) { } void SohMenu::InitElement() { diff --git a/soh/soh/SohGui/SohMenu.h b/soh/soh/SohGui/SohMenu.h index 4db6dd80890..a78f4f99cec 100644 --- a/soh/soh/SohGui/SohMenu.h +++ b/soh/soh/SohGui/SohMenu.h @@ -10,20 +10,20 @@ namespace SohGui { static const std::unordered_map menuThemeOptions = { - { UIWidgets::Colors::Red, "Red" }, - { UIWidgets::Colors::DarkRed, "Dark Red" }, - { UIWidgets::Colors::Orange, "Orange" }, - { UIWidgets::Colors::Green, "Green" }, - { UIWidgets::Colors::DarkGreen, "Dark Green" }, - { UIWidgets::Colors::LightBlue, "Light Blue" }, - { UIWidgets::Colors::Blue, "Blue" }, - { UIWidgets::Colors::DarkBlue, "Dark Blue" }, - { UIWidgets::Colors::Indigo, "Indigo" }, - { UIWidgets::Colors::Violet, "Violet" }, - { UIWidgets::Colors::Purple, "Purple" }, - { UIWidgets::Colors::Brown, "Brown" }, - { UIWidgets::Colors::Gray, "Gray" }, - { UIWidgets::Colors::DarkGray, "Dark Gray" }, + { UIWidgets2::Colors::Red, "Red" }, + { UIWidgets2::Colors::DarkRed, "Dark Red" }, + { UIWidgets2::Colors::Orange, "Orange" }, + { UIWidgets2::Colors::Green, "Green" }, + { UIWidgets2::Colors::DarkGreen, "Dark Green" }, + { UIWidgets2::Colors::LightBlue, "Light Blue" }, + { UIWidgets2::Colors::Blue, "Blue" }, + { UIWidgets2::Colors::DarkBlue, "Dark Blue" }, + { UIWidgets2::Colors::Indigo, "Indigo" }, + { UIWidgets2::Colors::Violet, "Violet" }, + { UIWidgets2::Colors::Purple, "Purple" }, + { UIWidgets2::Colors::Brown, "Brown" }, + { UIWidgets2::Colors::Gray, "Gray" }, + { UIWidgets2::Colors::DarkGray, "Dark Gray" }, }; static const std::unordered_map textureFilteringMap = { diff --git a/soh/soh/SohGui/UIWidgets2.cpp b/soh/soh/SohGui/UIWidgets2.cpp index cf508eb3e5a..103c9d58cf6 100644 --- a/soh/soh/SohGui/UIWidgets2.cpp +++ b/soh/soh/SohGui/UIWidgets2.cpp @@ -1,4 +1,4 @@ -#include "UIWidgets.hpp" +#include "UIWidgets2.hpp" #define IMGUI_DEFINE_MATH_OPERATORS #include #include @@ -8,7 +8,7 @@ #include #include -namespace UIWidgets { +namespace UIWidgets2 { // Automatically adds newlines to break up text longer than a specified number of characters // Manually included newlines will still be respected and reset the line length @@ -51,14 +51,14 @@ void Tooltip(const char* text) { void PushStyleMenu(const ImVec4& color) { ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_PopupBg, UIWidgets::ColorValues.at(Colors::DarkGray)); - ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::ColorValues.at(Colors::DarkGray)); + ImGui::PushStyleColor(ImGuiCol_PopupBg, ColorValues.at(Colors::DarkGray)); + ImGui::PushStyleColor(ImGuiCol_Border, ColorValues.at(Colors::DarkGray)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 15.0f)); ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 3.0f); } void PushStyleMenu(Colors color) { - PushStyleMenu(UIWidgets::ColorValues.at(color)); + PushStyleMenu(ColorValues.at(color)); } void PopStyleMenu() { @@ -112,7 +112,7 @@ void PushStyleButton(const ImVec4& color) { } void PushStyleButton(Colors color) { - PushStyleButton(UIWidgets::ColorValues.at(color)); + PushStyleButton(ColorValues.at(color)); } void PopStyleButton() { @@ -165,7 +165,7 @@ void PushStyleCheckbox(const ImVec4& color) { } void PushStyleCheckbox(Colors color) { - PushStyleCheckbox(UIWidgets::ColorValues.at(color)); + PushStyleCheckbox(ColorValues.at(color)); } void PopStyleCheckbox() { @@ -319,7 +319,7 @@ void PushStyleCombobox(const ImVec4& color) { } void PushStyleCombobox(Colors color) { - PushStyleCombobox(UIWidgets::ColorValues.at(color)); + PushStyleCombobox(ColorValues.at(color)); } void PopStyleCombobox() { @@ -328,7 +328,7 @@ void PopStyleCombobox() { } void PushStyleSlider(Colors color_) { - const ImVec4& color = UIWidgets::ColorValues.at(color_); + const ImVec4& color = ColorValues.at(color_); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 1.0f)); ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 1.0f)); @@ -556,7 +556,7 @@ void DrawFlagArray32(const std::string& name, uint32_t& flags) { uint32_t bitMask = 1 << flagIndex; bool flag = (flags & bitMask) != 0; std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, + if (Checkbox(label.c_str(), &flag, CheckboxOptions{ { .tooltip = label.c_str() } }.LabelPosition(LabelPosition::None))) { if (flag) { flags |= bitMask; @@ -579,7 +579,7 @@ void DrawFlagArray16(const std::string& name, uint16_t& flags) { uint16_t bitMask = 1 << flagIndex; bool flag = (flags & bitMask) != 0; std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, + if (Checkbox(label.c_str(), &flag, CheckboxOptions{ { .tooltip = label.c_str() } }.LabelPosition(LabelPosition::None))) { if (flag) { flags |= bitMask; @@ -602,7 +602,7 @@ void DrawFlagArray8(const std::string& name, uint8_t& flags) { uint8_t bitMask = 1 << flagIndex; bool flag = (flags & bitMask) != 0; std::string label = fmt::format("0x{:02X} ({})", flagIndex, flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, + if (Checkbox(label.c_str(), &flag, CheckboxOptions{ { .tooltip = label.c_str() } }.LabelPosition(LabelPosition::None))) { if (flag) { flags |= bitMask; @@ -625,7 +625,7 @@ void DrawFlagArray8Mask(const std::string& name, uint8_t& flags) { uint8_t bitMask = 1 << flagIndex; bool flag = (flags & bitMask) != 0; std::string label = fmt::format("0x{:02X} ({})", bitMask, flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, + if (Checkbox(label.c_str(), &flag, CheckboxOptions{ { .tooltip = label.c_str() } }.LabelPosition(LabelPosition::None))) { if (flag) { flags |= bitMask; diff --git a/soh/soh/SohGui/UIWidgets2.hpp b/soh/soh/SohGui/UIWidgets2.hpp index 75e66283e5a..327109c8c1c 100644 --- a/soh/soh/SohGui/UIWidgets2.hpp +++ b/soh/soh/SohGui/UIWidgets2.hpp @@ -12,30 +12,30 @@ #include "soh/ShipUtils.h" #include "soh/ShipInit.hpp" -namespace UIWidgets { +namespace UIWidgets2 { using SectionFunc = void(*)(); - //struct TextFilters { - // static int FilterNumbers(ImGuiInputTextCallbackData* data) { - // if (data->EventChar < 256 && strchr("1234567890", (char)data->EventChar)) { - // return 0; - // } - // return 1; - // } - - // static int FilterAlphaNum(ImGuiInputTextCallbackData* data) { - // const char* alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789"; - // if (data->EventChar < 256 && strchr(alphanum, (char)data->EventChar)) { - // return 0; - // } - // return 1; - // } - //}; - - /*std::string WrappedText(const char* text, unsigned int charactersPerLine = 60); + struct TextFilters { + static int FilterNumbers(ImGuiInputTextCallbackData* data) { + if (data->EventChar < 256 && strchr("1234567890", (char)data->EventChar)) { + return 0; + } + return 1; + } + + static int FilterAlphaNum(ImGuiInputTextCallbackData* data) { + const char* alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789"; + if (data->EventChar < 256 && strchr(alphanum, (char)data->EventChar)) { + return 0; + } + return 1; + } + }; + + std::string WrappedText(const char* text, unsigned int charactersPerLine = 60); std::string WrappedText(const std::string& text, unsigned int charactersPerLine = 60); - void Tooltip(const char* text);*/ + void Tooltip(const char* text); // mostly in order for colors usable by the menu without custom text color enum Colors { @@ -668,7 +668,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboMap, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -681,7 +681,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboVector, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -694,7 +694,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboArray, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; }