From 73304657b9e0c7640057f8f3149df02194625582 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Wed, 29 May 2024 13:08:00 +1000 Subject: [PATCH 1/8] Initial PR commit. Copy files from Shipwright. Bare minimum UIWidgets fixes to successfully build. Add window and button. Update CVar names to match current project. --- mm/2s2h/BenGui/BenGui.cpp | 6 + mm/2s2h/BenGui/BenMenuBar.cpp | 8 + .../ResolutionEditor/ResolutionEditor.cpp | 484 ++++++++++++++++++ .../ResolutionEditor/ResolutionEditor.h | 16 + 4 files changed, 514 insertions(+) create mode 100644 mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp create mode 100644 mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.h diff --git a/mm/2s2h/BenGui/BenGui.cpp b/mm/2s2h/BenGui/BenGui.cpp index 1b605880af..5542bf7faf 100644 --- a/mm/2s2h/BenGui/BenGui.cpp +++ b/mm/2s2h/BenGui/BenGui.cpp @@ -8,6 +8,7 @@ #include #include "UIWidgets.hpp" #include "HudEditor.h" +#include #ifdef __APPLE__ #include "graphic/Fast3D/gfx_metal.h" @@ -37,6 +38,7 @@ std::shared_ptr mHudEditorWindow; std::shared_ptr mActorViewerWindow; std::shared_ptr mCollisionViewerWindow; std::shared_ptr mEventLogWindow; +std::shared_ptr mAdvancedResolutionSettingsWindow; void SetupGuiElements() { auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); @@ -91,6 +93,9 @@ void SetupGuiElements() { mEventLogWindow = std::make_shared("gWindows.EventLog", "Event Log"); gui->AddGuiWindow(mEventLogWindow); + + mAdvancedResolutionSettingsWindow = std::make_shared("gWindows.gAdvancedResolutionEditor", "Advanced Resolution Settings"); + gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); } void Destroy() { @@ -105,5 +110,6 @@ void Destroy() { mSaveEditorWindow = nullptr; mHudEditorWindow = nullptr; mActorViewerWindow = nullptr; + mAdvancedResolutionSettingsWindow = nullptr; } } // namespace BenGui diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 5cea0a4439..3e811e618f 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -13,6 +13,7 @@ #include "2s2h/DeveloperTools/DeveloperTools.h" #include "2s2h/DeveloperTools/WarpPoint.h" #include "HudEditor.h" +#include extern bool ShouldClearTextureCacheAtEndOfFrame; @@ -129,6 +130,7 @@ void DrawBenMenu() { } extern std::shared_ptr mInputEditorWindow; +extern std::shared_ptr mAdvancedResolutionSettingsWindow; void DrawSettingsMenu() { if (UIWidgets::BeginMenu("Settings")) { @@ -172,6 +174,7 @@ void DrawSettingsMenu() { if (UIWidgets::BeginMenu("Graphics")) { #ifndef __APPLE__ + // TODO: Will need to disable this slider when "Advanced Resolution" mode is active. if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f)) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); @@ -289,6 +292,11 @@ void DrawSettingsMenu() { // Currently this only has "Overlays Text Font", it doesn't use our new UIWidgets so it stands out // Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); + if (mAdvancedResolutionSettingsWindow) { + UIWidgets::WindowButton("Advanced Resolution", "gWindows.gAdvancedResolutionEditor", + mAdvancedResolutionSettingsWindow);//, { .tooltip = "" }); + } + ImGui::EndMenu(); } // #region 2S2H [Todo] None of this works yet diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp new file mode 100644 index 0000000000..a8c47459ac --- /dev/null +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -0,0 +1,484 @@ +#include "ResolutionEditor.h" +#include + +#include <2s2h/BenGui/UIWidgets.hpp> +#include + +/* Console Variables are grouped under gAdvancedResolution. (e.g. CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled") + + The following cvars are used in Libultraship and can be edited here: + - Enabled - Turns Advanced Resolution Mode on. + - AspectRatioX, AspectRatioY - Aspect ratio controls. To toggle off, set either to zero. + - VerticalPixelCount, VerticalResolutionToggle - Resolution controls. + - PixelPerfectMode, IntegerScale.Factor - Pixel Perfect Mode a.k.a. integer scaling controls. + - IntegerScale.FitAutomatically - Automatic resizing for Pixel Perfect Mode. + - IntegerScale.NeverExceedBounds - Prevents manual resizing from exceeding screen bounds. + + The following cvars are also implemented in LUS for niche use cases: + - IgnoreAspectCorrection - Stretch framebuffer to fill screen. + This is something of a power-user setting for niche setups that most people won't need or care about, + but may be useful if playing the Switch/Wii U ports on a 4:3 television. + - IntegerScale.ExceedBoundsBy - Offset the max screen bounds, usually by +1. + This isn't that useful at the moment, so it's unused here. +*/ + +namespace AdvancedResolutionSettings { +enum setting { UPDATE_aspectRatioX, UPDATE_aspectRatioY, UPDATE_verticalPixelCount }; + +const char* aspectRatioPresetLabels[] = { + "Off", "Custom", "Original (4:3)", "Widescreen (16:9)", "Nintendo 3DS (5:3)", "16:10 (8:5)", "Ultrawide (21:9)" +}; +const float aspectRatioPresetsX[] = { 0.0f, 16.0f, 4.0f, 16.0f, 5.0f, 16.0f, 21.0f }; +const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; +const int default_aspectRatio = 1; // Default combo list option + +const char* pixelCountPresetLabels[] = { "Custom", "Native N64 (240p)", "2x (480p)", "3x (720p)", "4x (960p)", + "5x (1200p)", "6x (1440p)", "Full HD (1080p)", "4K (2160p)" }; +const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160 }; +const int default_pixelCount = 0; // Default combo list option + +// Resolution clamp values as hardcoded in Ship::Gui::ApplyResolutionChanges() +const uint32_t minVerticalPixelCount = SCREEN_HEIGHT; +const uint32_t maxVerticalPixelCount = 4320; // 18x native, or 8K TV resolution + +const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. + +enum messageType { MESSAGE_ERROR, MESSAGE_WARNING, MESSAGE_QUESTION, MESSAGE_INFO, MESSAGE_GRAY_75 }; +const ImVec4 messageColor[]{ + { 0.85f, 0.0f, 0.0f, 1.0f }, // MESSAGE_ERROR + { 0.85f, 0.85f, 0.0f, 1.0f }, // MESSAGE_WARNING + { 0.0f, 0.85f, 0.85f, 1.0f }, // MESSAGE_QUESTION + { 0.0f, 0.85f, 0.55f, 1.0f }, // MESSAGE_INFO + { 0.75f, 0.75f, 0.75f, 1.0f } // MESSAGE_GRAY_75 +}; +const float enhancementSpacerHeight = 19.0f; + +void AdvancedResolutionSettingsWindow::InitElement() { +} + +void AdvancedResolutionSettingsWindow::DrawElement() { + ImGui::SetNextWindowSize(ImVec2(497, 599), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Advanced Resolution Settings", &mIsVisible)) { + // Initialise update flags. + bool update[3]; + for (uint8_t i = 0; i < sizeof(update); i++) + update[i] = false; + + // Initialise integer scale bounds. + short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get + // overridden depending on viewport res + + short integerScale_maximumBounds = 1; // can change when window is resized + // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. + if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > + ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + // Scale to window height + integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + } else { + // Scale to window width + integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + } + // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. + // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. + if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { + max_integerScaleFactor = + integerScale_maximumBounds + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + } + + // Combo List defaults + static int item_aspectRatio = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", 3); + static int item_pixelCount = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", default_pixelCount); + // Stored Values for non-UIWidgets elements + static float aspectRatioX = + CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioPresetsX[item_aspectRatio]); + static float aspectRatioY = + CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioPresetsY[item_aspectRatio]); + static int verticalPixelCount = + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", pixelCountPresets[item_pixelCount]); + // Additional settings + static bool showHorizontalResField = false; + static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + // Disabling flags + const bool disabled_everything = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); + const bool disabled_pixelCount = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); + +#ifdef __APPLE__ + // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) + ImGui::TextColored(messageColor[MESSAGE_INFO], + ICON_FA_INFO_CIRCLE " These settings may behave incorrectly on Retina displays."); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); +#endif + + if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { + // The original resolution slider (for convenience) + const bool disabled_resolutionSlider = (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || + CVarGetInteger("gLowResMode", 0); // TODO: Currently unused. +#ifndef __APPLE__ + if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f)) { + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( + CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); + } + UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); +#endif + // TODO: Note to self: There's probably no reason to even expose this window on Apple. + + // The original MSAA slider (also for convenience) +#ifndef __WIIU__ + if (UIWidgets::CVarSliderInt("MSAA: %d", CVAR_MSAA_VALUE, 1, 8, 1)) { + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); + }; + UIWidgets::Tooltip( + "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); +#endif + + // N64 Mode toggle (again for convenience) + UIWidgets::CVarCheckbox("(Legacy) N64 Mode", CVAR_LOW_RES_MODE); + //, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); + } + + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Activator + UIWidgets::CVarCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled"); + //, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); + // Error/Warning display + if (!CVarGetInteger("gLowResMode", 0)) { + if (IsDroppingFrames()) { // Significant frame drop warning + ImGui::TextColored(messageColor[MESSAGE_WARNING], + ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); + // UIWidgets::Spacer(2); + } else { // No warnings + // UIWidgets::Spacer(enhancementSpacerHeight); + } + } else { // N64 Mode warning + ImGui::TextColored(messageColor[MESSAGE_QUESTION], + ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); + ImGui::SameLine(); + if (ImGui::Button("Click to disable")) { + CVarSetInteger("gLowResMode", 0); + CVarSave(); + } + } + // Resolution visualiser + ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, + gfx_current_game_window_viewport.height); + ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + if (disabled_everything) { // Hide aspect ratio controls. + // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + // Aspect Ratio + ImGui::Text("Force aspect ratio:"); + ImGui::SameLine(); + ImGui::TextColored(messageColor[MESSAGE_GRAY_75], "(Select \"Off\" to disable.)"); + // Presets + if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, + IM_ARRAYSIZE(aspectRatioPresetLabels)) && + item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. + aspectRatioX = aspectRatioPresetsX[item_aspectRatio]; + aspectRatioY = aspectRatioPresetsY[item_aspectRatio]; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); + CVarSave(); + } + // Hide aspect ratio input fields if using one of the presets. + if (item_aspectRatio == default_aspectRatio && !showHorizontalResField) { + // Declare input interaction bools outside of IF statement to prevent Y field from disappearing. + const bool input_X = ImGui::InputFloat("X", &aspectRatioX, 0.1f, 1.0f, "%.3f"); + const bool input_Y = ImGui::InputFloat("Y", &aspectRatioY, 0.1f, 1.0f, "%.3f"); + if (input_X || input_Y) { + item_aspectRatio = default_aspectRatio; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + } + } else if (showHorizontalResField) { // Show calculated aspect ratio + if (item_aspectRatio) { + // UIWidgets::Spacer(2); + const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height; + ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio); + } else { + // UIWidgets::Spacer(enhancementSpacerHeight); + } + } + + if (disabled_everything) { // Hide aspect ratio controls. + // UIWidgets::ReEnableComponent("disabledTooltipText"); + } + // UIWidgets::Spacer(0); + + // Vertical Resolution + UIWidgets::CVarCheckbox("Set fixed vertical resolution (disables Resolution slider)", CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle"); + //, true, false, disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip( + "Override the resolution scale slider and use the settings below, irrespective of window size."); + if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. + // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, + IM_ARRAYSIZE(pixelCountPresetLabels)) && + item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. + verticalPixelCount = pixelCountPresets[item_pixelCount]; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); + CVarSave(); + } + // Horizontal Resolution, if visibility is enabled for it. + if (showHorizontalResField) { + // Only show the field if Aspect Ratio is being enforced. + if ((aspectRatioX > 0.0f) && (aspectRatioY > 0.0f)) { + // So basically we're "faking" this one by setting aspectRatioX instead. + if (ImGui::InputInt("Horiz. Pixel Count", &horizontalPixelCount, 8, 320)) { + item_aspectRatio = default_aspectRatio; + if (horizontalPixelCount < SCREEN_WIDTH) { + horizontalPixelCount = SCREEN_WIDTH; + } + aspectRatioX = horizontalPixelCount; + aspectRatioY = verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + } + } else { // Display a notice instead. + ImGui::TextColored(messageColor[MESSAGE_QUESTION], + ICON_FA_QUESTION_CIRCLE " \"Force aspect ratio\" required."); + // ImGui::Text(" "); + ImGui::SameLine(); + if (ImGui::Button("Click to resolve")) { + item_aspectRatio = default_aspectRatio; // Set it to Custom + aspectRatioX = aspectRatioPresetsX[2]; // but use the 4:3 defaults + aspectRatioY = aspectRatioPresetsY[2]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + } + // Vertical Resolution part 2 + if (ImGui::InputInt("Vertical Pixel Count", &verticalPixelCount, 8, 240)) { + item_pixelCount = default_pixelCount; + update[UPDATE_verticalPixelCount] = true; + + // Account for the natural instinct to enter horizontal first. + // Ignore vertical resolutions that are below the lower clamp constant. + if (showHorizontalResField && !(verticalPixelCount < minVerticalPixelCount)) { + item_aspectRatio = default_aspectRatio; + aspectRatioX = horizontalPixelCount; + aspectRatioY = verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + } + } + if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. + // UIWidgets::ReEnableComponent("disabledTooltipText"); + } + + // UIWidgets::Spacer(0); + + // Integer scaling settings group (Pixel-perfect Mode) + static const ImGuiTreeNodeFlags IntegerScalingResolvedImGuiFlag = + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen + : ImGuiTreeNodeFlags_None; + if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { + const bool disabled_pixelPerfectMode = + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; + // Pixel-perfect Mode + UIWidgets::CVarCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode"); + //, true, true, disabled_pixelCount || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Don't scale image to fill window."); + if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); + CVarSave(); + } + + // Integer Scaling + UIWidgets::CVarSliderInt("Integer scale factor: %d", /*"##ARSIntScale",*/ CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, max_integerScaleFactor, /*"%d",*/ 1); + //, true, disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)); + UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); + // Display warning if size is being clamped or if framebuffer is larger than viewport. + if (!disabled_pixelPerfectMode && + (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + ImGui::SameLine(); + ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); + } + + UIWidgets::CVarCheckbox("Automatically scale image to fit viewport", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically"); + //, true, true, disabled_pixelPerfectMode, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { + // This is just here to update the value shown on the slider. + // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", integerScale_maximumBounds); + // CVarSave(); + } + } // End of integer scaling settings + + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Collapsible panel for additional settings + if (ImGui::CollapsingHeader("Additional Settings")) { + // UIWidgets::Spacer(0); + + // TODO: Should I remove anything to do with console ports or is this harmless to leave here? +#if defined(__SWITCH__) || defined(__WIIU__) + // Disable aspect correction, stretching the framebuffer to fill the viewport. + // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. + // The associated cvar is still functional on PC platforms if you want to use it though. + UIWidgets::CVarCheckbox("Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); + //, false, true, CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); +#else + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { + // This setting is intentionally not exposed on PC platforms, + // but may be accidentally activated for varying reasons. + // Having this button should hopefully prevent support headaches. + ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE + " If the image is stretched and you don't know why, click this."); + if (ImGui::Button("Click to reenable aspect correction.")) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); + CVarSave(); + } + // UIWidgets::Spacer(2); + } +#endif + + // A requested addition; an alternative way of displaying the resolution field. + if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", &showHorizontalResField)) { + if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off + // Refresh relevant values + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } else { // when turning this setting on + item_aspectRatio = default_aspectRatio; + if (aspectRatioX > 0.0f) { + // Refresh relevant values in the opposite order + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + } + } + update[UPDATE_aspectRatioX] = true; + } + + // Beginning of Integer Scaling additional settings. + { + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Integer Scaling - Never Exceed Bounds. + const bool disabled_neverExceedBounds = + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0) || disabled_everything; + const bool checkbox_neverExceedBounds = + UIWidgets::CVarCheckbox("Prevent integer scaling from exceeding screen bounds.\n" + "(Makes screen bounds take priority over specified factor.)", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds"); + // true, false, disabled_neverExceedBounds, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::Tooltip( + "Prevents integer scaling factor from exceeding screen bounds.\n\n" + "Enabled: Will clamp the scaling factor and display a gentle warning in the resolution editor.\n" + "Disabled: Will allow scaling to exceed screen bounds, for users who want to crop overscan.\n\n" + " " ICON_FA_INFO_CIRCLE + " Please note that exceeding screen bounds may show a scroll bar on-screen."); + + // Initialise the (currently unused) "Exceed Bounds By" cvar if it's been changed. + if (checkbox_neverExceedBounds && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + CVarSave(); + } + + // Integer Scaling - Exceed Bounds By 1x/Offset. + // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". + /* + UIWidgets::CVarCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy"); + //, false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + */ + // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. + // I've ended up commenting this one out because of the scroll bar, and for simplicity. + + // Display an info message about the scroll bar. + if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + if (disabled_neverExceedBounds) { // Dim this help text accordingly + // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + ImGui::TextColored(messageColor[MESSAGE_INFO], + " " ICON_FA_INFO_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + if (disabled_neverExceedBounds) { // Dim this help text accordingly + // UIWidgets::ReEnableComponent("disabledTooltipText"); + } + + // Another support helper button, to disable the unused "Exceed Bounds By" cvar. + // (Remove this button if uncommenting the checkbox.) + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { + if (ImGui::Button("Click to reset a console variable that may be causing this.")) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + CVarSave(); + } + } + } else { + ImGui::Text(" "); + } + // Note to self: There was a commented out separator on this line in the Shipwright version of this file. + } // End of Integer Scaling additional settings. + + } // End of additional settings + + // Clamp and update the cvars that don't use UIWidgets + if (update[UPDATE_aspectRatioX] || update[UPDATE_aspectRatioY] || update[UPDATE_verticalPixelCount]) { + if (update[UPDATE_aspectRatioX]) { + if (aspectRatioX < 0.0f) { + aspectRatioX = 0.0f; + } + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioX); + } + if (update[UPDATE_aspectRatioY]) { + if (aspectRatioY < 0.0f) { + aspectRatioY = 0.0f; + } + CVarSetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioY", aspectRatioY); + } + if (update[UPDATE_verticalPixelCount]) { + // There's a upper and lower clamp on the Libultraship side too, + // so clamping it here is entirely visual, so the vertical resolution field reflects it. + if (verticalPixelCount < minVerticalPixelCount) { + verticalPixelCount = minVerticalPixelCount; + } + if (verticalPixelCount > maxVerticalPixelCount) { + verticalPixelCount = maxVerticalPixelCount; + } + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalPixelCount", verticalPixelCount); + } + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", item_aspectRatio); + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", item_pixelCount); + CVarSave(); + } + } + ImGui::End(); +} + +void AdvancedResolutionSettingsWindow::UpdateElement() { +} + +bool AdvancedResolutionSettingsWindow::IsDroppingFrames() { + // a rather imprecise way of checking for frame drops. + // but it's mostly there to inform the player of large drops. + const short targetFPS = CVarGetInteger("gInterpolationFPS", 20); + const float threshold = targetFPS / 20.0f + 4.1f; + return ImGui::GetIO().Framerate < targetFPS - threshold; +} +} // namespace AdvancedResolutionSettings diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.h b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.h new file mode 100644 index 0000000000..0edbb1980d --- /dev/null +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.h @@ -0,0 +1,16 @@ +#pragma once +#include + +namespace AdvancedResolutionSettings { +class AdvancedResolutionSettingsWindow : public Ship::GuiWindow { + private: + bool IsDroppingFrames(); + + public: + using Ship::GuiWindow::GuiWindow; + + void InitElement() override; + void DrawElement() override; + void UpdateElement() override; +}; +} // namespace AdvancedResolutionSettings From 5e17ac91a37abfbd12000aa64553f8ba616006b4 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Wed, 29 May 2024 15:46:47 +1000 Subject: [PATCH 2/8] Do a clang-format pass. --- mm/2s2h/BenGui/BenGui.cpp | 3 +- mm/2s2h/BenGui/BenMenuBar.cpp | 2 +- .../ResolutionEditor/ResolutionEditor.cpp | 75 +++++++++++-------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/mm/2s2h/BenGui/BenGui.cpp b/mm/2s2h/BenGui/BenGui.cpp index 5542bf7faf..c879b1487c 100644 --- a/mm/2s2h/BenGui/BenGui.cpp +++ b/mm/2s2h/BenGui/BenGui.cpp @@ -94,7 +94,8 @@ void SetupGuiElements() { mEventLogWindow = std::make_shared("gWindows.EventLog", "Event Log"); gui->AddGuiWindow(mEventLogWindow); - mAdvancedResolutionSettingsWindow = std::make_shared("gWindows.gAdvancedResolutionEditor", "Advanced Resolution Settings"); + mAdvancedResolutionSettingsWindow = std::make_shared( + "gWindows.gAdvancedResolutionEditor", "Advanced Resolution Settings"); gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); } diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 3e811e618f..f45a6402d5 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -294,7 +294,7 @@ void DrawSettingsMenu() { if (mAdvancedResolutionSettingsWindow) { UIWidgets::WindowButton("Advanced Resolution", "gWindows.gAdvancedResolutionEditor", - mAdvancedResolutionSettingsWindow);//, { .tooltip = "" }); + mAdvancedResolutionSettingsWindow); //, { .tooltip = "" }); } ImGui::EndMenu(); diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index a8c47459ac..0adb21126e 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -29,7 +29,7 @@ const char* aspectRatioPresetLabels[] = { "Off", "Custom", "Original (4:3)", "Widescreen (16:9)", "Nintendo 3DS (5:3)", "16:10 (8:5)", "Ultrawide (21:9)" }; const float aspectRatioPresetsX[] = { 0.0f, 16.0f, 4.0f, 16.0f, 5.0f, 16.0f, 21.0f }; -const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; +const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; const int default_aspectRatio = 1; // Default combo list option const char* pixelCountPresetLabels[] = { "Custom", "Native N64 (240p)", "2x (480p)", "3x (720p)", "4x (960p)", @@ -81,13 +81,14 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { - max_integerScaleFactor = - integerScale_maximumBounds + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); + max_integerScaleFactor = integerScale_maximumBounds + + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); } // Combo List defaults static int item_aspectRatio = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.AspectRatio", 3); - static int item_pixelCount = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", default_pixelCount); + static int item_pixelCount = + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".UIComboItem.PixelCount", default_pixelCount); // Stored Values for non-UIWidgets elements static float aspectRatioX = CVarGetFloat(CVAR_PREFIX_ADVANCED_RESOLUTION ".AspectRatioX", aspectRatioPresetsX[item_aspectRatio]); @@ -100,7 +101,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; // Disabling flags const bool disabled_everything = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); - const bool disabled_pixelCount = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); + const bool disabled_pixelCount = + !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); #ifdef __APPLE__ // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) @@ -111,9 +113,10 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { // The original resolution slider (for convenience) - const bool disabled_resolutionSlider = (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || - CVarGetInteger("gLowResMode", 0); // TODO: Currently unused. + const bool disabled_resolutionSlider = + (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || + CVarGetInteger("gLowResMode", 0); // TODO: Currently unused. #ifndef __APPLE__ if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f)) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( @@ -133,13 +136,13 @@ void AdvancedResolutionSettingsWindow::DrawElement() { #endif // N64 Mode toggle (again for convenience) - UIWidgets::CVarCheckbox("(Legacy) N64 Mode", CVAR_LOW_RES_MODE); + UIWidgets::CVarCheckbox("(Legacy) N64 Mode", CVAR_LOW_RES_MODE); //, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); } // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); // Activator - UIWidgets::CVarCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled"); + UIWidgets::CVarCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled"); //, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); // Error/Warning display if (!CVarGetInteger("gLowResMode", 0)) { @@ -215,7 +218,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // UIWidgets::Spacer(0); // Vertical Resolution - UIWidgets::CVarCheckbox("Set fixed vertical resolution (disables Resolution slider)", CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle"); + UIWidgets::CVarCheckbox("Set fixed vertical resolution (disables Resolution slider)", + CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle"); //, true, false, disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); UIWidgets::Tooltip( "Override the resolution scale slider and use the settings below, irrespective of window size."); @@ -289,12 +293,12 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Integer scaling settings group (Pixel-perfect Mode) static const ImGuiTreeNodeFlags IntegerScalingResolvedImGuiFlag = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen - : ImGuiTreeNodeFlags_None; + : ImGuiTreeNodeFlags_None; if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { const bool disabled_pixelPerfectMode = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; // Pixel-perfect Mode - UIWidgets::CVarCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode"); + UIWidgets::CVarCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode"); //, true, true, disabled_pixelCount || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); UIWidgets::Tooltip("Don't scale image to fill window."); if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { @@ -303,18 +307,23 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } // Integer Scaling - UIWidgets::CVarSliderInt("Integer scale factor: %d", /*"##ARSIntScale",*/ CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, max_integerScaleFactor, /*"%d",*/ 1); - //, true, disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)); + UIWidgets::CVarSliderInt("Integer scale factor: %d", + /*"##ARSIntScale",*/ CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, + max_integerScaleFactor, /*"%d",*/ 1); + //, true, disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION + //".IntegerScale.FitAutomatically", 0)); UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); // Display warning if size is being clamped or if framebuffer is larger than viewport. if (!disabled_pixelPerfectMode && (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) && - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1) > + integerScale_maximumBounds)) { ImGui::SameLine(); ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); } - UIWidgets::CVarCheckbox("Automatically scale image to fit viewport", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically"); + UIWidgets::CVarCheckbox("Automatically scale image to fit viewport", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically"); //, true, true, disabled_pixelPerfectMode, "", UIWidgets::CheckboxGraphics::Cross, false); UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { @@ -339,8 +348,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::CVarCheckbox("Disable aspect correction and stretch the output image.\n" "(Might be useful for 4:3 televisions!)\n" "Not available in Pixel Perfect Mode.", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); - //, false, true, CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); + //, false, true, CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + //disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); #else if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { // This setting is intentionally not exposed on PC platforms, @@ -357,7 +367,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { #endif // A requested addition; an alternative way of displaying the resolution field. - if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", &showHorizontalResField)) { + if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", + &showHorizontalResField)) { if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off // Refresh relevant values aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; @@ -372,19 +383,20 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } update[UPDATE_aspectRatioX] = true; } - + // Beginning of Integer Scaling additional settings. { // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - + // Integer Scaling - Never Exceed Bounds. const bool disabled_neverExceedBounds = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || - CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0) || disabled_everything; - const bool checkbox_neverExceedBounds = + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0) || + disabled_everything; + const bool checkbox_neverExceedBounds = UIWidgets::CVarCheckbox("Prevent integer scaling from exceeding screen bounds.\n" "(Makes screen bounds take priority over specified factor.)", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds"); + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds"); // true, false, disabled_neverExceedBounds, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip( "Prevents integer scaling factor from exceeding screen bounds.\n\n" @@ -401,10 +413,12 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } // Integer Scaling - Exceed Bounds By 1x/Offset. - // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". + // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". /* - UIWidgets::CVarCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy"); - //, false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::CVarCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy"); + //, false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); */ // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. // I've ended up commenting this one out because of the scroll bar, and for simplicity. @@ -421,7 +435,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (disabled_neverExceedBounds) { // Dim this help text accordingly // UIWidgets::ReEnableComponent("disabledTooltipText"); } - + // Another support helper button, to disable the unused "Exceed Bounds By" cvar. // (Remove this button if uncommenting the checkbox.) if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { @@ -433,7 +447,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } else { ImGui::Text(" "); } - // Note to self: There was a commented out separator on this line in the Shipwright version of this file. + // Note to self: There was a commented out separator on this line in the Shipwright version of this + // file. } // End of Integer Scaling additional settings. } // End of additional settings From 8ad347a866d72cf8815afb542dd04621b2e7c493 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Wed, 29 May 2024 16:28:35 +1000 Subject: [PATCH 3/8] Comments and tidy up And some fixes. --- .../ResolutionEditor/ResolutionEditor.cpp | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index 0adb21126e..81e24053b4 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -51,7 +51,6 @@ const ImVec4 messageColor[]{ { 0.0f, 0.85f, 0.55f, 1.0f }, // MESSAGE_INFO { 0.75f, 0.75f, 0.75f, 1.0f } // MESSAGE_GRAY_75 }; -const float enhancementSpacerHeight = 19.0f; void AdvancedResolutionSettingsWindow::InitElement() { } @@ -108,7 +107,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) ImGui::TextColored(messageColor[MESSAGE_INFO], ICON_FA_INFO_CIRCLE " These settings may behave incorrectly on Retina displays."); - UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + ImGui::SeparatorText(" "); // was PaddedSeparator #endif if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { @@ -137,28 +136,26 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // N64 Mode toggle (again for convenience) UIWidgets::CVarCheckbox("(Legacy) N64 Mode", CVAR_LOW_RES_MODE); - //, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); } - // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + ImGui::SeparatorText(""); // was PaddedSeparator // Activator UIWidgets::CVarCheckbox("Enable advanced settings.", CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled"); - //, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); + // Error/Warning display - if (!CVarGetInteger("gLowResMode", 0)) { + if (!CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { if (IsDroppingFrames()) { // Significant frame drop warning ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); // UIWidgets::Spacer(2); } else { // No warnings - // UIWidgets::Spacer(enhancementSpacerHeight); + ImGui::Text(" "); } } else { // N64 Mode warning ImGui::TextColored(messageColor[MESSAGE_QUESTION], - ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); - ImGui::SameLine(); + ICON_FA_QUESTION_CIRCLE " Legacy \"N64 Mode\" is overriding these settings."); if (ImGui::Button("Click to disable")) { - CVarSetInteger("gLowResMode", 0); + CVarSetInteger(CVAR_LOW_RES_MODE, 0); CVarSave(); } } @@ -167,7 +164,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { gfx_current_game_window_viewport.height); ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); - // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + ImGui::SeparatorText("Advanced settings"); // was PaddedSeparator + if (disabled_everything) { // Hide aspect ratio controls. // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } @@ -208,7 +206,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height; ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio); } else { - // UIWidgets::Spacer(enhancementSpacerHeight); + ImGui::Text(" "); } } @@ -220,7 +218,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Vertical Resolution UIWidgets::CVarCheckbox("Set fixed vertical resolution (disables Resolution slider)", CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle"); - //, true, false, disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + // TODO: disable this widget on the following: disabled_everything + UIWidgets::Tooltip( "Override the resolution scale slider and use the settings below, irrespective of window size."); if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. @@ -299,7 +298,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; // Pixel-perfect Mode UIWidgets::CVarCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode"); - //, true, true, disabled_pixelCount || disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + // TODO: disable this widget on the following: disabled_pixelCount || disabled_everything UIWidgets::Tooltip("Don't scale image to fill window."); if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); @@ -307,11 +306,10 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } // Integer Scaling - UIWidgets::CVarSliderInt("Integer scale factor: %d", - /*"##ARSIntScale",*/ CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, - max_integerScaleFactor, /*"%d",*/ 1); - //, true, disabled_pixelPerfectMode || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION - //".IntegerScale.FitAutomatically", 0)); + UIWidgets::CVarSliderInt("Integer scale factor: %d", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", + 1, max_integerScaleFactor, 1); + // TODO: disable this widget on the following: disabled_pixelPerfectMode || ".IntegerScale.FitAutomatically" + UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); // Display warning if size is being clamped or if framebuffer is larger than viewport. if (!disabled_pixelPerfectMode && @@ -334,7 +332,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } } // End of integer scaling settings - // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + ImGui::SeparatorText(""); // was PaddedSeparator // Collapsible panel for additional settings if (ImGui::CollapsingHeader("Additional Settings")) { @@ -349,8 +347,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { "(Might be useful for 4:3 televisions!)\n" "Not available in Pixel Perfect Mode.", CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); - //, false, true, CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || - //disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + // TODO: disable this widget on the following: ".PixelPerfectMode" = true || disabled_everything #else if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { // This setting is intentionally not exposed on PC platforms, @@ -367,6 +364,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { #endif // A requested addition; an alternative way of displaying the resolution field. + /* if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", &showHorizontalResField)) { if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off @@ -382,11 +380,12 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } } update[UPDATE_aspectRatioX] = true; - } + }*/ + // TODO: PLEASE let me remove this option. // Beginning of Integer Scaling additional settings. { - // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + ImGui::SeparatorText("Integer Scaling tweaks"); // was PaddedSeparator // Integer Scaling - Never Exceed Bounds. const bool disabled_neverExceedBounds = @@ -397,7 +396,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::CVarCheckbox("Prevent integer scaling from exceeding screen bounds.\n" "(Makes screen bounds take priority over specified factor.)", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds"); - // true, false, disabled_neverExceedBounds, "", UIWidgets::CheckboxGraphics::Cross, true); + // TODO: Should be enabled by default. + // TODO: disable this widget on the following: disabled_neverExceedBounds + UIWidgets::Tooltip( "Prevents integer scaling factor from exceeding screen bounds.\n\n" "Enabled: Will clamp the scaling factor and display a gentle warning in the resolution editor.\n" @@ -416,9 +417,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". /* UIWidgets::CVarCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy"); - //, false, false, !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || - disabled_everything, "", UIWidgets::CheckboxGraphics::Cross, false); + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy"); + // TODO: disable this widget on the following: ".PixelPerfectMode" = false || disabled_everything */ // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. // I've ended up commenting this one out because of the scroll bar, and for simplicity. @@ -447,8 +447,6 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } else { ImGui::Text(" "); } - // Note to self: There was a commented out separator on this line in the Shipwright version of this - // file. } // End of Integer Scaling additional settings. } // End of additional settings From a5cfca0398499f7fb4c503bf1fb4479abc08df4e Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Wed, 29 May 2024 16:40:43 +1000 Subject: [PATCH 4/8] Typos, Formatting, MSAA terminology. Typo fixes. Mirror MSAA slider with other PR. Formatting. --- .../ResolutionEditor/ResolutionEditor.cpp | 102 +++++++++--------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index 81e24053b4..860bdc3616 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -4,9 +4,9 @@ #include <2s2h/BenGui/UIWidgets.hpp> #include -/* Console Variables are grouped under gAdvancedResolution. (e.g. CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled") +/* Console Variables are grouped under CVAR_PREFIX_ADVANCED_RESOLUTION. - The following cvars are used in Libultraship and can be edited here: + The following CVars are used in Libultraship and can be edited here: - Enabled - Turns Advanced Resolution Mode on. - AspectRatioX, AspectRatioY - Aspect ratio controls. To toggle off, set either to zero. - VerticalPixelCount, VerticalResolutionToggle - Resolution controls. @@ -14,7 +14,7 @@ - IntegerScale.FitAutomatically - Automatic resizing for Pixel Perfect Mode. - IntegerScale.NeverExceedBounds - Prevents manual resizing from exceeding screen bounds. - The following cvars are also implemented in LUS for niche use cases: + The following CVars are also implemented in LUS for niche use cases: - IgnoreAspectCorrection - Stretch framebuffer to fill screen. This is something of a power-user setting for niche setups that most people won't need or care about, but may be useful if playing the Switch/Wii U ports on a 4:3 television. @@ -107,7 +107,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Display HiDPI warning. (Remove this once we can definitively say it's fixed.) ImGui::TextColored(messageColor[MESSAGE_INFO], ICON_FA_INFO_CIRCLE " These settings may behave incorrectly on Retina displays."); - ImGui::SeparatorText(" "); // was PaddedSeparator + ImGui::SeparatorText(""); // was PaddedSeparator #endif if (ImGui::CollapsingHeader("Original Settings", ImGuiTreeNodeFlags_DefaultOpen)) { @@ -115,7 +115,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { const bool disabled_resolutionSlider = (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || - CVarGetInteger("gLowResMode", 0); // TODO: Currently unused. + CVarGetInteger("gLowResMode", 0); + // TODO: Disabling logic currently unimplemented in this PR. #ifndef __APPLE__ if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f)) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( @@ -123,15 +124,18 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); #endif - // TODO: Note to self: There's probably no reason to even expose this window on Apple. // The original MSAA slider (also for convenience) #ifndef __WIIU__ - if (UIWidgets::CVarSliderInt("MSAA: %d", CVAR_MSAA_VALUE, 1, 8, 1)) { + if (UIWidgets::CVarSliderInt((CVarGetInteger(CVAR_MSAA_VALUE, 1) == 1) ? "Anti-aliasing (MSAA): Off" + : "Anti-aliasing (MSAA): %d", + CVAR_MSAA_VALUE, 1, 8, 1)) { Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); }; UIWidgets::Tooltip( - "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); + "Activates MSAA (multi-sample anti-aliasing) from 2x up to 8x, to smooth the edges of rendered " + "geometry.\n" + "Higher sample count will result in smoother edges on models, but may reduce performance."); #endif // N64 Mode toggle (again for convenience) @@ -336,52 +340,52 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Collapsible panel for additional settings if (ImGui::CollapsingHeader("Additional Settings")) { - // UIWidgets::Spacer(0); - - // TODO: Should I remove anything to do with console ports or is this harmless to leave here? + // Beginning of miscellanous additional settings. + { + // TODO: Should I remove anything to do with console ports or is this harmless to leave here? #if defined(__SWITCH__) || defined(__WIIU__) - // Disable aspect correction, stretching the framebuffer to fill the viewport. - // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. - // The associated cvar is still functional on PC platforms if you want to use it though. - UIWidgets::CVarCheckbox("Disable aspect correction and stretch the output image.\n" - "(Might be useful for 4:3 televisions!)\n" - "Not available in Pixel Perfect Mode.", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); - // TODO: disable this widget on the following: ".PixelPerfectMode" = true || disabled_everything + // Disable aspect correction, stretching the framebuffer to fill the viewport. + // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. + // The associated CVar is still functional on PC platforms if you want to use it though. + UIWidgets::CVarCheckbox("Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); + // TODO: disable this widget on the following: ".PixelPerfectMode" = true || disabled_everything #else - if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { - // This setting is intentionally not exposed on PC platforms, - // but may be accidentally activated for varying reasons. - // Having this button should hopefully prevent support headaches. - ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE - " If the image is stretched and you don't know why, click this."); - if (ImGui::Button("Click to reenable aspect correction.")) { - CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); - CVarSave(); + if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { + // This setting is intentionally not exposed on PC platforms, + // but may be accidentally activated for varying reasons. + // Having this button should hopefully prevent support headaches. + ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE + " If the image is stretched and you don't know why, click this."); + if (ImGui::Button("Click to reenable aspect correction.")) { + CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); + CVarSave(); + } + // UIWidgets::Spacer(2); } - // UIWidgets::Spacer(2); - } #endif - // A requested addition; an alternative way of displaying the resolution field. - /* - if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", - &showHorizontalResField)) { - if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off - // Refresh relevant values - aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; - horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; - } else { // when turning this setting on - item_aspectRatio = default_aspectRatio; - if (aspectRatioX > 0.0f) { - // Refresh relevant values in the opposite order - horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + // A requested addition; an alternative way of displaying the resolution field. + if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", + &showHorizontalResField)) { + if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off + // Refresh relevant values aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } else { // when turning this setting on + item_aspectRatio = default_aspectRatio; + if (aspectRatioX > 0.0f) { + // Refresh relevant values in the opposite order + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + } } + update[UPDATE_aspectRatioX] = true; } - update[UPDATE_aspectRatioX] = true; - }*/ - // TODO: PLEASE let me remove this option. + // Note to self: I would love to be able to remove this option. It adds so much complexity. + } // Beginning of Integer Scaling additional settings. { @@ -406,7 +410,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { " " ICON_FA_INFO_CIRCLE " Please note that exceeding screen bounds may show a scroll bar on-screen."); - // Initialise the (currently unused) "Exceed Bounds By" cvar if it's been changed. + // Initialise the (currently unused) "Exceed Bounds By" CVar if it's been changed. if (checkbox_neverExceedBounds && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); @@ -436,7 +440,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // UIWidgets::ReEnableComponent("disabledTooltipText"); } - // Another support helper button, to disable the unused "Exceed Bounds By" cvar. + // Another support helper button, to disable the unused "Exceed Bounds By" CVar. // (Remove this button if uncommenting the checkbox.) if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { if (ImGui::Button("Click to reset a console variable that may be causing this.")) { @@ -451,7 +455,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } // End of additional settings - // Clamp and update the cvars that don't use UIWidgets + // Clamp and update the CVars that don't use UIWidgets if (update[UPDATE_aspectRatioX] || update[UPDATE_aspectRatioY] || update[UPDATE_verticalPixelCount]) { if (update[UPDATE_aspectRatioX]) { if (aspectRatioX < 0.0f) { From 9626d4e22bf0b1d65c70a3914f58e4fc9391ed94 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Fri, 31 May 2024 14:54:04 +1000 Subject: [PATCH 5/8] Reimplement disabled flags for most things. TODOs squashed. Other TODOs added for the remaining region-based disable logic. --- .../ResolutionEditor/ResolutionEditor.cpp | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index 860bdc3616..8ea4dfcfdb 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -116,9 +116,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || CVarGetInteger("gLowResMode", 0); - // TODO: Disabling logic currently unimplemented in this PR. #ifndef __APPLE__ - if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f)) { + if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f, + { .disabled = disabled_resolutionSlider })) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); } @@ -172,7 +172,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (disabled_everything) { // Hide aspect ratio controls. // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } + } // TODO // Aspect Ratio ImGui::Text("Force aspect ratio:"); @@ -216,19 +216,20 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (disabled_everything) { // Hide aspect ratio controls. // UIWidgets::ReEnableComponent("disabledTooltipText"); - } + } // TODO + // UIWidgets::Spacer(0); // Vertical Resolution UIWidgets::CVarCheckbox("Set fixed vertical resolution (disables Resolution slider)", - CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle"); - // TODO: disable this widget on the following: disabled_everything + CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", + { .disabled = disabled_everything }); UIWidgets::Tooltip( "Override the resolution scale slider and use the settings below, irrespective of window size."); if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } + } // TODO if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, IM_ARRAYSIZE(pixelCountPresetLabels)) && item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. @@ -289,7 +290,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. // UIWidgets::ReEnableComponent("disabledTooltipText"); - } + } // TODO // UIWidgets::Spacer(0); @@ -300,9 +301,10 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { const bool disabled_pixelPerfectMode = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; + // Pixel-perfect Mode - UIWidgets::CVarCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode"); - // TODO: disable this widget on the following: disabled_pixelCount || disabled_everything + UIWidgets::CVarCheckbox("Pixel-perfect Mode", CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", + { .disabled = disabled_pixelCount || disabled_everything }); UIWidgets::Tooltip("Don't scale image to fill window."); if (disabled_pixelCount && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0)) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0); @@ -310,9 +312,11 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } // Integer Scaling - UIWidgets::CVarSliderInt("Integer scale factor: %d", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", - 1, max_integerScaleFactor, 1); - // TODO: disable this widget on the following: disabled_pixelPerfectMode || ".IntegerScale.FitAutomatically" + UIWidgets::CVarSliderInt( + "Integer scale factor: %d", CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.Factor", 1, + max_integerScaleFactor, 1, + { .disabled = disabled_pixelPerfectMode || + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".FitAutomatically", 0) }); UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); // Display warning if size is being clamped or if framebuffer is larger than viewport. @@ -325,8 +329,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } UIWidgets::CVarCheckbox("Automatically scale image to fit viewport", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically"); - //, true, true, disabled_pixelPerfectMode, "", UIWidgets::CheckboxGraphics::Cross, false); + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", + { .disabled = disabled_pixelPerfectMode }); UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.FitAutomatically", 0)) { // This is just here to update the value shown on the slider. @@ -342,16 +346,19 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Additional Settings")) { // Beginning of miscellanous additional settings. { - // TODO: Should I remove anything to do with console ports or is this harmless to leave here? + // Note for code review: + // - Should I remove anything to do with console ports or is this harmless to leave here? #if defined(__SWITCH__) || defined(__WIIU__) // Disable aspect correction, stretching the framebuffer to fill the viewport. // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. // The associated CVar is still functional on PC platforms if you want to use it though. - UIWidgets::CVarCheckbox("Disable aspect correction and stretch the output image.\n" - "(Might be useful for 4:3 televisions!)\n" - "Not available in Pixel Perfect Mode.", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection"); - // TODO: disable this widget on the following: ".PixelPerfectMode" = true || disabled_everything + UIWidgets::CVarCheckbox( + "Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", + { .disabled = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + disabled_everything }); #else if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0)) { // This setting is intentionally not exposed on PC platforms, @@ -384,7 +391,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } update[UPDATE_aspectRatioX] = true; } - // Note to self: I would love to be able to remove this option. It adds so much complexity. + // Note to self: It would be nice to remove this option. It adds so much complexity. } // Beginning of Integer Scaling additional settings. @@ -399,18 +406,15 @@ void AdvancedResolutionSettingsWindow::DrawElement() { const bool checkbox_neverExceedBounds = UIWidgets::CVarCheckbox("Prevent integer scaling from exceeding screen bounds.\n" "(Makes screen bounds take priority over specified factor.)", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds"); - // TODO: Should be enabled by default. - // TODO: disable this widget on the following: disabled_neverExceedBounds - + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", + { .disabled = disabled_neverExceedBounds, .defaultValue = true }); UIWidgets::Tooltip( "Prevents integer scaling factor from exceeding screen bounds.\n\n" "Enabled: Will clamp the scaling factor and display a gentle warning in the resolution editor.\n" "Disabled: Will allow scaling to exceed screen bounds, for users who want to crop overscan.\n\n" " " ICON_FA_INFO_CIRCLE " Please note that exceeding screen bounds may show a scroll bar on-screen."); - - // Initialise the (currently unused) "Exceed Bounds By" CVar if it's been changed. + // Initialise the (currently unused) "Exceed Bounds By" CVar to zero if the above has been changed. if (checkbox_neverExceedBounds && CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); @@ -420,28 +424,26 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Integer Scaling - Exceed Bounds By 1x/Offset. // A popular feature in some retro frontends/upscalers, sometimes called "crop overscan" or "1080p 5x". /* - UIWidgets::CVarCheckbox("Allow integer scale factor to go +1 above maximum screen bounds.", - CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy"); - // TODO: disable this widget on the following: ".PixelPerfectMode" = false || disabled_everything + UIWidgets::CVarCheckbox( + "Allow integer scale factor to go +1 above maximum screen bounds.", + CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", + { .disabled = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || + disabled_everything }); */ // It does actually function as expected, but exceeding the bottom of the screen shows a scroll bar. - // I've ended up commenting this one out because of the scroll bar, and for simplicity. + // I've ended up commenting this one out because it shows a scroll bar, and for simplicity's sake. + + // Note to self: Exceed Bounds behavior is actually slightly bugged right now, perhaps over in LUS. - // Display an info message about the scroll bar. + // Display an info message about the scroll bar, if either of the above options are in use. if (!CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.NeverExceedBounds", 1) || CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { - if (disabled_neverExceedBounds) { // Dim this help text accordingly - // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } ImGui::TextColored(messageColor[MESSAGE_INFO], " " ICON_FA_INFO_CIRCLE " A scroll bar may become visible if screen bounds are exceeded."); - if (disabled_neverExceedBounds) { // Dim this help text accordingly - // UIWidgets::ReEnableComponent("disabledTooltipText"); - } // Another support helper button, to disable the unused "Exceed Bounds By" CVar. - // (Remove this button if uncommenting the checkbox.) + // (Remove this button if uncommenting the "Exceed Bounds" checkbox.) if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { if (ImGui::Button("Click to reset a console variable that may be causing this.")) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); From 6ecc8ef2908d3c206a65d17cc6fc0ca64557dba9 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:15:08 +1000 Subject: [PATCH 6/8] Finish re-adding "disable" behavior. More UIWidgets. --- .../ResolutionEditor/ResolutionEditor.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index 8ea4dfcfdb..321aa96ea6 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -117,6 +117,8 @@ void AdvancedResolutionSettingsWindow::DrawElement() { CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || CVarGetInteger("gLowResMode", 0); #ifndef __APPLE__ + // TODO and note for code review: + // - This is copied from BenMenuBar. I'm aware this needs to be replaced with a non-float slider. if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f, { .disabled = disabled_resolutionSlider })) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( @@ -151,14 +153,14 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (IsDroppingFrames()) { // Significant frame drop warning ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); - // UIWidgets::Spacer(2); } else { // No warnings ImGui::Text(" "); } } else { // N64 Mode warning ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE " Legacy \"N64 Mode\" is overriding these settings."); - if (ImGui::Button("Click to disable")) { + if (UIWidgets::Button("Click to resolve")) { + // Not sure how necessary this button is if the checkbox is available. CVarSetInteger(CVAR_LOW_RES_MODE, 0); CVarSave(); } @@ -170,15 +172,15 @@ void AdvancedResolutionSettingsWindow::DrawElement() { ImGui::SeparatorText("Advanced settings"); // was PaddedSeparator - if (disabled_everything) { // Hide aspect ratio controls. - // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } // TODO + ImGui::BeginDisabled(disabled_everything); // Hide aspect ratio controls. // Aspect Ratio ImGui::Text("Force aspect ratio:"); ImGui::SameLine(); ImGui::TextColored(messageColor[MESSAGE_GRAY_75], "(Select \"Off\" to disable.)"); + // Presets + UIWidgets::PushStyleCombobox(); // Also repurposing this style for the Input fields. if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, IM_ARRAYSIZE(aspectRatioPresetLabels)) && item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. @@ -213,10 +215,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { ImGui::Text(" "); } } + UIWidgets::PopStyleCombobox(); - if (disabled_everything) { // Hide aspect ratio controls. - // UIWidgets::ReEnableComponent("disabledTooltipText"); - } // TODO + ImGui::EndDisabled(); // End of hide aspect ratio controls. (disabled_everything) // UIWidgets::Spacer(0); @@ -224,12 +225,12 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::CVarCheckbox("Set fixed vertical resolution (disables Resolution slider)", CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", { .disabled = disabled_everything }); - UIWidgets::Tooltip( "Override the resolution scale slider and use the settings below, irrespective of window size."); - if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. - // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); - } // TODO + + ImGui::BeginDisabled(disabled_pixelCount || disabled_everything); // Hide pixel count controls. + + UIWidgets::PushStyleCombobox(); // Also repurposing this style for the Input fields. if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, IM_ARRAYSIZE(pixelCountPresetLabels)) && item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. @@ -288,9 +289,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { update[UPDATE_aspectRatioY] = true; } } - if (disabled_pixelCount || disabled_everything) { // Hide pixel count controls. - // UIWidgets::ReEnableComponent("disabledTooltipText"); - } // TODO + UIWidgets::PopStyleCombobox(); + + ImGui::EndDisabled(); // End of hide pixel count controls. (disabled_pixelCount || disabled_everything) // UIWidgets::Spacer(0); @@ -298,6 +299,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { static const ImGuiTreeNodeFlags IntegerScalingResolvedImGuiFlag = CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None; + // TODO: Need to add a matching styled Collapsing Header to the UIWidgets at some point. if (ImGui::CollapsingHeader("Integer Scaling Settings", IntegerScalingResolvedImGuiFlag)) { const bool disabled_pixelPerfectMode = !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".PixelPerfectMode", 0) || disabled_everything; @@ -366,17 +368,16 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Having this button should hopefully prevent support headaches. ImGui::TextColored(messageColor[MESSAGE_QUESTION], ICON_FA_QUESTION_CIRCLE " If the image is stretched and you don't know why, click this."); - if (ImGui::Button("Click to reenable aspect correction.")) { + if (UIWidgets::Button("Click to reenable aspect correction.")) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IgnoreAspectCorrection", 0); CVarSave(); } - // UIWidgets::Spacer(2); } #endif // A requested addition; an alternative way of displaying the resolution field. - if (ImGui::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", - &showHorizontalResField)) { + if (UIWidgets::Checkbox("Show a horizontal resolution field, instead of aspect ratio.", + &showHorizontalResField)) { if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off // Refresh relevant values aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; @@ -391,7 +392,6 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } update[UPDATE_aspectRatioX] = true; } - // Note to self: It would be nice to remove this option. It adds so much complexity. } // Beginning of Integer Scaling additional settings. @@ -445,13 +445,13 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Another support helper button, to disable the unused "Exceed Bounds By" CVar. // (Remove this button if uncommenting the "Exceed Bounds" checkbox.) if (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0)) { - if (ImGui::Button("Click to reset a console variable that may be causing this.")) { + if (UIWidgets::Button("Click to reset a console variable that may be causing this.")) { CVarSetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".IntegerScale.ExceedBoundsBy", 0); CVarSave(); } } } else { - ImGui::Text(" "); + ImGui::Text(" "); // No message. } } // End of Integer Scaling additional settings. From dd06165b238613989a6bfe201ebabff50be98304 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Tue, 18 Jun 2024 04:07:41 +1000 Subject: [PATCH 7/8] Suggestions 1 --- .../ResolutionEditor/ResolutionEditor.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index 321aa96ea6..bbb2b3d3b4 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -41,9 +41,9 @@ const int default_pixelCount = 0; // Default combo list option const uint32_t minVerticalPixelCount = SCREEN_HEIGHT; const uint32_t maxVerticalPixelCount = 4320; // 18x native, or 8K TV resolution -const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. +const unsigned int default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. -enum messageType { MESSAGE_ERROR, MESSAGE_WARNING, MESSAGE_QUESTION, MESSAGE_INFO, MESSAGE_GRAY_75 }; +enum MessageType { MESSAGE_ERROR, MESSAGE_WARNING, MESSAGE_QUESTION, MESSAGE_INFO, MESSAGE_GRAY_75 }; const ImVec4 messageColor[]{ { 0.85f, 0.0f, 0.0f, 1.0f }, // MESSAGE_ERROR { 0.85f, 0.85f, 0.0f, 1.0f }, // MESSAGE_WARNING @@ -64,10 +64,10 @@ void AdvancedResolutionSettingsWindow::DrawElement() { update[i] = false; // Initialise integer scale bounds. - short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get + int max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get // overridden depending on viewport res - short integerScale_maximumBounds = 1; // can change when window is resized + int integerScale_maximumBounds = 1; // can change when window is resized // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { @@ -348,8 +348,6 @@ void AdvancedResolutionSettingsWindow::DrawElement() { if (ImGui::CollapsingHeader("Additional Settings")) { // Beginning of miscellanous additional settings. { - // Note for code review: - // - Should I remove anything to do with console ports or is this harmless to leave here? #if defined(__SWITCH__) || defined(__WIIU__) // Disable aspect correction, stretching the framebuffer to fill the viewport. // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. @@ -496,7 +494,7 @@ void AdvancedResolutionSettingsWindow::UpdateElement() { bool AdvancedResolutionSettingsWindow::IsDroppingFrames() { // a rather imprecise way of checking for frame drops. // but it's mostly there to inform the player of large drops. - const short targetFPS = CVarGetInteger("gInterpolationFPS", 20); + const int targetFPS = CVarGetInteger("gInterpolationFPS", 20); const float threshold = targetFPS / 20.0f + 4.1f; return ImGui::GetIO().Framerate < targetFPS - threshold; } From 1a098195c72e3f7099fead95928a5635f4ed9ee1 Mon Sep 17 00:00:00 2001 From: "Tina H. (sheepytina)" <99330992+sheepytina@users.noreply.github.com> Date: Tue, 18 Jun 2024 04:15:30 +1000 Subject: [PATCH 8/8] Suggestions 2 --- mm/2s2h/BenGui/BenMenuBar.cpp | 8 ++++++-- .../Enhancements/ResolutionEditor/ResolutionEditor.cpp | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index f45a6402d5..0dea0b940f 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -174,8 +174,12 @@ void DrawSettingsMenu() { if (UIWidgets::BeginMenu("Graphics")) { #ifndef __APPLE__ - // TODO: Will need to disable this slider when "Advanced Resolution" mode is active. - if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f)) { + const bool disabled_resolutionSlider = + (CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0) && + CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || + CVarGetInteger("gLowResMode", 0); + if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f, + { .disabled = disabled_resolutionSlider })) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); }; diff --git a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp index bbb2b3d3b4..cda6278d64 100644 --- a/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp +++ b/mm/2s2h/Enhancements/ResolutionEditor/ResolutionEditor.cpp @@ -65,7 +65,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // Initialise integer scale bounds. int max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get - // overridden depending on viewport res + // overridden depending on viewport res int integerScale_maximumBounds = 1; // can change when window is resized // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. @@ -117,8 +117,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0)) || CVarGetInteger("gLowResMode", 0); #ifndef __APPLE__ - // TODO and note for code review: - // - This is copied from BenMenuBar. I'm aware this needs to be replaced with a non-float slider. + // This is copied from BenMenuBar. I'm aware this needs to be replaced with a non-float slider. if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, 1.0f, { .disabled = disabled_resolutionSlider })) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(