Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Noxalus committed Jul 9, 2024
2 parents 0956d2d + dff6b4a commit 5e191aa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
6 changes: 3 additions & 3 deletions KHFM-VF-Patch/KHFM-VF-Patch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<PackageIcon>logo.png</PackageIcon>
<RepositoryUrl>https://github.com/Noxalus/KHFM-VF-Patch</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<Version>2.0.0</Version>
<AssemblyVersion>2.0.1.0</AssemblyVersion>
<FileVersion>2.0.1.0</FileVersion>
<Version>2.0.1</Version>
<ApplicationIcon>icon.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile> <!-- Enable single-file publish -->
<SelfContained>true</SelfContained> <!-- Include the .NET runtime -->
Expand Down
12 changes: 8 additions & 4 deletions KHFM-VF-Patch/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
</Image>

<StackPanel x:Name="PatchOptions" Grid.Column="0" Grid.Row="2">
<DockPanel>
<CheckBox x:Name="PatchVideosOption" Content="Mettre à jour les vidéos" FontWeight="Bold" />
</DockPanel>
<DockPanel Margin="20,0,0,20">
<TextBlock TextWrapping="Wrap" FontSize="10">Remplacer la piste audio et les sous-titres des vidéos pré-rendues de début et de fin de jeu.</TextBlock>
</DockPanel>

<DockPanel>
<CheckBox x:Name="PatchMagicOption" FontWeight="Bold" Content="Appliquer la correction de &quot;Magic&quot; en &quot;Magie&quot;" />
</DockPanel>
Expand All @@ -52,7 +59,7 @@
</DockPanel>

<DockPanel>
<CheckBox x:Name="PatchTextureOption" Content="Appliquer les corrections de traduction." FontWeight="Bold" />
<CheckBox x:Name="PatchTextureOption" Content="Appliquer les corrections de traduction" FontWeight="Bold" />
</DockPanel>
<DockPanel Margin="20,0,0,0">
<TextBlock TextWrapping="Wrap" Width="450" FontSize="10">
Expand All @@ -66,9 +73,6 @@
<Image Source="Resources/Images/TexturePatch.png" Margin="0,-20,0,0" Height="100" HorizontalAlignment="Right" />
</DockPanel>

<DockPanel Margin="0,0,0,0">
</DockPanel>

<DockPanel x:Name="SaveOriginalFilesCheckbox">
<CheckBox x:Name="SaveOriginalFilesOption" Content="Sauvegarder les fichiers originaux" FontWeight="Bold" />
</DockPanel>
Expand Down
39 changes: 37 additions & 2 deletions KHFM-VF-Patch/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public partial class MainWindow : Window
private bool _isSteamInstall;
private bool _shouldPatchMagic;
private bool _shouldPatchTexture;
private bool _shouldPatchVideos;
private bool _shouldSaveOriginalFiles;
private Random _random = new Random();

Expand Down Expand Up @@ -119,6 +120,19 @@ public bool ShouldPatchTexture
}
}

public bool ShouldPatchVideos
{
get { return _shouldPatchVideos; }
set
{
if (_shouldPatchVideos != value)
{
_shouldPatchVideos = value;
PatchVideosOption.IsChecked = value;
}
}
}

public bool ShouldSaveOriginalFiles
{
get { return _shouldSaveOriginalFiles; }
Expand All @@ -141,11 +155,13 @@ public MainWindow()
InitializeComponent();

// Enable all options by default
ShouldPatchVideos = true;
ShouldPatchMagic = true;
ShouldPatchTexture = true;
ShouldSaveOriginalFiles = true;

// Don't use data binding as I don't want to use MVVM pattern for a such simple app
PatchVideosOption.IsCheckedChanged += PatchVideosOption_IsCheckedChanged;
PatchMagicOption.IsCheckedChanged += OnPatchMagicOption_IsCheckedChanged;
PatchTextureOption.IsCheckedChanged += PatchTextureOption_IsCheckedChanged;
SaveOriginalFilesOption.IsCheckedChanged += SaveOriginalFilesOption_IsCheckedChanged;
Expand Down Expand Up @@ -177,11 +193,13 @@ public MainWindow()
// Check default installation folder for Steam
else if (CheckGameFolder(DEFAULT_STEAM_FOLDER, true))
{
_isSteamInstall = true;
_selectedGameFolder = DEFAULT_STEAM_FOLDER;
}
// Check default installation folder for the Steam Deck
else if (CheckGameFolder(DEFAULT_STEAM_DECK_FOLDER, true))
{
_isSteamInstall = true;
_selectedGameFolder = DEFAULT_STEAM_DECK_FOLDER;
}

Expand All @@ -195,6 +213,18 @@ public MainWindow()
}
}

#region Checkbox callbacks

// These should not be needed if we can use data binding...

private void PatchVideosOption_IsCheckedChanged(object? sender, RoutedEventArgs e)
{
if (sender is CheckBox checkbox)
{
_shouldPatchVideos = checkbox.IsChecked.HasValue && checkbox.IsChecked.Value;
}
}

private void OnPatchMagicOption_IsCheckedChanged(object? sender, RoutedEventArgs e)
{
if (sender is CheckBox checkbox)
Expand All @@ -221,6 +251,8 @@ private void SaveOriginalFilesOption_IsCheckedChanged(object? sender, RoutedEven

#endregion

#endregion

#region Random Quotes

private void StartRandomQuotes()
Expand Down Expand Up @@ -261,7 +293,7 @@ private void ReadyToPatchState()
if (!ShouldSaveOriginalFiles || CheckRemainingSpace(_selectedGameFolder))
{
SetUIVisibility(patch: true, gameFound: true, patchOptions: true, saveOriginalFiles: ShouldSaveOriginalFiles);
SetImageHeight(75);
SetImageHeight(0);
}
else
{
Expand Down Expand Up @@ -399,7 +431,10 @@ private async Task Patch(string? gameFolder)
Directory.Delete(patchesExtractionFolder, true);

// Update videos if the corresponding patch is found
await PatchVideos();
if (ShouldPatchVideos)
{
await PatchVideos();
}

// Extract VF patch files
await ExtractPatch(KH1_PATCH_VOICES_ZIP_NAME);
Expand Down

0 comments on commit 5e191aa

Please sign in to comment.