diff --git a/src/XIVLauncher.Core/Components/Background.cs b/src/XIVLauncher.Core/Components/Background.cs index a6cac62d..c3dd8967 100644 --- a/src/XIVLauncher.Core/Components/Background.cs +++ b/src/XIVLauncher.Core/Components/Background.cs @@ -14,9 +14,9 @@ public Background() public override void Draw() { - ImGui.SetCursorPos(new Vector2(0, ImGuiHelpers.ViewportSize.Y - bgTexture.Height)); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(0, ImGuiHelpers.ViewportSize.Y - bgTexture.Height))); - ImGui.Image(bgTexture.ImGuiHandle, new Vector2(bgTexture.Width, bgTexture.Height)); + ImGui.Image(bgTexture.ImGuiHandle, ImGuiHelpers.GetScaled(new Vector2(bgTexture.Width, bgTexture.Height))); /* ImGui.SetCursorPos(new Vector2()); diff --git a/src/XIVLauncher.Core/Components/Common/Button.cs b/src/XIVLauncher.Core/Components/Common/Button.cs index ba3748e8..d7607b55 100644 --- a/src/XIVLauncher.Core/Components/Common/Button.cs +++ b/src/XIVLauncher.Core/Components/Common/Button.cs @@ -27,7 +27,7 @@ public Button(string label, bool isEnabled = true, Vector4? color = null, Vector public override void Draw() { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(16f, 16f)); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, ImGuiHelpers.GetScaled(new Vector2(16f, 16f))); ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0); ImGui.PushStyleColor(ImGuiCol.Button, Color); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, HoverColor); diff --git a/src/XIVLauncher.Core/Components/Common/Checkbox.cs b/src/XIVLauncher.Core/Components/Common/Checkbox.cs index def2b2f8..e70ab306 100644 --- a/src/XIVLauncher.Core/Components/Common/Checkbox.cs +++ b/src/XIVLauncher.Core/Components/Common/Checkbox.cs @@ -28,7 +28,7 @@ public Checkbox(string label, bool value = false, bool isEnabled = true) public override void Draw() { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(0.5f, 0.5f)); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, ImGuiHelpers.GetScaled(new Vector2(0.5f, 0.5f))); ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0); ImGui.PushStyleColor(ImGuiCol.FrameBg, ImGuiColors.BlueShade1); ImGui.PushStyleColor(ImGuiCol.FrameBgActive, ImGuiColors.BlueShade2); diff --git a/src/XIVLauncher.Core/Components/Common/Input.cs b/src/XIVLauncher.Core/Components/Common/Input.cs index bd5a79dc..88edf6d1 100644 --- a/src/XIVLauncher.Core/Components/Common/Input.cs +++ b/src/XIVLauncher.Core/Components/Common/Input.cs @@ -70,7 +70,7 @@ private void SteamOnOnGamepadTextInputDismissed(bool success) public override void Draw() { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(12f, 10f)); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, ImGuiHelpers.GetScaled(new Vector2(12f, 10f))); ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0); ImGui.PushStyleColor(ImGuiCol.FrameBg, ImGuiColors.BlueShade1); ImGui.PushStyleColor(ImGuiCol.FrameBgActive, ImGuiColors.BlueShade2); diff --git a/src/XIVLauncher.Core/Components/FtsPage.cs b/src/XIVLauncher.Core/Components/FtsPage.cs index 3dbf3b7f..4727500f 100644 --- a/src/XIVLauncher.Core/Components/FtsPage.cs +++ b/src/XIVLauncher.Core/Components/FtsPage.cs @@ -63,9 +63,9 @@ public override void Draw() ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Vector4.Zero); ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero); - ImGui.SetCursorPos(new Vector2(316, 481)); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 481))); - if (ImGui.Button("###openGuideButton", new Vector2(649, 101))) + if (ImGui.Button("###openGuideButton", ImGuiHelpers.GetScaled(new Vector2(649, 101)))) { if (!this.isSteamDeckAppIdError) { @@ -77,9 +77,9 @@ public override void Draw() } } - ImGui.SetCursorPos(new Vector2(316, 598)); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 598))); - if (ImGui.Button("###finishFtsButton", new Vector2(649, 101)) && !this.isSteamDeckAppIdError) + if (ImGui.Button("###finishFtsButton", ImGuiHelpers.GetScaled(new Vector2(649, 101))) && !this.isSteamDeckAppIdError) { this.FinishFts(true); } diff --git a/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs b/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs index 14181e6b..4b2ce189 100644 --- a/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs +++ b/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs @@ -6,7 +6,7 @@ namespace XIVLauncher.Core.Components.LoadingPage; public class LoadingPage : Page { - private const int SPINNER_RADIUS = 15; + private int SPINNER_RADIUS = (int)ImGuiHelpers.GetScaled(15); public bool IsIndeterminate { get; set; } public bool CanCancel { get; set; } = true; @@ -30,7 +30,7 @@ public class LoadingPage : Page public LoadingPage(LauncherApp app) : base(app) { - this.spinner = new Spinner(SPINNER_RADIUS, 5, ImGui.GetColorU32(ImGuiCol.ButtonActive)); + this.spinner = new Spinner(SPINNER_RADIUS, (int)ImGuiHelpers.GetScaled(5), ImGui.GetColorU32(ImGuiCol.ButtonActive)); this.cancelButton.Click += () => this.Cancelled?.Invoke(); this.disableAutoLoginButton.Click += () => @@ -49,20 +49,20 @@ public override void Draw() { var vp = ImGuiHelpers.ViewportSize; - ImGui.SetCursorPosY(vp.Y / 2 - 100); + ImGui.SetCursorPosY(vp.Y / 2 - ImGuiHelpers.GetScaled(100)); // center text in window ImGuiHelpers.CenteredText(Line1); if (!string.IsNullOrEmpty(Line2)) { - ImGui.Dummy(new Vector2(2)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(2))); ImGuiHelpers.CenteredText(Line2); } if (!string.IsNullOrEmpty(Line3)) { - ImGui.Dummy(new Vector2(2)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(2))); ImGuiHelpers.CenteredText(Line3); } @@ -70,7 +70,7 @@ public override void Draw() if (CanCancel || isDrawDisableAutoLogin) { - ImGui.Dummy(new Vector2(20)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(20)));; } if (CanCancel) @@ -91,7 +91,7 @@ public override void Draw() ImGuiHelpers.CenteredText("Auto login disabled on next start!"); } - ImGui.Dummy(new Vector2(20)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(20))); if (IsIndeterminate) { @@ -102,7 +102,7 @@ public override void Draw() { var width = vp.X / 3; ImGuiHelpers.CenterCursorFor((int)width); - ImGui.ProgressBar(Progress, new Vector2(width, 20), ProgressText); + ImGui.ProgressBar(Progress, new Vector2(width, ImGuiHelpers.GetScaled(20)), ProgressText); } Program.Invalidate(10); diff --git a/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs b/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs index 29cfa9d2..e54f52d3 100644 --- a/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs +++ b/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs @@ -26,7 +26,7 @@ public void Open() public override void Draw() { - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(5)); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaled(new Vector2(5))); if (ImGui.BeginPopupContextItem(ACCOUNT_SWITCHER_POPUP_ID)) { @@ -47,7 +47,7 @@ public override void Draw() var textLength = ImGui.CalcTextSize(name).X; - if (ImGui.Button(name + $"###{account.Id}", new Vector2(textLength + 15, 40))) + if (ImGui.Button(name + $"###{account.Id}", new Vector2(textLength + ImGuiHelpers.GetScaled(15), ImGuiHelpers.GetScaled(40)))) { this.AccountChanged?.Invoke(this, account); } diff --git a/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs b/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs index e4792cfa..d62a45b9 100644 --- a/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs +++ b/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs @@ -11,7 +11,7 @@ public class ActionButtons : Component public override void Draw() { - var btnSize = new Vector2(80) * ImGuiHelpers.GlobalScale; + var btnSize = ImGuiHelpers.GetScaled(new Vector2(80)); ImGui.PushFont(FontManager.IconFont); diff --git a/src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs b/src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs index 7de7ff81..69cb65cf 100644 --- a/src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs +++ b/src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs @@ -59,13 +59,13 @@ void TriggerLogin() this.OnLogin?.Invoke(LoginAction.Game); } - this.loginInput = new Input("Username", "Enter your Username", new Vector2(12f, 0f), 128) + this.loginInput = new Input("Username", "Enter your Username", ImGuiHelpers.GetScaled(new Vector2(12f, 0f)), 128) { TakeKeyboardFocus = true }; this.loginInput.Enter += TriggerLogin; - this.passwordInput = new Input("Password", "Enter your password", new Vector2(12f, 0f), 128, flags: ImGuiInputTextFlags.Password | ImGuiInputTextFlags.NoUndoRedo); + this.passwordInput = new Input("Password", "Enter your password", ImGuiHelpers.GetScaled(new Vector2(12f, 0f)), 128, flags: ImGuiInputTextFlags.Password | ImGuiInputTextFlags.NoUndoRedo); this.passwordInput.Enter += TriggerLogin; this.oneTimePasswordCheckbox = new Checkbox("Use one-time password"); @@ -81,14 +81,14 @@ void TriggerLogin() private Vector2 GetSize() { var vp = ImGuiHelpers.ViewportSize; - return new Vector2(-1, vp.Y - 128f); + return new Vector2(ImGuiHelpers.GetScaled(-1), vp.Y - ImGuiHelpers.GetScaled(128f)); } public override void Draw() { if (ImGui.BeginChild("###loginFrame", this.GetSize())) { - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(32f, 32f)); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaled(new Vector2(32f, 32f))); this.loginInput.Draw(); this.passwordInput.Draw(); @@ -96,7 +96,7 @@ public override void Draw() this.useSteamServiceCheckbox.Draw(); this.autoLoginCheckbox.Draw(); - ImGui.Dummy(new Vector2(10)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10))); this.loginButton.Draw(); @@ -157,12 +157,12 @@ public override void Draw() ImGui.TextWrapped("Take care! No secrets provider is installed or configured. Passwords can't be saved."); ImGui.PopStyleColor(); - ImGui.Dummy(new Vector2(15)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(15))); } ImGui.PushFont(FontManager.IconFont); - var extraButtonSize = new Vector2(45) * ImGuiHelpers.GlobalScale; + var extraButtonSize = ImGuiHelpers.GetScaled(new Vector2(45)); if (ImGui.Button(FontAwesomeIcon.CaretDown.ToIconString(), extraButtonSize)) { diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index dd4ac281..7d6c0189 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -45,7 +45,7 @@ public MainPage(LauncherApp app) this.actionButtons.OnSettingsButtonClicked += () => this.App.State = LauncherApp.LauncherState.Settings; this.actionButtons.OnStatusButtonClicked += () => AppUtil.OpenBrowser("https://is.xivup.com/"); - this.Padding = new Vector2(32f, 32f); + this.Padding = ImGuiHelpers.GetScaled(new Vector2(32f, 32f)); var savedAccount = App.Accounts.CurrentAccount; @@ -71,7 +71,7 @@ public override void Draw() { base.Draw(); - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(32f, 32f)); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaled(new Vector2(32f, 32f))); this.newsFrame.Draw(); ImGui.SameLine(); diff --git a/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs b/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs index 1a3fc600..b1d8d67b 100644 --- a/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs +++ b/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs @@ -70,15 +70,15 @@ public void ReloadNews() private Vector2 GetSize() { var vp = ImGuiHelpers.ViewportSize; - var calculatedSize = vp.X >= 1280 ? vp.X * 0.7f : vp.X * 0.5f; - return new Vector2(calculatedSize, vp.Y - 128f); + var calculatedSize = vp.X >= ImGuiHelpers.GetScaled(1280) ? vp.X * 0.7f : vp.X * 0.5f; + return new Vector2(calculatedSize, vp.Y - ImGuiHelpers.GetScaled(128f)); } public override void Draw() { if (ImGui.BeginChild("###newsFrame", this.GetSize())) { - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(32f, 32f)); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaled(new Vector2(32f, 32f))); if (this.newsLoaded) { @@ -88,7 +88,7 @@ public override void Draw() if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) AppUtil.OpenBrowser(this.bannerList[this.currentBanner].Link.ToString()); - ImGui.Dummy(new Vector2(15)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(15))); void ShowNewsEntry(News newsEntry) { diff --git a/src/XIVLauncher.Core/Components/OtpEntryPage.cs b/src/XIVLauncher.Core/Components/OtpEntryPage.cs index 2a5c9aca..0cfbaff8 100644 --- a/src/XIVLauncher.Core/Components/OtpEntryPage.cs +++ b/src/XIVLauncher.Core/Components/OtpEntryPage.cs @@ -79,7 +79,7 @@ public override void Draw() { ImGui.PushStyleVar(ImGuiStyleVar.ChildRounding, 7f); - var childSize = new Vector2(300, 200); + var childSize = ImGuiHelpers.GetScaled(new Vector2(300, 200)); var vpSize = ImGuiHelpers.ViewportSize; ImGui.SetNextWindowPos(new Vector2(vpSize.X / 2 - childSize.X / 2, vpSize.Y / 2 - childSize.Y / 2), ImGuiCond.Always); @@ -87,12 +87,12 @@ public override void Draw() if (ImGui.BeginChild("###otp", childSize, true, ImGuiWindowFlags.AlwaysAutoResize)) { - ImGui.Dummy(new Vector2(40)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(40))); // center text in window ImGuiHelpers.CenteredText("Please enter your OTP"); - const int INPUT_WIDTH = 150; + int INPUT_WIDTH = (int)ImGuiHelpers.GetScaled(150); ImGui.SetNextItemWidth(INPUT_WIDTH); ImGuiHelpers.CenterCursorFor(INPUT_WIDTH); @@ -104,7 +104,7 @@ public override void Draw() var doEnter = ImGui.InputText("###otpInput", ref this.otp, 6, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.EnterReturnsTrue); - var buttonSize = new Vector2(INPUT_WIDTH/2-4, 30); + var buttonSize = new Vector2(INPUT_WIDTH/2 - ImGuiHelpers.GetScaled(4), ImGuiHelpers.GetScaled(30)); ImGuiHelpers.CenterCursorFor(INPUT_WIDTH); if (ImGui.Button("OK", buttonSize) || doEnter) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs index 98566370..43f93009 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs @@ -83,7 +83,7 @@ public override void Draw() if (ImGui.BeginChild("SearchResults")) { ImGui.TextColored(ImGuiColors.DalamudGrey, settingsTab.Title); - ImGui.Dummy(new Vector2(5)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(5))); foreach (SettingsEntry settingsTabEntry in eligible) { @@ -95,7 +95,7 @@ public override void Draw() ImGui.Separator(); - ImGui.Dummy(new Vector2(10)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10))); } ImGui.EndChild(); } @@ -108,11 +108,11 @@ public override void Draw() } } - ImGui.SetCursorPos(ImGuiHelpers.ViewportSize - new Vector2(60)); + ImGui.SetCursorPos(ImGuiHelpers.ViewportSize - ImGuiHelpers.GetScaled(new Vector2(60))); if (ImGui.BeginChild("###settingsFinishButton")) { - ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 100f); + ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, ImGuiHelpers.GetScaled(100f)); ImGui.PushFont(FontManager.IconFont); var invalid = this.tabs.Any(x => x.Entries.Any(y => y.IsVisible && !y.IsValid)); @@ -120,13 +120,13 @@ public override void Draw() { ImGui.BeginDisabled(); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGui.Button(FontAwesomeIcon.Ban.ToIconString(), new Vector2(40)); + ImGui.Button(FontAwesomeIcon.Ban.ToIconString(), ImGuiHelpers.GetScaled(new Vector2(40))); ImGui.PopStyleColor(); ImGui.EndDisabled(); } else { - if (ImGui.Button(FontAwesomeIcon.Check.ToIconString(), new Vector2(40))) + if (ImGui.Button(FontAwesomeIcon.Check.ToIconString(), ImGuiHelpers.GetScaled(new Vector2(40)))) { foreach (var settingsTab in this.tabs) { @@ -144,8 +144,8 @@ public override void Draw() ImGui.PopFont(); var vpSize = ImGuiHelpers.ViewportSize; - ImGui.SetCursorPos(new Vector2(vpSize.X - 260, 4)); - ImGui.SetNextItemWidth(250); + ImGui.SetCursorPos(new Vector2(vpSize.X - ImGuiHelpers.GetScaled(260), ImGuiHelpers.GetScaled(4))); + ImGui.SetNextItemWidth(ImGuiHelpers.GetScaled(250)); ImGui.InputTextWithHint("###searchInput", "Search for settings...", ref this.searchInput, 100); base.Draw(); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs index e50ebeda..4ba4d25f 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs @@ -18,7 +18,7 @@ public override void Draw() if (settingsEntry.IsVisible) settingsEntry.Draw(); - ImGui.Dummy(new Vector2(10) * ImGuiHelpers.GlobalScale); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10))); } base.Draw(); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabAbout.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabAbout.cs index a58992fb..3bc4a903 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabAbout.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabAbout.cs @@ -22,7 +22,7 @@ public SettingsTabAbout() public override void Draw() { - ImGui.Image(this.logoTexture.ImGuiHandle, new Vector2(256) * ImGuiHelpers.GlobalScale); + ImGui.Image(this.logoTexture.ImGuiHandle, ImGuiHelpers.GetScaled(new Vector2(256))); ImGui.Text($"XIVLauncher Core v{AppUtil.GetAssemblyVersion()}({AppUtil.GetGitHash()})"); ImGui.Text("By goaaats"); @@ -30,7 +30,7 @@ public override void Draw() if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) AppUtil.OpenBrowser("https://github.com/goaaats"); - ImGui.Dummy(new Vector2(20)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(20))); if (ImGui.Button("Open Repository")) { diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index 8d542456..573411dd 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -73,7 +73,7 @@ public override void Draw() ImGui.BeginDisabled(); ImGui.Text("Compatibility tool isn't set up. Please start the game at least once."); - ImGui.Dummy(new Vector2(10)); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10))); } if (ImGui.Button("Open prefix")) diff --git a/src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs b/src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs index 80cca165..6ec2b28c 100644 --- a/src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs +++ b/src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs @@ -17,7 +17,7 @@ public override void Draw() { ImGui.SetCursorPos(new Vector2(0)); - ImGui.Image(this.updateWarnTexture.ImGuiHandle, new Vector2(1280, 800)); + ImGui.Image(this.updateWarnTexture.ImGuiHandle, ImGuiHelpers.GetScaled(new Vector2(1280, 800))); base.Draw(); } diff --git a/src/XIVLauncher.Core/Components/UpdateWarnPage.cs b/src/XIVLauncher.Core/Components/UpdateWarnPage.cs index d8bd158c..20eecf02 100644 --- a/src/XIVLauncher.Core/Components/UpdateWarnPage.cs +++ b/src/XIVLauncher.Core/Components/UpdateWarnPage.cs @@ -17,22 +17,22 @@ public override void Draw() { ImGui.SetCursorPos(new Vector2(0)); - ImGui.Image(this.updateWarnTexture.ImGuiHandle, new Vector2(1280, 800)); + ImGui.Image(this.updateWarnTexture.ImGuiHandle, ImGuiHelpers.GetScaled(new Vector2(1280, 800))); ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Vector4.Zero); ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero); - ImGui.SetCursorPos(new Vector2(316, 481)); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 481))); - if (ImGui.Button("###openGuideButton", new Vector2(649, 101))) + if (ImGui.Button("###openGuideButton", ImGuiHelpers.GetScaled(new Vector2(649, 101)))) { Environment.Exit(0); } - ImGui.SetCursorPos(new Vector2(316, 598)); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 598))); - if (ImGui.Button("###finishFtsButton", new Vector2(649, 101))) + if (ImGui.Button("###finishFtsButton", ImGuiHelpers.GetScaled(new Vector2(649, 101)))) { App.FinishFromUpdateWarn(); } diff --git a/src/XIVLauncher.Core/ImGuiHelpers.cs b/src/XIVLauncher.Core/ImGuiHelpers.cs index 7150c262..21cd7f88 100644 --- a/src/XIVLauncher.Core/ImGuiHelpers.cs +++ b/src/XIVLauncher.Core/ImGuiHelpers.cs @@ -7,7 +7,22 @@ public static class ImGuiHelpers { public static Vector2 ViewportSize => ImGui.GetIO().DisplaySize; - public static float GlobalScale => ImGui.GetIO().FontGlobalScale; + public static float GlobalScale {get; set; } = 1.0f; + + public static float GetScaled(int size) + { + return GlobalScale * (float)size; + } + + public static float GetScaled(float size) + { + return GlobalScale * size; + } + + public static Vector2 GetScaled(Vector2 size) + { + return size * GlobalScale; + } public static void TextWrapped(string text) { diff --git a/src/XIVLauncher.Core/LauncherApp.cs b/src/XIVLauncher.Core/LauncherApp.cs index 098d0253..0749415f 100644 --- a/src/XIVLauncher.Core/LauncherApp.cs +++ b/src/XIVLauncher.Core/LauncherApp.cs @@ -324,21 +324,21 @@ public override void Draw() private void DrawModal() { - ImGui.SetNextWindowSize(new Vector2(450, 300)); + ImGui.SetNextWindowSize(ImGuiHelpers.GetScaled(new Vector2(450, 300))); if (ImGui.BeginPopupModal(this.modalTitle + "###xl_modal", ref this.isModalDrawing, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoTitleBar)) { - if (ImGui.BeginChild("###xl_modal_scrolling", new Vector2(0, -ImGui.GetTextLineHeightWithSpacing() * 2))) + if (ImGui.BeginChild("###xl_modal_scrolling", ImGuiHelpers.GetScaled(new Vector2(0, -ImGui.GetTextLineHeightWithSpacing() * 2)))) { ImGui.TextWrapped(this.modalText); } ImGui.EndChild(); - const float BUTTON_WIDTH = 120f; + float BUTTON_WIDTH = ImGuiHelpers.GetScaled(120f); ImGui.SetCursorPosX((ImGui.GetWindowWidth() - BUTTON_WIDTH) / 2); - if (ImGui.Button(modalButtonText, new Vector2(BUTTON_WIDTH, 40))) + if (ImGui.Button(modalButtonText, new Vector2(BUTTON_WIDTH, ImGuiHelpers.GetScaled(40)))) { modalButtonPressAction(); } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 9dabf1c4..c68e761f 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -257,16 +257,14 @@ private static void Main(string[] args) // Create window, GraphicsDevice, and all resources necessary for the demo. Sdl2Native.SDL_Init(SDLInitFlags.Video); - float dpiScale = 1f; - if (Environment.GetEnvironmentVariable("XDG_SESSION_TYPE") == "wayland" && SdlHelpers.GetCurrentVideoDriver() == "x11") { - dpiScale = SdlHelpers.GetDisplayDpiScale().Y; + ImGuiHelpers.GlobalScale = SdlHelpers.GetDisplayDpiScale().Y; } - var windowWidth = (int) Math.Round(1280 * dpiScale); - var windowHeight = (int) Math.Round(800 * dpiScale); + var windowWidth = (int)ImGuiHelpers.GetScaled(1280); + var windowHeight = (int)ImGuiHelpers.GetScaled(800); VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, windowWidth, windowHeight, WindowState.Normal, $"XIVLauncher {version}"), @@ -283,11 +281,10 @@ private static void Main(string[] args) cl = gd.ResourceFactory.CreateCommandList(); Log.Debug("Veldrid OK!"); - bindings = new ImGuiBindings(gd, gd.MainSwapchain.Framebuffer.OutputDescription, window.Width, window.Height, storage.GetFile("launcherUI.ini"), (Config.FontPxSize ?? 21.0f) * dpiScale); + bindings = new ImGuiBindings(gd, gd.MainSwapchain.Framebuffer.OutputDescription, window.Width, window.Height, storage.GetFile("launcherUI.ini"), ImGuiHelpers.GetScaled(Config.FontPxSize ?? 21.0f)); Log.Debug("ImGui OK!"); StyleModelV1.DalamudStandard.Apply(); - ImGui.GetIO().FontGlobalScale = Config.GlobalScale ?? 1.0f; var needUpdate = false; diff --git a/src/XIVLauncher.Core/Style/StyleModelV1.cs b/src/XIVLauncher.Core/Style/StyleModelV1.cs index 585d3616..8c88f985 100644 --- a/src/XIVLauncher.Core/Style/StyleModelV1.cs +++ b/src/XIVLauncher.Core/Style/StyleModelV1.cs @@ -26,34 +26,34 @@ private StyleModelV1() Name = "Dalamud Standard", Alpha = 1, - WindowPadding = new Vector2(8, 8), - WindowRounding = 4, + WindowPadding = ImGuiHelpers.GetScaled(new Vector2(8, 8)), + WindowRounding = ImGuiHelpers.GetScaled(4), WindowBorderSize = 0, WindowTitleAlign = new Vector2(0, 0.5f), WindowMenuButtonPosition = ImGuiDir.Right, ChildRounding = 0, - ChildBorderSize = 1, + ChildBorderSize = ImGuiHelpers.GetScaled(1), PopupRounding = 0, PopupBorderSize = 0, - FramePadding = new Vector2(4, 3), + FramePadding = ImGuiHelpers.GetScaled(new Vector2(4, 3)), //FrameRounding = 4, FrameRounding = 0, FrameBorderSize = 0, - ItemSpacing = new Vector2(8, 4), - ItemInnerSpacing = new Vector2(4, 4), - CellPadding = new Vector2(4, 2), + ItemSpacing = ImGuiHelpers.GetScaled(new Vector2(8, 4)), + ItemInnerSpacing = ImGuiHelpers.GetScaled(new Vector2(4, 4)), + CellPadding = ImGuiHelpers.GetScaled(new Vector2(4, 2)), TouchExtraPadding = new Vector2(0, 0), - IndentSpacing = 21, - ScrollbarSize = 16, - ScrollbarRounding = 9, - GrabMinSize = 13, - GrabRounding = 3, - LogSliderDeadzone = 4, - TabRounding = 1, + IndentSpacing = ImGuiHelpers.GetScaled(21), + ScrollbarSize = ImGuiHelpers.GetScaled(16), + ScrollbarRounding = ImGuiHelpers.GetScaled(9), + GrabMinSize = ImGuiHelpers.GetScaled(13), + GrabRounding = ImGuiHelpers.GetScaled(3), + LogSliderDeadzone = ImGuiHelpers.GetScaled(4), + TabRounding = ImGuiHelpers.GetScaled(1), TabBorderSize = 0, ButtonTextAlign = new Vector2(0.5f, 0.5f), SelectableTextAlign = new Vector2(0, 0), - DisplaySafeAreaPadding = new Vector2(3, 3), + DisplaySafeAreaPadding = ImGuiHelpers.GetScaled(new Vector2(3, 3)), Colors = new Dictionary { @@ -123,33 +123,33 @@ private StyleModelV1() Name = "Dalamud Classic", Alpha = 1, - WindowPadding = new Vector2(8, 8), - WindowRounding = 4, + WindowPadding = ImGuiHelpers.GetScaled(new Vector2(8, 8)), + WindowRounding = ImGuiHelpers.GetScaled(4), WindowBorderSize = 0, WindowTitleAlign = new Vector2(0, 0.5f), WindowMenuButtonPosition = ImGuiDir.Right, ChildRounding = 0, - ChildBorderSize = 1, + ChildBorderSize = ImGuiHelpers.GetScaled(1), PopupRounding = 0, PopupBorderSize = 0, - FramePadding = new Vector2(4, 3), - FrameRounding = 4, + FramePadding = ImGuiHelpers.GetScaled(new Vector2(4, 3)), + FrameRounding = ImGuiHelpers.GetScaled(4), FrameBorderSize = 0, - ItemSpacing = new Vector2(8, 4), - ItemInnerSpacing = new Vector2(4, 4), - CellPadding = new Vector2(4, 2), + ItemSpacing = ImGuiHelpers.GetScaled(new Vector2(8, 4)), + ItemInnerSpacing = ImGuiHelpers.GetScaled(new Vector2(4, 4)), + CellPadding = ImGuiHelpers.GetScaled(new Vector2(4, 2)), TouchExtraPadding = new Vector2(0, 0), - IndentSpacing = 21, - ScrollbarSize = 16, - ScrollbarRounding = 9, - GrabMinSize = 10, - GrabRounding = 3, - LogSliderDeadzone = 4, - TabRounding = 4, + IndentSpacing = ImGuiHelpers.GetScaled(21), + ScrollbarSize = ImGuiHelpers.GetScaled(16), + ScrollbarRounding = ImGuiHelpers.GetScaled(9), + GrabMinSize = ImGuiHelpers.GetScaled(10), + GrabRounding = ImGuiHelpers.GetScaled(3), + LogSliderDeadzone = ImGuiHelpers.GetScaled(4), + TabRounding = ImGuiHelpers.GetScaled(4), TabBorderSize = 0, ButtonTextAlign = new Vector2(0.5f, 0.5f), SelectableTextAlign = new Vector2(0, 0), - DisplaySafeAreaPadding = new Vector2(3, 3), + DisplaySafeAreaPadding = ImGuiHelpers.GetScaled(new Vector2(3, 3)), Colors = new Dictionary {