Scale menu at higher resolutions (#502)

* Scale menu at higher resolutions

* Options for menu extent/scaling

---------

Co-authored-by: coco875 <59367621+coco875@users.noreply.github.com>
This commit is contained in:
Daniel Worley
2025-08-07 13:53:24 -04:00
committed by GitHub
parent 575d860e5d
commit 334fdeafd2
5 changed files with 43 additions and 1 deletions
+15 -1
View File
@@ -551,7 +551,21 @@ void Menu::DrawElement() {
headerWidth += style.ItemSpacing.x;
}
}
ImVec2 menuSize = { std::fminf(1280, windowWidth), std::fminf(800, windowHeight) };
UIWidgets::MenuExtent menuExtent = static_cast<UIWidgets::MenuExtent>(
CVarGetInteger("gSettings.Menu.Extent", UIWidgets::MenuExtent::Condensed)
);
if (menuExtent == UIWidgets::MenuExtent::Stretched) {
menuSize = { 0.9f * windowWidth, 0.9f * windowHeight };
uiScale = CVarGetFloat("gSettings.Menu.Scale", 1.0f);
} else {
uiScale = 1.0f; // Scaling doesn't play nice with condensed menu
}
ImGuiIO& io = ImGui::GetIO();
io.FontGlobalScale = uiScale;
pos += window->WorkRect.GetSize() / 2 - menuSize / 2;
ImGui::SetNextWindowPos(pos);
ImGui::BeginChild("Menu Block", menuSize,
@@ -671,7 +685,7 @@ void Menu::DrawElement() {
float sectionHeight = menuSize.y - headerHeight - 4 - style.ItemSpacing.y * 2;
float columnHeight = sectionHeight - style.ItemSpacing.y * 4;
ImGui::SetNextWindowPos(pos + style.ItemSpacing * 2);
float sidebarWidth = 200 - style.ItemSpacing.x;
float sidebarWidth = 200 * uiScale - style.ItemSpacing.x;
const char* sidebarCvar = menuEntries.at(headerIndex).sidebarCvar;
+1
View File
@@ -93,6 +93,7 @@ class Menu : public GuiWindow {
bool popped;
ImVec2 poppedSize;
ImVec2 poppedPos;
float uiScale = 1.0f;
float windowHeight;
float windowWidth;
};
+17
View File
@@ -115,6 +115,23 @@ void PortMenu::AddSettings() {
.Tooltip("Changes the Theme of the Menu Widgets.")
.ComboMap(menuThemeOptions)
.DefaultIndex(Colors::LightBlue));
AddWidget(path, "Menu Extent", WIDGET_CVAR_COMBOBOX)
.CVar("gSettings.Menu.Extent")
.Options(ComboboxOptions()
.Tooltip("Changes the extent of the onscreen menu")
.ComboMap(menuExtentOptions)
.DefaultIndex(MenuExtent::Condensed));
AddWidget(path, "Menu Scale: %.0fx", WIDGET_CVAR_SLIDER_FLOAT)
.CVar("gSettings.Menu.Scale")
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger("gSettings.Menu.Extent", 0); })
.Options(FloatSliderOptions()
.Tooltip("Adjust the scale for the menu.")
.Min(1.0f)
.Max(2.0f)
.DefaultValue(1.0f)
.Format("%.1f")
.Step(0.1f));
AddWidget(path, "Controller pak screen", WIDGET_CVAR_CHECKBOX)
.CVar("gControllerPakScreen")
.Options(CheckboxOptions().Tooltip(
+5
View File
@@ -9,6 +9,11 @@
namespace GameUI {
static const std::unordered_map<int32_t, const char*> menuExtentOptions = {
{ UIWidgets::MenuExtent::Condensed, "Condensed" },
{ UIWidgets::MenuExtent::Stretched, "Stretched" },
};
static const std::unordered_map<int32_t, const char*> menuThemeOptions = {
{ UIWidgets::Colors::Red, "Red" },
{ UIWidgets::Colors::DarkRed, "Dark Red" },
+5
View File
@@ -104,6 +104,11 @@ namespace UIWidgets {
Right,
};
enum MenuExtent {
Condensed,
Stretched
};
struct WidgetOptions{
const char* tooltip = "";
bool disabled = false;