diff options
author | Rémy Raes <raes.remy@gmail.com> | 2024-11-22 15:19:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-22 15:19:07 +0100 |
commit | aba62bfaf4556c3b6285066b43a6063976a8d4f9 (patch) | |
tree | 9fca45a2619cf670beabab94f614dfe541a3b819 | |
parent | e7aa1c2a3459c9a4ad63d89b5da577bf10e8366c (diff) | |
download | NorthstarMods-aba62bfaf4556c3b6285066b43a6063976a8d4f9.tar.gz NorthstarMods-aba62bfaf4556c3b6285066b43a6063976a8d4f9.zip |
Make MAD process cancellable (#865)
Mod counterpart to the launcher PR that makes a mod download via MAD cancellable.
-rw-r--r-- | .github/nativefuncs.json | 6 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut | 19 |
2 files changed, 25 insertions, 0 deletions
diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index abc213ca..10ceebd5 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -415,6 +415,12 @@ "argTypes": "string name, string version" }, { + "name": "NSCancelModDownload", + "helpText": "prevents installation of the mod currently being installed", + "returnTypeString": "void", + "argTypes": "" + }, + { "name": "NSGetModInstallState", "helpText": "get status of the mod currently being installed", "returnTypeString": "ModInstallState", diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut index 4968714c..09001f57 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut @@ -9,6 +9,7 @@ global enum eModInstallStatus CHECKSUMING, EXTRACTING, DONE, + ABORTED, FAILED, FAILED_READING_ARCHIVE, FAILED_WRITING_TO_DISK, @@ -57,6 +58,11 @@ bool function DownloadMod( RequiredModInfo mod ) dialogData.message = Localize( "#DOWNLOADING_MOD_TEXT", mod.name, mod.version ) dialogData.showSpinner = true; + // Prevent download button + AddDialogButton( dialogData, "#CANCEL", void function() { + NSCancelModDownload() + }) + // Prevent user from closing dialog dialogData.forceChoice = true; OpenDialog( dialogData ) @@ -77,6 +83,13 @@ bool function DownloadMod( RequiredModInfo mod ) WaitFrame() } + // If download was aborted, don't close UI since it was closed by clicking cancel button + if ( state.status == eModInstallStatus.ABORTED ) + { + print("Mod download was cancelled by the user.") + return false; + } + printt( "Mod status:", state.status ) // Close loading dialog @@ -114,6 +127,12 @@ void function DisplayModDownloadErrorDialog( string modName ) { ModInstallState state = NSGetModInstallState() + // If user cancelled download, no need to display an error message + if ( state.status == eModInstallStatus.ABORTED ) + { + return + } + DialogData dialogData dialogData.header = Localize( "#FAILED_DOWNLOADING", modName ) dialogData.image = $"ui/menu/common/dialog_error" |