Skip to content

Commit

Permalink
Merge pull request #1117 from shananas/Random-Cleanup
Browse files Browse the repository at this point in the history
Random cleanup
  • Loading branch information
Vladabdf authored Sep 18, 2024
2 parents a2d7fde + 66d2041 commit 923c0e6
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 60 deletions.
4 changes: 2 additions & 2 deletions OpenKh.Tools.ModsManager/App.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
Expand All @@ -24,4 +24,4 @@
</setting>
</OpenKh.Tools.ModsManager.WinSettings>
</userSettings>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion OpenKh.Tools.ModsManager/Services/GameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
3 changes: 0 additions & 3 deletions OpenKh.Tools.ModsManager/Services/ModsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public static void InstallModFromZip(
break;
case MessageBoxResult.No:
throw new ModAlreadyExistsExceptions(modName);
break;
}
}

Expand Down Expand Up @@ -309,7 +308,6 @@ public static async Task InstallModFromGithub(
break;
case MessageBoxResult.No:
throw new ModAlreadyExistsExceptions(repositoryName);
break;
}
}

Expand Down Expand Up @@ -362,7 +360,6 @@ public static void InstallModFromLua(string fileName)
break;
case MessageBoxResult.No:
throw new ModAlreadyExistsExceptions(modName);
break;
}
}
Directory.CreateDirectory(modPath);
Expand Down
4 changes: 2 additions & 2 deletions OpenKh.Tools.ModsManager/Services/Pcsx2Injector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="OpenKh.Tools.ModsManager.UserControls.FolderSelectorControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.UserControls"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="20" d:DesignWidth="200"
x:Name="_self">
<Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="OpenKh.Tools.ModsManager.UserControls.SaveFileSelectorControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.UserControls"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="20" d:DesignWidth="200"
x:Name="_self">
<Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="OpenKh.Tools.ModsManager.UserControls.TaskStatusByIconControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.UserControls"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="32" d:DesignWidth="32">
<Image Name="_icon" />
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="OpenKh.Tools.ModsManager.UserControls.TaskStatusObserverControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.UserControls"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="15" d:DesignWidth="100">
<TextBlock Text="(Task result here)" Name="_label" />
</UserControl>
10 changes: 5 additions & 5 deletions OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public int GametoLaunch
}
ReloadModsList();
if (ModsList.Count > 0)
FetchUpdates();
_ = FetchUpdates();
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -542,7 +542,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
}));

CheckOpenkhUpdateCommand = new RelayCommand(
_ => UpdateOpenkhAsync()
_ => _ = UpdateOpenkhAsync()
);

YamlGeneratorCommand = new RelayCommand(
Expand All @@ -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);
Expand Down Expand Up @@ -1342,7 +1342,7 @@ public void LoadPreset(string presetName)
ConfigurationService.EnabledMods = File.ReadAllLines(filename);
ReloadModsList();
if (ModsList.Count > 0)
FetchUpdates();
_ = FetchUpdates();
}
else
{
Expand Down
19 changes: 5 additions & 14 deletions OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 "";
}
Expand Down Expand Up @@ -685,7 +675,6 @@ public SetupWizardViewModel()
{
case MessageBoxResult.Yes:
goto BEGIN;
break;
}
}
});
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions OpenKh.Tools.ModsManager/Views/CopySourceFilesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
<DataTemplate>
<DockPanel LastChildFill="True" VerticalAlignment="Top" Margin="3">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right" VerticalAlignment="Center">
<CheckBox Content="Exists" IsChecked="{Binding DestinationFileExists}" IsEnabled="False" VerticalAlignment="Center" Margin="3"
<CheckBox Content="Exists" IsChecked="{Binding DestinationFileExists}" IsEnabled="False" VerticalAlignment="Center" Margin="3"
Foreground="{Binding Foreground,ElementName=_forTheme}"
/>
<CheckBox Content="{Binding ActionName}" IsChecked="{Binding DoAction}" VerticalAlignment="Center" Margin="3"
<CheckBox Content="{Binding ActionName}" IsChecked="{Binding DoAction}" VerticalAlignment="Center" Margin="3"
Foreground="{Binding Foreground,ElementName=_forTheme}"
/>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Title="{Binding DialogTitle}" d:Title="Installing mod..." Height="120" Width="300" SizeToContent="WidthAndHeight" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<StackPanel Margin="10">
<TextBlock Margin="0 0 0 10" d:Text="Installing the mod XYZ">
<Run Text="{Binding OperationName}"/>
<Run Text="{Binding OperationName}"/>
<Run> the mod </Run>
<Run FontWeight="Bold" Text="{Binding ModName}" d:Text="openkh/mod-template"/>
<Run>...</Run>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public string ModName
OnPropertyChanged();
}
}

