-
-
Notifications
You must be signed in to change notification settings - Fork 39
Add Steam Game Properties Button to Details View #37
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
base: development
Are you sure you want to change the base?
Changes from all commits
dd3bb00
abf98af
eafaa29
f28298d
f3ee128
1af2dee
38edce4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<bool> Init() | |
| return true; | ||
|
|
||
| inited = await RefreshVersions(); | ||
|
|
||
| return inited; | ||
| } | ||
|
|
||
| public static void OpenSteamGameProperties(string? appId) | ||
| { | ||
| if(appId == null){ | ||
| return; | ||
| } | ||
|
|
||
| Process.Start(new ProcessStartInfo(){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please abide by the default coding conventions; fix the nest format
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a try-catch block in case it fails to open for whatever reason |
||
| FileName = $"steam://gameproperties/{appId}", | ||
| UseShellExecute = true | ||
| }); | ||
| } | ||
|
|
||
| private static Task<bool> 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename the id parameter and specify what it's for (ex. |
||
| { | ||
| var downloadUrl = linux ? (!x86 ? version.DownloadUrlLinux : null) : (x86 ? version.DownloadUrlWinX86 : version.DownloadUrlWin); | ||
| if (downloadUrl == null) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,16 +42,16 @@ 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\""; | ||
| SteamLaunchOptions.Text = $"{LdLibPathVar.Text} {LdPreloadVar.Text} %command%"; | ||
| } | ||
|
|
||
| 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep in mind that the installer supports multiple launchers. Make sure you only show this on Steam games or add support for other launchers |
||
| { | ||
| 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)}"); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is meant for MelonLoader-related operations only. Move this to the SteamLauncher class