diff --git a/src/XIVLauncher.Core/Accounts/AccountManager.cs b/src/XIVLauncher.Core/Accounts/AccountManager.cs index d74be57d..7b35a2d3 100644 --- a/src/XIVLauncher.Core/Accounts/AccountManager.cs +++ b/src/XIVLauncher.Core/Accounts/AccountManager.cs @@ -8,44 +8,44 @@ namespace XIVLauncher.Core.Accounts; public class AccountManager { - public ObservableCollection Accounts = new(); + public ObservableCollection Accounts = []; public XivAccount? CurrentAccount { - get { return Accounts.Count > 1 ? Accounts.FirstOrDefault(a => a.Id == Program.Config.CurrentAccountId) : Accounts.FirstOrDefault(); } + get { return this.Accounts.Count > 1 ? this.Accounts.FirstOrDefault(a => a.Id == Program.Config.CurrentAccountId) : this.Accounts.FirstOrDefault(); } set => Program.Config.CurrentAccountId = value?.Id; } public AccountManager(FileInfo configFile) { this.configFile = configFile; - Load(); + this.Load(); - Accounts.CollectionChanged += Accounts_CollectionChanged; + this.Accounts.CollectionChanged += this.Accounts_CollectionChanged; } private void Accounts_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { - Save(); + this.Save(); } public void UpdatePassword(XivAccount account, string password) { Log.Information("UpdatePassword() called"); - var existingAccount = Accounts.FirstOrDefault(a => a.Id == account.Id); + var existingAccount = this.Accounts.FirstOrDefault(a => a.Id == account.Id); if (existingAccount is not null) existingAccount.Password = password; } public void UpdateLastSuccessfulOtp(XivAccount account, string lastOtp) { - var existingAccount = Accounts.FirstOrDefault(a => a.Id == account.Id); + var existingAccount = this.Accounts.FirstOrDefault(a => a.Id == account.Id); if (existingAccount is not null) existingAccount.LastSuccessfulOtp = lastOtp; - Save(); + this.Save(); } public void AddAccount(XivAccount account) { - var existingAccount = Accounts.FirstOrDefault(a => a.Id == account.Id); + var existingAccount = this.Accounts.FirstOrDefault(a => a.Id == account.Id); Log.Verbose($"existingAccount: {existingAccount?.Id}"); @@ -59,12 +59,12 @@ public void AddAccount(XivAccount account) if (existingAccount != null) return; - Accounts.Add(account); + this.Accounts.Add(account); } public void RemoveAccount(XivAccount account) { - Accounts.Remove(account); + this.Accounts.Remove(account); } #region SaveLoad @@ -73,21 +73,21 @@ public void RemoveAccount(XivAccount account) public void Save() { - File.WriteAllText(this.configFile.FullName, JsonConvert.SerializeObject(Accounts, Formatting.Indented)); + File.WriteAllText(this.configFile.FullName, JsonConvert.SerializeObject(this.Accounts, Formatting.Indented)); } public void Load() { if (!this.configFile.Exists) { - Save(); + this.Save(); return; } - Accounts = JsonConvert.DeserializeObject>(File.ReadAllText(this.configFile.FullName)); + this.Accounts = JsonConvert.DeserializeObject>(File.ReadAllText(this.configFile.FullName)); // If the file is corrupted, this will be null anyway - Accounts ??= new ObservableCollection(); + this.Accounts ??= []; } #endregion diff --git a/src/XIVLauncher.Core/Accounts/AccountSwitcherEntry.cs b/src/XIVLauncher.Core/Accounts/AccountSwitcherEntry.cs index add3ba45..407e6a9e 100644 --- a/src/XIVLauncher.Core/Accounts/AccountSwitcherEntry.cs +++ b/src/XIVLauncher.Core/Accounts/AccountSwitcherEntry.cs @@ -13,13 +13,13 @@ public AccountSwitcherEntry(XivAccount account) public void UpdateProfileImage(DirectoryInfo storage) { - if (string.IsNullOrEmpty(Account.ThumbnailUrl)) + if (string.IsNullOrEmpty(this.Account.ThumbnailUrl)) return; var cacheFolder = Path.Combine(storage.FullName, "profilePictures"); Directory.CreateDirectory(cacheFolder); - var uri = new Uri(Account.ThumbnailUrl); + var uri = new Uri(this.Account.ThumbnailUrl); var cacheFile = Path.Combine(cacheFolder, uri.Segments.Last()); byte[] imageBytes; diff --git a/src/XIVLauncher.Core/Accounts/Secrets/Providers/FileSecretProvider.cs b/src/XIVLauncher.Core/Accounts/Secrets/Providers/FileSecretProvider.cs index 9cbc5bec..14a09555 100644 --- a/src/XIVLauncher.Core/Accounts/Secrets/Providers/FileSecretProvider.cs +++ b/src/XIVLauncher.Core/Accounts/Secrets/Providers/FileSecretProvider.cs @@ -14,7 +14,7 @@ public FileSecretProvider(FileInfo configFile) if (configFile.Exists) this.savedPasswords = JsonSerializer.Deserialize>(configFile.OpenText().ReadToEnd())!; - this.savedPasswords ??= new Dictionary(); + this.savedPasswords ??= []; } public string? GetPassword(string accountName) @@ -36,14 +36,14 @@ public void SavePassword(string accountName, string password) this.savedPasswords.Add(accountName, password); } - Save(); + this.Save(); } public void DeletePassword(string accountName) { this.savedPasswords.Remove(accountName); - Save(); + this.Save(); } private void Save() diff --git a/src/XIVLauncher.Core/Accounts/Secrets/Providers/KeychainSecretProvider.cs b/src/XIVLauncher.Core/Accounts/Secrets/Providers/KeychainSecretProvider.cs index 87e5c5e5..5bf3445f 100644 --- a/src/XIVLauncher.Core/Accounts/Secrets/Providers/KeychainSecretProvider.cs +++ b/src/XIVLauncher.Core/Accounts/Secrets/Providers/KeychainSecretProvider.cs @@ -13,7 +13,7 @@ public class KeychainSecretProvider : ISecretProvider public KeychainSecretProvider() { - this.IsAvailable = SetDummyAndCheck(); + this.IsAvailable = this.SetDummyAndCheck(); } public bool SetDummyAndCheck() diff --git a/src/XIVLauncher.Core/Accounts/XivAccount.cs b/src/XIVLauncher.Core/Accounts/XivAccount.cs index 7511144f..55a2fe40 100644 --- a/src/XIVLauncher.Core/Accounts/XivAccount.cs +++ b/src/XIVLauncher.Core/Accounts/XivAccount.cs @@ -8,9 +8,9 @@ namespace XIVLauncher.Core.Accounts; public class XivAccount { [JsonIgnore] - public string Id => $"{UserName}-{UseOtp}-{UseSteamServiceAccount}"; + public string Id => $"{this.UserName}-{this.UseOtp}-{this.UseSteamServiceAccount}"; - public override string ToString() => Id; + public override string ToString() => this.Id; public string UserName { get; private set; } @@ -19,17 +19,17 @@ public string Password { get { - if (string.IsNullOrEmpty(UserName)) + if (string.IsNullOrEmpty(this.UserName)) return string.Empty; - var credentials = Program.Secrets.GetPassword(UserName); + var credentials = Program.Secrets.GetPassword(this.UserName); return credentials ?? string.Empty; } set { if (!string.IsNullOrEmpty(value)) { - Program.Secrets.SavePassword(UserName, value); + Program.Secrets.SavePassword(this.UserName, value); } } } @@ -46,17 +46,17 @@ public string Password public XivAccount(string userName) { - UserName = userName.ToLower(); + this.UserName = userName.ToLower(); } public string? FindCharacterThumb() { - if (string.IsNullOrEmpty(ChosenCharacterName) || string.IsNullOrEmpty(ChosenCharacterWorld)) + if (string.IsNullOrEmpty(this.ChosenCharacterName) || string.IsNullOrEmpty(this.ChosenCharacterWorld)) return null; try { - dynamic searchResponse = GetCharacterSearch(ChosenCharacterName, ChosenCharacterWorld) + dynamic searchResponse = GetCharacterSearch(this.ChosenCharacterName, this.ChosenCharacterWorld) .GetAwaiter().GetResult(); if (searchResponse.Results.Count > 1) //If we get more than one match from XIVAPI @@ -64,7 +64,7 @@ public XivAccount(string userName) foreach (var accountInfo in searchResponse.Results) { //We have to check with it all lower in case they type their character name LiKe ThIsLoL. The server XIVAPI returns also contains the DC name, so let's just do a contains on the server to make it easy. - if (accountInfo.Name.Value.ToLower() == ChosenCharacterName.ToLower() && accountInfo.Server.Value.ToLower().Contains(ChosenCharacterWorld.ToLower())) + if (accountInfo.Name.Value.ToLower() == this.ChosenCharacterName.ToLower() && accountInfo.Server.Value.ToLower().Contains(this.ChosenCharacterWorld.ToLower())) { return accountInfo.Avatar.Value; } diff --git a/src/XIVLauncher.Core/Components/Background.cs b/src/XIVLauncher.Core/Components/Background.cs index 21533bf7..dd2ae199 100644 --- a/src/XIVLauncher.Core/Components/Background.cs +++ b/src/XIVLauncher.Core/Components/Background.cs @@ -15,8 +15,8 @@ public Background() public override void Draw() { - ImGui.SetCursorPos(new Vector2(0, ImGuiHelpers.ViewportSize.Y - bgTexture.Height)); - ImGui.Image(bgTexture.ImGuiHandle, new Vector2(bgTexture.Width, bgTexture.Height)); + ImGui.SetCursorPos(new Vector2(0, ImGuiHelpers.ViewportSize.Y - this.bgTexture.Height)); + ImGui.Image(this.bgTexture.ImGuiHandle, new Vector2(this.bgTexture.Width, this.bgTexture.Height)); base.Draw(); } } diff --git a/src/XIVLauncher.Core/Components/Common/Button.cs b/src/XIVLauncher.Core/Components/Common/Button.cs index f559d676..49e52e09 100644 --- a/src/XIVLauncher.Core/Components/Common/Button.cs +++ b/src/XIVLauncher.Core/Components/Common/Button.cs @@ -19,22 +19,22 @@ public class Button : Component public Button(string label, bool isEnabled = true, Vector4? color = null, Vector4? hoverColor = null, Vector4? textColor = null) { - Label = label; - IsEnabled = isEnabled; - Color = color ?? ImGuiColors.Blue; - HoverColor = hoverColor ?? ImGuiColors.BlueShade3; - TextColor = textColor ?? ImGuiColors.DalamudWhite; + this.Label = label; + this.IsEnabled = isEnabled; + this.Color = color ?? ImGuiColors.Blue; + this.HoverColor = hoverColor ?? ImGuiColors.BlueShade3; + this.TextColor = textColor ?? ImGuiColors.DalamudWhite; } public override void Draw() { ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(16f, 16f)); ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0); - ImGui.PushStyleColor(ImGuiCol.Button, Color); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, HoverColor); - ImGui.PushStyleColor(ImGuiCol.Text, TextColor); + ImGui.PushStyleColor(ImGuiCol.Button, this.Color); + ImGui.PushStyleColor(ImGuiCol.ButtonHovered, this.HoverColor); + ImGui.PushStyleColor(ImGuiCol.Text, this.TextColor); - if (ImGui.Button(Label, new Vector2(Width ?? -1, 0)) || (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter))) + if (ImGui.Button(this.Label, new Vector2(this.Width ?? -1, 0)) || (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter))) { this.Click?.Invoke(); } diff --git a/src/XIVLauncher.Core/Components/Common/Checkbox.cs b/src/XIVLauncher.Core/Components/Common/Checkbox.cs index cd171801..9c3aab69 100644 --- a/src/XIVLauncher.Core/Components/Common/Checkbox.cs +++ b/src/XIVLauncher.Core/Components/Common/Checkbox.cs @@ -14,17 +14,17 @@ public class Checkbox : Component public bool Value { - get => inputBacking; - set => inputBacking = value; + get => this.inputBacking; + set => this.inputBacking = value; } public event Action? OnChange; public Checkbox(string label, bool value = false, bool isEnabled = true) { - Label = label; - Value = value; - IsEnabled = isEnabled; + this.Label = label; + this.Value = value; + this.IsEnabled = isEnabled; } public override void Draw() @@ -40,7 +40,7 @@ public override void Draw() if (!this.IsEnabled) ImGui.BeginDisabled(); - if (ImGui.Checkbox($"###{Id}", ref inputBacking)) + if (ImGui.Checkbox($"###{this.Id}", ref this.inputBacking)) { this.OnChange?.Invoke(this.inputBacking); } @@ -50,7 +50,7 @@ public override void Draw() ImGui.SameLine(); - ImGui.Text(Label); + ImGui.Text(this.Label); if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) { diff --git a/src/XIVLauncher.Core/Components/Common/Input.cs b/src/XIVLauncher.Core/Components/Common/Input.cs index 9ee1fb05..7d283447 100644 --- a/src/XIVLauncher.Core/Components/Common/Input.cs +++ b/src/XIVLauncher.Core/Components/Common/Input.cs @@ -34,8 +34,8 @@ public class Input : Component public string Value { - get => inputBacking; - set => inputBacking = value; + get => this.inputBacking; + set => this.inputBacking = value; } public Input( @@ -46,19 +46,19 @@ public Input( bool isEnabled = true, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) { - Label = label; - Hint = hint; - MaxLength = maxLength; - Flags = flags; - IsEnabled = isEnabled; - Spacing = spacing ?? Vector2.Zero; + this.Label = label; + this.Hint = hint; + this.MaxLength = maxLength; + this.Flags = flags; + this.IsEnabled = isEnabled; + this.Spacing = spacing ?? Vector2.Zero; - SteamDeckPrompt = hint; + this.SteamDeckPrompt = hint; if (Program.Steam != null) { Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed; - HasSteamDeckInput = Program.IsSteamDeckHardware; + this.HasSteamDeckInput = Program.IsSteamDeckHardware; } } @@ -80,10 +80,10 @@ public override void Draw() ImGui.PushStyleColor(ImGuiCol.TextDisabled, ImGuiColors.TextDisabled); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.Text); - if (TakeKeyboardFocus && ImGui.IsWindowAppearing()) + if (this.TakeKeyboardFocus && ImGui.IsWindowAppearing()) ImGui.SetKeyboardFocusHere(); - ImGui.Text(Label); + ImGui.Text(this.Label); if (!this.IsEnabled || this.isSteamDeckInputActive) ImGui.BeginDisabled(); @@ -93,20 +93,20 @@ public override void Draw() ImGui.PopStyleColor(); - ImGui.InputTextWithHint($"###{Id}", Hint, ref inputBacking, MaxLength, Flags); + ImGui.InputTextWithHint($"###{this.Id}", this.Hint, ref this.inputBacking, this.MaxLength, this.Flags); if (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter)) { Enter?.Invoke(); } - if (ImGui.IsItemActivated() && HasSteamDeckInput && Program.Steam != null && Program.Steam.IsValid) + if (ImGui.IsItemActivated() && this.HasSteamDeckInput && Program.Steam != null && Program.Steam.IsValid) { - this.isSteamDeckInputActive = Program.Steam?.ShowGamepadTextInput(Flags.HasFlag(ImGuiInputTextFlags.Password), false, SteamDeckPrompt, (int)MaxLength, this.inputBacking) ?? false; + this.isSteamDeckInputActive = Program.Steam?.ShowGamepadTextInput(this.Flags.HasFlag(ImGuiInputTextFlags.Password), false, this.SteamDeckPrompt, (int)this.MaxLength, this.inputBacking) ?? false; Log.Information("SteamDeck Input Active({Name}): {IsActive}", this.Label, this.isSteamDeckInputActive); } - ImGui.Dummy(Spacing); + ImGui.Dummy(this.Spacing); if (!this.IsEnabled || this.isSteamDeckInputActive) ImGui.EndDisabled(); diff --git a/src/XIVLauncher.Core/Components/Component.cs b/src/XIVLauncher.Core/Components/Component.cs index a09a3ea5..a5d2bd6d 100644 --- a/src/XIVLauncher.Core/Components/Component.cs +++ b/src/XIVLauncher.Core/Components/Component.cs @@ -8,13 +8,13 @@ public abstract class Component public Margins Margins { get; set; } = new(); - public BlockingCollection Children { get; } = new(); + public BlockingCollection Children { get; } = []; protected Guid Id { get; } = Guid.NewGuid(); public virtual void Draw() { - foreach (var child in Children) + foreach (var child in this.Children) { if (child.Enabled) child.Draw(); diff --git a/src/XIVLauncher.Core/Components/FtsPage.cs b/src/XIVLauncher.Core/Components/FtsPage.cs index fbc6ad42..b9af02de 100644 --- a/src/XIVLauncher.Core/Components/FtsPage.cs +++ b/src/XIVLauncher.Core/Components/FtsPage.cs @@ -24,34 +24,34 @@ public void OpenFtsIfNeeded() { if (CoreEnvironmentSettings.IsDeckFirstRun.Value) { - App.State = LauncherApp.LauncherState.Fts; + this.App.State = LauncherApp.LauncherState.Fts; return; } else return; } - if (!(App.Settings.CompletedFts ?? false) && Program.IsSteamDeckHardware) + if (!(this.App.Settings.CompletedFts ?? false) && Program.IsSteamDeckHardware) { - App.State = LauncherApp.LauncherState.Fts; + this.App.State = LauncherApp.LauncherState.Fts; return; } if (Program.IsSteamDeckHardware && (Program.Steam == null || !Program.Steam.IsValid)) { // If IsIgnoringSteam == true, skip the error screen. This fixes a bug with Steam Deck always showing the Fts Error screen. - if (App.Settings.IsIgnoringSteam ?? false) return; - App.State = LauncherApp.LauncherState.Fts; + if (this.App.Settings.IsIgnoringSteam ?? false) return; + this.App.State = LauncherApp.LauncherState.Fts; this.isSteamDeckAppIdError = true; } } private void FinishFts(bool save) { - App.State = LauncherApp.LauncherState.Main; + this.App.State = LauncherApp.LauncherState.Main; if (save) - App.Settings.CompletedFts = true; + this.App.Settings.CompletedFts = true; } public override void Draw() diff --git a/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs b/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs index 3431bd00..05b661ad 100644 --- a/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs +++ b/src/XIVLauncher.Core/Components/LoadingPage/LoadingPage.cs @@ -38,7 +38,7 @@ public LoadingPage(LauncherApp app) this.disableAutoLoginButton.Click += () => { this.hasDisabledAutoLogin = true; - App.Settings.IsAutologin = false; + this.App.Settings.IsAutologin = false; }; } @@ -54,28 +54,28 @@ public override void Draw() ImGui.SetCursorPosY(vp.Y / 2 - 100); // center text in window - ImGuiHelpers.CenteredText(Line1); + ImGuiHelpers.CenteredText(this.Line1); - if (!string.IsNullOrEmpty(Line2)) + if (!string.IsNullOrEmpty(this.Line2)) { ImGui.Dummy(new Vector2(2)); - ImGuiHelpers.CenteredText(Line2); + ImGuiHelpers.CenteredText(this.Line2); } - if (!string.IsNullOrEmpty(Line3)) + if (!string.IsNullOrEmpty(this.Line3)) { ImGui.Dummy(new Vector2(2)); - ImGuiHelpers.CenteredText(Line3); + ImGuiHelpers.CenteredText(this.Line3); } - var isDrawDisableAutoLogin = CanDisableAutoLogin && (App.Settings.IsAutologin ?? false); + var isDrawDisableAutoLogin = this.CanDisableAutoLogin && (this.App.Settings.IsAutologin ?? false); - if (CanCancel || isDrawDisableAutoLogin) + if (this.CanCancel || isDrawDisableAutoLogin) { ImGui.Dummy(new Vector2(20)); } - if (CanCancel) + if (this.CanCancel) { this.cancelButton.Width = (int)vp.X / 4; ImGuiHelpers.CenterCursorFor(this.cancelButton.Width.Value); @@ -95,7 +95,7 @@ public override void Draw() ImGui.Dummy(new Vector2(20)); - if (IsIndeterminate) + if (this.IsIndeterminate) { ImGuiHelpers.CenterCursorFor(SPINNER_RADIUS * 2); this.spinner.Draw(); @@ -104,7 +104,7 @@ public override void Draw() { var width = vp.X / 3; ImGuiHelpers.CenterCursorFor((int)width); - ImGui.ProgressBar(Progress, new Vector2(width, 20), ProgressText); + ImGui.ProgressBar(this.Progress, new Vector2(width, 20), this.ProgressText); } Program.Invalidate(10); diff --git a/src/XIVLauncher.Core/Components/LoadingPage/Spinner.cs b/src/XIVLauncher.Core/Components/LoadingPage/Spinner.cs index 9d512ab8..1c208753 100644 --- a/src/XIVLauncher.Core/Components/LoadingPage/Spinner.cs +++ b/src/XIVLauncher.Core/Components/LoadingPage/Spinner.cs @@ -31,18 +31,18 @@ public override void Draw() var aMin = Math.PI * 2.0f * ((float)start) / (float)NUM_SEGMENTS; var aMax = Math.PI * 2.0f * ((float)NUM_SEGMENTS - 3) / (float)NUM_SEGMENTS; - var centre = new Vector2(pos.X + radius, pos.Y + radius + framePadding.Y); + var centre = new Vector2(pos.X + this.radius, pos.Y + this.radius + framePadding.Y); var drawList = ImGui.GetWindowDrawList(); for (var i = 0; i < NUM_SEGMENTS; i++) { var a = aMin + (i / (float)NUM_SEGMENTS) * (aMax - aMin); - drawList.PathLineTo(new Vector2((float)(centre.X + Math.Cos(a + time * 8) * radius), - (float)(centre.Y + Math.Sin(a + time * 8) * radius))); + drawList.PathLineTo(new Vector2((float)(centre.X + Math.Cos(a + time * 8) * this.radius), + (float)(centre.Y + Math.Sin(a + time * 8) * this.radius))); } - drawList.PathStroke(this.color, ImDrawFlags.RoundCornersAll, thickness); + drawList.PathStroke(this.color, ImDrawFlags.RoundCornersAll, this.thickness); base.Draw(); } diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 9a5a5ed7..60e0b430 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -51,12 +51,12 @@ public MainPage(LauncherApp app) this.Padding = new Vector2(32f, 32f); - var savedAccount = App.Accounts.CurrentAccount; + var savedAccount = this.App.Accounts.CurrentAccount; if (savedAccount != null) this.SwitchAccount(savedAccount, false); if (PlatformHelpers.IsElevated()) - App.ShowMessage("XIVLauncher is running as administrator/root user.\nThis can cause various issues, including but not limited to addons failing to launch and hotkey applications failing to respond.\n\nPlease take care to avoid running XIVLauncher with elevated privileges", "XIVLauncher"); + this.App.ShowMessage("XIVLauncher is running as administrator/root user.\nThis can cause various issues, including but not limited to addons failing to launch and hotkey applications failing to respond.\n\nPlease take care to avoid running XIVLauncher with elevated privileges", "XIVLauncher"); Troubleshooting.LogTroubleshooting(); } @@ -65,10 +65,10 @@ public MainPage(LauncherApp app) public void DoAutoLoginIfApplicable() { - Debug.Assert(App.State == LauncherApp.LauncherState.Main); + Debug.Assert(this.App.State == LauncherApp.LauncherState.Main); - if ((App.Settings.IsAutologin ?? false) && !string.IsNullOrEmpty(this.loginFrame.Username) && !string.IsNullOrEmpty(this.loginFrame.Password)) - ProcessLogin(LoginAction.Game); + if ((this.App.Settings.IsAutologin ?? false) && !string.IsNullOrEmpty(this.loginFrame.Username) && !string.IsNullOrEmpty(this.loginFrame.Password)) + this.ProcessLogin(LoginAction.Game); } public override void Draw() @@ -93,20 +93,20 @@ private void SwitchAccount(XivAccount account, bool saveAsCurrent) this.loginFrame.Username = account.UserName; this.loginFrame.IsOtp = account.UseOtp; this.loginFrame.IsSteam = account.UseSteamServiceAccount; - this.loginFrame.IsAutoLogin = App.Settings.IsAutologin ?? false; + this.loginFrame.IsAutoLogin = this.App.Settings.IsAutologin ?? false; if (account.SavePassword) this.loginFrame.Password = account.Password; if (saveAsCurrent) { - App.Accounts.CurrentAccount = account; + this.App.Accounts.CurrentAccount = account; } } private void AccountSwitcherOnAccountChanged(object? sender, XivAccount e) { - SwitchAccount(e, true); + this.SwitchAccount(e, true); } private void ProcessLogin(LoginAction action) @@ -123,16 +123,16 @@ private void ProcessLogin(LoginAction action) { if (GameHelpers.CheckIsGameOpen() && action == LoginAction.Repair) { - App.ShowMessageBlocking("The game and/or the official launcher are open. XIVLauncher cannot repair the game if this is the case.\nPlease close them and try again.", "XIVLauncher"); + this.App.ShowMessageBlocking("The game and/or the official launcher are open. XIVLauncher cannot repair the game if this is the case.\nPlease close them and try again.", "XIVLauncher"); - Reactivate(); + this.Reactivate(); return; } - if (Repository.Ffxiv.GetVer(App.Settings.GamePath) == Constants.BASE_GAME_VERSION && - App.Settings.IsUidCacheEnabled == true) + if (Repository.Ffxiv.GetVer(this.App.Settings.GamePath) == Constants.BASE_GAME_VERSION && + this.App.Settings.IsUidCacheEnabled == true) { - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( "You enabled the UID cache in the patcher settings.\nThis setting does not allow you to reinstall FFXIV.\n\nIf you want to reinstall FFXIV, please take care to disable it first.", "XIVLauncher Error"); @@ -140,11 +140,11 @@ private void ProcessLogin(LoginAction action) return; } - IsLoggingIn = true; + this.IsLoggingIn = true; - App.Settings.IsAutologin = this.loginFrame.IsAutoLogin; + this.App.Settings.IsAutologin = this.loginFrame.IsAutoLogin; - var result = await Login(loginFrame.Username, loginFrame.Password, loginFrame.IsOtp, loginFrame.IsSteam, false, action).ConfigureAwait(false); + var result = await this.Login(this.loginFrame.Username, this.loginFrame.Password, this.loginFrame.IsOtp, this.loginFrame.IsSteam, false, action).ConfigureAwait(false); if (result) { @@ -157,7 +157,7 @@ private void ProcessLogin(LoginAction action) } }).ContinueWith(t => { - if (!App.HandleContinuationBlocking(t)) + if (!this.App.HandleContinuationBlocking(t)) this.Reactivate(); }); } @@ -172,12 +172,12 @@ public async Task Login(string username, string password, bool isOtp, bool else gameRunner = new UnixGameRunner(Program.CompatibilityTools, null, false); - App.Launcher.LaunchGame(gameRunner, "0", 1, 2, false, "", App.Settings.GamePath!, ClientLanguage.Japanese, true, DpiAwareness.Unaware); + this.App.Launcher.LaunchGame(gameRunner, "0", 1, 2, false, "", this.App.Settings.GamePath!, ClientLanguage.Japanese, true, DpiAwareness.Unaware); return false; } - var bootRes = await HandleBootCheck().ConfigureAwait(false); + var bootRes = await this.HandleBootCheck().ConfigureAwait(false); if (!bootRes) return false; @@ -186,22 +186,22 @@ public async Task Login(string username, string password, bool isOtp, bool if (isOtp) { - App.AskForOtp(); - otp = App.WaitForOtp(); + this.App.AskForOtp(); + otp = this.App.WaitForOtp(); // Make sure we are loading again - App.State = LauncherApp.LauncherState.Loading; + this.App.State = LauncherApp.LauncherState.Loading; Program.Invalidate(10); } if (otp == null) return false; - PersistAccount(username, password, isOtp, isSteam); + this.PersistAccount(username, password, isOtp, isSteam); - var loginResult = await TryLoginToGame(username, password, otp, isSteam, action).ConfigureAwait(false); + var loginResult = await this.TryLoginToGame(username, password, otp, isSteam, action).ConfigureAwait(false); - return await TryProcessLoginResult(loginResult, isSteam, action).ConfigureAwait(false); + return await this.TryProcessLoginResult(loginResult, isSteam, action).ConfigureAwait(false); } private async Task TryLoginToGame(string username, string password, string otp, bool isSteam, LoginAction action) @@ -228,13 +228,13 @@ public async Task Login(string username, string password, bool isOtp, bool try { - var enableUidCache = App.Settings.IsUidCacheEnabled ?? false; - var gamePath = App.Settings.GamePath!; + var enableUidCache = this.App.Settings.IsUidCacheEnabled ?? false; + var gamePath = this.App.Settings.GamePath!; if (action == LoginAction.Repair) - return await App.Launcher.Login(username, password, otp, isSteam, false, gamePath, true, App.Settings.IsFt.GetValueOrDefault(false)).ConfigureAwait(false); + return await this.App.Launcher.Login(username, password, otp, isSteam, false, gamePath, true, this.App.Settings.IsFt.GetValueOrDefault(false)).ConfigureAwait(false); else - return await App.Launcher.Login(username, password, otp, isSteam, enableUidCache, gamePath, false, App.Settings.IsFt.GetValueOrDefault(false)).ConfigureAwait(false); + return await this.App.Launcher.Login(username, password, otp, isSteam, enableUidCache, gamePath, false, this.App.Settings.IsFt.GetValueOrDefault(false)).ConfigureAwait(false); } catch (Exception ex) { @@ -289,7 +289,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, { if (loginResult.State == Launcher.LoginState.NeedsPatchGame) { - if (!await RepairGame(loginResult).ConfigureAwait(false)) + if (!await this.RepairGame(loginResult).ConfigureAwait(false)) return false; loginResult.State = Launcher.LoginState.Ok; @@ -319,7 +319,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, if (loginResult.State == Launcher.LoginState.NeedsPatchGame) { - if (!await InstallGamePatch(loginResult).ConfigureAwait(false)) + if (!await this.InstallGamePatch(loginResult).ConfigureAwait(false)) { Log.Error("patchSuccess != true"); return false; @@ -330,7 +330,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, if (action == LoginAction.GameNoLaunch) { - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( Loc.Localize("LoginNoStartOk", "An update check was executed and any pending updates were installed."), "XIVLauncher"); @@ -365,16 +365,16 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, while (true) { - List exceptions = new(); + List exceptions = []; try { - using var process = await StartGameAndAddon(loginResult, isSteam, action == LoginAction.GameNoDalamud, action == LoginAction.GameNoThirdparty).ConfigureAwait(false); + using var process = await this.StartGameAndAddon(loginResult, isSteam, action == LoginAction.GameNoDalamud, action == LoginAction.GameNoThirdparty).ConfigureAwait(false); if (process is null) throw new InvalidOperationException("Could not obtain Process Handle"); - if (process.ExitCode != 0 && (App.Settings.TreatNonZeroExitCodeAsFailure ?? false)) + if (process.ExitCode != 0 && (this.App.Settings.TreatNonZeroExitCodeAsFailure ?? false)) { throw new InvalidOperationException("Game exited with non-zero exit code"); @@ -618,9 +618,9 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b Troubleshooting.LogTroubleshooting(); var dalamudLauncher = new DalamudLauncher(dalamudRunner, Program.DalamudUpdater, - App.Settings.DalamudLoadMethod.GetValueOrDefault(DalamudLoadMethod.DllInject), App.Settings.GamePath, - App.Storage.Root, App.Storage.GetFolder("logs"), App.Settings.ClientLanguage ?? ClientLanguage.English, - App.Settings.DalamudLoadDelay, false, false, noThird, Troubleshooting.GetTroubleshootingJson()); + this.App.Settings.DalamudLoadMethod.GetValueOrDefault(DalamudLoadMethod.DllInject), this.App.Settings.GamePath, + this.App.Storage.Root, this.App.Storage.GetFolder("logs"), this.App.Settings.ClientLanguage ?? ClientLanguage.English, + this.App.Settings.DalamudLoadDelay, false, false, noThird, Troubleshooting.GetTroubleshootingJson()); try { @@ -651,12 +651,12 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b */ } - if (App.Settings.DalamudEnabled.GetValueOrDefault(true) && !forceNoDalamud) + if (this.App.Settings.DalamudEnabled.GetValueOrDefault(true) && !forceNoDalamud) { try { - App.StartLoading("Waiting for Dalamud to be ready...", "This may take a little while. Please hold!"); - dalamudOk = dalamudLauncher.HoldForUpdate(App.Settings.GamePath) == DalamudLauncher.DalamudInstallState.Ok; + this.App.StartLoading("Waiting for Dalamud to be ready...", "This may take a little while. Please hold!"); + dalamudOk = dalamudLauncher.HoldForUpdate(this.App.Settings.GamePath) == DalamudLauncher.DalamudInstallState.Ok; } catch (DalamudRunnerException ex) { @@ -692,27 +692,27 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b } // Hack: Force C.utf8 to fix incorrect unicode paths - if (App.Settings.FixLocale == true && !string.IsNullOrEmpty(Program.CType)) + if (this.App.Settings.FixLocale == true && !string.IsNullOrEmpty(Program.CType)) { System.Environment.SetEnvironmentVariable("LC_ALL", Program.CType); System.Environment.SetEnvironmentVariable("LC_CTYPE", Program.CType); } // Hack: Strip out gameoverlayrenderer.so entries from LD_PRELOAD - if (App.Settings.FixLDP == true) + if (this.App.Settings.FixLDP == true) { var ldpreload = CoreEnvironmentSettings.GetCleanEnvironmentVariable("LD_PRELOAD", "gameoverlayrenderer.so"); System.Environment.SetEnvironmentVariable("LD_PRELOAD", ldpreload); } // Hack: XMODIFIERS=@im=null - if (App.Settings.FixIM == true) + if (this.App.Settings.FixIM == true) { System.Environment.SetEnvironmentVariable("XMODIFIERS", "@im=null"); } // Deal with "Additional Arguments". VAR=value %command% -args - var launchOptions = (App.Settings.AdditionalArgs ?? string.Empty).Split("%command%", 2); + var launchOptions = (this.App.Settings.AdditionalArgs ?? string.Empty).Split("%command%", 2); var launchEnv = ""; var gameArgs = ""; @@ -751,16 +751,16 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b } else if (Environment.OSVersion.Platform == PlatformID.Unix) { - if (App.Settings.WineStartupType == WineStartupType.Custom) + if (this.App.Settings.WineStartupType == WineStartupType.Custom) { - if (App.Settings.WineBinaryPath == null) + if (this.App.Settings.WineBinaryPath == null) throw new InvalidOperationException("Custom wine binary path wasn't set."); - else if (!Directory.Exists(App.Settings.WineBinaryPath)) + else if (!Directory.Exists(this.App.Settings.WineBinaryPath)) throw new InvalidOperationException("Custom wine binary path is invalid: no such directory.\n" + - "Check path carefully for typos: " + App.Settings.WineBinaryPath); - else if (!File.Exists(Path.Combine(App.Settings.WineBinaryPath, "wine64"))) + "Check path carefully for typos: " + this.App.Settings.WineBinaryPath); + else if (!File.Exists(Path.Combine(this.App.Settings.WineBinaryPath, "wine64"))) throw new InvalidOperationException("Custom wine binary path is invalid: no wine64 found at that location.\n" + - "Check path carefully for typos: " + App.Settings.WineBinaryPath); + "Check path carefully for typos: " + this.App.Settings.WineBinaryPath); } var signal = new ManualResetEvent(false); @@ -768,20 +768,20 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b var _ = Task.Run(async () => { - var tempPath = App.Storage.GetFolder("temp"); - var winver = (App.Settings.SetWin7 ?? true) ? "win7" : "win10"; + var tempPath = this.App.Storage.GetFolder("temp"); + var winver = (this.App.Settings.SetWin7 ?? true) ? "win7" : "win10"; await Program.CompatibilityTools.EnsureTool(tempPath).ConfigureAwait(false); Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); - var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Settings.Prefix, tempPath); + var gameFixApply = new GameFixApply(this.App.Settings.GamePath, this.App.Settings.GameConfigPath, Program.CompatibilityTools.Settings.Prefix, tempPath); gameFixApply.UpdateProgress += (text, hasProgress, progress) => { - App.LoadingPage.Line1 = "Applying game-specific fixes..."; - App.LoadingPage.Line2 = text; - App.LoadingPage.Line3 = "This may take a little while. Please hold!"; - App.LoadingPage.IsIndeterminate = !hasProgress; - App.LoadingPage.Progress = progress; + this.App.LoadingPage.Line1 = "Applying game-specific fixes..."; + this.App.LoadingPage.Line2 = text; + this.App.LoadingPage.Line3 = "This may take a little while. Please hold!"; + this.App.LoadingPage.IsIndeterminate = !hasProgress; + this.App.LoadingPage.Progress = progress; }; gameFixApply.Run(); @@ -795,21 +795,21 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b signal.Set(); }); - App.StartLoading("Ensuring compatibility tool...", "This may take a little while. Please hold!"); + this.App.StartLoading("Ensuring compatibility tool...", "This may take a little while. Please hold!"); signal.WaitOne(); signal.Dispose(); if (isFailed) return null!; - App.StartLoading("Starting game...", "Have fun!"); + this.App.StartLoading("Starting game...", "Have fun!"); runner = new UnixGameRunner(Program.CompatibilityTools, dalamudLauncher, dalamudOk); // SE has its own way of encoding spaces when encrypting arguments, which interferes // with quoting, but they are necessary when passing paths unencrypted - var userPath = Program.CompatibilityTools.UnixToWinePath(App.Settings.GameConfigPath!.FullName); - if (App.Settings.IsEncryptArgs.GetValueOrDefault(true)) + var userPath = Program.CompatibilityTools.UnixToWinePath(this.App.Settings.GameConfigPath!.FullName); + if (this.App.Settings.IsEncryptArgs.GetValueOrDefault(true)) gameArgs += $" UserPath={userPath}"; else gameArgs += $" UserPath=\"{userPath}\""; @@ -822,32 +822,32 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b } // We won't do any sanity checks here anymore, since that should be handled in StartLogin - var launchedProcess = App.Launcher.LaunchGame(runner, + var launchedProcess = this.App.Launcher.LaunchGame(runner, loginResult.UniqueId, loginResult.OauthLogin.Region, loginResult.OauthLogin.MaxExpansion, isSteam, gameArgs, - App.Settings.GamePath, - App.Settings.ClientLanguage.GetValueOrDefault(ClientLanguage.English), - App.Settings.IsEncryptArgs.GetValueOrDefault(true), - App.Settings.DpiAwareness.GetValueOrDefault(DpiAwareness.Unaware)); + this.App.Settings.GamePath, + this.App.Settings.ClientLanguage.GetValueOrDefault(ClientLanguage.English), + this.App.Settings.IsEncryptArgs.GetValueOrDefault(true), + this.App.Settings.DpiAwareness.GetValueOrDefault(DpiAwareness.Unaware)); // Hide the launcher if not Steam Deck or if using as a compatibility tool (XLM) // Show the Steam Deck prompt if on steam deck and not using as a compatibility tool if (!Program.IsSteamDeckHardware || CoreEnvironmentSettings.IsSteamCompatTool) { - Hide(); + this.Hide(); } else { - App.State = LauncherApp.LauncherState.SteamDeckPrompt; + this.App.State = LauncherApp.LauncherState.SteamDeckPrompt; } if (launchedProcess == null) { Log.Information("GameProcess was null..."); - IsLoggingIn = false; + this.IsLoggingIn = false; return null!; } @@ -855,9 +855,9 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b try { - App.Settings.Addons ??= new List(); + this.App.Settings.Addons ??= []; - var addons = App.Settings.Addons.Where(x => x.IsEnabled).Select(x => x.Addon).Cast().ToList(); + var addons = this.App.Settings.Addons.Where(x => x.IsEnabled).Select(x => x.Addon).Cast().ToList(); addonMgr.RunAddons(launchedProcess.Id, addons); } @@ -873,7 +873,7 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b .Show(); */ - IsLoggingIn = false; + this.IsLoggingIn = false; addonMgr.StopAddons(); throw; @@ -890,9 +890,9 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b try { - if (App.Steam?.IsValid == true) + if (this.App.Steam?.IsValid == true) { - App.Steam.Shutdown(); + this.App.Steam.Shutdown(); } } catch (Exception ex) @@ -905,13 +905,13 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b private void PersistAccount(string username, string password, bool isOtp, bool isSteam) { - if (App.Accounts.CurrentAccount != null && App.Accounts.CurrentAccount.UserName.Equals(username, StringComparison.Ordinal) && - App.Accounts.CurrentAccount.Password != password && - App.Accounts.CurrentAccount.SavePassword) - App.Accounts.UpdatePassword(App.Accounts.CurrentAccount, password); + if (this.App.Accounts.CurrentAccount != null && this.App.Accounts.CurrentAccount.UserName.Equals(username, StringComparison.Ordinal) && + this.App.Accounts.CurrentAccount.Password != password && + this.App.Accounts.CurrentAccount.SavePassword) + this.App.Accounts.UpdatePassword(this.App.Accounts.CurrentAccount, password); - if (App.Accounts.CurrentAccount == null || - App.Accounts.CurrentAccount.Id != $"{username}-{isOtp}-{isSteam}") + if (this.App.Accounts.CurrentAccount == null || + this.App.Accounts.CurrentAccount.Id != $"{username}-{isOtp}-{isSteam}") { var accountToSave = new XivAccount(username) { @@ -921,9 +921,9 @@ private void PersistAccount(string username, string password, bool isOtp, bool i UseSteamServiceAccount = isSteam }; - App.Accounts.AddAccount(accountToSave); + this.App.Accounts.AddAccount(accountToSave); - App.Accounts.CurrentAccount = accountToSave; + this.App.Accounts.CurrentAccount = accountToSave; } } @@ -931,23 +931,23 @@ private async Task HandleBootCheck() { try { - if (App.Settings.PatchPath is { Exists: false }) + if (this.App.Settings.PatchPath is { Exists: false }) { - App.Settings.PatchPath = null; + this.App.Settings.PatchPath = null; } - App.Settings.PatchPath ??= new DirectoryInfo(Path.Combine(Paths.RoamingPath, "patches")); + this.App.Settings.PatchPath ??= new DirectoryInfo(Path.Combine(Paths.RoamingPath, "patches")); PatchListEntry[] bootPatches; try { - bootPatches = await App.Launcher.CheckBootVersion(App.Settings.GamePath!).ConfigureAwait(false); + bootPatches = await this.App.Launcher.CheckBootVersion(this.App.Settings.GamePath!).ConfigureAwait(false); } catch (Exception ex) { Log.Error(ex, "Unable to check boot version"); - App.ShowMessage( + this.App.ShowMessage( Loc.Localize("CheckBootVersionError", "XIVLauncher was not able to check the boot version for the select game installation. This can happen if a maintenance is currently in progress or if your connection to the version check server is not available. Please report this error if you are able to login with the official launcher, but not XIVLauncher."), "XIVLauncher"); @@ -958,11 +958,11 @@ private async Task HandleBootCheck() if (bootPatches.Length == 0) return true; - return await TryHandlePatchAsync(Repository.Boot, bootPatches, "").ConfigureAwait(false); + return await this.TryHandlePatchAsync(Repository.Boot, bootPatches, "").ConfigureAwait(false); } catch (Exception ex) { - App.ShowExceptionBlocking(ex, "PatchBoot"); + this.App.ShowExceptionBlocking(ex, "PatchBoot"); Environment.Exit(0); return false; @@ -976,7 +976,7 @@ private Task InstallGamePatch(Launcher.LoginResult loginResult) Debug.Assert(loginResult.PendingPatches != null, "loginResult.PendingPatches != null ASSERTION FAILED"); - return TryHandlePatchAsync(Repository.Ffxiv, loginResult.PendingPatches, loginResult.UniqueId); + return this.TryHandlePatchAsync(Repository.Ffxiv, loginResult.PendingPatches, loginResult.UniqueId); } private async Task TryHandlePatchAsync(Repository repository, PatchListEntry[] pendingPatches, string sid) @@ -996,7 +996,7 @@ private async Task TryHandlePatchAsync(Repository repository, PatchListEnt if (GameHelpers.CheckIsGameOpen()) { - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( Loc.Localize("GameIsOpenError", "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."), "XIVLauncher"); @@ -1004,10 +1004,10 @@ private async Task TryHandlePatchAsync(Repository repository, PatchListEnt return false; } - using var installer = new PatchInstaller(App.Settings.KeepPatches ?? false); - Program.Patcher = new PatchManager(App.Settings.PatchAcquisitionMethod ?? AcquisitionMethod.Aria, App.Settings.PatchSpeedLimit, repository, pendingPatches, App.Settings.GamePath, - App.Settings.PatchPath, installer, App.Launcher, sid); - Program.Patcher.OnFail += PatcherOnFail; + using var installer = new PatchInstaller(this.App.Settings.KeepPatches ?? false); + Program.Patcher = new PatchManager(this.App.Settings.PatchAcquisitionMethod ?? AcquisitionMethod.Aria, this.App.Settings.PatchSpeedLimit, repository, pendingPatches, this.App.Settings.GamePath, + this.App.Settings.PatchPath, installer, this.App.Launcher, sid); + Program.Patcher.OnFail += this.PatcherOnFail; installer.OnFail += this.InstallerOnFail; /* @@ -1039,17 +1039,17 @@ void UpdatePatchStatus() { Thread.Sleep(30); - App.LoadingPage.Line2 = string.Format("Working on {0}/{1}", Program.Patcher.CurrentInstallIndex, Program.Patcher.Downloads.Count); - App.LoadingPage.Line3 = string.Format("{0} left to download at {1}/s", ApiHelpers.BytesToString(Program.Patcher.AllDownloadsLength < 0 ? 0 : Program.Patcher.AllDownloadsLength), + this.App.LoadingPage.Line2 = string.Format("Working on {0}/{1}", Program.Patcher.CurrentInstallIndex, Program.Patcher.Downloads.Count); + this.App.LoadingPage.Line3 = string.Format("{0} left to download at {1}/s", ApiHelpers.BytesToString(Program.Patcher.AllDownloadsLength < 0 ? 0 : Program.Patcher.AllDownloadsLength), ApiHelpers.BytesToString(Program.Patcher.Speeds.Sum())); - App.LoadingPage.Progress = Program.Patcher.CurrentInstallIndex / (float)Program.Patcher.Downloads.Count; + this.App.LoadingPage.Progress = Program.Patcher.CurrentInstallIndex / (float)Program.Patcher.Downloads.Count; } } try { - var aria2LogFile = new FileInfo(Path.Combine(App.Storage.GetFolder("logs").FullName, "launcher.log")); + var aria2LogFile = new FileInfo(Path.Combine(this.App.Storage.GetFolder("logs").FullName, "launcher.log")); await Program.Patcher.PatchAsync(aria2LogFile, false).ConfigureAwait(false); } finally @@ -1065,14 +1065,14 @@ void UpdatePatchStatus() var message = Loc.Localize("PatchManNoInstaller", "The patch installer could not start correctly.\n{0}\n\nIf you have denied access to it, please try again. If this issue persists, please contact us via Discord."); - App.ShowMessageBlocking(string.Format(message, ex.Message), "XIVLauncher Error"); + this.App.ShowMessageBlocking(string.Format(message, ex.Message), "XIVLauncher Error"); } catch (NotEnoughSpaceException sex) { switch (sex.Kind) { case NotEnoughSpaceException.SpaceKind.Patches: - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( string.Format( Loc.Localize("FreeSpaceError", "There is not enough space on your drive to download patches.\n\nYou can change the location patches are downloaded to in the settings.\n\nRequired:{0}\nFree:{1}"), @@ -1080,7 +1080,7 @@ void UpdatePatchStatus() break; case NotEnoughSpaceException.SpaceKind.AllPatches: - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( string.Format( Loc.Localize("FreeSpaceErrorAll", "There is not enough space on your drive to download all patches.\n\nYou can change the location patches are downloaded to in the XIVLauncher settings.\n\nRequired:{0}\nFree:{1}"), @@ -1088,7 +1088,7 @@ void UpdatePatchStatus() break; case NotEnoughSpaceException.SpaceKind.Game: - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( string.Format( Loc.Localize("FreeSpaceGameError", "There is not enough space on your drive to install patches.\n\nYou can change the location the game is installed to in the settings.\n\nRequired:{0}\nFree:{1}"), @@ -1103,11 +1103,11 @@ void UpdatePatchStatus() catch (Exception ex) { Log.Error(ex, "Error during patching"); - App.ShowExceptionBlocking(ex, "HandlePatchAsync"); + this.App.ShowExceptionBlocking(ex, "HandlePatchAsync"); } finally { - App.State = LauncherApp.LauncherState.Main; + this.App.State = LauncherApp.LauncherState.Main; } return false; @@ -1118,14 +1118,14 @@ private void PatcherOnFail(PatchListEntry patch, string context) var dlFailureLoc = Loc.Localize("PatchManDlFailure", "XIVLauncher could not verify the downloaded game files. Please restart and try again.\n\nThis usually indicates a problem with your internet connection.\nIf this error persists, try using a VPN set to Japan.\n\nContext: {0}\n{1}"); - App.ShowMessageBlocking(string.Format(dlFailureLoc, context, patch.VersionId), "XIVLauncher Error"); + this.App.ShowMessageBlocking(string.Format(dlFailureLoc, context, patch.VersionId), "XIVLauncher Error"); Environment.Exit(0); } private void InstallerOnFail() { - App.ShowMessageBlocking( + this.App.ShowMessageBlocking( Loc.Localize("PatchInstallerInstallFailed", "The patch installer ran into an error.\nPlease report this error.\n\nPlease try again or use the official launcher."), "XIVLauncher Error"); @@ -1198,7 +1198,7 @@ private async Task RepairGame(Launcher.LoginResult loginResult) { case PatchVerifier.VerifyState.Done: // TODO: ask the user if they want to login or rerun after repair - App.ShowMessageBlocking(verify.NumBrokenFiles switch + this.App.ShowMessageBlocking(verify.NumBrokenFiles switch { 0 => Loc.Localize("GameRepairSuccess0", "All game files seem to be valid."), 1 => Loc.Localize("GameRepairSuccess1", "XIVLauncher has successfully repaired 1 game file."), @@ -1213,12 +1213,12 @@ private async Task RepairGame(Launcher.LoginResult loginResult) if (verify.LastException is NoVersionReferenceException) { - App.ShowMessageBlocking(Loc.Localize("NoVersionReferenceError", + this.App.ShowMessageBlocking(Loc.Localize("NoVersionReferenceError", "The version of the game you are on cannot be repaired by XIVLauncher yet, as reference information is not yet available.\nPlease try again later.")); } else { - App.ShowMessageBlocking(verify.LastException + "\n\n" + Loc.Localize("GameRepairError", "An error occurred while repairing the game files.\nYou may have to reinstall the game.")); + this.App.ShowMessageBlocking(verify.LastException + "\n\n" + Loc.Localize("GameRepairError", "An error occurred while repairing the game files.\nYou may have to reinstall the game.")); } doVerify = false; @@ -1241,7 +1241,7 @@ private void Hide() private void Reactivate() { - IsLoggingIn = false; + this.IsLoggingIn = false; this.App.State = LauncherApp.LauncherState.Main; Program.ShowWindow(); diff --git a/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs b/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs index 9634a4e6..6f6aaddd 100644 --- a/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs +++ b/src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs @@ -15,7 +15,7 @@ public class NewsFrame : Component private readonly Timer bannerTimer; private Headlines? headlines; - private TextureWrap[] banners = { }; + private TextureWrap[] banners = []; private IReadOnlyList bannerList = new List(); @@ -28,8 +28,8 @@ public NewsFrame(LauncherApp app) this.app = app; this.ReloadNews(); - this.bannerTimer = new Timer(TimerElapsed); - bannerTimer.Change(0, BANNER_TIME); + this.bannerTimer = new Timer(this.TimerElapsed); + this.bannerTimer.Change(0, BANNER_TIME); } private void TimerElapsed(object? state) @@ -49,16 +49,16 @@ public void ReloadNews() await Headlines.GetWorlds(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false); - bannerList = await Headlines.GetBanners(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false); + this.bannerList = await Headlines.GetBanners(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false); await Headlines.GetMessage(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false); - headlines = await Headlines.GetNews(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false); + this.headlines = await Headlines.GetNews(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false); - this.banners = new TextureWrap[bannerList.Count]; + this.banners = new TextureWrap[this.bannerList.Count]; - for (var i = 0; i < bannerList.Count; i++) + for (var i = 0; i < this.bannerList.Count; i++) { var textureBytes = await Program.HttpClient.GetByteArrayAsync(this.bannerList[i].LsbBanner).ConfigureAwait(false); this.banners[i] = TextureWrap.Load(textureBytes); diff --git a/src/XIVLauncher.Core/Components/OtpEntryPage.cs b/src/XIVLauncher.Core/Components/OtpEntryPage.cs index a5590286..0060be3c 100644 --- a/src/XIVLauncher.Core/Components/OtpEntryPage.cs +++ b/src/XIVLauncher.Core/Components/OtpEntryPage.cs @@ -29,7 +29,7 @@ private void SteamOnOnGamepadTextInputDismissed(bool success) { if (success) { - if (Program.Steam is not null) Result = Program.Steam.GetEnteredGamepadText(); + if (Program.Steam is not null) this.Result = Program.Steam.GetEnteredGamepadText(); } } @@ -42,16 +42,16 @@ public void Reset() // TODO(goat): This doesn't work if you call it right after starting the app... Steam probably takes a little while to initialize. Might be annoying for autologin. // BUG: We have to turn this off when using OTP server, because there's no way to dismiss open keyboards - if (Program.Steam != null && Program.Steam.IsValid && Program.IsSteamDeckHardware && App.Settings.IsOtpServer is false) + if (Program.Steam != null && Program.Steam.IsValid && Program.IsSteamDeckHardware && this.App.Settings.IsOtpServer is false) { var success = Program.Steam.ShowGamepadTextInput(false, false, "Please enter your OTP", 6, string.Empty); Log.Verbose("ShowGamepadTextInput: {Success}", success); } - if (App.Settings.IsOtpServer ?? false) + if (this.App.Settings.IsOtpServer ?? false) { this.otpListener = new OtpListener("core-" + AppUtil.GetAssemblyVersion()); - this.otpListener.OnOtpReceived += TryAcceptOtp; + this.otpListener.OnOtpReceived += this.TryAcceptOtp; try { @@ -112,7 +112,7 @@ public override void Draw() if (ImGui.Button("OK", buttonSize) || doEnter) { - TryAcceptOtp(this.otp); + this.TryAcceptOtp(this.otp); } ImGui.SameLine(); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/NumericSettingsEntry.cs b/src/XIVLauncher.Core/Components/SettingsPage/NumericSettingsEntry.cs index f3db9275..d20aba95 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/NumericSettingsEntry.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/NumericSettingsEntry.cs @@ -22,7 +22,7 @@ public override void Draw() ImGuiHelpers.TextWrapped(this.Name); - if (ImGui.InputInt(string.Empty, ref nativeValue, Step)) + if (ImGui.InputInt(string.Empty, ref nativeValue, this.Step)) { this.InternalValue = Math.Max(this.MinValue, Math.Min(this.MaxValue, nativeValue)); } diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsEntry{T}.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsEntry{T}.cs index 20ce9b33..1e2df187 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsEntry{T}.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsEntry{T}.cs @@ -20,7 +20,7 @@ public class SettingsEntry : SettingsEntry public Func? CheckVisibility { get; init; } - public override bool IsVisible => CheckVisibility?.Invoke() ?? true; + public override bool IsVisible => this.CheckVisibility?.Invoke() ?? true; public T? Value => this.InternalValue == default ? default : (T)this.InternalValue; @@ -43,7 +43,7 @@ public override void Draw() var value = this.Value as DirectoryInfo; var nativeBuffer = value?.FullName ?? string.Empty; - if (ImGui.InputText($"###{Id.ToString()}", ref nativeBuffer, 10000)) + if (ImGui.InputText($"###{this.Id.ToString()}", ref nativeBuffer, 10000)) { this.InternalValue = !string.IsNullOrEmpty(nativeBuffer) ? new DirectoryInfo(nativeBuffer) : null; } @@ -54,7 +54,7 @@ public override void Draw() var nativeBuffer = this.Value as string ?? string.Empty; - if (ImGui.InputText($"###{Id.ToString()}", ref nativeBuffer, 1000)) + if (ImGui.InputText($"###{this.Id.ToString()}", ref nativeBuffer, 1000)) { this.InternalValue = nativeBuffer; } @@ -63,7 +63,7 @@ public override void Draw() { var nativeValue = this.Value as bool? ?? false; - if (ImGui.Checkbox($"{Name}###{Id.ToString()}", ref nativeValue)) + if (ImGui.Checkbox($"{this.Name}###{this.Id.ToString()}", ref nativeValue)) { this.InternalValue = nativeValue; } @@ -76,7 +76,7 @@ public override void Draw() var values = Enum.GetValues(type); var descriptions = values.Cast().Select(x => x.GetAttribute() ?? new SettingsDescriptionAttribute(x.ToString(), string.Empty)).ToArray(); - if (ImGui.BeginCombo($"###{Id.ToString()}", descriptions[idx].FriendlyName)) + if (ImGui.BeginCombo($"###{this.Id.ToString()}", descriptions[idx].FriendlyName)) { foreach (int value in values) { diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs index 6c8ed064..420fbbf4 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs @@ -9,7 +9,7 @@ namespace XIVLauncher.Core.Components.SettingsPage; public class SettingsPage : Page { private readonly SettingsTab[] tabs = - { + [ new SettingsTabGame(), new SettingsTabPatching(), new SettingsTabWine(), @@ -17,7 +17,7 @@ public class SettingsPage : Page new SettingsTabAbout(), new SettingsTabDebug(), new SettingsTabTroubleshooting(), - }; + ]; private string searchInput = string.Empty; diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs index 5ec75444..2f295789 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs @@ -14,7 +14,7 @@ public abstract class SettingsTab : Component public override void Draw() { - foreach (SettingsEntry settingsEntry in Entries) + foreach (SettingsEntry settingsEntry in this.Entries) { if (settingsEntry.IsVisible) settingsEntry.Draw(); @@ -27,7 +27,7 @@ public override void Draw() public void Load() { - foreach (SettingsEntry settingsEntry in Entries) + foreach (SettingsEntry settingsEntry in this.Entries) { settingsEntry.Load(); } @@ -35,7 +35,7 @@ public void Load() public virtual void Save() { - foreach (SettingsEntry settingsEntry in Entries) + foreach (SettingsEntry settingsEntry in this.Entries) { settingsEntry.Save(); } diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDalamud.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDalamud.cs index 801bb243..5e078770 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDalamud.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDalamud.cs @@ -10,8 +10,8 @@ public class SettingsTabDalamud : SettingsTab public SettingsTabDalamud() { - this.Entries = new SettingsEntry[] - { + this.Entries = + [ new SettingsEntry("Enable Dalamud", "Enable the Dalamud plugin system", () => Program.Config.DalamudEnabled ?? true, b => Program.Config.DalamudEnabled = b), @@ -19,7 +19,7 @@ public SettingsTabDalamud() new NumericSettingsEntry("Injection Delay (ms)", "Choose how long to wait after the game has loaded before injecting.", () => Program.Config.DalamudLoadDelay, delay => Program.Config.DalamudLoadDelay = delay, 0, int.MaxValue, 1000), - enableManualInjection = new SettingsEntry("Enable Manual Injection", "Use a local build of Dalamud instead of the automatically provided one (For developers only!)", () => Program.Config.DalamudManualInjectionEnabled ?? false, (enabled) => + this.enableManualInjection = new SettingsEntry("Enable Manual Injection", "Use a local build of Dalamud instead of the automatically provided one (For developers only!)", () => Program.Config.DalamudManualInjectionEnabled ?? false, (enabled) => { Program.Config.DalamudManualInjectionEnabled = enabled; @@ -39,13 +39,13 @@ public SettingsTabDalamud() new SettingsEntry("Manual Injection Path", "The path to the local version of Dalamud where Dalamud.Injector.exe is located", () => Program.Config.DalamudManualInjectPath, (input) => { - if (enableManualInjection.Value == false) return; + if (this.enableManualInjection.Value == false) return; if (input is null) return; Program.Config.DalamudManualInjectPath = input; Program.DalamudUpdater.RunnerOverride = new FileInfo(Path.Combine(input.FullName, Program.DALAMUD_INJECTOR_NAME)); }) { - CheckVisibility = () => enableManualInjection.Value, + CheckVisibility = () => this.enableManualInjection.Value, CheckValidity = input => { if (input is null || !input.Exists) @@ -59,6 +59,6 @@ public SettingsTabDalamud() return null; }, }, - }; + ]; } } diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs index 2418c2d9..26b396ab 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs @@ -5,7 +5,7 @@ namespace XIVLauncher.Core.Components.SettingsPage.Tabs; public class SettingsTabGame : SettingsTab { public override SettingsEntry[] Entries { get; } = - { + [ new SettingsEntry("Game Path", "Where the game is or will be installed.", () => Program.Config.GamePath, x => Program.Config.GamePath = x) { CheckValidity = x => @@ -38,7 +38,7 @@ public class SettingsTabGame : SettingsTab CheckVisibility = () => !CoreEnvironmentSettings.IsSteamCompatTool, }, new SettingsEntry("Use Experimental UID Cache", "Tries to save your login token for the next start. Can result in launching with expired sessions.\nDisable if receiving FFXIV error 1012 or 500X.", () => Program.Config.IsUidCacheEnabled ?? false, x => Program.Config.IsUidCacheEnabled = x), - }; + ]; public override string Title => "Game"; diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabPatching.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabPatching.cs index 51ca1b66..9bd5d6a6 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabPatching.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabPatching.cs @@ -5,7 +5,7 @@ namespace XIVLauncher.Core.Components.SettingsPage.Tabs; public class SettingsTabPatching : SettingsTab { public override SettingsEntry[] Entries { get; } = - { + [ new SettingsEntry("Patch Path", "Where patches should be downloaded to.", () => Program.Config.PatchPath, x => Program.Config.PatchPath = x) { CheckValidity = x => @@ -22,7 +22,7 @@ public class SettingsTabPatching : SettingsTab new NumericSettingsEntry("Maximum Speed", "Maximum download speed in bytes per second. Set to 0 for unlimited.", () => (int)Program.Config.PatchSpeedLimit, x => Program.Config.PatchSpeedLimit = x, 0, int.MaxValue, 1000), new SettingsEntry("Keep Patches", "Keep patches on disk after installing.", () => Program.Config.KeepPatches ?? false, x => Program.Config.KeepPatches = x), - }; + ]; public override string Title => "Patching"; } diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs index 2bb8141f..8cf6c64f 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs @@ -8,7 +8,7 @@ namespace XIVLauncher.Core.Components.SettingsPage.Tabs; public class SettingsTabTroubleshooting : SettingsTab { public override SettingsEntry[] Entries { get; } = - { + [ new SettingsEntry("Hack: Disable gameoverlayrenderer.so", "Fixes some stuttering issues after 40+ minutes, but may affect steam overlay and input.", () => Program.Config.FixLDP ?? false, x => Program.Config.FixLDP = x), new SettingsEntry("Hack: XMODIFIERS=\"@im=null\"", "Fixes some mouse-related issues, some stuttering issues", () => Program.Config.FixIM ?? false, x => Program.Config.FixIM = x), new SettingsEntry($"Hack: Force locale to {(!string.IsNullOrEmpty(Program.CType) ? Program.CType : "C.UTF-8 (exact value depends on distro)")}", @@ -23,7 +23,7 @@ public class SettingsTabTroubleshooting : SettingsTab return null; } }, - }; + ]; public override string Title => "Troubleshooting"; public override void Draw() diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index b9a95b1b..030065c8 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -14,16 +14,16 @@ public class SettingsTabWine : SettingsTab public SettingsTabWine() { - Entries = new SettingsEntry[] - { - startupTypeSetting = new SettingsEntry("Wine Version", "Choose how XIVLauncher will start and manage your wine installation.", + this.Entries = + [ + this.startupTypeSetting = new SettingsEntry("Wine Version", "Choose how XIVLauncher will start and manage your wine installation.", () => Program.Config.WineStartupType ?? WineStartupType.Managed, x => Program.Config.WineStartupType = x), new SettingsEntry("Wine Binary Path", "Set the path XIVLauncher will use to run applications via wine.\nIt should be an absolute path to a folder containing wine64 and wineserver binaries.", () => Program.Config.WineBinaryPath, s => Program.Config.WineBinaryPath = s) { - CheckVisibility = () => startupTypeSetting.Value == WineStartupType.Custom + CheckVisibility = () => this.startupTypeSetting.Value == WineStartupType.Custom }, new SettingsEntry("Enable Feral's GameMode", "Enable launching with Feral Interactive's GameMode CPU optimizations.", () => Program.Config.GameModeEnabled ?? true, b => Program.Config.GameModeEnabled = b) @@ -57,7 +57,7 @@ public SettingsTabWine() new SettingsEntry("DXVK Overlay", "Configure how much of the DXVK overlay is to be shown.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type), new SettingsEntry("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s) - }; + ]; } public override SettingsEntry[] Entries { get; } diff --git a/src/XIVLauncher.Core/Components/UpdateWarnPage.cs b/src/XIVLauncher.Core/Components/UpdateWarnPage.cs index 62303df8..43aa0244 100644 --- a/src/XIVLauncher.Core/Components/UpdateWarnPage.cs +++ b/src/XIVLauncher.Core/Components/UpdateWarnPage.cs @@ -35,7 +35,7 @@ public override void Draw() if (ImGui.Button("###finishFtsButton", new Vector2(649, 101))) { - App.FinishFromUpdateWarn(); + this.App.FinishFromUpdateWarn(); } ImGui.PopStyleColor(3); diff --git a/src/XIVLauncher.Core/GlyphRangesJapanese.cs b/src/XIVLauncher.Core/GlyphRangesJapanese.cs index 6e9f7318..3712e52a 100644 --- a/src/XIVLauncher.Core/GlyphRangesJapanese.cs +++ b/src/XIVLauncher.Core/GlyphRangesJapanese.cs @@ -8,8 +8,8 @@ public static class GlyphRangesJapanese /// /// Gets the unicode glyph ranges for the Japanese language. /// - public static ushort[] GlyphRanges => new ushort[] - { + public static ushort[] GlyphRanges => + [ 0x0020, 0x00FF, 0x0391, 0x03A1, 0x03A3, 0x03A9, 0x03B1, 0x03C1, 0x03C3, 0x03C9, 0x0401, 0x0401, 0x0410, 0x044F, 0x0451, 0x0451, 0x2000, 0x206F, 0x2103, 0x2103, 0x212B, 0x212B, 0x2190, 0x2193, 0x21D2, 0x21D2, 0x21D4, 0x21D4, 0x2200, 0x2200, 0x2202, 0x2203, 0x2207, 0x2208, 0x220B, 0x220B, 0x2212, 0x2212, 0x221A, 0x221A, 0x221D, 0x221E, 0x2220, 0x2220, 0x2227, 0x222C, 0x2234, 0x2235, @@ -524,5 +524,5 @@ public static class GlyphRangesJapanese 0x9F4E, 0x9F4F, 0x9F52, 0x9F52, 0x9F54, 0x9F54, 0x9F5F, 0x9F63, 0x9F66, 0x9F67, 0x9F6A, 0x9F6A, 0x9F6C, 0x9F6C, 0x9F72, 0x9F72, 0x9F76, 0x9F77, 0x9F8D, 0x9F8D, 0x9F95, 0x9F95, 0x9F9C, 0x9F9D, 0x9FA0, 0x9FA0, 0xFF01, 0xFF01, 0xFF03, 0xFF06, 0xFF08, 0xFF0C, 0xFF0E, 0xFF3B, 0xFF3D, 0xFF5D, 0xFF61, 0xFF9F, 0xFFE3, 0xFFE3, 0xFFE5, 0xFFE5, 0xFFFF, 0xFFFF, 0, - }; + ]; } diff --git a/src/XIVLauncher.Core/ImGuiBindings.cs b/src/XIVLauncher.Core/ImGuiBindings.cs index 527837e8..c00487df 100644 --- a/src/XIVLauncher.Core/ImGuiBindings.cs +++ b/src/XIVLauncher.Core/ImGuiBindings.cs @@ -51,13 +51,13 @@ public class ImGuiBindings : IDisposable // Image trackers private readonly Dictionary setsByView - = new Dictionary(); + = []; private readonly Dictionary autoViewsByTexture - = new Dictionary(); + = []; - private readonly Dictionary viewsById = new Dictionary(); - private readonly List ownedResources = new List(); + private readonly Dictionary viewsById = []; + private readonly List ownedResources = []; private int lastAssignedID = 100; private delegate void SetClipboardTextDelegate(IntPtr userData, string text); @@ -74,8 +74,8 @@ private readonly Dictionary autoViewsByTexture public ImGuiBindings(GraphicsDevice gd, OutputDescription outputDescription, int width, int height, FileInfo iniPath, float fontPxSize) { this.gd = gd; - windowWidth = width; - windowHeight = height; + this.windowWidth = width; + this.windowHeight = height; IntPtr context = ImGui.CreateContext(); ImGui.SetCurrentContext(context); @@ -85,37 +85,37 @@ public ImGuiBindings(GraphicsDevice gd, OutputDescription outputDescription, int ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.NavEnableGamepad; ImGui.GetIO().BackendFlags |= ImGuiBackendFlags.HasGamepad; - SetIniPath(iniPath.FullName); + this.SetIniPath(iniPath.FullName); - setText = new SetClipboardTextDelegate(SetClipboardText); - getText = new GetClipboardTextDelegate(GetClipboardText); + this.setText = new SetClipboardTextDelegate(SetClipboardText); + this.getText = new GetClipboardTextDelegate(GetClipboardText); var io = ImGui.GetIO(); - io.SetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(setText); - io.GetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(getText); + io.SetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(this.setText); + io.GetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(this.getText); io.ClipboardUserData = IntPtr.Zero; - CreateDeviceResources(gd, outputDescription, fontPxSize); + this.CreateDeviceResources(gd, outputDescription, fontPxSize); SetKeyMappings(); - SetPerFrameImGuiData(1f / 60f); + this.SetPerFrameImGuiData(1f / 60f); ImGui.NewFrame(); - frameBegun = true; + this.frameBegun = true; } private void SetIniPath(string iniPath) { - if (iniPathPtr != IntPtr.Zero) + if (this.iniPathPtr != IntPtr.Zero) { - Marshal.FreeHGlobal(iniPathPtr); + Marshal.FreeHGlobal(this.iniPathPtr); } - iniPathPtr = Marshal.StringToHGlobalAnsi(iniPath); + this.iniPathPtr = Marshal.StringToHGlobalAnsi(iniPath); unsafe { - ImGui.GetIO().NativePtr->IniFilename = (byte*)iniPathPtr.ToPointer(); + ImGui.GetIO().NativePtr->IniFilename = (byte*)this.iniPathPtr.ToPointer(); } } @@ -132,49 +132,49 @@ private static string GetClipboardText() public void WindowResized(int width, int height) { - windowWidth = width; - windowHeight = height; + this.windowWidth = width; + this.windowHeight = height; } public void DestroyDeviceObjects() { - Dispose(); + this.Dispose(); } public void CreateDeviceResources(GraphicsDevice gd, OutputDescription outputDescription, float fontPxSize) { this.gd = gd; ResourceFactory factory = gd.ResourceFactory; - vertexBuffer = factory.CreateBuffer(new BufferDescription(10000, BufferUsage.VertexBuffer | BufferUsage.Dynamic)); - vertexBuffer.Name = "ImGui.NET Vertex Buffer"; - indexBuffer = factory.CreateBuffer(new BufferDescription(2000, BufferUsage.IndexBuffer | BufferUsage.Dynamic)); - indexBuffer.Name = "ImGui.NET Index Buffer"; + this.vertexBuffer = factory.CreateBuffer(new BufferDescription(10000, BufferUsage.VertexBuffer | BufferUsage.Dynamic)); + this.vertexBuffer.Name = "ImGui.NET Vertex Buffer"; + this.indexBuffer = factory.CreateBuffer(new BufferDescription(2000, BufferUsage.IndexBuffer | BufferUsage.Dynamic)); + this.indexBuffer.Name = "ImGui.NET Index Buffer"; var fontMr = new FontManager(); fontMr.SetupFonts(fontPxSize); - RecreateFontDeviceTexture(gd); + this.RecreateFontDeviceTexture(gd); Log.Debug("Fonts OK!"); - projMatrixBuffer = factory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer | BufferUsage.Dynamic)); - projMatrixBuffer.Name = "ImGui.NET Projection Buffer"; + this.projMatrixBuffer = factory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer | BufferUsage.Dynamic)); + this.projMatrixBuffer.Name = "ImGui.NET Projection Buffer"; - byte[] vertexShaderBytes = LoadEmbeddedShaderCode(gd.ResourceFactory, "imgui-vertex", ShaderStages.Vertex); - byte[] fragmentShaderBytes = LoadEmbeddedShaderCode(gd.ResourceFactory, "imgui-frag", ShaderStages.Fragment); - vertexShader = factory.CreateShader(new ShaderDescription(ShaderStages.Vertex, vertexShaderBytes, gd.BackendType == GraphicsBackend.Metal ? "VS" : "main")); - fragmentShader = factory.CreateShader(new ShaderDescription(ShaderStages.Fragment, fragmentShaderBytes, gd.BackendType == GraphicsBackend.Metal ? "FS" : "main")); + byte[] vertexShaderBytes = this.LoadEmbeddedShaderCode(gd.ResourceFactory, "imgui-vertex", ShaderStages.Vertex); + byte[] fragmentShaderBytes = this.LoadEmbeddedShaderCode(gd.ResourceFactory, "imgui-frag", ShaderStages.Fragment); + this.vertexShader = factory.CreateShader(new ShaderDescription(ShaderStages.Vertex, vertexShaderBytes, gd.BackendType == GraphicsBackend.Metal ? "VS" : "main")); + this.fragmentShader = factory.CreateShader(new ShaderDescription(ShaderStages.Fragment, fragmentShaderBytes, gd.BackendType == GraphicsBackend.Metal ? "FS" : "main")); - VertexLayoutDescription[] vertexLayouts = new VertexLayoutDescription[] - { + VertexLayoutDescription[] vertexLayouts = + [ new VertexLayoutDescription( new VertexElementDescription("in_position", VertexElementSemantic.Position, VertexElementFormat.Float2), new VertexElementDescription("in_texCoord", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2), new VertexElementDescription("in_color", VertexElementSemantic.Color, VertexElementFormat.Byte4_Norm)) - }; + ]; - layout = factory.CreateResourceLayout(new ResourceLayoutDescription( + this.layout = factory.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription("ProjectionMatrixBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex), new ResourceLayoutElementDescription("MainSampler", ResourceKind.Sampler, ShaderStages.Fragment))); - textureLayout = factory.CreateResourceLayout(new ResourceLayoutDescription( + this.textureLayout = factory.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription("MainTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment))); GraphicsPipelineDescription pd = new GraphicsPipelineDescription( @@ -182,17 +182,17 @@ public void CreateDeviceResources(GraphicsDevice gd, OutputDescription outputDes new DepthStencilStateDescription(false, false, ComparisonKind.Always), new RasterizerStateDescription(FaceCullMode.None, PolygonFillMode.Solid, FrontFace.Clockwise, false, true), PrimitiveTopology.TriangleList, - new ShaderSetDescription(vertexLayouts, new[] { vertexShader, fragmentShader }), - new ResourceLayout[] { layout, textureLayout }, + new ShaderSetDescription(vertexLayouts, [this.vertexShader, this.fragmentShader]), + [this.layout, this.textureLayout], outputDescription, ResourceBindingModel.Default); - pipeline = factory.CreateGraphicsPipeline(ref pd); + this.pipeline = factory.CreateGraphicsPipeline(ref pd); - mainResourceSet = factory.CreateResourceSet(new ResourceSetDescription(layout, - projMatrixBuffer, + this.mainResourceSet = factory.CreateResourceSet(new ResourceSetDescription(this.layout, + this.projMatrixBuffer, gd.PointSampler)); - fontTextureResourceSet = factory.CreateResourceSet(new ResourceSetDescription(textureLayout, fontTextureView)); + this.fontTextureResourceSet = factory.CreateResourceSet(new ResourceSetDescription(this.textureLayout, this.fontTextureView)); } /// @@ -201,14 +201,14 @@ public void CreateDeviceResources(GraphicsDevice gd, OutputDescription outputDes /// public IntPtr GetOrCreateImGuiBinding(ResourceFactory factory, TextureView textureView) { - if (!setsByView.TryGetValue(textureView, out ResourceSetInfo rsi)) + if (!this.setsByView.TryGetValue(textureView, out ResourceSetInfo rsi)) { - ResourceSet resourceSet = factory.CreateResourceSet(new ResourceSetDescription(textureLayout, textureView)); - rsi = new ResourceSetInfo(GetNextImGuiBindingID(), resourceSet); + ResourceSet resourceSet = factory.CreateResourceSet(new ResourceSetDescription(this.textureLayout, textureView)); + rsi = new ResourceSetInfo(this.GetNextImGuiBindingID(), resourceSet); - setsByView.Add(textureView, rsi); - viewsById.Add(rsi.ImGuiBinding, rsi); - ownedResources.Add(resourceSet); + this.setsByView.Add(textureView, rsi); + this.viewsById.Add(rsi.ImGuiBinding, rsi); + this.ownedResources.Add(resourceSet); } return rsi.ImGuiBinding; @@ -216,7 +216,7 @@ public IntPtr GetOrCreateImGuiBinding(ResourceFactory factory, TextureView textu private IntPtr GetNextImGuiBindingID() { - int newID = lastAssignedID++; + int newID = this.lastAssignedID++; return (IntPtr)newID; } @@ -226,14 +226,14 @@ private IntPtr GetNextImGuiBindingID() /// public IntPtr GetOrCreateImGuiBinding(ResourceFactory factory, Texture texture) { - if (!autoViewsByTexture.TryGetValue(texture, out var textureView)) + if (!this.autoViewsByTexture.TryGetValue(texture, out var textureView)) { textureView = factory.CreateTextureView(texture); - autoViewsByTexture.Add(texture, textureView); - ownedResources.Add(textureView); + this.autoViewsByTexture.Add(texture, textureView); + this.ownedResources.Add(textureView); } - return GetOrCreateImGuiBinding(factory, textureView); + return this.GetOrCreateImGuiBinding(factory, textureView); } /// @@ -241,7 +241,7 @@ public IntPtr GetOrCreateImGuiBinding(ResourceFactory factory, Texture texture) /// public ResourceSet GetImageResourceSet(IntPtr imGuiBinding) { - if (!viewsById.TryGetValue(imGuiBinding, out ResourceSetInfo tvi)) + if (!this.viewsById.TryGetValue(imGuiBinding, out ResourceSetInfo tvi)) { throw new InvalidOperationException("No registered ImGui binding with id " + imGuiBinding.ToString()); } @@ -251,16 +251,16 @@ public ResourceSet GetImageResourceSet(IntPtr imGuiBinding) public void ClearCachedImageResources() { - foreach (IDisposable resource in ownedResources) + foreach (IDisposable resource in this.ownedResources) { resource.Dispose(); } - ownedResources.Clear(); - setsByView.Clear(); - viewsById.Clear(); - autoViewsByTexture.Clear(); - lastAssignedID = 100; + this.ownedResources.Clear(); + this.setsByView.Clear(); + this.viewsById.Clear(); + this.autoViewsByTexture.Clear(); + this.lastAssignedID = 100; } private byte[] LoadEmbeddedShaderCode(ResourceFactory factory, string name, ShaderStages stage) @@ -307,18 +307,18 @@ public void RecreateFontDeviceTexture(GraphicsDevice gd) int width, height, bytesPerPixel; io.Fonts.GetTexDataAsRGBA32(out pixels, out width, out height, out bytesPerPixel); // Store our identifier - io.Fonts.SetTexID(fontAtlasID); + io.Fonts.SetTexID(this.fontAtlasID); - fontTexture = gd.ResourceFactory.CreateTexture(TextureDescription.Texture2D( + this.fontTexture = gd.ResourceFactory.CreateTexture(TextureDescription.Texture2D( (uint)width, (uint)height, 1, 1, PixelFormat.R8_G8_B8_A8_UNorm, TextureUsage.Sampled)); - fontTexture.Name = "ImGui.NET Font Texture"; + this.fontTexture.Name = "ImGui.NET Font Texture"; gd.UpdateTexture( - fontTexture, + this.fontTexture, pixels, (uint)(bytesPerPixel * width * height), 0, @@ -329,7 +329,7 @@ public void RecreateFontDeviceTexture(GraphicsDevice gd) 1, 0, 0); - fontTextureView = gd.ResourceFactory.CreateTextureView(fontTexture); + this.fontTextureView = gd.ResourceFactory.CreateTextureView(this.fontTexture); io.Fonts.ClearTexData(); } @@ -342,11 +342,11 @@ public void RecreateFontDeviceTexture(GraphicsDevice gd) /// public void Render(GraphicsDevice gd, CommandList cl) { - if (frameBegun) + if (this.frameBegun) { - frameBegun = false; + this.frameBegun = false; ImGui.Render(); - RenderImDrawData(ImGui.GetDrawData(), gd, cl); + this.RenderImDrawData(ImGui.GetDrawData(), gd, cl); } } @@ -355,15 +355,15 @@ public void Render(GraphicsDevice gd, CommandList cl) /// public void Update(float deltaSeconds, InputSnapshot snapshot) { - if (frameBegun) + if (this.frameBegun) { ImGui.Render(); } - SetPerFrameImGuiData(deltaSeconds); - UpdateImGuiInput(snapshot); + this.SetPerFrameImGuiData(deltaSeconds); + this.UpdateImGuiInput(snapshot); - frameBegun = true; + this.frameBegun = true; ImGui.NewFrame(); } @@ -375,9 +375,9 @@ private void SetPerFrameImGuiData(float deltaSeconds) { ImGuiIOPtr io = ImGui.GetIO(); io.DisplaySize = new Vector2( - windowWidth / scaleFactor.X, - windowHeight / scaleFactor.Y); - io.DisplayFramebufferScale = scaleFactor; + this.windowWidth / this.scaleFactor.X, + this.windowHeight / this.scaleFactor.Y); + io.DisplayFramebufferScale = this.scaleFactor; io.DeltaTime = deltaSeconds; // DeltaTime is in seconds. } @@ -436,29 +436,29 @@ private void UpdateImGuiInput(InputSnapshot snapshot) if (keyEvent.Key == Key.ControlLeft) { - controlDown = keyEvent.Down; + this.controlDown = keyEvent.Down; } if (keyEvent.Key == Key.ShiftLeft) { - shiftDown = keyEvent.Down; + this.shiftDown = keyEvent.Down; } if (keyEvent.Key == Key.AltLeft) { - altDown = keyEvent.Down; + this.altDown = keyEvent.Down; } if (keyEvent.Key == Key.WinLeft) { - winKeyDown = keyEvent.Down; + this.winKeyDown = keyEvent.Down; } } - io.KeyCtrl = controlDown; - io.KeyAlt = altDown; - io.KeyShift = shiftDown; - io.KeySuper = winKeyDown; + io.KeyCtrl = this.controlDown; + io.KeyAlt = this.altDown; + io.KeyShift = this.shiftDown; + io.KeySuper = this.winKeyDown; } private static void SetKeyMappings() @@ -499,18 +499,18 @@ private void RenderImDrawData(ImDrawDataPtr drawData, GraphicsDevice gd, Command uint totalVbSize = (uint)(drawData.TotalVtxCount * Unsafe.SizeOf()); - if (totalVbSize > vertexBuffer.SizeInBytes) + if (totalVbSize > this.vertexBuffer.SizeInBytes) { - gd.DisposeWhenIdle(vertexBuffer); - vertexBuffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)(totalVbSize * 1.5f), BufferUsage.VertexBuffer | BufferUsage.Dynamic)); + gd.DisposeWhenIdle(this.vertexBuffer); + this.vertexBuffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)(totalVbSize * 1.5f), BufferUsage.VertexBuffer | BufferUsage.Dynamic)); } uint totalIbSize = (uint)(drawData.TotalIdxCount * sizeof(ushort)); - if (totalIbSize > indexBuffer.SizeInBytes) + if (totalIbSize > this.indexBuffer.SizeInBytes) { - gd.DisposeWhenIdle(indexBuffer); - indexBuffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)(totalIbSize * 1.5f), BufferUsage.IndexBuffer | BufferUsage.Dynamic)); + gd.DisposeWhenIdle(this.indexBuffer); + this.indexBuffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)(totalIbSize * 1.5f), BufferUsage.IndexBuffer | BufferUsage.Dynamic)); } for (int i = 0; i < drawData.CmdListsCount; i++) @@ -518,13 +518,13 @@ private void RenderImDrawData(ImDrawDataPtr drawData, GraphicsDevice gd, Command ImDrawListPtr cmdList = drawData.CmdListsRange[i]; cl.UpdateBuffer( - vertexBuffer, + this.vertexBuffer, vertexOffsetInVertices * (uint)Unsafe.SizeOf(), cmdList.VtxBuffer.Data, (uint)(cmdList.VtxBuffer.Size * Unsafe.SizeOf())); cl.UpdateBuffer( - indexBuffer, + this.indexBuffer, indexOffsetInElements * sizeof(ushort), cmdList.IdxBuffer.Data, (uint)(cmdList.IdxBuffer.Size * sizeof(ushort))); @@ -545,10 +545,10 @@ private void RenderImDrawData(ImDrawDataPtr drawData, GraphicsDevice gd, Command this.gd.UpdateBuffer(this.projMatrixBuffer, 0, ref mvp); - cl.SetVertexBuffer(0, vertexBuffer); - cl.SetIndexBuffer(indexBuffer, IndexFormat.UInt16); - cl.SetPipeline(pipeline); - cl.SetGraphicsResourceSet(0, mainResourceSet); + cl.SetVertexBuffer(0, this.vertexBuffer); + cl.SetIndexBuffer(this.indexBuffer, IndexFormat.UInt16); + cl.SetPipeline(this.pipeline); + cl.SetGraphicsResourceSet(0, this.mainResourceSet); drawData.ScaleClipRects(io.DisplayFramebufferScale); @@ -572,13 +572,13 @@ private void RenderImDrawData(ImDrawDataPtr drawData, GraphicsDevice gd, Command { if (pcmd.TextureId != IntPtr.Zero) { - if (pcmd.TextureId == fontAtlasID) + if (pcmd.TextureId == this.fontAtlasID) { - cl.SetGraphicsResourceSet(1, fontTextureResourceSet); + cl.SetGraphicsResourceSet(1, this.fontTextureResourceSet); } else { - cl.SetGraphicsResourceSet(1, GetImageResourceSet(pcmd.TextureId)); + cl.SetGraphicsResourceSet(1, this.GetImageResourceSet(pcmd.TextureId)); } } @@ -603,19 +603,19 @@ private void RenderImDrawData(ImDrawDataPtr drawData, GraphicsDevice gd, Command /// public void Dispose() { - vertexBuffer.Dispose(); - indexBuffer.Dispose(); - projMatrixBuffer.Dispose(); - fontTexture.Dispose(); - fontTextureView.Dispose(); - vertexShader.Dispose(); - fragmentShader.Dispose(); - layout.Dispose(); - textureLayout.Dispose(); - pipeline.Dispose(); - mainResourceSet.Dispose(); - - foreach (IDisposable resource in ownedResources) + this.vertexBuffer.Dispose(); + this.indexBuffer.Dispose(); + this.projMatrixBuffer.Dispose(); + this.fontTexture.Dispose(); + this.fontTextureView.Dispose(); + this.vertexShader.Dispose(); + this.fragmentShader.Dispose(); + this.layout.Dispose(); + this.textureLayout.Dispose(); + this.pipeline.Dispose(); + this.mainResourceSet.Dispose(); + + foreach (IDisposable resource in this.ownedResources) { resource.Dispose(); } @@ -628,8 +628,8 @@ private struct ResourceSetInfo public ResourceSetInfo(IntPtr imGuiBinding, ResourceSet resourceSet) { - ImGuiBinding = imGuiBinding; - ResourceSet = resourceSet; + this.ImGuiBinding = imGuiBinding; + this.ResourceSet = resourceSet; } } } diff --git a/src/XIVLauncher.Core/LauncherApp.cs b/src/XIVLauncher.Core/LauncherApp.cs index 2d09ed2f..31c90562 100644 --- a/src/XIVLauncher.Core/LauncherApp.cs +++ b/src/XIVLauncher.Core/LauncherApp.cs @@ -133,7 +133,7 @@ public LauncherApp(Storage storage, bool needsUpdateWarning, string frontierUrl, this.Accounts = new AccountManager(this.Storage.GetFile("accounts.json")); this.UniqueIdCache = new CommonUniqueIdCache(this.Storage.GetFile("uidCache.json")); - this.Launcher = new Launcher(Program.Steam, UniqueIdCache, Program.CommonSettings, frontierUrl); + this.Launcher = new Launcher(Program.Steam, this.UniqueIdCache, Program.CommonSettings, frontierUrl); this.mainPage = new MainPage(this); this.setPage = new SettingsPage(this); @@ -332,9 +332,9 @@ private void DrawModal() const float BUTTON_WIDTH = 120f; ImGui.SetCursorPosX((ImGui.GetWindowWidth() - BUTTON_WIDTH) / 2); - if (ImGui.Button(modalButtonText, new Vector2(BUTTON_WIDTH, 40))) + if (ImGui.Button(this.modalButtonText, new Vector2(BUTTON_WIDTH, 40))) { - modalButtonPressAction(); + this.modalButtonPressAction(); } ImGui.EndPopup(); diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 2b6d6b12..e921bf06 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -69,7 +69,7 @@ sealed class Program private const string APP_NAME = "xlcore"; - private static string[] mainArgs = { }; + private static string[] mainArgs = []; private static uint invalidationFrames = 0; private static Vector2 lastMousePosition = Vector2.Zero; @@ -160,7 +160,7 @@ private static void LoadConfig(Storage storage) /// A instance. private static DalamudUpdater CreateDalamudUpdater() { - FileInfo runnerOverride = null; + FileInfo? runnerOverride = null; if (Config.DalamudManualInjectPath is not null && Config.DalamudManualInjectionEnabled == true && Config.DalamudManualInjectPath.Exists && @@ -200,8 +200,8 @@ private static void Main(string[] args) Loc.SetupWithFallbacks(); - Dictionary apps = new Dictionary(); - uint[] ignoredIds = { 0, STEAM_APP_ID, STEAM_APP_ID_FT}; + Dictionary apps = []; + uint[] ignoredIds = [0, STEAM_APP_ID, STEAM_APP_ID_FT]; if (!ignoredIds.Contains(CoreEnvironmentSettings.SteamAppId)) { apps.Add(CoreEnvironmentSettings.SteamAppId, "XLM"); @@ -370,7 +370,7 @@ private static void Main(string[] args) if (Patcher is not null) { Patcher.CancelAllDownloads(); - Task.Run(async() => + Task.Run(async () => { await PatchManager.UnInitializeAcquisition().ConfigureAwait(false); Environment.Exit(0); @@ -480,7 +480,7 @@ public static void ClearLogs(bool tsbutton = false) { storage.GetFolder("logs").Delete(true); storage.GetFolder("logs"); - string[] logfiles = { "dalamud.boot.log", "dalamud.boot.old.log", "dalamud.log", "dalamud.injector.log" }; + string[] logfiles = ["dalamud.boot.log", "dalamud.boot.old.log", "dalamud.log", "dalamud.injector.log"]; foreach (string logfile in logfiles) if (storage.GetFile(logfile).Exists) storage.GetFile(logfile).Delete(); if (tsbutton) diff --git a/src/XIVLauncher.Core/Style/StyleModelV1.cs b/src/XIVLauncher.Core/Style/StyleModelV1.cs index 7f7f417b..5263dd96 100644 --- a/src/XIVLauncher.Core/Style/StyleModelV1.cs +++ b/src/XIVLauncher.Core/Style/StyleModelV1.cs @@ -16,7 +16,7 @@ public class StyleModelV1 : StyleModel /// private StyleModelV1() { - this.Colors = new Dictionary(); + this.Colors = []; this.Name = "Unknown"; } @@ -350,7 +350,7 @@ public static StyleModelV1 Get() model.SelectableTextAlign = style.SelectableTextAlign; model.DisplaySafeAreaPadding = style.DisplaySafeAreaPadding; - model.Colors = new Dictionary(); + model.Colors = []; foreach (var imGuiCol in Enum.GetValues()) { diff --git a/src/XIVLauncher.Core/Support/Troubleshooting.cs b/src/XIVLauncher.Core/Support/Troubleshooting.cs index 3721c638..699b64ec 100644 --- a/src/XIVLauncher.Core/Support/Troubleshooting.cs +++ b/src/XIVLauncher.Core/Support/Troubleshooting.cs @@ -33,7 +33,7 @@ public static void LogException(Exception exception, string context) try { var fixedContext = - context?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? + context?.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? string.Empty; var payload = new ExceptionPayload