aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts/ui')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut2
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut35
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut4
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut109
4 files changed, 112 insertions, 38 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut
index 1e10aa45..b89e665b 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut
@@ -56,6 +56,6 @@ void function ConnectWithPassword( var button )
if ( GetTopNonDialogMenu() == file.menu )
{
TriggerConnectToServerCallbacks()
- thread ThreadedAuthAndConnectToServer( Hud_GetUTF8Text( Hud_GetChild( file.menu, "EnterPasswordBox" ) ) )
+ thread ThreadedAuthAndConnectToServer( Hud_GetUTF8Text( Hud_GetChild( file.menu, "EnterPasswordBox" ) ), true )
}
} \ No newline at end of file
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 4d299362..4968714c 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut
@@ -1,8 +1,10 @@
global function DownloadMod
global function DisplayModDownloadErrorDialog
+global function FetchVerifiedModsManifesto
global enum eModInstallStatus
{
+ MANIFESTO_FETCHING,
DOWNLOADING,
CHECKSUMING,
EXTRACTING,
@@ -18,6 +20,35 @@ global enum eModInstallStatus
const int MB = 1024*1000;
+
+void function FetchVerifiedModsManifesto()
+{
+ print("Start fetching verified mods manifesto from the Internet")
+
+ // Fetching UI
+ DialogData dialogData
+ dialogData.header = Localize( "#MANIFESTO_FETCHING_TITLE" )
+ dialogData.message = Localize( "#MANIFESTO_FETCHING_TEXT" )
+ dialogData.showSpinner = true;
+
+ // Prevent user from closing dialog
+ dialogData.forceChoice = true;
+ OpenDialog( dialogData )
+
+ // Do the actual fetching
+ NSFetchVerifiedModsManifesto()
+
+ ModInstallState state = NSGetModInstallState()
+ while ( state.status == eModInstallStatus.MANIFESTO_FETCHING )
+ {
+ state = NSGetModInstallState()
+ WaitFrame()
+ }
+
+ // Close dialog when manifesto has been received
+ CloseActiveMenu()
+}
+
bool function DownloadMod( RequiredModInfo mod )
{
// Downloading mod UI
@@ -58,6 +89,10 @@ void function UpdateModDownloadDialog( RequiredModInfo mod, ModInstallState stat
{
switch ( state.status )
{
+ case eModInstallStatus.MANIFESTO_FETCHING:
+ Hud_SetText( header, Localize( "#MANIFESTO_FETCHING_TITLE" ) )
+ Hud_SetText( body, Localize( "#MANIFESTO_FETCHING_TEXT" ) )
+ break
case eModInstallStatus.DOWNLOADING:
Hud_SetText( header, Localize( "#DOWNLOADING_MOD_TITLE_W_PROGRESS", string( state.ratio ) ) )
Hud_SetText( body, Localize( "#DOWNLOADING_MOD_TEXT_W_PROGRESS", mod.name, mod.version, floor( state.progress / MB ), floor( state.total / MB ) ) )
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
index 3f643aa3..f08d69a7 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
@@ -338,6 +338,10 @@ void function RefreshMods()
{
string mod = modNames[i]
+ // Do not display remote mods
+ if ( NSIsModRemote( mod ) )
+ continue
+
if ( searchTerm.len() && mod.tolower().find( searchTerm ) == null )
continue
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
index 1bc8e405..cdeb8b3e 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
@@ -967,49 +967,93 @@ void function OnServerSelected_Threaded( var button )
bool autoDownloadAllowed = GetConVarBool( "allow_mod_auto_download" )
int downloadedMods = 0;
+ // Check out if there's any server-required mod that is not locally installed
+ array<string> modNames = NSGetModNames()
+ bool uninstalledModFound = false
+ foreach ( requiredModInfo in server.requiredMods )
+ {
+ // Tolerate core mods having different versions
+ if ( requiredModInfo.name.len() > 10 && requiredModInfo.name.slice(0, 10) == "Northstar." )
+ continue
+
+ if ( !modNames.contains( requiredModInfo.name ) )
+ {
+ print( format ( "\"%s\" was not found locally, triggering manifesto fetching.", requiredModInfo.name ) )
+ uninstalledModFound = true
+ break
+ } else if ( NSGetModVersionByModName( requiredModInfo.name ) != requiredModInfo.version ) {
+ print( format ( "\"%s\" was found locally but has version \"%s\" while server requires \"%s\", triggering manifesto fetching.", requiredModInfo.name, NSGetModVersionByModName( requiredModInfo.name ), requiredModInfo.version ) )
+ uninstalledModFound = true
+ break
+ }
+ }
+
+ // If yes, we fetch the verified mods manifesto, to check whether uninstalled
+ // mods can be installed through auto-download
+ if ( uninstalledModFound && autoDownloadAllowed )
+ {
+ print("Auto-download is allowed, checking if missing mods can be installed automatically.")
+ FetchVerifiedModsManifesto()
+ }
+
foreach ( RequiredModInfo mod in server.requiredMods )
{
- if ( !NSGetModNames().contains( mod.name ) )
+ // Tolerate core mods having different versions
+ if ( mod.name.len() > 10 && mod.name.slice(0, 10) == "Northstar." )
+ continue
+
+ if ( !NSGetModNames().contains( mod.name ) || NSGetModVersionByModName( mod.name ) != mod.version )
{
- // Check if mod can be auto-downloaded
- bool modIsVerified = NSIsModDownloadable( mod.name, mod.version )
+ // Auto-download mod
+ if ( autoDownloadAllowed )
+ {
+ bool modIsVerified = NSIsModDownloadable( mod.name, mod.version )
- // Display an error message if not
- if ( !modIsVerified || !autoDownloadAllowed )
+ // Display error message if mod is not verified
+ if ( !modIsVerified )
+ {
+ DialogData dialogData
+ dialogData.header = "#ERROR"
+ dialogData.message = Localize( "#MISSING_MOD", mod.name, mod.version )
+ dialogData.message += "\n" + Localize( "#MOD_NOT_VERIFIED" )
+ dialogData.image = $"ui/menu/common/dialog_error"
+
+ AddDialogButton( dialogData, "#DISMISS" )
+ AddDialogFooter( dialogData, "#A_BUTTON_SELECT" )
+ AddDialogFooter( dialogData, "#B_BUTTON_DISMISS_RUI" )
+
+ OpenDialog( dialogData )
+ return
+ }
+ else
+ {
+ if ( DownloadMod( mod ) )
+ {
+ downloadedMods++
+ }
+ else
+ {
+ DisplayModDownloadErrorDialog( mod.name )
+ return
+ }
+ }
+ }
+
+ // Mod not found, display error message
+ else
{
DialogData dialogData
dialogData.header = "#ERROR"
dialogData.message = Localize( "#MISSING_MOD", mod.name, mod.version )
dialogData.image = $"ui/menu/common/dialog_error"
- // Specify error (only if autoDownloadAllowed is set)
- if ( autoDownloadAllowed )
- {
- dialogData.message += "\n" + Localize( "#MOD_NOT_VERIFIED" )
- }
-
AddDialogButton( dialogData, "#DISMISS" )
-
AddDialogFooter( dialogData, "#A_BUTTON_SELECT" )
AddDialogFooter( dialogData, "#B_BUTTON_DISMISS_RUI" )
OpenDialog( dialogData )
-
return
}
-
- else // Launch download
- {
- if ( DownloadMod( mod ) )
- {
- downloadedMods++
- }
- else
- {
- DisplayModDownloadErrorDialog( mod.name )
- return
- }
- }
}
else
{
@@ -1050,13 +1094,6 @@ void function OnServerSelected_Threaded( var button )
}
}
- // Make Northstar aware new mods have been added
- if ( downloadedMods > 0 )
- {
- print( "Some new mods have been downloaded or enabled, reloading mods." )
- NSReloadMods();
- }
-
if ( server.requiresPassword )
{
OnCloseServerBrowserMenu()
@@ -1065,12 +1102,12 @@ void function OnServerSelected_Threaded( var button )
else
{
TriggerConnectToServerCallbacks()
- thread ThreadedAuthAndConnectToServer()
+ thread ThreadedAuthAndConnectToServer( "", downloadedMods != 0 )
}
}
-void function ThreadedAuthAndConnectToServer( string password = "" )
+void function ThreadedAuthAndConnectToServer( string password = "", bool modsChanged = false )
{
if ( NSIsAuthenticatingWithServer() )
return
@@ -1098,8 +1135,6 @@ void function ThreadedAuthAndConnectToServer( string password = "" )
if ( NSWasAuthSuccessful() )
{
- bool modsChanged = false
-
// disable all RequiredOnClient mods that are not required by the server and are currently enabled
foreach ( string modName in NSGetModNames() )
{