mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-21 04:42:52 +12:00
Added option to have OCI window close after its finished
This commit is contained in:
parent
dba0a7d951
commit
ec03c8127b
|
@ -50,6 +50,9 @@
|
|||
<setting name="ReinstallInstalled" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="CloseWindowOnFinish" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</ModAssistant.Properties.Settings>
|
||||
<ModAssistant.Settings1>
|
||||
<setting name="InstallFolder" serializeAs="String">
|
||||
|
|
|
@ -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<string> 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);
|
||||
|
|
|
@ -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<string> _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");
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace ModAssistant.API
|
|||
catch
|
||||
{
|
||||
SetMessage((string)Application.Current.FindResource("OneClick:AssetInstallFailed"));
|
||||
App.CloseWindowOnFinish = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
<sys:String x:Key="Options:BeatSaver">BeatSaver</sys:String>
|
||||
<sys:String x:Key="Options:ModelSaber">ModelSaber</sys:String>
|
||||
<sys:String x:Key="Options:Playlists">Playlists</sys:String>
|
||||
<sys:String x:Key="Options:CloseWindow">Close window when finished</sys:String>
|
||||
<sys:String x:Key="Options:GameType">Game Type</sys:String>
|
||||
<sys:String x:Key="Options:GameType:Steam">Steam</sys:String>
|
||||
<sys:String x:Key="Options:GameType:Oculus">Oculus</sys:String>
|
||||
|
|
|
@ -218,6 +218,23 @@
|
|||
IsChecked="{Binding PlaylistsProtocolHandlerEnabled}"
|
||||
Unchecked="PlaylistsProtocolHandler_Unchecked" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="11"
|
||||
Margin="50,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Text="{DynamicResource Options:CloseWindow}" />
|
||||
<CheckBox
|
||||
Name="CloseWindowToggle"
|
||||
Grid.Row="11"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Checked="CloseWindowOnFinish_Checked"
|
||||
IsChecked="{Binding CloseWindowOnFinish}"
|
||||
Unchecked="CloseWindowOnFinish_Unchecked" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="12"
|
||||
Margin="5"
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace ModAssistant.Pages
|
|||
public bool ModelSaberProtocolHandlerEnabled { get; set; }
|
||||
public bool BeatSaverProtocolHandlerEnabled { get; set; }
|
||||
public bool PlaylistsProtocolHandlerEnabled { get; set; }
|
||||
public bool CloseWindowOnFinish { get; set; }
|
||||
public string LogURL { get; private set; }
|
||||
|
||||
public Options()
|
||||
|
@ -36,6 +37,7 @@ namespace ModAssistant.Pages
|
|||
CheckInstalledMods = App.CheckInstalledMods;
|
||||
SelectInstalledMods = App.SelectInstalledMods;
|
||||
ReinstallInstalledMods = App.ReinstallInstalledMods;
|
||||
CloseWindowOnFinish = App.CloseWindowOnFinish;
|
||||
if (!CheckInstalledMods)
|
||||
{
|
||||
SelectInstalled.IsEnabled = false;
|
||||
|
@ -116,6 +118,22 @@ namespace ModAssistant.Pages
|
|||
}
|
||||
}
|
||||
|
||||
private void CloseWindowOnFinish_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.CloseWindowOnFinish = true;
|
||||
App.CloseWindowOnFinish = true;
|
||||
CloseWindowOnFinish = true;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void CloseWindowOnFinish_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.CloseWindowOnFinish = false;
|
||||
App.CloseWindowOnFinish = false;
|
||||
CloseWindowOnFinish = false;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
public void ModelSaberProtocolHandler_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OneClickInstaller.Register("modelsaber");
|
||||
|
|
12
ModAssistant/Properties/Settings.Designer.cs
generated
12
ModAssistant/Properties/Settings.Designer.cs
generated
|
@ -178,5 +178,17 @@ namespace ModAssistant.Properties {
|
|||
this["ReinstallInstalled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool CloseWindowOnFinish {
|
||||
get {
|
||||
return ((bool)(this["CloseWindowOnFinish"]));
|
||||
}
|
||||
set {
|
||||
this["CloseWindowOnFinish"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,5 +41,8 @@
|
|||
<Setting Name="ReinstallInstalled" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="CloseWindowOnFinish" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
Loading…
Reference in a new issue