diff --git a/BeatSaberModManager/Models/Implementations/Json/LegacyGameVersionJsonSerializerContext.cs b/BeatSaberModManager/Models/Implementations/Json/LegacyGameVersionJsonSerializerContext.cs
index 80e1d68..9296bb7 100644
--- a/BeatSaberModManager/Models/Implementations/Json/LegacyGameVersionJsonSerializerContext.cs
+++ b/BeatSaberModManager/Models/Implementations/Json/LegacyGameVersionJsonSerializerContext.cs
@@ -1,10 +1,10 @@
using System.Text.Json.Serialization;
-using BeatSaberModManager.Models.Implementations.LegacyVersions;
+using BeatSaberModManager.Models.Implementations.Versions;
namespace BeatSaberModManager.Models.Implementations.Json
{
- [JsonSerializable(typeof(SteamLegacyGameVersion[]))]
+ [JsonSerializable(typeof(SteamGameVersion[]))]
internal sealed partial class LegacyGameVersionJsonSerializerContext : JsonSerializerContext;
}
diff --git a/BeatSaberModManager/Models/Implementations/Versions/OculusGameVersion.cs b/BeatSaberModManager/Models/Implementations/Versions/OculusGameVersion.cs
new file mode 100644
index 0000000..f4cf2d8
--- /dev/null
+++ b/BeatSaberModManager/Models/Implementations/Versions/OculusGameVersion.cs
@@ -0,0 +1,100 @@
+using System;
+
+using BeatSaberModManager.Models.Interfaces;
+
+
+namespace BeatSaberModManager.Models.Implementations.Versions
+{
+ ///
+ ///
+ ///
+ public class OculusGameVersion : IGameVersion
+ {
+ ///
+ public required string GameVersion { get; init; }
+
+ ///
+ public DateTime ReleaseDate { get; init; }
+
+ ///
+ public Uri? ReleaseUrl { get; init; }
+
+ ///
+ public Uri? ReleaseImage { get; init; }
+
+ ///
+ ///
+ ///
+ public string? InstallDir { get; set; }
+
+ ///
+ public int CompareTo(IGameVersion? other) => throw new NotImplementedException();
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ if (ReferenceEquals(obj, null))
+ {
+ return false;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public override int GetHashCode()
+ {
+ throw new NotImplementedException();
+ }
+
+ public static bool operator ==(OculusGameVersion left, OculusGameVersion right)
+ {
+ if (ReferenceEquals(left, null))
+ {
+ return ReferenceEquals(right, null);
+ }
+
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(OculusGameVersion left, OculusGameVersion right)
+ {
+ return !(left == right);
+ }
+
+ public static bool operator <(OculusGameVersion left, OculusGameVersion right)
+ {
+ return ReferenceEquals(left, null) ? !ReferenceEquals(right, null) : left.CompareTo(right) < 0;
+ }
+
+ public static bool operator <=(OculusGameVersion left, OculusGameVersion right)
+ {
+ return ReferenceEquals(left, null) || left.CompareTo(right) <= 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool operator >(OculusGameVersion left, OculusGameVersion right)
+ {
+ return !ReferenceEquals(left, null) && left.CompareTo(right) > 0;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool operator >=(OculusGameVersion left, OculusGameVersion right)
+ {
+ return ReferenceEquals(left, null) ? ReferenceEquals(right, null) : left.CompareTo(right) >= 0;
+ }
+ }
+}
diff --git a/BeatSaberModManager/Models/Implementations/LegacyVersions/SteamLegacyGameVersion.cs b/BeatSaberModManager/Models/Implementations/Versions/SteamGameVersion.cs
similarity index 73%
rename from BeatSaberModManager/Models/Implementations/LegacyVersions/SteamLegacyGameVersion.cs
rename to BeatSaberModManager/Models/Implementations/Versions/SteamGameVersion.cs
index 9da07a3..6c4539e 100644
--- a/BeatSaberModManager/Models/Implementations/LegacyVersions/SteamLegacyGameVersion.cs
+++ b/BeatSaberModManager/Models/Implementations/Versions/SteamGameVersion.cs
@@ -5,12 +5,12 @@
using BeatSaberModManager.Models.Interfaces;
-namespace BeatSaberModManager.Models.Implementations.LegacyVersions
+namespace BeatSaberModManager.Models.Implementations.Versions
{
///
/// TODO
///
- public class SteamLegacyGameVersion : ILegacyGameVersion
+ public class SteamGameVersion : IGameVersion
{
///
public override int GetHashCode() => ManifestId.GetHashCode();
@@ -22,7 +22,7 @@ public class SteamLegacyGameVersion : ILegacyGameVersion
///
[JsonPropertyName("ReleaseDate")]
[JsonConverter(typeof(UnixDateTimeConverter))]
- public required DateTime ReleaseDate { get; init; }
+ public DateTime ReleaseDate { get; init; }
///
[JsonPropertyName("ReleaseURL")]
@@ -37,7 +37,13 @@ public class SteamLegacyGameVersion : ILegacyGameVersion
///
[JsonPropertyName("BSManifest")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
- public required ulong ManifestId { get; init; }
+ public ulong ManifestId { get; init; }
+
+ ///
+ ///
+ ///
+ [JsonIgnore]
+ public string? InstallDir { get; set; }
[JsonIgnore]
private Version Version
@@ -60,11 +66,11 @@ private Version Version
private Version? _version;
///
- public int CompareTo(ILegacyGameVersion? other)
+ public int CompareTo(IGameVersion? other)
{
if (ReferenceEquals(this, other))
return 0;
- if (other is not SteamLegacyGameVersion steamLegacyGameVersion)
+ if (other is not SteamGameVersion steamLegacyGameVersion)
return 1;
return Version.CompareTo(steamLegacyGameVersion.Version);
}
@@ -74,7 +80,7 @@ public override bool Equals(object? obj)
{
if (ReferenceEquals(this, obj))
return true;
- if (obj is not SteamLegacyGameVersion steamLegacyGameVersion)
+ if (obj is not SteamGameVersion steamLegacyGameVersion)
return false;
return ManifestId == steamLegacyGameVersion.ManifestId;
}
@@ -85,7 +91,7 @@ public override bool Equals(object? obj)
///
///
///
- public static bool operator ==(SteamLegacyGameVersion? left, SteamLegacyGameVersion? right)
+ public static bool operator ==(SteamGameVersion? left, SteamGameVersion? right)
{
if (left is null)
return right is null;
@@ -98,7 +104,7 @@ public override bool Equals(object? obj)
///
///
///
- public static bool operator !=(SteamLegacyGameVersion left, SteamLegacyGameVersion right) => !(left == right);
+ public static bool operator !=(SteamGameVersion left, SteamGameVersion right) => !(left == right);
///
///
@@ -106,7 +112,7 @@ public override bool Equals(object? obj)
///
///
///
- public static bool operator <(SteamLegacyGameVersion? left, SteamLegacyGameVersion? right)
+ public static bool operator <(SteamGameVersion? left, SteamGameVersion? right)
{
if (left is null)
return right is not null;
@@ -119,7 +125,7 @@ public override bool Equals(object? obj)
///
///
///
- public static bool operator <=(SteamLegacyGameVersion? left, SteamLegacyGameVersion? right) => left is null || left.CompareTo(right) <= 0;
+ public static bool operator <=(SteamGameVersion? left, SteamGameVersion? right) => left is null || left.CompareTo(right) <= 0;
///
///
@@ -127,7 +133,7 @@ public override bool Equals(object? obj)
///
///
///
- public static bool operator >(SteamLegacyGameVersion? left, SteamLegacyGameVersion? right) => left is not null && left.CompareTo(right) > 0;
+ public static bool operator >(SteamGameVersion? left, SteamGameVersion? right) => left is not null && left.CompareTo(right) > 0;
///
///
@@ -135,6 +141,6 @@ public override bool Equals(object? obj)
///
///
///
- public static bool operator >=(SteamLegacyGameVersion? left, SteamLegacyGameVersion? right) => left is null ? right is null : left.CompareTo(right) >= 0;
+ public static bool operator >=(SteamGameVersion? left, SteamGameVersion? right) => left is null ? right is null : left.CompareTo(right) >= 0;
}
}
diff --git a/BeatSaberModManager/Models/Interfaces/ILegacyGameVersion.cs b/BeatSaberModManager/Models/Interfaces/IGameVersion.cs
similarity index 87%
rename from BeatSaberModManager/Models/Interfaces/ILegacyGameVersion.cs
rename to BeatSaberModManager/Models/Interfaces/IGameVersion.cs
index 604a0cd..d3af8b7 100644
--- a/BeatSaberModManager/Models/Interfaces/ILegacyGameVersion.cs
+++ b/BeatSaberModManager/Models/Interfaces/IGameVersion.cs
@@ -6,7 +6,7 @@ namespace BeatSaberModManager.Models.Interfaces
///
///
///
- public interface ILegacyGameVersion : IComparable
+ public interface IGameVersion : IComparable
{
///
///
diff --git a/BeatSaberModManager/Program.cs b/BeatSaberModManager/Program.cs
index 8268a32..f79e905 100644
--- a/BeatSaberModManager/Program.cs
+++ b/BeatSaberModManager/Program.cs
@@ -18,11 +18,11 @@
using BeatSaberModManager.Services.Implementations.BeatSaber.Playlists;
using BeatSaberModManager.Services.Implementations.DependencyManagement;
using BeatSaberModManager.Services.Implementations.Http;
-using BeatSaberModManager.Services.Implementations.LegacyVersions.Steam;
using BeatSaberModManager.Services.Implementations.Progress;
using BeatSaberModManager.Services.Implementations.ProtocolHandlerRegistrars;
using BeatSaberModManager.Services.Implementations.Settings;
using BeatSaberModManager.Services.Implementations.Updater;
+using BeatSaberModManager.Services.Implementations.Versions.Steam;
using BeatSaberModManager.Services.Interfaces;
using BeatSaberModManager.ViewModels;
using BeatSaberModManager.Views;
diff --git a/BeatSaberModManager/Resources/Styles/AsyncImage.axaml b/BeatSaberModManager/Resources/Styles/AsyncImage.axaml
index 3dcf1fe..b7a3ac6 100644
--- a/BeatSaberModManager/Resources/Styles/AsyncImage.axaml
+++ b/BeatSaberModManager/Resources/Styles/AsyncImage.axaml
@@ -23,7 +23,8 @@
+ Stretch="{TemplateBinding Stretch}"
+ >
diff --git a/BeatSaberModManager/Resources/Styles/CardControl.axaml b/BeatSaberModManager/Resources/Styles/CardControl.axaml
index c93003d..9f03aa9 100644
--- a/BeatSaberModManager/Resources/Styles/CardControl.axaml
+++ b/BeatSaberModManager/Resources/Styles/CardControl.axaml
@@ -3,14 +3,14 @@
xmlns:c="using:BeatSaberModManager.Views.Controls">
-
+
-
+
diff --git a/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberGameLauncher.cs b/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberGameLauncher.cs
index f10d542..49f8219 100644
--- a/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberGameLauncher.cs
+++ b/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberGameLauncher.cs
@@ -1,8 +1,8 @@
using System;
using System.Diagnostics;
-using System.IO;
-using BeatSaberModManager.Models.Implementations;
+using BeatSaberModManager.Models.Implementations.Versions;
+using BeatSaberModManager.Models.Interfaces;
using BeatSaberModManager.Services.Interfaces;
using BeatSaberModManager.Utils;
@@ -10,18 +10,18 @@
namespace BeatSaberModManager.Services.Implementations.BeatSaber
{
///
- public class BeatSaberGameLauncher(IInstallDirLocator installDirLocator) : IGameLauncher
+ public class BeatSaberGameLauncher : IGameLauncher
{
///
- public void LaunchGame(string installDir)
+ public void LaunchGame(IGameVersion gameVersion)
{
- switch (installDirLocator.DetectPlatform(installDir))
+ switch (gameVersion)
{
- case PlatformType.Steam when new DirectoryInfo(installDir).Parent?.Parent?.Name == "steamapps":
+ case SteamGameVersion steamGameVersion:
PlatformUtils.TryOpenUri(new Uri("steam://rungameid/620980"));
break;
- case PlatformType.Oculus:
- PlatformUtils.TryStartProcess(new ProcessStartInfo("Beat Saber.exe") { WorkingDirectory = installDir }, out _);
+ case OculusGameVersion oculusGameVersion:
+ PlatformUtils.TryStartProcess(new ProcessStartInfo("Beat Saber.exe") { WorkingDirectory = oculusGameVersion.InstallDir }, out _);
break;
default:
throw new InvalidOperationException("Could not detect platform.");
diff --git a/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberInstallDirLocator.cs b/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberInstallDirLocator.cs
index e013640..2df96af 100644
--- a/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberInstallDirLocator.cs
+++ b/BeatSaberModManager/Services/Implementations/BeatSaber/BeatSaberInstallDirLocator.cs
@@ -5,7 +5,8 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using BeatSaberModManager.Models.Implementations;
+using BeatSaberModManager.Models.Implementations.Versions;
+using BeatSaberModManager.Models.Interfaces;
using BeatSaberModManager.Services.Interfaces;
using BeatSaberModManager.Utils;
@@ -15,43 +16,42 @@
namespace BeatSaberModManager.Services.Implementations.BeatSaber
{
///
- public partial class BeatSaberInstallDirLocator(IInstallDirValidator installDirValidator) : IInstallDirLocator
+ public partial class BeatSaberInstallDirLocator(IInstallDirValidator installDirValidator, IGameVersionProvider gameVersionProvider) : IInstallDirLocator
{
///
- public ValueTask LocateInstallDirAsync() =>
+ public ValueTask LocateInstallDirAsync() =>
OperatingSystem.IsWindows() ? LocateWindowsInstallDirAsync()
: OperatingSystem.IsLinux() ? LocateLinuxSteamInstallDirAsync()
: throw new PlatformNotSupportedException();
- ///
- public PlatformType DetectPlatform(string installDir)
- {
- string pluginsDir = Path.Join(installDir, "Beat Saber_Data", "Plugins");
- return File.Exists(Path.Join(pluginsDir, "steam_api64.dll")) || File.Exists(Path.Join(pluginsDir, "x86_64", "steam_api64.dll")) ? PlatformType.Steam : PlatformType.Oculus;
- }
-
[SupportedOSPlatform("windows")]
- private ValueTask LocateWindowsInstallDirAsync()
+ private ValueTask LocateWindowsInstallDirAsync()
{
string? steamInstallDir = LocateWindowsSteamInstallDir();
- return steamInstallDir is null ? ValueTask.FromResult(LocateOculusBeatSaberInstallDir()) : LocateSteamBeatSaberInstallDirAsync(steamInstallDir);
+ return steamInstallDir is null ? LocateOculusBeatSaberInstallDirAsync() : LocateSteamBeatSaberInstallDirAsync(steamInstallDir);
}
[SupportedOSPlatform("linux")]
- private ValueTask LocateLinuxSteamInstallDirAsync()
+ private ValueTask LocateLinuxSteamInstallDirAsync()
{
string homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string steamInstallDir = Path.Join(homeDir, ".steam", "root");
return LocateSteamBeatSaberInstallDirAsync(steamInstallDir);
}
- private async ValueTask LocateSteamBeatSaberInstallDirAsync(string steamInstallDir)
+ private async ValueTask LocateSteamBeatSaberInstallDirAsync(string steamInstallDir)
{
await foreach (string libPath in EnumerateSteamLibraryPathsAsync(steamInstallDir).ConfigureAwait(false))
{
string? installDir = await MatchSteamBeatSaberInstallDirAsync(libPath).ConfigureAwait(false);
- if (installDir is not null)
- return Path.GetFullPath(installDir);
+ if (installDir is null)
+ return null;
+ string? gameVersion = await gameVersionProvider.DetectGameVersionAsync(installDir).ConfigureAwait(false);
+ return gameVersion is null ? null : new SteamGameVersion
+ {
+ GameVersion = gameVersion,
+ InstallDir = installDir
+ };
}
return null;
@@ -81,7 +81,7 @@ public PlatformType DetectPlatform(string installDir)
}
[SupportedOSPlatform("windows")]
- private string? LocateOculusBeatSaberInstallDir()
+ private async ValueTask LocateOculusBeatSaberInstallDirAsync()
{
using RegistryKey? oculusInstallDirKey = Registry.LocalMachine.OpenSubKey("Software")?.OpenSubKey("Wow6432Node")?.OpenSubKey("Oculus VR, LLC")?.OpenSubKey("Oculus")?.OpenSubKey("Config");
string? oculusInstallDir = oculusInstallDirKey?.GetValue("InitialAppLibrary")?.ToString();
@@ -89,7 +89,14 @@ public PlatformType DetectPlatform(string installDir)
return null;
string finalPath = Path.Join(oculusInstallDir, "Software", "hyperbolic-magnetism-beat-saber");
string? installDir = installDirValidator.ValidateInstallDir(finalPath) ? finalPath : LocateInOculusLibrary();
- return installDir is null ? null : Path.GetFullPath(installDir);
+ if (installDir is null)
+ return null;
+ string? gameVersion = await gameVersionProvider.DetectGameVersionAsync(installDir).ConfigureAwait(false);
+ return gameVersion is null ? null : new OculusGameVersion
+ {
+ GameVersion = gameVersion,
+ InstallDir = Path.GetFullPath(installDir)
+ };
}
[SupportedOSPlatform("windows")]
diff --git a/BeatSaberModManager/Services/Implementations/LegacyVersions/Steam/SteamLegacyGameVersionInstaller.cs b/BeatSaberModManager/Services/Implementations/Versions/Steam/SteamLegacyGameVersionInstaller.cs
similarity index 77%
rename from BeatSaberModManager/Services/Implementations/LegacyVersions/Steam/SteamLegacyGameVersionInstaller.cs
rename to BeatSaberModManager/Services/Implementations/Versions/Steam/SteamLegacyGameVersionInstaller.cs
index 93316d6..83b1ed8 100644
--- a/BeatSaberModManager/Services/Implementations/LegacyVersions/Steam/SteamLegacyGameVersionInstaller.cs
+++ b/BeatSaberModManager/Services/Implementations/Versions/Steam/SteamLegacyGameVersionInstaller.cs
@@ -4,7 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
-using BeatSaberModManager.Models.Implementations.LegacyVersions;
+using BeatSaberModManager.Models.Implementations.Versions;
using BeatSaberModManager.Models.Interfaces;
using BeatSaberModManager.Services.Interfaces;
@@ -15,19 +15,19 @@
using SteamKit2;
-namespace BeatSaberModManager.Services.Implementations.LegacyVersions.Steam
+namespace BeatSaberModManager.Services.Implementations.Versions.Steam
{
///
public class SteamLegacyGameVersionInstaller(ISteamAuthenticator steamAuthenticator, ILogger logger) : ILegacyGameVersionInstaller
{
///
- public async Task InstallLegacyGameVersionAsync(ILegacyGameVersion legacyGameVersion, CancellationToken cancellationToken, IProgress? progress = null)
+ public async Task InstallLegacyGameVersionAsync(IGameVersion gameVersion, CancellationToken cancellationToken, IProgress? progress = null)
{
- ArgumentNullException.ThrowIfNull(legacyGameVersion);
- if (legacyGameVersion is not SteamLegacyGameVersion steamLegacyGameVersion)
+ ArgumentNullException.ThrowIfNull(gameVersion);
+ if (gameVersion is not SteamGameVersion steamLegacyGameVersion)
return null;
string appDataDirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- string legacyGameVersionsDirPath = Path.Join(appDataDirPath, ThisAssembly.Info.Product, "LegacyGameVersions", legacyGameVersion.GameVersion);
+ string legacyGameVersionsDirPath = Path.Join(appDataDirPath, ThisAssembly.Info.Product, "LegacyGameVersions", gameVersion.GameVersion);
(string? username, string? password, bool rememberLogin) = await steamAuthenticator.ProvideLoginDetailsAsync().ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
return null;
@@ -50,6 +50,6 @@ public class SteamLegacyGameVersionInstaller(ISteamAuthenticator steamAuthentica
}
///
- public Task UninstallLegacyGameVersionAsync(ILegacyGameVersion legacyGameVersion) => throw new NotImplementedException();
+ public Task UninstallLegacyGameVersionAsync(IGameVersion gameVersion) => throw new NotImplementedException();
}
}
diff --git a/BeatSaberModManager/Services/Implementations/LegacyVersions/Steam/SteamLegacyGameVersionProvider.cs b/BeatSaberModManager/Services/Implementations/Versions/Steam/SteamLegacyGameVersionProvider.cs
similarity index 74%
rename from BeatSaberModManager/Services/Implementations/LegacyVersions/Steam/SteamLegacyGameVersionProvider.cs
rename to BeatSaberModManager/Services/Implementations/Versions/Steam/SteamLegacyGameVersionProvider.cs
index ae136a5..b8204f5 100644
--- a/BeatSaberModManager/Services/Implementations/LegacyVersions/Steam/SteamLegacyGameVersionProvider.cs
+++ b/BeatSaberModManager/Services/Implementations/Versions/Steam/SteamLegacyGameVersionProvider.cs
@@ -12,17 +12,17 @@
using BeatSaberModManager.Services.Interfaces;
-namespace BeatSaberModManager.Services.Implementations.LegacyVersions.Steam
+namespace BeatSaberModManager.Services.Implementations.Versions.Steam
{
///
/// TODO
///
public class SteamLegacyGameVersionProvider(HttpProgressClient httpClient, IGameVersionProvider gameVersionProvider) : ILegacyGameVersionProvider
{
- private IReadOnlyList? _availableGameVersions;
+ private IReadOnlyList? _availableGameVersions;
///
- public async Task?> GetAvailableGameVersionsAsync()
+ public async Task?> GetAvailableGameVersionsAsync()
{
if (_availableGameVersions is not null)
return _availableGameVersions;
@@ -32,19 +32,19 @@ public class SteamLegacyGameVersionProvider(HttpProgressClient httpClient, IGame
#pragma warning disable CA2007
await using Stream contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
#pragma warning restore CA2007
- _availableGameVersions = await JsonSerializer.DeserializeAsync(contentStream, LegacyGameVersionJsonSerializerContext.Default.SteamLegacyGameVersionArray).ConfigureAwait(false);
+ _availableGameVersions = await JsonSerializer.DeserializeAsync(contentStream, LegacyGameVersionJsonSerializerContext.Default.SteamGameVersionArray).ConfigureAwait(false);
return _availableGameVersions;
}
///
- public async Task?> GetInstalledLegacyGameVersionsAsync()
+ public async Task?> GetInstalledLegacyGameVersionsAsync()
{
- IReadOnlyList? availableGameVersions = await GetAvailableGameVersionsAsync().ConfigureAwait(false);
+ IReadOnlyList? availableGameVersions = await GetAvailableGameVersionsAsync().ConfigureAwait(false);
if (availableGameVersions is null)
return null;
string appDataDirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string legacyGameVersionsDirPath = Path.Join(appDataDirPath, ThisAssembly.Info.Product, "LegacyGameVersions");
- List<(ILegacyGameVersion GameVersion, string InstallDir)> installedGameVersions = [];
+ List<(IGameVersion GameVersion, string InstallDir)> installedGameVersions = [];
try
{
foreach (string dir in Directory.EnumerateDirectories(legacyGameVersionsDirPath))
@@ -52,7 +52,7 @@ public class SteamLegacyGameVersionProvider(HttpProgressClient httpClient, IGame
string? installedVersion = await gameVersionProvider.DetectGameVersionAsync(dir).ConfigureAwait(false);
if (installedVersion is null)
continue;
- ILegacyGameVersion? legacyGameVersion = availableGameVersions.FirstOrDefault(version => version.GameVersion == installedVersion);
+ IGameVersion? legacyGameVersion = availableGameVersions.FirstOrDefault(version => version.GameVersion == installedVersion);
if (legacyGameVersion is not null)
installedGameVersions.Add((legacyGameVersion, dir));
}
diff --git a/BeatSaberModManager/Services/Interfaces/IGameLauncher.cs b/BeatSaberModManager/Services/Interfaces/IGameLauncher.cs
index ec29e65..e689a57 100644
--- a/BeatSaberModManager/Services/Interfaces/IGameLauncher.cs
+++ b/BeatSaberModManager/Services/Interfaces/IGameLauncher.cs
@@ -1,4 +1,7 @@
-namespace BeatSaberModManager.Services.Interfaces
+using BeatSaberModManager.Models.Interfaces;
+
+
+namespace BeatSaberModManager.Services.Interfaces
{
///
/// Provides a method to launch the game.
@@ -8,7 +11,7 @@ public interface IGameLauncher
///
/// Launches the game.
///
- /// The game's installation directory.
- void LaunchGame(string installDir);
+ /// The game version to start.
+ void LaunchGame(IGameVersion gameVersion);
}
}
diff --git a/BeatSaberModManager/Services/Interfaces/IInstallDirLocator.cs b/BeatSaberModManager/Services/Interfaces/IInstallDirLocator.cs
index 6c56275..59f4123 100644
--- a/BeatSaberModManager/Services/Interfaces/IInstallDirLocator.cs
+++ b/BeatSaberModManager/Services/Interfaces/IInstallDirLocator.cs
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using BeatSaberModManager.Models.Implementations;
+using BeatSaberModManager.Models.Interfaces;
namespace BeatSaberModManager.Services.Interfaces
@@ -14,13 +15,6 @@ public interface IInstallDirLocator
/// Asynchronously locates a game's installation directory, optionally asynchronously.
///
/// The installation directory of the game if found, null otherwise.
- ValueTask LocateInstallDirAsync();
-
- ///
- /// Detects the of an installation.
- ///
- /// The game's installation directory.
- /// The detected .
- PlatformType DetectPlatform(string installDir);
+ ValueTask LocateInstallDirAsync();
}
}
diff --git a/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionInstaller.cs b/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionInstaller.cs
index eec0fae..e02999c 100644
--- a/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionInstaller.cs
+++ b/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionInstaller.cs
@@ -15,17 +15,17 @@ public interface ILegacyGameVersionInstaller
///
///
///
- ///
+ ///
///
///
///
- Task InstallLegacyGameVersionAsync(ILegacyGameVersion legacyGameVersion, CancellationToken cancellationToken, IProgress? progress = null);
+ Task InstallLegacyGameVersionAsync(IGameVersion gameVersion, CancellationToken cancellationToken, IProgress? progress = null);
///
///
///
- ///
+ ///
///
- Task UninstallLegacyGameVersionAsync(ILegacyGameVersion legacyGameVersion);
+ Task UninstallLegacyGameVersionAsync(IGameVersion gameVersion);
}
}
diff --git a/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionProvider.cs b/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionProvider.cs
index 2a82652..650408e 100644
--- a/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionProvider.cs
+++ b/BeatSaberModManager/Services/Interfaces/ILegacyGameVersionProvider.cs
@@ -15,12 +15,12 @@ public interface ILegacyGameVersionProvider
///
///
///
- Task?> GetAvailableGameVersionsAsync();
+ Task?> GetAvailableGameVersionsAsync();
///
///
///
///
- Task?> GetInstalledLegacyGameVersionsAsync();
+ Task?> GetInstalledLegacyGameVersionsAsync();
}
}
diff --git a/BeatSaberModManager/ViewModels/GameVersionViewModel.cs b/BeatSaberModManager/ViewModels/GameVersionViewModel.cs
index 4b2aa9f..88badb2 100644
--- a/BeatSaberModManager/ViewModels/GameVersionViewModel.cs
+++ b/BeatSaberModManager/ViewModels/GameVersionViewModel.cs
@@ -17,10 +17,10 @@ public class GameVersionViewModel : ViewModelBase
///
///
///
- ///
- public GameVersionViewModel(ILegacyGameVersion legacyGameVersion)
+ ///
+ public GameVersionViewModel(IGameVersion gameVersion)
{
- LegacyGameVersion = legacyGameVersion;
+ GameVersion = gameVersion;
this.WhenAnyValue(static x => x.InstallDir)
.Select(static x => x is not null)
.ToProperty(this, nameof(IsInstalled), out _isInstalled);
@@ -29,7 +29,7 @@ public GameVersionViewModel(ILegacyGameVersion legacyGameVersion)
///
///
///
- public ILegacyGameVersion LegacyGameVersion { get; }
+ public IGameVersion GameVersion { get; }
///
/// The directory the version is installed at.
diff --git a/BeatSaberModManager/ViewModels/LegacyGameVersionsViewModel.cs b/BeatSaberModManager/ViewModels/LegacyGameVersionsViewModel.cs
index 172e895..39b3a92 100644
--- a/BeatSaberModManager/ViewModels/LegacyGameVersionsViewModel.cs
+++ b/BeatSaberModManager/ViewModels/LegacyGameVersionsViewModel.cs
@@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
+using BeatSaberModManager.Models.Implementations.Progress;
using BeatSaberModManager.Models.Interfaces;
using BeatSaberModManager.Services.Implementations.Progress;
using BeatSaberModManager.Services.Interfaces;
@@ -30,7 +31,7 @@ public class LegacyGameVersionsViewModel : ViewModelBase
///
/// TODO
///
- public LegacyGameVersionsViewModel(SettingsViewModel settingsViewModel, DashboardViewModel dashboardViewModel, ILegacyGameVersionProvider legacyGameVersionProvider, ILegacyGameVersionInstaller legacyGameVersionInstaller, StatusProgress statusProgress)
+ public LegacyGameVersionsViewModel(SettingsViewModel settingsViewModel, IInstallDirLocator installDirLocator, ILegacyGameVersionProvider legacyGameVersionProvider, ILegacyGameVersionInstaller legacyGameVersionInstaller, StatusProgress statusProgress)
{
_legacyGameVersionProvider = legacyGameVersionProvider;
_legacyGameVersionInstaller = legacyGameVersionInstaller;
@@ -42,16 +43,16 @@ public LegacyGameVersionsViewModel(SettingsViewModel settingsViewModel, Dashboar
.ToProperty(this, nameof(IsSuccess), out _isSuccess);
IObservable legacyGameVersions = InitializeCommand.WhereNotNull()
.Select(static x => x.ToArray());
- legacyGameVersions.CombineLatest(dashboardViewModel.WhenAnyValue(static x => x.GameVersion))
- .FirstAsync()
- .Select(static x => x.First.FirstOrDefault(gameVersion => gameVersion.LegacyGameVersion.GameVersion == x.Second))
+ legacyGameVersions
+ .SelectMany(async gameVersions => (GameVersions: gameVersions, InstalledVersion: await installDirLocator.LocateInstallDirAsync().ConfigureAwait(false)))
+ .Select(static x => x.GameVersions.FirstOrDefault(gameVersion => gameVersion.GameVersion == x.InstalledVersion))
.WhereNotNull()
- .Do(currentGameVersion => currentGameVersion.InstallDir = settingsViewModel.InstallDir)
+ .Do(currentGameVersion => currentGameVersion.InstallDir = "") //TODO
.Subscribe(currentGameVersion => SelectedLegacyGameVersion = currentGameVersion);
legacyGameVersions
.Select(static gameVersions => gameVersions
- .OrderByDescending(static x => x.LegacyGameVersion.ReleaseDate)
- .GroupBy(static version => version.LegacyGameVersion.ReleaseDate.Year)
+ .OrderByDescending(static x => x.GameVersion.ReleaseDate)
+ .GroupBy(static version => version.GameVersion.ReleaseDate.Year)
.ToArray())
.ToProperty(this, nameof(LegacyGameVersions), out _legacyGameVersions);
IObservable whenAnySelectedLegacyGameVersion = this.WhenAnyValue(static x => x.SelectedLegacyGameVersion);
@@ -59,8 +60,8 @@ public LegacyGameVersionsViewModel(SettingsViewModel settingsViewModel, Dashboar
InstallCommand = ReactiveCommand.CreateFromTask(InstallSelectedLegacyGameVersionAsync, canInstallVersion);
IObservable canUninstallVersion = whenAnySelectedLegacyGameVersion.Select(static version => version is not null && version.IsInstalled);
UninstallCommand = ReactiveCommand.CreateFromTask(UninstallSelectedLegacyGameVersionAsync, canUninstallVersion);
- IObservable canViewMoreInfo = whenAnySelectedLegacyGameVersion.Select(static version => version?.LegacyGameVersion.ReleaseUrl is not null);
- MoreInfoCommand = ReactiveCommand.Create(() => PlatformUtils.TryOpenUri(SelectedLegacyGameVersion!.LegacyGameVersion.ReleaseUrl!), canViewMoreInfo);
+ IObservable canViewMoreInfo = whenAnySelectedLegacyGameVersion.Select(static version => version?.GameVersion.ReleaseUrl is not null);
+ MoreInfoCommand = ReactiveCommand.Create(() => PlatformUtils.TryOpenUri(SelectedLegacyGameVersion!.GameVersion.ReleaseUrl!), canViewMoreInfo);
whenAnySelectedLegacyGameVersion.Where(static version => version is not null && version.IsInstalled)
.Subscribe(version => settingsViewModel.InstallDir = version!.InstallDir);
}
@@ -122,22 +123,23 @@ public GameVersionViewModel? SelectedLegacyGameVersion
private async Task?> GetLegacyGameVersionsAsync()
{
- IReadOnlyList? availableGameVersions = await _legacyGameVersionProvider.GetAvailableGameVersionsAsync().ConfigureAwait(true);
+ IReadOnlyList? availableGameVersions = await _legacyGameVersionProvider.GetAvailableGameVersionsAsync().ConfigureAwait(true);
if (availableGameVersions is null)
return null;
GameVersionViewModel[] gameVersionViewModels = availableGameVersions.Select(static x => new GameVersionViewModel(x)).ToArray();
- IReadOnlyList<(ILegacyGameVersion GameVersion, string InstallDir)>? installedGameVersions = await _legacyGameVersionProvider.GetInstalledLegacyGameVersionsAsync().ConfigureAwait(true);
+ IReadOnlyList<(IGameVersion GameVersion, string InstallDir)>? installedGameVersions = await _legacyGameVersionProvider.GetInstalledLegacyGameVersionsAsync().ConfigureAwait(true);
if (installedGameVersions is null)
return gameVersionViewModels;
foreach (GameVersionViewModel gameVersionViewModel in gameVersionViewModels)
- gameVersionViewModel.InstallDir = installedGameVersions.FirstOrDefault(x => x.GameVersion == gameVersionViewModel.LegacyGameVersion).InstallDir;
+ gameVersionViewModel.InstallDir = installedGameVersions.FirstOrDefault(x => x.GameVersion == gameVersionViewModel.GameVersion).InstallDir;
return gameVersionViewModels;
}
private async Task InstallSelectedLegacyGameVersionAsync()
{
GameVersionViewModel selectedGameVersion = SelectedLegacyGameVersion!;
- string? installDir = await _legacyGameVersionInstaller.InstallLegacyGameVersionAsync(selectedGameVersion.LegacyGameVersion, CancellationToken.None, StatusProgress).ConfigureAwait(true);
+ StatusProgress.Report(new ProgressInfo(StatusType.Installing, selectedGameVersion.GameVersion.GameVersion));
+ string? installDir = await _legacyGameVersionInstaller.InstallLegacyGameVersionAsync(selectedGameVersion.GameVersion, CancellationToken.None, StatusProgress).ConfigureAwait(true);
selectedGameVersion.InstallDir = installDir;
return installDir is not null;
}
@@ -145,7 +147,7 @@ private async Task InstallSelectedLegacyGameVersionAsync()
private async Task UninstallSelectedLegacyGameVersionAsync()
{
GameVersionViewModel selectedGameVersion = SelectedLegacyGameVersion!;
- bool success = await _legacyGameVersionInstaller.UninstallLegacyGameVersionAsync(selectedGameVersion.LegacyGameVersion).ConfigureAwait(true);
+ bool success = await _legacyGameVersionInstaller.UninstallLegacyGameVersionAsync(selectedGameVersion.GameVersion).ConfigureAwait(true);
if (success)
selectedGameVersion.InstallDir = null;
return success;
diff --git a/BeatSaberModManager/Views/Dialogs/SteamAuthenticationLoginDetailsDialog.axaml b/BeatSaberModManager/Views/Dialogs/SteamAuthenticationLoginDetailsDialog.axaml
index 54bd9af..8a2fe2c 100644
--- a/BeatSaberModManager/Views/Dialogs/SteamAuthenticationLoginDetailsDialog.axaml
+++ b/BeatSaberModManager/Views/Dialogs/SteamAuthenticationLoginDetailsDialog.axaml
@@ -14,7 +14,7 @@
-
+
diff --git a/BeatSaberModManager/Views/Helpers/AsyncImageCache.cs b/BeatSaberModManager/Views/Helpers/AsyncImageCache.cs
index 9000c0c..e3a7bca 100644
--- a/BeatSaberModManager/Views/Helpers/AsyncImageCache.cs
+++ b/BeatSaberModManager/Views/Helpers/AsyncImageCache.cs
@@ -20,7 +20,7 @@ public static class AsyncImageCache
private static readonly HttpClient _httpClient = new();
private static readonly Dictionary> _loadingQueue = [];
private static readonly Dictionary _cache = [];
- private static readonly PixelSize _imageSize = new(200, 200);
+ private static readonly PixelSize _imageSize = new(512, 512);
///
///
diff --git a/BeatSaberModManager/Views/Pages/LegacyGameVersionsPage.axaml b/BeatSaberModManager/Views/Pages/LegacyGameVersionsPage.axaml
index a1437bb..73c46f7 100644
--- a/BeatSaberModManager/Views/Pages/LegacyGameVersionsPage.axaml
+++ b/BeatSaberModManager/Views/Pages/LegacyGameVersionsPage.axaml
@@ -42,13 +42,17 @@
-
-
+
+
+
+
+