From d1bbba626d3e71e56c8cb769f0dcefcb2347d772 Mon Sep 17 00:00:00 2001 From: Archez Date: Thu, 7 Nov 2024 18:08:37 -0500 Subject: [PATCH] Add alt assets toggle to menus (#824) * Add alt assets toggle to menus * Add toggle to control alt asset hotkey --- mm/2s2h/BenGui/BenMenuBar.cpp | 6 ++++++ mm/2s2h/BenGui/SearchableMenuItems.h | 31 +++++++++++++++++++--------- mm/2s2h/BenPort.cpp | 10 +++++---- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 2911b6458..c3d3a0547 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -620,6 +620,12 @@ void DrawEnhancementsMenu() { ImGui::SeparatorText("Clock"); UIWidgets::CVarCombobox("Clock Type", "gEnhancements.Graphics.ClockType", clockTypeOptions); UIWidgets::CVarCheckbox("24 Hours Clock", "gEnhancements.Graphics.24HoursClock"); + + ImGui::SeparatorText("Mods"); + UIWidgets::CVarCheckbox("Use Alternate Assets", "gEnhancements.Mods.AlternateAssets", + { .tooltip = "Toggle between standard assets and alternate assets. Usually mods " + "will indicate if this setting has to be used or not." }); + MotionBlur_RenderMenuOptions(); ImGui::SeparatorText("Other"); UIWidgets::CVarCheckbox("Authentic logo", "gEnhancements.Graphics.AuthenticLogo", diff --git a/mm/2s2h/BenGui/SearchableMenuItems.h b/mm/2s2h/BenGui/SearchableMenuItems.h index 6e5d65a9f..89e6a77cd 100644 --- a/mm/2s2h/BenGui/SearchableMenuItems.h +++ b/mm/2s2h/BenGui/SearchableMenuItems.h @@ -449,7 +449,7 @@ void AddSettings() { "gSettings.MenuTheme", "Changes the Theme of the Menu Widgets.", WIDGET_CVAR_COMBOBOX, - { .comboBoxOptions = menuThemeOptions } }, + { .defaultVariant = COLOR_INDIGO, .comboBoxOptions = menuThemeOptions } }, #if not defined(__SWITCH__) and not defined(__WIIU__) { "Menubar Controller Navigation", CVAR_IMGUI_CONTROLLER_NAV, "Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: " @@ -467,15 +467,6 @@ void AddSettings() { CVarGetInteger("gSettings.CursorVisibility", 0)); } }, #endif - { "Open App Files Folder", - "", - "Opens the folder that contains the save and mods folders, etc.", - WIDGET_BUTTON, - {}, - [](widgetInfo& info) { - std::string filesPath = Ship::Context::GetInstance()->GetAppDirectoryPath(); - SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str()); - } }, { "Search In Sidebar", "gSettings.SidebarSearch", "Displays the Search menu as a sidebar entry in Settings instead of in the header.", @@ -500,6 +491,20 @@ void AddSettings() { { "Search Input Autofocus", "gSettings.SearchAutofocus", "Search input box gets autofocus when visible. Does not affect using other widgets.", WIDGET_CVAR_CHECKBOX }, + { .widgetName = "Alt Assets Tab hotkey", + .widgetCVar = "gEnhancements.Mods.AlternateAssetsHotkey", + .widgetTooltip = "Allows pressing the Tab key to toggle alternate assets", + .widgetType = WIDGET_CVAR_CHECKBOX, + .widgetOptions = { .defaultVariant = true } }, + { "Open App Files Folder", + "", + "Opens the folder that contains the save and mods folders, etc.", + WIDGET_BUTTON, + {}, + [](widgetInfo& info) { + std::string filesPath = Ship::Context::GetInstance()->GetAppDirectoryPath(); + SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str()); + } }, } } }); // Audio Settings settingsSidebar.push_back( @@ -1170,6 +1175,12 @@ void AddEnhancements() { { .comboBoxOptions = clockTypeOptions } }, { "24 Hours Clock", "gEnhancements.Graphics.24HoursClock", "Changes from a 12 Hour to a 24 Hour Clock", WIDGET_CVAR_CHECKBOX }, + { .widgetName = "Mods", .widgetType = WIDGET_SEPARATOR_TEXT }, + { .widgetName = "Use Alternate Assets", + .widgetCVar = "gEnhancements.Mods.AlternateAssets", + .widgetTooltip = "Toggle between standard assets and alternate assets. Usually mods will indicate if " + "this setting has to be used or not.", + .widgetType = WIDGET_CVAR_CHECKBOX }, { .widgetName = "Motion Blur", .widgetType = WIDGET_SEPARATOR_TEXT }, { "Motion Blur Mode", "gEnhancements.Graphics.MotionBlur.Mode", diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index dbb56d2af..7179d9db5 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -154,7 +154,7 @@ OTRGlobals::OTRGlobals() { Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3, { .SampleRate = 44100, .SampleLength = 1024, .DesiredBuffered = 2480 }); - prevAltAssets = CVarGetInteger("gAltAssets", 0); + prevAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0); context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); // Override LUS defaults @@ -688,8 +688,10 @@ extern "C" void Graph_StartFrame() { #endif case KbScancode::LUS_KB_TAB: { // Toggle HD Assets - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); - // ShouldClearTextureCacheAtEndOfFrame = true; + if (CVarGetInteger("gEnhancements.Mods.AlternateAssetsHotkey", 1)) { + CVarSetInteger("gEnhancements.Mods.AlternateAssets", + !CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0)); + } break; } } @@ -778,7 +780,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } } - bool curAltAssets = CVarGetInteger("gAltAssets", 0); + bool curAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0); if (prevAltAssets != curAltAssets) { prevAltAssets = curAltAssets; Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);