From c13c4a8d2da821e558392a40379a8ad2e2f73d3e Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 21 Apr 2024 20:15:55 -0700 Subject: [PATCH] Get rid of GetScaledInt, GetScaledVector2 --- src/XIVLauncher.Core/Components/Background.cs | 4 ++-- .../Components/Common/Button.cs | 2 +- .../Components/Common/Checkbox.cs | 2 +- .../Components/Common/Input.cs | 2 +- src/XIVLauncher.Core/Components/FtsPage.cs | 8 +++---- .../Components/LoadingPage/LoadingPage.cs | 12 +++++----- .../Components/MainPage/AccountSwitcher.cs | 2 +- .../Components/MainPage/ActionButtons.cs | 2 +- .../Components/MainPage/LoginFrame.cs | 12 +++++----- .../Components/MainPage/MainPage.cs | 4 ++-- .../Components/MainPage/NewsFrame.cs | 4 ++-- .../Components/OtpEntryPage.cs | 6 ++--- .../Components/SettingsPage/SettingsPage.cs | 10 ++++---- .../Components/SettingsPage/SettingsTab.cs | 2 +- .../SettingsPage/Tabs/SettingsTabAbout.cs | 4 ++-- .../SettingsPage/Tabs/SettingsTabWine.cs | 2 +- .../Components/SteamDeckPromptPage.cs | 2 +- .../Components/UpdateWarnPage.cs | 10 ++++---- src/XIVLauncher.Core/ImGuiHelpers.cs | 12 +--------- src/XIVLauncher.Core/LauncherApp.cs | 4 ++-- src/XIVLauncher.Core/Program.cs | 4 ++-- src/XIVLauncher.Core/Style/StyleModelV1.cs | 24 +++++++++---------- 22 files changed, 62 insertions(+), 72 deletions(-) diff --git a/src/XIVLauncher.Core/Components/Background.cs b/src/XIVLauncher.Core/Components/Background.cs index b50f8fe4..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(ImGuiHelpers.GetScaledVector2(new Vector2(0, ImGuiHelpers.ViewportSize.Y - bgTexture.Height))); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(0, ImGuiHelpers.ViewportSize.Y - bgTexture.Height))); - ImGui.Image(bgTexture.ImGuiHandle, ImGuiHelpers.GetScaledVector2(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 32b6cb76..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, ImGuiHelpers.GetScaledVector2(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 ed65b48c..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, ImGuiHelpers.GetScaledVector2(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 df79a6ce..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, ImGuiHelpers.GetScaledVector2(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 4b755abf..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(ImGuiHelpers.GetScaledVector2(new Vector2(316, 481))); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 481))); - if (ImGui.Button("###openGuideButton", ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(new Vector2(316, 598))); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 598))); - if (ImGui.Button("###finishFtsButton", ImGuiHelpers.GetScaledVector2(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 aac3c87a..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 int SPINNER_RADIUS = ImGuiHelpers.GetScaledInt(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, ImGuiHelpers.GetScaledInt(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 += () => @@ -56,13 +56,13 @@ public override void Draw() if (!string.IsNullOrEmpty(Line2)) { - ImGui.Dummy(ImGuiHelpers.GetScaledVector2(new Vector2(2))); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(2))); ImGuiHelpers.CenteredText(Line2); } if (!string.IsNullOrEmpty(Line3)) { - ImGui.Dummy(ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(new Vector2(20))); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(20))); if (IsIndeterminate) { diff --git a/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs b/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs index cf4a5ed8..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, ImGuiHelpers.GetScaledVector2(new Vector2(5))); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaled(new Vector2(5))); if (ImGui.BeginPopupContextItem(ACCOUNT_SWITCHER_POPUP_ID)) { diff --git a/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs b/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs index d2ad9ba4..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 = ImGuiHelpers.GetScaledVector2(new Vector2(80)); + 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 f7f17d7f..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", ImGuiHelpers.GetScaledVector2(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", ImGuiHelpers.GetScaledVector2(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"); @@ -88,7 +88,7 @@ public override void Draw() { if (ImGui.BeginChild("###loginFrame", this.GetSize())) { - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(new Vector2(15))); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(15))); } ImGui.PushFont(FontManager.IconFont); - var extraButtonSize = ImGuiHelpers.GetScaledVector2(new Vector2(45)); + 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 617cca30..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 = ImGuiHelpers.GetScaledVector2(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, ImGuiHelpers.GetScaledVector2(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 411e6aef..b1d8d67b 100644 --- a/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs +++ b/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs @@ -78,7 +78,7 @@ public override void Draw() { if (ImGui.BeginChild("###newsFrame", this.GetSize())) { - ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(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 0edebc60..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 = ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(new Vector2(40))); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(40))); // center text in window ImGuiHelpers.CenteredText("Please enter your OTP"); - int INPUT_WIDTH = ImGuiHelpers.GetScaledInt(150); + int INPUT_WIDTH = (int)ImGuiHelpers.GetScaled(150); ImGui.SetNextItemWidth(INPUT_WIDTH); ImGuiHelpers.CenterCursorFor(INPUT_WIDTH); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs index 351ea081..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(ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(new Vector2(10))); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10))); } ImGui.EndChild(); } @@ -108,7 +108,7 @@ public override void Draw() } } - ImGui.SetCursorPos(ImGuiHelpers.ViewportSize - ImGuiHelpers.GetScaledVector2(new Vector2(60))); + ImGui.SetCursorPos(ImGuiHelpers.ViewportSize - ImGuiHelpers.GetScaled(new Vector2(60))); if (ImGui.BeginChild("###settingsFinishButton")) { @@ -120,13 +120,13 @@ public override void Draw() { ImGui.BeginDisabled(); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGui.Button(FontAwesomeIcon.Ban.ToIconString(), ImGuiHelpers.GetScaledVector2(new Vector2(40))); + ImGui.Button(FontAwesomeIcon.Ban.ToIconString(), ImGuiHelpers.GetScaled(new Vector2(40))); ImGui.PopStyleColor(); ImGui.EndDisabled(); } else { - if (ImGui.Button(FontAwesomeIcon.Check.ToIconString(), ImGuiHelpers.GetScaledVector2(new Vector2(40)))) + if (ImGui.Button(FontAwesomeIcon.Check.ToIconString(), ImGuiHelpers.GetScaled(new Vector2(40)))) { foreach (var settingsTab in this.tabs) { diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs index 6f0227fe..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(ImGuiHelpers.GetScaledVector2(new Vector2(10))); + 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 056fa6d7..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, ImGuiHelpers.GetScaledVector2(new Vector2(256))); + 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(ImGuiHelpers.GetScaledVector2(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 e6be240c..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(ImGuiHelpers.GetScaledVector2(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 4e58b563..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, ImGuiHelpers.GetScaledVector2(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 a16f145d..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, ImGuiHelpers.GetScaledVector2(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(ImGuiHelpers.GetScaledVector2(new Vector2(316, 481))); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 481))); - if (ImGui.Button("###openGuideButton", ImGuiHelpers.GetScaledVector2(new Vector2(649, 101)))) + if (ImGui.Button("###openGuideButton", ImGuiHelpers.GetScaled(new Vector2(649, 101)))) { Environment.Exit(0); } - ImGui.SetCursorPos(ImGuiHelpers.GetScaledVector2(new Vector2(316, 598))); + ImGui.SetCursorPos(ImGuiHelpers.GetScaled(new Vector2(316, 598))); - if (ImGui.Button("###finishFtsButton", ImGuiHelpers.GetScaledVector2(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 c67d4e54..21cd7f88 100644 --- a/src/XIVLauncher.Core/ImGuiHelpers.cs +++ b/src/XIVLauncher.Core/ImGuiHelpers.cs @@ -19,17 +19,7 @@ public static float GetScaled(float size) return GlobalScale * size; } - public static int GetScaledInt(int size) - { - return (int)(GlobalScale * (float)size); - } - - public static int GetScaledInt(float size) - { - return (int)(GlobalScale * size); - } - - public static Vector2 GetScaledVector2(Vector2 size) + public static Vector2 GetScaled(Vector2 size) { return size * GlobalScale; } diff --git a/src/XIVLauncher.Core/LauncherApp.cs b/src/XIVLauncher.Core/LauncherApp.cs index be5cb853..0749415f 100644 --- a/src/XIVLauncher.Core/LauncherApp.cs +++ b/src/XIVLauncher.Core/LauncherApp.cs @@ -324,11 +324,11 @@ public override void Draw() private void DrawModal() { - ImGui.SetNextWindowSize(ImGuiHelpers.GetScaledVector2(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", ImGuiHelpers.GetScaledVector2(new Vector2(0, -ImGui.GetTextLineHeightWithSpacing() * 2)))) + if (ImGui.BeginChild("###xl_modal_scrolling", ImGuiHelpers.GetScaled(new Vector2(0, -ImGui.GetTextLineHeightWithSpacing() * 2)))) { ImGui.TextWrapped(this.modalText); } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index deae4875..c68e761f 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -263,8 +263,8 @@ private static void Main(string[] args) ImGuiHelpers.GlobalScale = SdlHelpers.GetDisplayDpiScale().Y; } - var windowWidth = ImGuiHelpers.GetScaledInt(1280); - var windowHeight = ImGuiHelpers.GetScaledInt(800); + var windowWidth = (int)ImGuiHelpers.GetScaled(1280); + var windowHeight = (int)ImGuiHelpers.GetScaled(800); VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, windowWidth, windowHeight, WindowState.Normal, $"XIVLauncher {version}"), diff --git a/src/XIVLauncher.Core/Style/StyleModelV1.cs b/src/XIVLauncher.Core/Style/StyleModelV1.cs index 490b9062..8c88f985 100644 --- a/src/XIVLauncher.Core/Style/StyleModelV1.cs +++ b/src/XIVLauncher.Core/Style/StyleModelV1.cs @@ -26,7 +26,7 @@ private StyleModelV1() Name = "Dalamud Standard", Alpha = 1, - WindowPadding = ImGuiHelpers.GetScaledVector2(new Vector2(8, 8)), + WindowPadding = ImGuiHelpers.GetScaled(new Vector2(8, 8)), WindowRounding = ImGuiHelpers.GetScaled(4), WindowBorderSize = 0, WindowTitleAlign = new Vector2(0, 0.5f), @@ -35,13 +35,13 @@ private StyleModelV1() ChildBorderSize = ImGuiHelpers.GetScaled(1), PopupRounding = 0, PopupBorderSize = 0, - FramePadding = ImGuiHelpers.GetScaledVector2(new Vector2(4, 3)), + FramePadding = ImGuiHelpers.GetScaled(new Vector2(4, 3)), //FrameRounding = 4, FrameRounding = 0, FrameBorderSize = 0, - ItemSpacing = ImGuiHelpers.GetScaledVector2(new Vector2(8, 4)), - ItemInnerSpacing = new Vector2(4, 4) * ImGuiHelpers.GlobalScale, - CellPadding = ImGuiHelpers.GetScaledVector2(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 = ImGuiHelpers.GetScaled(21), ScrollbarSize = ImGuiHelpers.GetScaled(16), @@ -53,7 +53,7 @@ private StyleModelV1() TabBorderSize = 0, ButtonTextAlign = new Vector2(0.5f, 0.5f), SelectableTextAlign = new Vector2(0, 0), - DisplaySafeAreaPadding = ImGuiHelpers.GetScaledVector2(new Vector2(3, 3)), + DisplaySafeAreaPadding = ImGuiHelpers.GetScaled(new Vector2(3, 3)), Colors = new Dictionary { @@ -123,7 +123,7 @@ private StyleModelV1() Name = "Dalamud Classic", Alpha = 1, - WindowPadding = ImGuiHelpers.GetScaledVector2(new Vector2(8, 8)), + WindowPadding = ImGuiHelpers.GetScaled(new Vector2(8, 8)), WindowRounding = ImGuiHelpers.GetScaled(4), WindowBorderSize = 0, WindowTitleAlign = new Vector2(0, 0.5f), @@ -132,12 +132,12 @@ private StyleModelV1() ChildBorderSize = ImGuiHelpers.GetScaled(1), PopupRounding = 0, PopupBorderSize = 0, - FramePadding = ImGuiHelpers.GetScaledVector2(new Vector2(4, 3)), + FramePadding = ImGuiHelpers.GetScaled(new Vector2(4, 3)), FrameRounding = ImGuiHelpers.GetScaled(4), FrameBorderSize = 0, - ItemSpacing = ImGuiHelpers.GetScaledVector2(new Vector2(8, 4)), - ItemInnerSpacing = ImGuiHelpers.GetScaledVector2(new Vector2(4, 4)), - CellPadding = ImGuiHelpers.GetScaledVector2(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 = ImGuiHelpers.GetScaled(21), ScrollbarSize = ImGuiHelpers.GetScaled(16), @@ -149,7 +149,7 @@ private StyleModelV1() TabBorderSize = 0, ButtonTextAlign = new Vector2(0.5f, 0.5f), SelectableTextAlign = new Vector2(0, 0), - DisplaySafeAreaPadding = ImGuiHelpers.GetScaledVector2(new Vector2(3, 3)), + DisplaySafeAreaPadding = ImGuiHelpers.GetScaled(new Vector2(3, 3)), Colors = new Dictionary {