Added option to automatically select installed mods.

This commit is contained in:
Assistant 2019-05-04 07:07:52 -04:00
parent f2ad770858
commit 0f374b32ab
11 changed files with 155 additions and 35 deletions

View file

@ -29,6 +29,9 @@
<setting name="Agreed" serializeAs="String">
<value>False</value>
</setting>
<setting name="SelectInstalled" serializeAs="String">
<value>False</value>
</setting>
</ModAssistant.Properties.Settings>
<ModAssistant.Settings1>
<setting name="InstallFolder" serializeAs="String">

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using ModAssistant;
@ -18,6 +19,8 @@ namespace ModAssistant
public static string BeatSaberInstallType;
public static bool SaveModSelection;
public static bool CheckInstalledMods;
public static bool SelectInstalledMods;
public static string Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
public static List<string> SavedMods = ModAssistant.Properties.Settings.Default.SavedMods.Split(',').ToList();
@ -27,8 +30,9 @@ namespace ModAssistant
BeatSaberInstallType = ModAssistant.Properties.Settings.Default.StoreType;
SaveModSelection = ModAssistant.Properties.Settings.Default.SaveSelected;
CheckInstalledMods = ModAssistant.Properties.Settings.Default.CheckInstalled;
SelectInstalledMods = ModAssistant.Properties.Settings.Default.SelectInstalled;
Update.Run();
Updater.Run();
if (e.Args.Length == 0)
{

View file

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace ModAssistant
{
class Update
{
private static string ExePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
public static bool NeedsUpdate()
{
return false;
}
public static void Run()
{
//MessageBox.Show(Update.ExePath);
}
}
}

View file

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace ModAssistant
{
class Updater
{
private static string APILatestURL = "https://api.github.com/repos/Assistant/ModAssistant/releases/latest";
private static string ExePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
public static bool CheckForUpdate()
{
return false;
}
public static void Run()
{
}
}
class Update
{
public string url;
public string assets_url;
public string upload_url;
public string html_url;
public int id;
public string node_id;
public string tag_name;
public string target_commitish;
public string name;
public bool draft;
public User author;
public bool prerelease;
public string created_at;
public string published_at;
public Assets[] assets;
public string tarball_url;
public string zipball_url;
public string body;
}
class Assets
{
public string url;
public int id;
public string node_id;
public string name;
public string label;
public User uploader;
public string content_type;
public string state;
public int size;
public string created_at;
public string updated_at;
public string browser_download_url;
}
class User
{
public string login;
public int id;
public string node_id;
public string avatar_url;
public string gravatar_id;
public string url;
public string html_url;
public string followers_url;
public string following_url;
public string gists_url;
public string starred_url;
public string subscriptions_url;
public string organizations_url;
public string repos_url;
public string events_url;
public string received_events_url;
public string type;
public bool site_admin;
}
}

View file

@ -45,7 +45,7 @@ namespace ModAssistant
InitializeComponent();
Instance = this;
VersionText.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
VersionText.Text = App.Version;
if (Properties.Settings.Default.Agreed)
{

View file

@ -64,7 +64,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Classes\Diagnostics.cs" />
<Compile Include="Classes\Update.cs" />
<Compile Include="Classes\Updater.cs" />
<Compile Include="Pages\Intro.xaml.cs">
<DependentUpon>Intro.xaml</DependentUpon>
</Compile>

View file

@ -28,7 +28,7 @@ namespace ModAssistant.Pages
{
public static Mods Instance = new Mods();
public string[] DefaultMods = { "SongLoader", "ScoreSaber", "BeatSaverDownloader" };
public List<string> DefaultMods = new List<string>(){ "SongLoader", "ScoreSaber", "BeatSaverDownloader" };
public Mod[] ModsList;
public static List<Mod> InstalledMods = new List<Mod>();
public List<string> CategoryNames = new List<string>();
@ -98,6 +98,10 @@ namespace ModAssistant.Pages
if (!InstalledMods.Contains(mod))
{
InstalledMods.Add(mod);
if (App.SelectInstalledMods && !DefaultMods.Contains(mod.name))
{
DefaultMods.Add(mod.name);
}
}
}
}
@ -437,7 +441,7 @@ namespace ModAssistant.Pages
private void Uninstall_Click(object sender, RoutedEventArgs e)
{
Mod mod = ((sender as System.Windows.Controls.Button).Tag as Mod);
if (System.Windows.Forms.MessageBox.Show($"Uninstall {mod.name}?", $"Are you sure you want to remove {mod.name}?\nThis can break other of your mods.", MessageBoxButtons.YesNo) == DialogResult.Yes)
if (System.Windows.Forms.MessageBox.Show($"Are you sure you want to remove {mod.name}?\nThis could break your other mods.", $"Uninstall {mod.name}?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Mod.DownloadLink links = null;
foreach (Mod.DownloadLink link in mod.downloads)
@ -454,6 +458,15 @@ namespace ModAssistant.Pages
}
mod.ListItem.IsInstalled = false;
mod.ListItem.InstalledVersion = null;
if (App.SelectInstalledMods)
{
mod.ListItem.IsSelected = false;
UnresolveDependencies(mod);
App.SavedMods.Remove(mod.name);
Properties.Settings.Default.SavedMods = String.Join(",", App.SavedMods.ToArray());
Properties.Settings.Default.Save();
RefreshModsList();
}
view.Refresh();
}
}

View file

@ -51,15 +51,18 @@
<TextBlock Margin="5,5,5,0" Text="Will slow down mod list loading" HorizontalAlignment="Left" />
<TextBlock Margin="5,0,5,5" Text="Requires application restart" HorizontalAlignment="Left" />
</StackPanel>
<TextBlock Grid.Row="6" Margin="20,5,5,5" Text="Select Installed Mods" FontWeight="Bold" HorizontalAlignment="Left" FontSize="16" />
<CheckBox Grid.Row="6" Grid.Column="1" Name="SelectInstalled" VerticalAlignment="Center" HorizontalAlignment="Left" IsChecked="{Binding SelectInstalledMods, Mode=TwoWay}" Checked="SelectInstalled_Checked" Unchecked="SelectInstalled_Unchecked"/>
<TextBlock Grid.Row="6" Margin="5" Text="Enable OneClick Installs" FontWeight="Bold" HorizontalAlignment="Left" FontSize="16" />
<CheckBox Grid.Row="6" Grid.Column="1" Name="ProtocolHandler" VerticalAlignment="Center" HorizontalAlignment="Left" IsChecked="{Binding ProtocolHandlerEnabled, Mode=TwoWay}" Checked="ProtocolHandler_Checked" Unchecked="ProtocolHandler_Unchecked"/>
<StackPanel Grid.Row="7" Margin="20,0,0,0" Background="LightYellow" HorizontalAlignment="Left">
<TextBlock Grid.Row="7" Margin="5" Text="Enable OneClick Installs" FontWeight="Bold" HorizontalAlignment="Left" FontSize="16" />
<CheckBox Grid.Row="7" Grid.Column="1" Name="ProtocolHandler" VerticalAlignment="Center" HorizontalAlignment="Left" IsChecked="{Binding ProtocolHandlerEnabled, Mode=TwoWay}" Checked="ProtocolHandler_Checked" Unchecked="ProtocolHandler_Unchecked"/>
<StackPanel Grid.Row="8" Margin="20,0,0,0" Background="LightYellow" HorizontalAlignment="Left">
<TextBlock Margin="5,5,5,0" Text="Allows use of OneClick Install links" HorizontalAlignment="Left" />
<TextBlock Margin="5,0,5,5" Text="Requires Admin" HorizontalAlignment="Left" />
</StackPanel>
<StackPanel Grid.Row="8" Margin="5" Orientation="Horizontal" HorizontalAlignment="Left">
<StackPanel Grid.Row="9" Margin="5" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Text="Game Type: " FontWeight="Bold" FontSize="16" />
<TextBlock Text="{Binding InstallType}" FontSize="16"/>
</StackPanel>

View file

@ -28,6 +28,8 @@ namespace ModAssistant.Pages
public string InstallType { get; set; }
public bool SaveSelection { get; set; }
public bool CheckInstalledMods { get; set; }
public bool SelectInstalledMods { get; set; }
public Options()
{
@ -36,6 +38,9 @@ namespace ModAssistant.Pages
InstallType = App.BeatSaberInstallType;
SaveSelection = App.SaveModSelection;
CheckInstalledMods = App.CheckInstalledMods;
SelectInstalledMods = App.SelectInstalledMods;
if (!CheckInstalledMods)
SelectInstalled.IsEnabled = false;
this.DataContext = this;
}
@ -70,6 +75,7 @@ namespace ModAssistant.Pages
App.CheckInstalledMods = true;
CheckInstalledMods = true;
Properties.Settings.Default.Save();
SelectInstalled.IsEnabled = true;
}
private void CheckInstalled_Unchecked(object sender, RoutedEventArgs e)
@ -78,6 +84,7 @@ namespace ModAssistant.Pages
App.CheckInstalledMods = false;
CheckInstalledMods = false;
Properties.Settings.Default.Save();
SelectInstalled.IsEnabled = false;
}
private void ProtocolHandler_Checked(object sender, RoutedEventArgs e)
@ -89,5 +96,21 @@ namespace ModAssistant.Pages
{
}
private void SelectInstalled_Checked(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.SelectInstalled = true;
App.SelectInstalledMods = true;
SelectInstalledMods = true;
Properties.Settings.Default.Save();
}
private void SelectInstalled_Unchecked(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.SelectInstalled = false;
App.SelectInstalledMods = false;
SelectInstalledMods = false;
Properties.Settings.Default.Save();
}
}
}

View file

@ -94,5 +94,17 @@ namespace ModAssistant.Properties {
this["Agreed"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool SelectInstalled {
get {
return ((bool)(this["SelectInstalled"]));
}
set {
this["SelectInstalled"] = value;
}
}
}
}

View file

@ -20,5 +20,8 @@
<Setting Name="Agreed" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="SelectInstalled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>