From d82df62d81571e4db119482457fe1ab524fb1189 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 86b8b997..22f92f27 100644 --- a/src/XIVLauncher.Core/Components/Background.cs +++ b/src/XIVLauncher.Core/Components/Background.cs @@ -15,9 +15,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 5b2b1f16..fa7565ea 100644 --- a/src/XIVLauncher.Core/Components/Common/Button.cs +++ b/src/XIVLauncher.Core/Components/Common/Button.cs @@ -28,7 +28,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 9028d896..7493f355 100644 --- a/src/XIVLauncher.Core/Components/Common/Checkbox.cs +++ b/src/XIVLauncher.Core/Components/Common/Checkbox.cs @@ -29,7 +29,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 2bc3b2db..32055804 100644 --- a/src/XIVLauncher.Core/Components/Common/Input.cs +++ b/src/XIVLauncher.Core/Components/Common/Input.cs @@ -72,7 +72,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 368385f1..94ba52f1 100644 --- a/src/XIVLauncher.Core/Components/FtsPage.cs +++ b/src/XIVLauncher.Core/Components/FtsPage.cs @@ -64,9 +64,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) { @@ -78,9 +78,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 4bdab083..dbada57f 100644 --- a/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs +++ b/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs @@ -8,7 +8,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; @@ -32,7 +32,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 += () => @@ -58,13 +58,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); } @@ -72,7 +72,7 @@ public override void Draw() if (CanCancel || isDrawDisableAutoLogin) { - ImGui.Dummy(ImGuiHelpers.GetScaledVector2(new Vector2(20)));; + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(20)));; } if (CanCancel) @@ -93,7 +93,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 8700a6a5..36c81561 100644 --- a/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs +++ b/src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs @@ -28,7 +28,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 db59dee1..c9ed51a9 100644 --- a/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs +++ b/src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs @@ -12,7 +12,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 1d306e4a..fb996cf1 100644 --- a/src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs +++ b/src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs @@ -61,13 +61,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"); @@ -90,7 +90,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(); @@ -98,7 +98,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(); @@ -159,12 +159,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 f9c5ac87..56e66bc5 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -49,7 +49,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; @@ -75,7 +75,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 0e0fa6aa..1d222f74 100644 --- a/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs +++ b/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs @@ -80,7 +80,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) { @@ -90,7 +90,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 213fc29a..0cc2fc8a 100644 --- a/src/XIVLauncher.Core/Components/OtpEntryPage.cs +++ b/src/XIVLauncher.Core/Components/OtpEntryPage.cs @@ -82,7 +82,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); @@ -90,12 +90,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 8e8a5ef7..70bfb393 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs @@ -85,7 +85,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) { @@ -97,7 +97,7 @@ public override void Draw() ImGui.Separator(); - ImGui.Dummy(ImGuiHelpers.GetScaledVector2(new Vector2(10))); + ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10))); } ImGui.EndChild(); } @@ -110,7 +110,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")) { @@ -122,13 +122,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 a9efa317..70291fab 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs @@ -19,7 +19,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 9b6fc826..374fa559 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabAbout.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabAbout.cs @@ -21,7 +21,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"); @@ -29,7 +29,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 be86941e..8f3a2759 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -75,7 +75,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 f3b47ba2..5522923f 100644 --- a/src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs +++ b/src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs @@ -18,7 +18,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 68ba5590..6de7d526 100644 --- a/src/XIVLauncher.Core/Components/UpdateWarnPage.cs +++ b/src/XIVLauncher.Core/Components/UpdateWarnPage.cs @@ -18,22 +18,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 174ca500..891fb1f2 100644 --- a/src/XIVLauncher.Core/ImGuiHelpers.cs +++ b/src/XIVLauncher.Core/ImGuiHelpers.cs @@ -20,17 +20,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 185c61a3..f64d065a 100644 --- a/src/XIVLauncher.Core/LauncherApp.cs +++ b/src/XIVLauncher.Core/LauncherApp.cs @@ -318,11 +318,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 ac47fbd5..fb59158a 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -268,8 +268,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 df9faa7c..32a48de2 100644 --- a/src/XIVLauncher.Core/Style/StyleModelV1.cs +++ b/src/XIVLauncher.Core/Style/StyleModelV1.cs @@ -28,7 +28,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), @@ -37,13 +37,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), @@ -55,7 +55,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 { @@ -125,7 +125,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), @@ -134,12 +134,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), @@ -151,7 +151,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 {