auto restart if path changed in settings

This commit is contained in:
Asval 2019-12-09 17:36:39 +01:00
parent 7df8475d21
commit 23e454533c
3 changed files with 17 additions and 8 deletions

View File

@ -13,7 +13,6 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FProp = FModel.Properties.Settings;
namespace FModel
{
@ -164,6 +163,7 @@ namespace FModel
}
private void MI_Settings_Click(object sender, RoutedEventArgs e)
{
DebugHelper.WriteLine("FWindow: Settings");
if (!FormsUtility.IsWindowOpen<Window>("Settings"))
{
new FModel_Settings().Show();

View File

@ -112,7 +112,6 @@ namespace FModel.Forms
private void Button_Click(object sender, RoutedEventArgs e)
{
SetUserSettings();
DebugHelper.WriteUserSettings();
Close();
}
@ -188,8 +187,13 @@ namespace FModel.Forms
if (restart)
{
DarkMessageBox.Show("Please, restart FModel to apply your new path(s)", "FModel Path(s) Changed", MessageBoxButton.OK, MessageBoxImage.Information);
DarkMessageBox.Show("FModel is about to restart because you applied your new path(s)", "FModel Path(s) Changed", MessageBoxButton.OK, MessageBoxImage.Information);
DebugHelper.WriteLine("FModel is restarting");
System.Windows.Forms.Application.Restart();
Application.Current.Shutdown();
}
else
DebugHelper.WriteUserSettings();
}
private async void UpdateImageBox(object sender, RoutedEventArgs e)

View File

@ -12,6 +12,8 @@ namespace FModel.Methods.PAKs
{
static class RegisterFromPath
{
private static string _ePath = string.Empty;
public static void FilterPAKs()
{
if (string.IsNullOrEmpty(FProp.Default.FPak_Path))
@ -87,11 +89,14 @@ namespace FModel.Methods.PAKs
private static string GetDatFile()
{
string ePath = $"{GetEpicDirectory()}\\UnrealEngineLauncher\\LauncherInstalled.dat";
if (File.Exists(ePath))
if (!string.IsNullOrEmpty(_ePath))
return _ePath;
_ePath = $"{GetEpicDirectory()}\\UnrealEngineLauncher\\LauncherInstalled.dat";
if (File.Exists(_ePath))
{
DebugHelper.WriteLine("EPIC .dat file at " + ePath);
return ePath;
DebugHelper.WriteLine("EPIC .dat file at " + _ePath);
return _ePath;
}
else
DebugHelper.WriteLine("EPIC .dat file not found");
@ -135,7 +140,7 @@ namespace FModel.Methods.PAKs
{
JToken game = GetGameData();
if (game != null)
DebugHelper.WriteLine("Fortnite version: " + game["AppVersion"] + " found in .dat file");
DebugHelper.WriteLine(game["AppVersion"] + " found in .dat file");
}
}
}