From 649f5d524f20417359ac759162b59720d91df5b0 Mon Sep 17 00:00:00 2001 From: Martin Barker <37368+barkermn01@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:52:59 +0000 Subject: [PATCH 1/2] Added support for notifying / asking user to allow 7th heaven to restart because they have changed there game path in the settings --- AppCore/StringKey.cs | 3 ++- .../Languages/StringResources.br.xaml | 1 + .../Languages/StringResources.es.xaml | 1 + .../Languages/StringResources.fr.xaml | 1 + .../Languages/StringResources.gr.xaml | 1 + .../Languages/StringResources.ja.xaml | 1 + AppUI/Resources/StringResources.xaml | 1 + AppUI/Windows/GeneralSettingsWindow.xaml.cs | 27 +++++++++++++++++++ AppUI/Windows/MainWindow.xaml.cs | 6 +++++ 9 files changed, 41 insertions(+), 1 deletion(-) diff --git a/AppCore/StringKey.cs b/AppCore/StringKey.cs index c8e702d4..8bc9b464 100644 --- a/AppCore/StringKey.cs +++ b/AppCore/StringKey.cs @@ -119,7 +119,8 @@ public enum StringKey EnterNameForCatalog, GeneralSettingsHaveBeenUpdated, SettingsNotValid, - MissingFf7ExePath, + MissingFf7ExePath, + Ff7ExePathChanged, MissingLibraryPath, MissingTexturesPath, MissingMoviePath, diff --git a/AppUI/Resources/Languages/StringResources.br.xaml b/AppUI/Resources/Languages/StringResources.br.xaml index 48b5c0a5..a93ada91 100644 --- a/AppUI/Resources/Languages/StringResources.br.xaml +++ b/AppUI/Resources/Languages/StringResources.br.xaml @@ -796,6 +796,7 @@ Mais tarde, se quiser utilizar os arquivos de alta qualidade .OGG, mude a config Verificando ff7 exe ... Verifying FF7_Launcher exe ... + Alteração no caminho do jogo detectada, recomendamos fortemente que você reinicie o 7th Heaven. Você gostaria de fazer isso agora? ff7.exe detectado como diferente. Criando backup e copiando .exe correto ... Não foi possível copiar ff7.exe. Abortando ... Não foi possível criar backup de ff7.exe. Abortando ... diff --git a/AppUI/Resources/Languages/StringResources.es.xaml b/AppUI/Resources/Languages/StringResources.es.xaml index f2d53de7..9a60b563 100644 --- a/AppUI/Resources/Languages/StringResources.es.xaml +++ b/AppUI/Resources/Languages/StringResources.es.xaml @@ -488,6 +488,7 @@ Haz clic en 'Cancelar' para detener el proceso. Configuración no válida Falta la ruta del FF7 Exe. + Se detectó un cambio en la ruta del juego, recomendamos encarecidamente que reinicies 7th Heaven. ¿Te gustaría hacerlo ahora? Falta la ruta de la Biblioteca. Falta la ruta de las Texturas (Aali OpenGL). Falta la ruta para las Cinemáticas. diff --git a/AppUI/Resources/Languages/StringResources.fr.xaml b/AppUI/Resources/Languages/StringResources.fr.xaml index bfc41ba6..480aacb1 100644 --- a/AppUI/Resources/Languages/StringResources.fr.xaml +++ b/AppUI/Resources/Languages/StringResources.fr.xaml @@ -791,6 +791,7 @@ Plus tard, si vous souhaitez utiliser des fichiers .OGG de haute qualité, remet Vérification de ff7 exe... Verifying FF7_Launcher exe ... + Changement de chemin de jeu détecté, nous vous recommandons vivement de redémarrer 7th Heaven. Souhaitez-vous le faire maintenant ? ff7.exe détecté comme étant différent. création d'une sauvegarde et copie du bon fichier .exe... échec de la copie de ff7.exe. Abandon... échec de la création d'une sauvegarde de ff7.exe. Abandon... diff --git a/AppUI/Resources/Languages/StringResources.gr.xaml b/AppUI/Resources/Languages/StringResources.gr.xaml index 0581a04b..01afc951 100644 --- a/AppUI/Resources/Languages/StringResources.gr.xaml +++ b/AppUI/Resources/Languages/StringResources.gr.xaml @@ -485,6 +485,7 @@ Οι ρυθμίσεις δεν είναι έγκυρες Λείπει η διαδρομή FF7 Exe. + Änderung des Spielpfads erkannt, wir empfehlen dringend, dass Sie 7th Heaven neu starten. Möchten Sie dies jetzt tun? Λείπει η διαδρομή βιβλιοθήκης. Λείπει η διαδρομή για Υφές (Aali OpenGL). Λείπει η διαδρομή για αρχεία βίντεο. diff --git a/AppUI/Resources/Languages/StringResources.ja.xaml b/AppUI/Resources/Languages/StringResources.ja.xaml index a87dad74..b8ebe149 100644 --- a/AppUI/Resources/Languages/StringResources.ja.xaml +++ b/AppUI/Resources/Languages/StringResources.ja.xaml @@ -476,6 +476,7 @@ Click 'Cancel' to stop the process. Settings Not Valid Missing FF7 Exe path. + Game path change detected, we highly recommend you restart 7th heaven would you like to now? Missing Library path. Missing Textures (Aali OpenGL) path. Missing Movie path. diff --git a/AppUI/Resources/StringResources.xaml b/AppUI/Resources/StringResources.xaml index 42603bcb..70246660 100644 --- a/AppUI/Resources/StringResources.xaml +++ b/AppUI/Resources/StringResources.xaml @@ -486,6 +486,7 @@ Click 'Cancel' to stop the process. Settings Not Valid Missing FF7 Exe path. + Game path change detected, we highly recommend you restart 7th heaven would you like to now? Missing Library path. Missing Textures (Aali OpenGL) path. Missing Movie path. diff --git a/AppUI/Windows/GeneralSettingsWindow.xaml.cs b/AppUI/Windows/GeneralSettingsWindow.xaml.cs index 08b286a2..2e392ce6 100644 --- a/AppUI/Windows/GeneralSettingsWindow.xaml.cs +++ b/AppUI/Windows/GeneralSettingsWindow.xaml.cs @@ -4,6 +4,9 @@ using AppUI.ViewModels; using System.IO; using System.Windows; +using System.Diagnostics; +using System; +using System.Threading; namespace AppUI.Windows { @@ -20,6 +23,8 @@ public partial class GeneralSettingsWindow : Window private FFNxDriverUpdater FFNxUpdater = new FFNxDriverUpdater(); + private bool PathChanged = false; + public GeneralSettingsWindow() { InitializeComponent(); @@ -41,6 +46,22 @@ private void btnOk_Click(object sender, RoutedEventArgs e) { bool settingsSaved = ViewModel.SaveSettings(); + if (PathChanged) + { + MessageDialogViewModel mdvm = MessageDialogWindow.Show(ResourceHelper.Get(StringKey.Ff7ExePathChanged), + ResourceHelper.Get(StringKey.Ff7ExePathChanged).Split(",")[0], + MessageBoxButton.YesNo, + MessageBoxImage.Warning); + + if (mdvm.Result == MessageBoxResult.Yes) + { + string exePath = Process.GetCurrentProcess().MainModule.FileName; + Process.Start(exePath); + + AppUI.MainWindow.dirtyHack.Close(); + } + } + if (settingsSaved) { this.DialogResult = true; @@ -80,6 +101,12 @@ private void btnFf7Exe_Click(object sender, RoutedEventArgs e) ViewModel.FF7ExePathInput = exePath; } + + string original = Sys.Settings.FF7Exe; + if ((original != null || original != "") && original != exePath ) + { + PathChanged = true; + } } private void btnLibrary_Click(object sender, RoutedEventArgs e) diff --git a/AppUI/Windows/MainWindow.xaml.cs b/AppUI/Windows/MainWindow.xaml.cs index 27f12fcb..e24fc08b 100644 --- a/AppUI/Windows/MainWindow.xaml.cs +++ b/AppUI/Windows/MainWindow.xaml.cs @@ -20,6 +20,11 @@ namespace AppUI /// public partial class MainWindow : Window { + // whom ever though that the settigns save should be handled by this window was wrong + // the settings class it's self should have a save method inside it but it does not this is horrible but the only way for + // game directory change notification to work. + public static MainWindow dirtyHack; + private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); internal MainWindowViewModel ViewModel { get; set; } @@ -29,6 +34,7 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); + dirtyHack = this; ViewModel = new MainWindowViewModel(); this.DataContext = ViewModel; From 2b9cbe462ec6e484cf0515d9452d828a78aebb1c Mon Sep 17 00:00:00 2001 From: Martin Barker <37368+barkermn01@users.noreply.github.com> Date: Wed, 11 Dec 2024 23:43:58 +0000 Subject: [PATCH 2/2] removed dirty hack and used Application.Shutdown() method --- AppUI/ViewModels/GeneralSettingsViewModel.cs | 4 ---- AppUI/Windows/GeneralSettingsWindow.xaml.cs | 3 +-- AppUI/Windows/MainWindow.xaml.cs | 6 ------ 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/AppUI/ViewModels/GeneralSettingsViewModel.cs b/AppUI/ViewModels/GeneralSettingsViewModel.cs index 27cac969..85e0546b 100644 --- a/AppUI/ViewModels/GeneralSettingsViewModel.cs +++ b/AppUI/ViewModels/GeneralSettingsViewModel.cs @@ -4,16 +4,12 @@ using Microsoft.Win32; using AppUI.Classes; using AppUI.Windows; -using AppUI; -using AppUI.ViewModels; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; namespace AppUI.ViewModels diff --git a/AppUI/Windows/GeneralSettingsWindow.xaml.cs b/AppUI/Windows/GeneralSettingsWindow.xaml.cs index 2e392ce6..a119b012 100644 --- a/AppUI/Windows/GeneralSettingsWindow.xaml.cs +++ b/AppUI/Windows/GeneralSettingsWindow.xaml.cs @@ -57,8 +57,7 @@ private void btnOk_Click(object sender, RoutedEventArgs e) { string exePath = Process.GetCurrentProcess().MainModule.FileName; Process.Start(exePath); - - AppUI.MainWindow.dirtyHack.Close(); + System.Windows.Application.Current.Shutdown(); } } diff --git a/AppUI/Windows/MainWindow.xaml.cs b/AppUI/Windows/MainWindow.xaml.cs index e24fc08b..27f12fcb 100644 --- a/AppUI/Windows/MainWindow.xaml.cs +++ b/AppUI/Windows/MainWindow.xaml.cs @@ -20,11 +20,6 @@ namespace AppUI /// public partial class MainWindow : Window { - // whom ever though that the settigns save should be handled by this window was wrong - // the settings class it's self should have a save method inside it but it does not this is horrible but the only way for - // game directory change notification to work. - public static MainWindow dirtyHack; - private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); internal MainWindowViewModel ViewModel { get; set; } @@ -34,7 +29,6 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); - dirtyHack = this; ViewModel = new MainWindowViewModel(); this.DataContext = ViewModel;