public string ProgressText
{
get => _progressText;
Expand All @@ -58,7 +58,7 @@ public string ProgressText
OnPropertyChanged();
}
}

public bool ProgressUnknown
{
get => _progressUnknown;
Expand All @@ -68,7 +68,7 @@ private set
OnPropertyChanged();
}
}

public float ProgressValue
{
get => _progressValue;
Expand Down
2 changes: 1 addition & 1 deletion OpenKh.Tools.ModsManager/Views/InstallModView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<StackPanel Grid.Row="0">
<TextBlock Margin="0 0 0 3">Add a new mod from GitHub</TextBlock>
<Grid Margin="0 0 0 5" Background="White">
<TextBlock Margin="5,1" MinWidth="50" Text="eg. openkh/my-kingdomhearts-mod"
<TextBlock Margin="5,1" MinWidth="50" Text="eg. openkh/my-kingdomhearts-mod"
Foreground="Gray" Visibility="{Binding ElementName=txtSourceModUrl, Path=Text.IsEmpty, Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False"/>
<TextBox Name="txtSourceModUrl" Background="Transparent" Text="{Binding RepositoryName, UpdateSourceTrigger=PropertyChanged}" KeyUp="txtSourceModUrl_KeyUp" />
</Grid>
Expand Down
6 changes: 3 additions & 3 deletions OpenKh.Tools.ModsManager/Views/ModDetailsView.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="OpenKh.Tools.ModsManager.Views.ModDetailsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.Views"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="256">
<UserControl.Resources>
<SolidColorBrush x:Key="textHyperlink" Color="#569CD6"/>
Expand Down
6 changes: 3 additions & 3 deletions OpenKh.Tools.ModsManager/Views/ModManagerView.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="OpenKh.Tools.ModsManager.Views.ModManagerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenKh.Tools.ModsManager.Views"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="600" Background="{Binding ColorTheme.BackgroundColor}">
<UserControl.Resources>
<ControlTemplate x:Key="modList" TargetType="ListBox">
Expand Down
7 changes: 3 additions & 4 deletions OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
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"
FocusManager.FocusedElement="{Binding ElementName=txtSourceModUrl}"
Title="Presets" Height="300" Width="300" SizeToContent="Height" Background="{Binding ColorTheme.BackgroundColor}">

<Window.InputBindings>
<KeyBinding Key="Esc" Command="{Binding CloseCommand}"/>
</Window.InputBindings>
Expand All @@ -25,7 +24,7 @@
<StackPanel DockPanel.Dock="Bottom">
<TextBlock Margin="0 0 0 3" Foreground="{Binding ColorTheme.TextColor}">Name Preset</TextBlock>
<Grid Margin="0 0 0 5" Background="White">
<TextBlock Margin="5,1" MinWidth="50" Text="Enter New Preset Name"
<TextBlock Margin="5,1" MinWidth="50" Text="Enter New Preset Name"
Foreground="Gray" Visibility="{Binding ElementName=txtSourceModUrl, Path=Text.IsEmpty, Converter={StaticResource BooleanToVisibilityConverter}}" IsHitTestVisible="False"/>
<TextBox Name="txtSourceModUrl" Background="Transparent" Text="{Binding PresetName, UpdateSourceTrigger=PropertyChanged}" KeyUp="txtSourceModUrl_KeyUp" />
</Grid>
Expand Down Expand Up @@ -56,6 +55,6 @@
<Button Click="Button_RemovePreset">Remove</Button>
</StackPanel>
</Grid>

</DockPanel>
</Window>
4 changes: 2 additions & 2 deletions OpenKh.Tools.ModsManager/Views/PresetsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
}
}
Loading

0 comments on commit 923c0e6

Please sign in to comment.