diff --git a/MelonLoader.Installer/Views/DetailsView.axaml b/MelonLoader.Installer/Views/DetailsView.axaml index 8c7cddc..b64a626 100644 --- a/MelonLoader.Installer/Views/DetailsView.axaml +++ b/MelonLoader.Installer/Views/DetailsView.axaml @@ -30,7 +30,7 @@ Name="VersionCombobox" Grid.Row="10" Margin="5" HorizontalAlignment="Center" SelectedIndex="0" MaxDropDownHeight="150" /> Or select a + Foreground="Gray" TextDecorations="Underline" FontSize="13" Cursor="Hand">Or add a zipped version Dispatcher.UIThread.Post(() => OnInstallProgress(progress, newStatus)), - (errorMessage) => Dispatcher.UIThread.Post(() => OnInstallFinished(errorMessage))); + (errorMessage) => Dispatcher.UIThread.Post(() => OnOperationFinished(errorMessage))); } private void OnInstallProgress(double progress, string? newStatus) @@ -153,14 +153,14 @@ private void OnInstallProgress(double progress, string? newStatus) MelonIcon.Opacity = progress * 0.7 + 0.3; } - private void OnInstallFinished(string? errorMessage, bool showConfirmation = true) + private void OnOperationFinished(string? errorMessage, bool addedLocalBuild = false) { if (Model == null) return; - var wasReinstall = Model.Game.MLInstalled; - Model.Game.ValidateGame(); + var currentMLVersion = Model.Game.MLVersion; + Model.Game.ValidateGame(); Model.Installing = false; #if LINUX @@ -173,8 +173,26 @@ private void OnInstallFinished(string? errorMessage, bool showConfirmation = tru return; } - if (showConfirmation) - DialogBox.ShowNotice("Success!", $"Successfully {(Model.Game.MLInstalled ? (wasReinstall ? "reinstalled" : "installed") : "uninstalled")} MelonLoader!"); + if (addedLocalBuild) + return; + + bool isReinstall = false; + string operationType = Model.Game.MLInstalled ? "Installed" : "Uninstalled"; + if (Model.Game.MLInstalled + && (Model.Game.MLVersion != null) + && (currentMLVersion != null)) + { + var comp = Model.Game.MLVersion.CompareSortOrderTo(currentMLVersion); + isReinstall = comp == 0; + operationType = comp switch + { + > 0 => "Upgraded", + 0 => "Reinstalled", + < 0 => "Downgraded" + }; + } + + DialogBox.ShowNotice("Success!", $"Successfully {operationType}{((!Model.Game.MLInstalled || isReinstall) ? string.Empty : " to")}\nMelonLoader{(Model.Game.MLInstalled ? $" v{Model.Game.MLVersion}" : string.Empty)}"); } private void OpenDirHandler(object sender, RoutedEventArgs args) @@ -197,8 +215,8 @@ private void UninstallHandler(object sender, RoutedEventArgs args) return; var error = MLManager.Uninstall(Model.Game.Dir, !KeepFilesCheck.IsChecked!.Value); - - OnInstallFinished(error); + + OnOperationFinished(error); } private async void SelectZipHandler(object sender, TappedEventArgs args) @@ -241,7 +259,7 @@ private async void SelectZipHandler(object sender, TappedEventArgs args) } } - OnInstallFinished(errorMessage, false); + OnOperationFinished(errorMessage, true); UpdateVersionList(); }))); } diff --git a/MelonLoader.Installer/Views/DialogBox.axaml b/MelonLoader.Installer/Views/DialogBox.axaml index 19009d5..b294c02 100644 --- a/MelonLoader.Installer/Views/DialogBox.axaml +++ b/MelonLoader.Installer/Views/DialogBox.axaml @@ -15,9 +15,9 @@ Height="100" SizeToContent="WidthAndHeight" RenderOptions.BitmapInterpolationMode="HighQuality"> - - - + + +