diff --git a/ModAssistant/App.config b/ModAssistant/App.config index 2da4524..1eb1102 100644 --- a/ModAssistant/App.config +++ b/ModAssistant/App.config @@ -50,6 +50,9 @@ True + + False + diff --git a/ModAssistant/App.xaml.cs b/ModAssistant/App.xaml.cs index 14cf15a..5230a7c 100644 --- a/ModAssistant/App.xaml.cs +++ b/ModAssistant/App.xaml.cs @@ -21,6 +21,7 @@ namespace ModAssistant public static bool CheckInstalledMods; public static bool SelectInstalledMods; public static bool ReinstallInstalledMods; + public static bool CloseWindowOnFinish; public static string Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); public static List SavedMods = ModAssistant.Properties.Settings.Default.SavedMods.Split(',').ToList(); public static MainWindow window; @@ -69,6 +70,7 @@ namespace ModAssistant CheckInstalledMods = ModAssistant.Properties.Settings.Default.CheckInstalled; SelectInstalledMods = ModAssistant.Properties.Settings.Default.SelectInstalled; ReinstallInstalledMods = ModAssistant.Properties.Settings.Default.ReinstallInstalled; + CloseWindowOnFinish = ModAssistant.Properties.Settings.Default.CloseWindowOnFinish; await ArgumentHandler(e.Args); await Init(); @@ -108,6 +110,12 @@ namespace ModAssistant await OneClickInstaller.InstallAsset(args[1]); } + if (CloseWindowOnFinish) + { + await Task.Delay(5 * 1000); + Current.Shutdown(); + } + Update = false; GUI = false; args = Shift(args, 2); diff --git a/ModAssistant/Classes/External Interfaces/BeatSaver.cs b/ModAssistant/Classes/External Interfaces/BeatSaver.cs index 41fad31..d58fd26 100644 --- a/ModAssistant/Classes/External Interfaces/BeatSaver.cs +++ b/ModAssistant/Classes/External Interfaces/BeatSaver.cs @@ -61,6 +61,7 @@ namespace ModAssistant.API { ModAssistant.Utils.Log($"Failed downloading BeatSaver map: {id} | Error: {e.Message}", "ERROR"); Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:Failed"), (map.Name ?? id))}"); + App.CloseWindowOnFinish = false; } return map; } @@ -71,6 +72,7 @@ namespace ModAssistant.API { ModAssistant.Utils.Log($"Max tries reached: Skipping {url}", "ERROR"); Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:RatelimitSkip"), url)}"); + App.CloseWindowOnFinish = false; throw new Exception("Max retries allowed"); } @@ -97,6 +99,7 @@ namespace ModAssistant.API else { Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:Failed"), url)}"); + App.CloseWindowOnFinish = false; return response; } } @@ -197,9 +200,9 @@ namespace ModAssistant.API return mapName; } - public static BeatSaver.BeatSaverRatelimit GetRatelimit(HttpResponseHeaders headers) + public static BeatSaverRatelimit GetRatelimit(HttpResponseHeaders headers) { - BeatSaver.BeatSaverRatelimit ratelimit = new BeatSaver.BeatSaverRatelimit(); + BeatSaverRatelimit ratelimit = new BeatSaverRatelimit(); if (headers.TryGetValues("Rate-Limit-Remaining", out IEnumerable _remaining)) @@ -241,6 +244,8 @@ namespace ModAssistant.API { if (retries == 0) { + Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:RatelimitSkip"), url)}"); + App.CloseWindowOnFinish = false; ModAssistant.Utils.Log($"Max tries reached: Couldn't download {url}", "ERROR"); throw new Exception("Max retries allowed"); } diff --git a/ModAssistant/Classes/External Interfaces/Playlists.cs b/ModAssistant/Classes/External Interfaces/Playlists.cs index ab6b09a..30b52bc 100644 --- a/ModAssistant/Classes/External Interfaces/Playlists.cs +++ b/ModAssistant/Classes/External Interfaces/Playlists.cs @@ -77,6 +77,7 @@ namespace ModAssistant.API { Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("Options:FailedPlaylistSong"), song.songName)}"); ModAssistant.Utils.Log($"Failed installing BeatSaver map: {song.songName} | {song.key} | {song.hash} | ({response?.response?.ratelimit?.Remaining})"); + App.CloseWindowOnFinish = false; await Task.Delay(3 * 1000); Errors++; } diff --git a/ModAssistant/Classes/External Interfaces/Utils.cs b/ModAssistant/Classes/External Interfaces/Utils.cs index 604cef4..c2c04ec 100644 --- a/ModAssistant/Classes/External Interfaces/Utils.cs +++ b/ModAssistant/Classes/External Interfaces/Utils.cs @@ -69,6 +69,7 @@ namespace ModAssistant.API catch { SetMessage((string)Application.Current.FindResource("OneClick:AssetInstallFailed")); + App.CloseWindowOnFinish = false; } } } diff --git a/ModAssistant/Localisation/en.xaml b/ModAssistant/Localisation/en.xaml index 25105a7..d59414c 100644 --- a/ModAssistant/Localisation/en.xaml +++ b/ModAssistant/Localisation/en.xaml @@ -141,6 +141,7 @@ BeatSaver ModelSaber Playlists + Close window when finished Game Type Steam Oculus diff --git a/ModAssistant/Pages/Options.xaml b/ModAssistant/Pages/Options.xaml index 325bb27..0376030 100644 --- a/ModAssistant/Pages/Options.xaml +++ b/ModAssistant/Pages/Options.xaml @@ -218,6 +218,23 @@ IsChecked="{Binding PlaylistsProtocolHandlerEnabled}" Unchecked="PlaylistsProtocolHandler_Unchecked" /> + + + True + + False + \ No newline at end of file