aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut9
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut148
2 files changed, 10 insertions, 147 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 acc6bb36..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
@@ -1,5 +1,4 @@
global function AddNorthstarConnectWithPasswordMenu
-global function SetPasswordTargetServer
struct
{
@@ -7,7 +6,6 @@ struct
var enterPasswordBox
var enterPasswordDummy
var connectButton
- ServerInfo& targetServer
} file
void function AddNorthstarConnectWithPasswordMenu()
@@ -53,16 +51,11 @@ void function OnConnectWithPasswordMenuOpened()
}
-void function SetPasswordTargetServer( ServerInfo server )
-{
- file.targetServer = server
-}
-
void function ConnectWithPassword( var button )
{
if ( GetTopNonDialogMenu() == file.menu )
{
TriggerConnectToServerCallbacks()
- thread JoinServer( file.targetServer, 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_serverbrowser.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
index 1396dd22..cdeb8b3e 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
@@ -2,10 +2,7 @@ untyped
// Only way to get Hud_GetPos(sliderButton) working was to use untyped
global function AddNorthstarServerBrowserMenu
-
-global function JoinServer
-global function JoinServerByName
-global function CancelJoinServer
+global function ThreadedAuthAndConnectToServer
global function AddConnectToServerCallback
global function RemoveConnectToServerCallback
@@ -373,7 +370,7 @@ void function ToggleConnectingHUD( bool vis )
void function ConnectingButton_Activate( var button )
{
- CancelJoinServer()
+ file.cancelConnection = true
}
////////////////////////////
@@ -1100,18 +1097,17 @@ void function OnServerSelected_Threaded( var button )
if ( server.requiresPassword )
{
OnCloseServerBrowserMenu()
- SetPasswordTargetServer( file.lastSelectedServer )
AdvanceMenu( GetMenu( "ConnectWithPasswordMenu" ) )
}
else
{
TriggerConnectToServerCallbacks()
- thread ThreadedAuthAndConnectToServer()
+ thread ThreadedAuthAndConnectToServer( "", downloadedMods != 0 )
}
}
-void function ThreadedAuthAndConnectToServer( string password = "" )
+void function ThreadedAuthAndConnectToServer( string password = "", bool modsChanged = false )
{
if ( NSIsAuthenticatingWithServer() )
return
@@ -1139,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() )
{
@@ -1356,138 +1350,14 @@ void function RemoveConnectToServerCallback( void functionref( ServerInfo ) call
void function TriggerConnectToServerCallbacks( ServerInfo ornull targetServer = null )
{
- if ( !targetServer )
- targetServer = file.lastSelectedServer
-
- expect ServerInfo( targetServer )
-
- foreach( callback in file.connectCallbacks )
- {
- callback( targetServer )
- }
-}
-
-//////////////////////////////////////
-// Join server
-//////////////////////////////////////
-
-void function CancelJoinServer()
-{
- file.cancelConnection = true
-}
-
-bool function JoinServerByName( string serverName, string password = "" )
-{
- // Request list of online servers.
- NSRequestServerList()
- while ( NSIsRequestingServerList() )
+ ServerInfo server;
+ if (targetServer == null)
{
- WaitFrame()
- }
-
- // Go through all servers that are currently online
- foreach ( server in NSGetGameServers() )
- {
- // Join the server if it has the correct server name.
- if ( server.name == serverName )
- {
- return JoinServer( server )
- }
- }
-
- print( format( "Failed to connect to server %s: No such server", serverName ) )
-
- return false
-}
-
-bool function JoinServer( ServerInfo server, string password = "" )
-{
- if ( NSIsAuthenticatingWithServer() )
- return false
-
- printt( format( "Connecting to server %s with id of %s", server.name, server.id ) )
-
- TriggerConnectToServerCallbacks( server )
- NSTryAuthWithServer( server.index, password )
-
- ToggleConnectingHUD( true )
-
- while ( NSIsAuthenticatingWithServer() && !file.cancelConnection )
- WaitFrame()
-
- ToggleConnectingHUD( false )
-
- if ( file.cancelConnection )
- {
- file.cancelConnection = false
- return false
+ targetServer = file.lastSelectedServer
}
- file.cancelConnection = false
-
- 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() )
- {
- if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName ) )
- {
- // find the mod name in the list of server required mods
- bool found = false
- foreach ( RequiredModInfo mod in server.requiredMods )
- {
- if ( mod.name == modName )
- {
- found = true
- break
- }
- }
- // if we didnt find the mod name, disable the mod
- if ( !found )
- {
- modsChanged = true
- NSSetModEnabled( modName, false )
- }
- }
- }
-
- // enable all RequiredOnClient mods that are required by the server and are currently disabled
- foreach ( RequiredModInfo mod in server.requiredMods )
- {
- if ( NSIsModRequiredOnClient( mod.name ) && !NSIsModEnabled( mod.name ) )
- {
- modsChanged = true
- NSSetModEnabled( mod.name, true )
- }
- }
-
- // only actually reload if we need to since the uiscript reset on reload lags hard
- if ( modsChanged )
- ReloadMods()
-
- NSConnectToAuthedServer()
- return true
- }
- else
+ foreach( callback in file.connectCallbacks )
{
- string reason = NSGetAuthFailReason()
-
- DialogData dialogData
- dialogData.header = "#ERROR"
- dialogData.message = reason
- dialogData.image = $"ui/menu/common/dialog_error"
-
- #if PC_PROG
- AddDialogButton( dialogData, "#DISMISS" )
-
- AddDialogFooter( dialogData, "#A_BUTTON_SELECT" )
- #endif // PC_PROG
- AddDialogFooter( dialogData, "#B_BUTTON_DISMISS_RUI" )
-
- OpenDialog( dialogData )
- return false
+ callback( expect ServerInfo( targetServer ) )
}
- return false
}