Skip to content

Commit

Permalink
Fix an exception related to the check to know if the code is executed…
Browse files Browse the repository at this point in the history
… from VS.
  • Loading branch information
Noxalus committed Jul 6, 2024
1 parent 987f0dd commit d099346
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions KHFM-VF-Patch/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Threading.Tasks;
using System.Threading;
using System.Linq;
using System.Reflection;

namespace KHFM_VF_Patch;

Expand Down Expand Up @@ -143,12 +142,10 @@ public MainWindow()
PatchTextureOption.IsCheckedChanged += PatchTextureOption_IsCheckedChanged;
SaveOriginalFilesOption.IsCheckedChanged += SaveOriginalFilesOption_IsCheckedChanged;

// TODO: Find a better way to do that
// Determine if this program is executed from a build or from Visual Studio
var assemblyPath = Assembly.GetEntryAssembly().Location;
var assemblyDirectory = Path.GetDirectoryName(assemblyPath);
var isUsingVisualStudio = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("VSAPPIDDIR"));

if (assemblyDirectory.EndsWith("win-x64"))
if (isUsingVisualStudio)
{
PROJECT_DIRECTORY = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.Parent.FullName;
}
Expand Down Expand Up @@ -186,7 +183,7 @@ public MainWindow()
ReadyToPatchState();
}
else
{
{
Debug.WriteLine("Default game folder not found.");
}
}
Expand Down Expand Up @@ -272,8 +269,6 @@ private void ReadyToPatchState()

if (!ShouldSaveOriginalFiles || CheckRemainingSpace(_selectedGameFolder))
{
_isSteamInstall = true;

SetUIVisibility(patch: true, gameFound: true, patchOptions: true, saveOriginalFiles: ShouldSaveOriginalFiles);
SetImageHeight(75);
}
Expand Down Expand Up @@ -324,8 +319,6 @@ private async void BrowseFolderButtonClick(object sender, RoutedEventArgs e)
if (result.Count == 1)
{
var path = result[0].Path.LocalPath;
Debug.WriteLine($"Selected: {path}");
Console.WriteLine($"Selected: {path}");

// Check if install is a Steam install
var steamFolder = Path.Combine(path, "STEAM");
Expand Down Expand Up @@ -501,7 +494,7 @@ private async Task PatchVideos()

var openingVideoFile = Path.Combine(PATCH_FOLDER, KH1_PATCH_EXTRACTION_FOLDER_NAME, KH1_OPENING_VIDEO_FILENAME);
var endingVideoFile = Path.Combine(PATCH_FOLDER, KH1_PATCH_EXTRACTION_FOLDER_NAME, KH1_ENDING_VIDEO_FILENAME);
var movieFolderPath = _isSteamInstall ? @"STEAM\dt\KH1Movie" : @"EPIC\en\KH1Movie";
var movieFolderPath = _isSteamInstall ? @"STEAM/dt/KH1Movie" : @"EPIC/en/KH1Movie";
var gameVideosFolder = Path.Combine(_selectedGameFolder, movieFolderPath);
var originalOpeningVideoFile = Path.Combine(gameVideosFolder, KH1_OPENING_VIDEO_FILENAME);
var originalEndingVideoFile = Path.Combine(gameVideosFolder, KH1_ENDING_VIDEO_FILENAME);
Expand Down Expand Up @@ -595,7 +588,7 @@ public static string GetMountPoint(string path)

return path;
}

private bool CheckRemainingSpace(string folder)
{
// Required at least 4GB to save original files
Expand Down

0 comments on commit d099346

Please sign in to comment.