Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoresaber support #2

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ModAssistant/Classes/OneClickInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ModAssistant
{
class OneClickInstaller
{
private static readonly string[] Protocols = new[] { "modelsaber", "beatsaver", "bsplaylist" };
private static readonly string[] Protocols = new[] { "modelsaber", "beatsaver", "bsplaylist", "web+bsmap" };
public static OneClickStatus Status = new OneClickStatus();

public static async Task InstallAsset(string link)
Expand All @@ -28,6 +28,9 @@ public static async Task InstallAsset(string link)
case "beatsaver":
await BeatSaver(uri);
break;
case "web+bsmap":
await ScoreSaber(uri);
break;
case "bsplaylist":
await Playlist(uri);
break;
Expand Down Expand Up @@ -56,6 +59,12 @@ private static async Task BeatSaver(Uri uri)
await API.BeatSaver.GetFromKey(Key);
}

private static async Task ScoreSaber(Uri uri)
{
string Hash = uri.Host;
await API.BeatSaver.GetFromHash(Hash);
}

private static async Task ModelSaber(Uri uri)
{
if (App.OCIWindow != "No" && App.OCIWindow != "Notify") Status.Show();
Expand Down
1 change: 1 addition & 0 deletions ModAssistant/Localisation/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
<sys:String x:Key="Options:ReinstallInstalledMods">Reinstall Installed Mods</sys:String>
<sys:String x:Key="Options:EnableOneClickInstalls">Enable OneClick™ Installs</sys:String>
<sys:String x:Key="Options:BeatSaver">BeatSaver</sys:String>
<sys:String x:Key="Options:ScoreSaber">ScoreSaber</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>
Expand Down
9 changes: 9 additions & 0 deletions ModAssistant/Pages/Options.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@
Unchecked="BeatSaverProtocolHandler_Unchecked"/>
<MenuItem
Padding="5,0"
Header="{DynamicResource Options:ScoreSaber}"
Name="ScoreSaberProtocolHandler"
IsCheckable="True"
StaysOpenOnClick="True"
Checked="ScoreSaberProtocolHandler_Checked"
IsChecked="{Binding ScoreSaberProtocolHandlerEnabled}"
Unchecked="ScoreSaberProtocolHandler_Unchecked"/>
<MenuItem
Padding="5,0"
Header="{DynamicResource Options:ModelSaber}"
Name="ModelSaberProtocolHandler"
IsCheckable="True"
Expand Down
13 changes: 13 additions & 0 deletions ModAssistant/Pages/Options.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class Options : Page
public bool ReinstallInstalledMods { get; set; }
public bool ModelSaberProtocolHandlerEnabled { get; set; }
public bool BeatSaverProtocolHandlerEnabled { get; set; }
public bool ScoreSaberProtocolHandlerEnabled { get; set; }
public bool PlaylistsProtocolHandlerEnabled { get; set; }
public bool CloseWindowOnFinish { get; set; }
public string LogURL { get; private set; }
Expand Down Expand Up @@ -55,6 +56,7 @@ public void UpdateHandlerStatus()
{
ModelSaberProtocolHandlerEnabled = OneClickInstaller.IsRegistered("modelsaber");
BeatSaverProtocolHandlerEnabled = OneClickInstaller.IsRegistered("beatsaver");
ScoreSaberProtocolHandlerEnabled = OneClickInstaller.IsRegistered("web+bsmap");
PlaylistsProtocolHandlerEnabled = OneClickInstaller.IsRegistered("bsplaylist");
}

Expand Down Expand Up @@ -154,6 +156,17 @@ public void BeatSaverProtocolHandler_Unchecked(object sender, RoutedEventArgs e)
{
OneClickInstaller.Unregister("beatsaver");
}

public void ScoreSaberProtocolHandler_Checked(object sender, RoutedEventArgs e)
{
OneClickInstaller.Register("web+bsmap", Description: "URL:web+bsmap OneClick Install");
}

public void ScoreSaberProtocolHandler_Unchecked(object sender, RoutedEventArgs e)
{
OneClickInstaller.Unregister("web+bsmap");
}

public void PlaylistsProtocolHandler_Checked(object sender, RoutedEventArgs e)
{
OneClickInstaller.Register("bsplaylist", Description: "URL:BeatSaver Playlist OneClick Install");
Expand Down