Skip to content

Commit

Permalink
Merge pull request #1 from rankynbass/PR152-fix-scaling
Browse files Browse the repository at this point in the history
Fix *all* the scaling
  • Loading branch information
Maia-Everett committed Apr 22, 2024
2 parents 6936908 + c13c4a8 commit 4a04bc6
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/XIVLauncher.Core/Components/Background.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Components/Common/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Components/Common/Checkbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Components/Common/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/XIVLauncher.Core/Components/FtsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}
Expand Down
16 changes: 8 additions & 8 deletions src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 += () =>
Expand All @@ -49,28 +49,28 @@ 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);
}

var isDrawDisableAutoLogin = CanDisableAutoLogin && (App.Settings.IsAutologin ?? false);

if (CanCancel || isDrawDisableAutoLogin)
{
ImGui.Dummy(new Vector2(20));
ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(20)));;
}

if (CanCancel)
Expand All @@ -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)
{
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/XIVLauncher.Core/Components/MainPage/AccountSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Components/MainPage/ActionButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 7 additions & 7 deletions src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -81,22 +81,22 @@ 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();

this.oneTimePasswordCheckbox.Draw();
this.useSteamServiceCheckbox.Draw();
this.autoLoginCheckbox.Draw();

ImGui.Dummy(new Vector2(10));
ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10)));

this.loginButton.Draw();

Expand Down Expand Up @@ -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))
{
Expand Down
4 changes: 2 additions & 2 deletions src/XIVLauncher.Core/Components/MainPage/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions src/XIVLauncher.Core/Components/OtpEntryPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ 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);
ImGui.SetNextWindowBgAlpha(0.4f);

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);

Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -95,7 +95,7 @@ public override void Draw()

ImGui.Separator();

ImGui.Dummy(new Vector2(10));
ImGui.Dummy(ImGuiHelpers.GetScaled(new Vector2(10)));
}
ImGui.EndChild();
}
Expand All @@ -108,25 +108,25 @@ 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));
if (invalid)
{
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)
{
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ 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");

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"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Components/SteamDeckPromptPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Loading

0 comments on commit 4a04bc6

Please sign in to comment.