From 60353a87526fc6b1bef7ab687c4b540ece007371 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 4 Sep 2024 00:55:54 +0200 Subject: [PATCH 1/4] build: add NSCancelModDownload signature to nativefuncs.json configuration --- .github/nativefuncs.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 110429031..25fee7dc5 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -540,6 +540,12 @@ "returnTypeString": "void", "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", From 104352ec5b6819ea377886026a32abe32c81c7a5 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 4 Sep 2024 00:56:26 +0200 Subject: [PATCH 2/4] feat: MAD UI displays a "cancel" button --- .../mod/scripts/vscripts/ui/menu_ns_moddownload.nut | 5 +++++ 1 file changed, 5 insertions(+) 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 4968714c7..1b0c8976f 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut @@ -57,6 +57,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 ) From 075ad22e523118ff41158fd62b35b8a87f64ca02 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 4 Sep 2024 02:20:35 +0200 Subject: [PATCH 3/4] fix: don't close dialog UI twice on download cancel --- .../mod/scripts/vscripts/ui/menu_ns_moddownload.nut | 8 ++++++++ 1 file changed, 8 insertions(+) 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 1b0c8976f..25eaedbc4 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, @@ -82,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 From 8a5ba6132319e4eea02f699cd6fb0669dd24282a Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 4 Sep 2024 02:30:45 +0200 Subject: [PATCH 4/4] fix: don't display error message if user cancelled download --- .../mod/scripts/vscripts/ui/menu_ns_moddownload.nut | 6 ++++++ 1 file changed, 6 insertions(+) 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 25eaedbc4..09001f57b 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut @@ -127,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"