diff --git a/MelonLoader.Installer/GameLaunchers/EgsLauncher.cs b/MelonLoader.Installer/GameLaunchers/EgsLauncher.cs index f9bfb9a..f98a20c 100644 --- a/MelonLoader.Installer/GameLaunchers/EgsLauncher.cs +++ b/MelonLoader.Installer/GameLaunchers/EgsLauncher.cs @@ -47,7 +47,7 @@ public override void AddGames() if (name == null) continue; - GameManager.TryAddGame(dir, name, this, null, out _); + GameManager.TryAddGame(dir, null, name, this, null, out _); } } } diff --git a/MelonLoader.Installer/GameLaunchers/GogLauncher.cs b/MelonLoader.Installer/GameLaunchers/GogLauncher.cs index 77ef37e..2c0d165 100644 --- a/MelonLoader.Installer/GameLaunchers/GogLauncher.cs +++ b/MelonLoader.Installer/GameLaunchers/GogLauncher.cs @@ -34,7 +34,7 @@ public override void AddGames() if (name == null) continue; - GameManager.TryAddGame(path, name, this, null, out _); + GameManager.TryAddGame(path, null, name, this, null, out _); } } } diff --git a/MelonLoader.Installer/GameLaunchers/SteamLauncher.cs b/MelonLoader.Installer/GameLaunchers/SteamLauncher.cs index cc3b880..3096988 100644 --- a/MelonLoader.Installer/GameLaunchers/SteamLauncher.cs +++ b/MelonLoader.Installer/GameLaunchers/SteamLauncher.cs @@ -71,7 +71,7 @@ public override void AddGames() continue; var iconPath = Path.Combine(steamPath, "appcache", "librarycache", id + "_icon.jpg"); - GameManager.TryAddGame(appDir, name, this, iconPath, out _); + GameManager.TryAddGame(appDir, id, name, this, iconPath, out _); } } } diff --git a/MelonLoader.Installer/GameManager.cs b/MelonLoader.Installer/GameManager.cs index 28d5065..9e56ca0 100644 --- a/MelonLoader.Installer/GameManager.cs +++ b/MelonLoader.Installer/GameManager.cs @@ -32,7 +32,7 @@ private static void LoadSavedGames() { foreach (var gamePath in Config.LoadGameList()) { - TryAddGame(gamePath, null, null, null, out _); + TryAddGame(gamePath, null, null, null, null, out _); } // In case it was manually edited or if any games were removed @@ -86,7 +86,7 @@ public static void RemoveGame(GameModel game) Games.Remove(game); } - public static GameModel? TryAddGame(string path, string? customName, GameLauncher? launcher, string? iconPath, [NotNullWhen(false)] out string? errorMessage) + public static GameModel? TryAddGame(string path, string? id, string? customName, GameLauncher? launcher, string? iconPath, [NotNullWhen(false)] out string? errorMessage) { if (File.Exists(path)) { @@ -169,7 +169,7 @@ public static void RemoveGame(GameModel game) var isProtected = Directory.Exists(Path.Combine(path, "EasyAntiCheat")); - var result = new GameModel(exe, customName ?? Path.GetFileNameWithoutExtension(exe), !is64, linux, launcher, icon, mlVersion, isProtected); + var result = new GameModel(exe, id, customName ?? Path.GetFileNameWithoutExtension(exe), !is64, linux, launcher, icon, mlVersion, isProtected); errorMessage = null; AddGameSorted(result); diff --git a/MelonLoader.Installer/MLManager.cs b/MelonLoader.Installer/MLManager.cs index e7c9500..ab0f9d3 100644 --- a/MelonLoader.Installer/MLManager.cs +++ b/MelonLoader.Installer/MLManager.cs @@ -1,4 +1,5 @@ using Semver; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Text.Json.Nodes; @@ -49,9 +50,22 @@ public static async Task Init() return true; inited = await RefreshVersions(); + return inited; } + public static void OpenSteamGameProperties(string? appId) + { + if(appId == null){ + return; + } + + Process.Start(new ProcessStartInfo(){ + FileName = $"steam://gameproperties/{appId}", + UseShellExecute = true + }); + } + private static Task RefreshVersions() { Versions.Clear(); @@ -332,7 +346,7 @@ public static void SetLocalZip(string zipPath, InstallProgressEventHandler? onPr onFinished?.Invoke(null); } - public static async Task InstallAsync(string gameDir, bool removeUserFiles, MLVersion version, bool linux, bool x86, InstallProgressEventHandler? onProgress, InstallFinishedEventHandler? onFinished) + public static async Task InstallAsync(string gameDir, string? id, bool removeUserFiles, MLVersion version, bool linux, bool x86, InstallProgressEventHandler? onProgress, InstallFinishedEventHandler? onFinished) { var downloadUrl = linux ? (!x86 ? version.DownloadUrlLinux : null) : (x86 ? version.DownloadUrlWinX86 : version.DownloadUrlWin); if (downloadUrl == null) diff --git a/MelonLoader.Installer/ViewModels/GameModel.cs b/MelonLoader.Installer/ViewModels/GameModel.cs index 1bfd0b3..c58e626 100644 --- a/MelonLoader.Installer/ViewModels/GameModel.cs +++ b/MelonLoader.Installer/ViewModels/GameModel.cs @@ -4,9 +4,10 @@ namespace MelonLoader.Installer.ViewModels; -public class GameModel(string path, string name, bool is32Bit, bool isLinux, GameLauncher? launcher, Bitmap? icon, SemVersion? mlVersion, bool isProtected) : ViewModelBase +public class GameModel(string path, string? id, string name, bool is32Bit, bool isLinux, GameLauncher? launcher, Bitmap? icon, SemVersion? mlVersion, bool isProtected) : ViewModelBase { public string Path => path; + public string? Id => id; public string Name => name; public bool Is32Bit => is32Bit; public bool IsLinux => isLinux; diff --git a/MelonLoader.Installer/Views/DetailsView.axaml b/MelonLoader.Installer/Views/DetailsView.axaml index 8c7cddc..79ff644 100644 --- a/MelonLoader.Installer/Views/DetailsView.axaml +++ b/MelonLoader.Installer/Views/DetailsView.axaml @@ -58,26 +58,31 @@ VerticalAlignment="Center" Opacity="0.7" FontSize="14" /> - + How do I start MelonLoader? Linux Launch Instructions - - In order to start MelonLoader under Wine, you'll need to export the following variable: - WINEDLLOVERRIDES="version=n,b" - On Steam, you can set the launch options to: - WINEDLLOVERRIDES="version=n,b" %command%" - - - In order to start MelonLoader, you'll need to export the following variables: - - LD_PRELOAD="libversion.so" - On Steam, you can set the launch options to: - - + + In order to start MelonLoader under Wine, you'll need to export the following variable: + WINEDLLOVERRIDES="version=n,b" + On Steam, you can set the launch options to: + WINEDLLOVERRIDES="version=n,b" %command% + + + In order to start MelonLoader, you'll need to export the following variables: + + LD_PRELOAD="libversion.so" + On Steam, you can set the launch options to: + + + \ No newline at end of file diff --git a/MelonLoader.Installer/Views/DetailsView.axaml.cs b/MelonLoader.Installer/Views/DetailsView.axaml.cs index e3e9320..8c674a9 100644 --- a/MelonLoader.Installer/Views/DetailsView.axaml.cs +++ b/MelonLoader.Installer/Views/DetailsView.axaml.cs @@ -42,8 +42,8 @@ protected override async void OnDataContextChanged(EventArgs e) if (Model == null) return; - -#if LINUX + + #if LINUX if (Model.Game.IsLinux) { LdLibPathVar.Text = $"LD_LIBRARY_PATH=\"{Model.Game.Dir}:$LD_LIBRARY_PATH\""; @@ -51,7 +51,7 @@ protected override async void OnDataContextChanged(EventArgs e) } ShowLinuxInstructions.IsVisible = Model.Game.MLInstalled; -#endif + #endif Model.Game.PropertyChanged += PropertyChangedHandler; @@ -138,12 +138,27 @@ private void InstallHandler(object sender, RoutedEventArgs args) Model.Installing = true; ShowLinuxInstructions.IsVisible = false; - _ = MLManager.InstallAsync(Path.GetDirectoryName(Model.Game.Path)!, Model.Game.MLInstalled && !KeepFilesCheck.IsChecked!.Value, + _ = MLManager.InstallAsync(Path.GetDirectoryName(Model.Game.Path)!, Model.Game.Id, Model.Game.MLInstalled && !KeepFilesCheck.IsChecked!.Value, (MLVersion)VersionCombobox.SelectedItem!, Model.Game.IsLinux, Model.Game.Is32Bit, (progress, newStatus) => Dispatcher.UIThread.Post(() => OnInstallProgress(progress, newStatus)), (errorMessage) => Dispatcher.UIThread.Post(() => OnOperationFinished(errorMessage))); } + private void GamePropsHandler(object sender, RoutedEventArgs args) + { + if (Model == null || !Model.Game.ValidateGame()) + { + MainWindow.Instance.ShowMainView(); + return; + } + + if(Model.Game.Id != null) + { + MLManager.OpenSteamGameProperties(Model.Game.Id); + } + + } + private void OnInstallProgress(double progress, string? newStatus) { if (newStatus != null) @@ -163,9 +178,9 @@ private void OnOperationFinished(string? errorMessage, bool addedLocalBuild = fa Model.Game.ValidateGame(); Model.Installing = false; -#if LINUX - ShowLinuxInstructions.IsVisible = Model.Game.MLInstalled; -#endif + #if LINUX + ShowLinuxInstructions.IsVisible = Model.Game.MLInstalled; + #endif if (errorMessage != null) { @@ -192,6 +207,13 @@ private void OnOperationFinished(string? errorMessage, bool addedLocalBuild = fa }; } + #if LINUX + if(isInstall && Model.Game.MLInstalled){ + Model.LinuxInstructions = true; + } + + #endif + DialogBox.ShowNotice("SUCCESS!", $"Successfully {operationType}{((!Model.Game.MLInstalled || isInstall) ? string.Empty : " to")}\nMelonLoader v{(Model.Game.MLInstalled ? Model.Game.MLVersion : currentMLVersion)}"); } diff --git a/MelonLoader.Installer/Views/MainView.axaml.cs b/MelonLoader.Installer/Views/MainView.axaml.cs index 570326b..b3cd754 100644 --- a/MelonLoader.Installer/Views/MainView.axaml.cs +++ b/MelonLoader.Installer/Views/MainView.axaml.cs @@ -103,7 +103,7 @@ public async void AddGameManuallyHandler(object sender, RoutedEventArgs args) return; var path = files[0].Path.LocalPath; - GameManager.TryAddGame(path, null, null, null, out var error); + GameManager.TryAddGame(path, null, null, null, null, out var error); if (error != null) { DialogBox.ShowError(error);