From 01c0872f6830555e950d02f7271560fb810802b0 Mon Sep 17 00:00:00 2001 From: shananas Date: Tue, 17 Sep 2024 12:40:11 -0400 Subject: [PATCH 1/2] Random Whitespace Cleanup and Warning Removals --- OpenKh.Tools.ModsManager/App.config | 4 ++-- .../Services/GameService.cs | 2 +- .../Services/ModsService.cs | 3 --- .../Services/Pcsx2Injector.cs | 4 ++-- .../UserControls/FolderSelectorControl.xaml | 6 +++--- .../UserControls/SaveFileSelectorControl.xaml | 6 +++--- .../UserControls/TaskStatusByIconControl.xaml | 6 +++--- .../TaskStatusObserverControl.xaml | 6 +++--- .../ViewModels/MainViewModel.cs | 10 +++++----- .../ViewModels/SetupWizardViewModel.cs | 19 +++++-------------- .../Views/CopySourceFilesWindow.xaml | 4 ++-- .../Views/InstallModProgressWindow.xaml | 2 +- .../Views/InstallModProgressWindow.xaml.cs | 6 +++--- .../Views/InstallModView.xaml | 2 +- .../Views/ModDetailsView.xaml | 6 +++--- .../Views/ModManagerView.xaml | 6 +++--- .../Views/PresetsWindow.xaml | 6 +++--- .../Views/PresetsWindow.xaml.cs | 4 ++-- .../Views/WorkInProgressWindow.xaml | 2 +- .../WinSettings.Designer.cs | 2 +- 20 files changed, 47 insertions(+), 59 deletions(-) diff --git a/OpenKh.Tools.ModsManager/App.config b/OpenKh.Tools.ModsManager/App.config index 9765fc06e..afdeab31d 100644 --- a/OpenKh.Tools.ModsManager/App.config +++ b/OpenKh.Tools.ModsManager/App.config @@ -1,4 +1,4 @@ - + @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/OpenKh.Tools.ModsManager/Services/GameService.cs b/OpenKh.Tools.ModsManager/Services/GameService.cs index 08941fe9b..4c4340953 100644 --- a/OpenKh.Tools.ModsManager/Services/GameService.cs +++ b/OpenKh.Tools.ModsManager/Services/GameService.cs @@ -55,7 +55,7 @@ public static GameInfoModel DetectGameId(string isoFilePath) var data = stream.SetPosition(blockIndex * BlockIso).ReadBytes(BlockIso); var expectData = Encoding.UTF8.GetBytes(detector.ProductId); if (string.Join(' ', data).Contains(string.Join(' ', expectData))) // TODO: inefficient, but it works lol - return game; + return game; } } diff --git a/OpenKh.Tools.ModsManager/Services/ModsService.cs b/OpenKh.Tools.ModsManager/Services/ModsService.cs index 48c2a780c..a10e6a0c5 100644 --- a/OpenKh.Tools.ModsManager/Services/ModsService.cs +++ b/OpenKh.Tools.ModsManager/Services/ModsService.cs @@ -152,7 +152,6 @@ public static void InstallModFromZip( break; case MessageBoxResult.No: throw new ModAlreadyExistsExceptions(modName); - break; } } @@ -309,7 +308,6 @@ public static async Task InstallModFromGithub( break; case MessageBoxResult.No: throw new ModAlreadyExistsExceptions(repositoryName); - break; } } @@ -362,7 +360,6 @@ public static void InstallModFromLua(string fileName) break; case MessageBoxResult.No: throw new ModAlreadyExistsExceptions(modName); - break; } } Directory.CreateDirectory(modPath); diff --git a/OpenKh.Tools.ModsManager/Services/Pcsx2Injector.cs b/OpenKh.Tools.ModsManager/Services/Pcsx2Injector.cs index a6349bf50..8a644f6dc 100644 --- a/OpenKh.Tools.ModsManager/Services/Pcsx2Injector.cs +++ b/OpenKh.Tools.ModsManager/Services/Pcsx2Injector.cs @@ -587,7 +587,7 @@ private void MainLoop(Stream stream, IDebugging debugging) while (!_cancellationToken.IsCancellationRequested && !isProcessDead) { var operation = stream.SetPosition(OperationAddress).ReadInt32(); - if (stream.Position == OperationAddress) + if (stream.Position == OperationAddress) break; // The emulator stopped its execution switch ((Operation)operation) @@ -747,7 +747,7 @@ private void PatchKh2FmPs2(Stream stream) // Fix weird game bug where KH2FM would crash on map change // when the region is different from JP or FM. WritePatch(stream, 0x015ABE8, ADDIU(V0, Zero, 1)); - + // Fix issue where KH2FM fails to load movie cutscenes // when the region is different from FM. WritePatch(stream, 0x022BC68, ADDIU(A2, A1, -0x6130)); diff --git a/OpenKh.Tools.ModsManager/UserControls/FolderSelectorControl.xaml b/OpenKh.Tools.ModsManager/UserControls/FolderSelectorControl.xaml index 268e16379..8f762f48f 100644 --- a/OpenKh.Tools.ModsManager/UserControls/FolderSelectorControl.xaml +++ b/OpenKh.Tools.ModsManager/UserControls/FolderSelectorControl.xaml @@ -1,10 +1,10 @@ diff --git a/OpenKh.Tools.ModsManager/UserControls/SaveFileSelectorControl.xaml b/OpenKh.Tools.ModsManager/UserControls/SaveFileSelectorControl.xaml index 70f82775d..581648231 100644 --- a/OpenKh.Tools.ModsManager/UserControls/SaveFileSelectorControl.xaml +++ b/OpenKh.Tools.ModsManager/UserControls/SaveFileSelectorControl.xaml @@ -1,10 +1,10 @@ diff --git a/OpenKh.Tools.ModsManager/UserControls/TaskStatusByIconControl.xaml b/OpenKh.Tools.ModsManager/UserControls/TaskStatusByIconControl.xaml index f947b21b2..1b682e478 100644 --- a/OpenKh.Tools.ModsManager/UserControls/TaskStatusByIconControl.xaml +++ b/OpenKh.Tools.ModsManager/UserControls/TaskStatusByIconControl.xaml @@ -1,10 +1,10 @@ diff --git a/OpenKh.Tools.ModsManager/UserControls/TaskStatusObserverControl.xaml b/OpenKh.Tools.ModsManager/UserControls/TaskStatusObserverControl.xaml index baad3bdd5..c62e48fda 100644 --- a/OpenKh.Tools.ModsManager/UserControls/TaskStatusObserverControl.xaml +++ b/OpenKh.Tools.ModsManager/UserControls/TaskStatusObserverControl.xaml @@ -1,10 +1,10 @@ diff --git a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs index bd4843114..c29f9366a 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs @@ -285,7 +285,7 @@ public int GametoLaunch } ReloadModsList(); if (ModsList.Count > 0) - FetchUpdates(); + _ = FetchUpdates(); } } @@ -533,7 +533,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress => CheckForModUpdatesCommand = new RelayCommand(_ => { - FetchUpdates(); + _ = FetchUpdates(); }); OpenLinkCommand = new RelayCommand(url => Process.Start(new ProcessStartInfo(url as string) @@ -542,7 +542,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress => })); CheckOpenkhUpdateCommand = new RelayCommand( - _ => UpdateOpenkhAsync() + _ => _ = UpdateOpenkhAsync() ); YamlGeneratorCommand = new RelayCommand( @@ -564,7 +564,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress => ); _pcsx2Injector = new Pcsx2Injector(new OperationDispatcher()); - FetchUpdates(); + _ = FetchUpdates(); if (ConfigurationService.WizardVersionNumber < _wizardVersionNumber) WizardCommand.Execute(null); @@ -1342,7 +1342,7 @@ public void LoadPreset(string presetName) ConfigurationService.EnabledMods = File.ReadAllLines(filename); ReloadModsList(); if (ModsList.Count > 0) - FetchUpdates(); + _ = FetchUpdates(); } else { diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index e4bb468a5..a19a763de 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -1,7 +1,5 @@ using Octokit; using OpenKh.Common; -using OpenKh.Kh1; -using OpenKh.Kh2; using OpenKh.Tools.Common.Wpf; using OpenKh.Tools.ModsManager.Services; using System; @@ -11,15 +9,12 @@ using System.Net; using System.Threading.Tasks; using System.Windows; -using Xe.IO; using Xe.Tools; using Xe.Tools.Wpf.Commands; using Xe.Tools.Wpf.Dialogs; using Ionic.Zip; -using System.Diagnostics; using System.Text.RegularExpressions; using System.Threading; -using System.Runtime.ExceptionServices; namespace OpenKh.Tools.ModsManager.ViewModels { @@ -45,13 +40,11 @@ public class SetupWizardViewModel : BaseNotifyPropertyChanged const int PC = 2; private int _gameEdition; - private string _pcVersion; private string _isoLocation; private string _openKhGameEngineLocation; private string _pcsx2Location; private string _pcReleaseLocation; private string _pcReleaseLocationKH3D; - private string _pcReleasesSelected; private int _gameCollection = 0; private string _pcReleaseLanguage; private string _gameDataLocation; @@ -245,17 +238,14 @@ public int LaunchOption switch (value) { case 1: - _pcVersion = "Steam"; ConfigurationService.PCVersion = "Steam"; WizardPageAfterLuaBackend = PageSteamAPITrick; break; case 2: - _pcVersion = "Other"; ConfigurationService.PCVersion = "Other"; WizardPageAfterLuaBackend = PageGameData; break; default: - _pcVersion = "EGS"; ConfigurationService.PCVersion = "EGS"; WizardPageAfterLuaBackend = PageGameData; break; @@ -325,19 +315,19 @@ public string PcReleaseSelections Directory.Exists(PcReleaseLocationKH3D) && (File.Exists(Path.Combine(PcReleaseLocationKH3D, "EOSSDK-Win64-Shipping.dll")) || File.Exists(Path.Combine(PcReleaseLocationKH3D, "steam_api64.dll"))) && _gameEdition == 2) { - return _pcReleasesSelected = "both"; + return "both"; } else if (Directory.Exists(PcReleaseLocation) && (File.Exists(Path.Combine(PcReleaseLocation, "EOSSDK-Win64-Shipping.dll")) || File.Exists(Path.Combine(PcReleaseLocation, "steam_api64.dll"))) && _gameEdition == 2) { - return _pcReleasesSelected = "1.5+2.5"; + return "1.5+2.5"; } else if (Directory.Exists(PcReleaseLocationKH3D) && (File.Exists(Path.Combine(PcReleaseLocationKH3D, "EOSSDK-Win64-Shipping.dll")) || File.Exists(Path.Combine(PcReleaseLocationKH3D, "steam_api64.dll"))) && _gameEdition == 2) { - return _pcReleasesSelected = "2.8"; + return "2.8"; } return ""; } @@ -685,7 +675,6 @@ public SetupWizardViewModel() { case MessageBoxResult.Yes: goto BEGIN; - break; } } }); @@ -995,7 +984,9 @@ public SetupWizardViewModel() var releases = gitClient.Repository.Release.GetLatest(owner: "Sirius902", name: "LuaBackend").Result; string DownPath = Path.GetTempPath() + "LuaBackend" + Path.GetExtension(releases.Assets[0].Name); string TempExtractionLocation = Path.GetTempPath() + "LuaBackend"; + #pragma warning disable SYSLIB0014 // Type or member is obsolete var _client = new WebClient(); + #pragma warning restore SYSLIB0014 // Type or member is obsolete _client.DownloadFile(new System.Uri(releases.Assets[0].BrowserDownloadUrl), DownPath); try { diff --git a/OpenKh.Tools.ModsManager/Views/CopySourceFilesWindow.xaml b/OpenKh.Tools.ModsManager/Views/CopySourceFilesWindow.xaml index 66fda7c37..a9c5ecc0e 100644 --- a/OpenKh.Tools.ModsManager/Views/CopySourceFilesWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/CopySourceFilesWindow.xaml @@ -52,10 +52,10 @@ - - diff --git a/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml b/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml index 1d27439b8..5a845e7a8 100644 --- a/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml @@ -8,7 +8,7 @@ Title="{Binding DialogTitle}" d:Title="Installing mod..." Height="120" Width="300" SizeToContent="WidthAndHeight" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> - + the mod ... diff --git a/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml.cs b/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml.cs index 75004fb30..e83376ef2 100644 --- a/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml.cs +++ b/OpenKh.Tools.ModsManager/Views/InstallModProgressWindow.xaml.cs @@ -48,7 +48,7 @@ public string ModName OnPropertyChanged(); } } - + public string ProgressText { get => _progressText; @@ -58,7 +58,7 @@ public string ProgressText OnPropertyChanged(); } } - + public bool ProgressUnknown { get => _progressUnknown; @@ -68,7 +68,7 @@ private set OnPropertyChanged(); } } - + public float ProgressValue { get => _progressValue; diff --git a/OpenKh.Tools.ModsManager/Views/InstallModView.xaml b/OpenKh.Tools.ModsManager/Views/InstallModView.xaml index 19baa83c8..fefdd5c67 100644 --- a/OpenKh.Tools.ModsManager/Views/InstallModView.xaml +++ b/OpenKh.Tools.ModsManager/Views/InstallModView.xaml @@ -25,7 +25,7 @@ Add a new mod from GitHub - diff --git a/OpenKh.Tools.ModsManager/Views/ModDetailsView.xaml b/OpenKh.Tools.ModsManager/Views/ModDetailsView.xaml index 756a0e450..6bab87326 100644 --- a/OpenKh.Tools.ModsManager/Views/ModDetailsView.xaml +++ b/OpenKh.Tools.ModsManager/Views/ModDetailsView.xaml @@ -1,10 +1,10 @@ diff --git a/OpenKh.Tools.ModsManager/Views/ModManagerView.xaml b/OpenKh.Tools.ModsManager/Views/ModManagerView.xaml index 9962d5533..1454354b4 100644 --- a/OpenKh.Tools.ModsManager/Views/ModManagerView.xaml +++ b/OpenKh.Tools.ModsManager/Views/ModManagerView.xaml @@ -1,10 +1,10 @@ diff --git a/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml b/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml index 208d2a715..996510029 100644 --- a/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml @@ -10,7 +10,7 @@ ResizeMode="NoResize" FocusManager.FocusedElement="{Binding ElementName=txtSourceModUrl}" Title="Presets" Height="300" Width="300" SizeToContent="Height" Background="{Binding ColorTheme.BackgroundColor}"> - + @@ -25,7 +25,7 @@ Name Preset - @@ -56,6 +56,6 @@ - + diff --git a/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml.cs b/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml.cs index 486e457be..0abbf523a 100644 --- a/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml.cs +++ b/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml.cs @@ -59,10 +59,10 @@ private void Button_RemovePreset(object sender, RoutedEventArgs e) string presetName = (string)List_Presets.SelectedItem; MessageBoxResult messageBoxResult = MessageBox.Show($"Do you want to remove {presetName} preset.", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) - { + { MainVm.RemovePreset(presetName); } - + } } } diff --git a/OpenKh.Tools.ModsManager/Views/WorkInProgressWindow.xaml b/OpenKh.Tools.ModsManager/Views/WorkInProgressWindow.xaml index 896c3937b..987d2830a 100644 --- a/OpenKh.Tools.ModsManager/Views/WorkInProgressWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/WorkInProgressWindow.xaml @@ -8,7 +8,7 @@ Title="{Binding DialogTitle}" d:Title="Installing mod..." Height="120" Width="300" SizeToContent="WidthAndHeight" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> - + diff --git a/OpenKh.Tools.ModsManager/WinSettings.Designer.cs b/OpenKh.Tools.ModsManager/WinSettings.Designer.cs index 447c996ce..275f3b433 100644 --- a/OpenKh.Tools.ModsManager/WinSettings.Designer.cs +++ b/OpenKh.Tools.ModsManager/WinSettings.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 From 66d20410eda699330a9b865071d99f31e21862f3 Mon Sep 17 00:00:00 2001 From: shananas Date: Tue, 17 Sep 2024 12:49:54 -0400 Subject: [PATCH 2/2] Removed uneeded line --- OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml b/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml index 996510029..75aea700b 100644 --- a/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml @@ -4,7 +4,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.Views" - xmlns:ctrls="clr-namespace:System.Windows.Controls" mc:Ignorable="d" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"