aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/ui
diff options
context:
space:
mode:
authorEmma Miler <27428383+emma-miler@users.noreply.github.com>2022-03-27 00:45:23 +0100
committerGitHub <noreply@github.com>2022-03-27 00:45:23 +0100
commit3e7186801d70e50a9135b897ef572076fe442cf4 (patch)
tree80e535d881b8e90a5c4e3b2c2b8ac733ba163c84 /Northstar.Client/mod/scripts/vscripts/ui
parentbd102d798a0b9db2dcbd6bd4045fb84c53fc031a (diff)
downloadNorthstarMods-3e7186801d70e50a9135b897ef572076fe442cf4.tar.gz
NorthstarMods-3e7186801d70e50a9135b897ef572076fe442cf4.zip
Add mod code for updating state for discord RPC (#274)v1.6.0-rc3
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts/ui')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_lobby.nut2
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_main.nut16
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut14
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut7
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/ui_vscript.gnut352
5 files changed, 381 insertions, 10 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_lobby.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_lobby.nut
index 3c868aab..938e0d3f 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_lobby.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_lobby.nut
@@ -372,6 +372,8 @@ void function StartPrivateMatch( var button )
return
ClientCommand( "StartPrivateMatchSearch" )
+ NSSetLoading(true)
+ NSUpdateListenServer()
}
void function DoRoomInviteIfAllowed( var button )
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_main.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_main.nut
index 87cba57e..b20699f9 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_main.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_main.nut
@@ -72,7 +72,7 @@ void function OnMainMenu_Open()
{
Signal( uiGlobal.signalDummy, "EndOnMainMenu_Open" )
EndSignal( uiGlobal.signalDummy, "EndOnMainMenu_Open" )
-
+
SetConVarString( "communities_hostname", "" ) // disable communities due to crash exploits that are still possible through it
UpdatePromoData() // On script restarts this gives us the last data until the new request is complete
@@ -93,7 +93,7 @@ void function OnMainMenu_Open()
ClientCommand( "map " + Dev_CommandLineParmValue( "+map" ) )
Dev_CommandLineRemoveParm( "+map" )
}
-
+
// do agree to ns remote auth dialog
if ( !GetConVarBool( "ns_has_agreed_to_send_token" ) )
NorthstarMasterServerAuthDialog()
@@ -136,7 +136,7 @@ void function NorthstarMasterServerAuthDialog()
{
// todo: this should be in localisation
DialogData dialogData
- dialogData.header = "#DIALOG_TITLE_INSTALLED_NORTHSTAR"
+ dialogData.header = "#DIALOG_TITLE_INSTALLED_NORTHSTAR"
dialogData.image = $"rui/menu/fd_menu/upgrade_northstar_chassis"
dialogData.message = "#AUTHENTICATION_AGREEMENT_DIALOG_TEXT"
AddDialogButton( dialogData, "#YES", NorthstarMasterServerAuthDialogAgree )
@@ -148,11 +148,11 @@ void function NorthstarMasterServerAuthDialogAgree()
{
int oldValue = GetConVarInt( "ns_has_agreed_to_send_token" )
SetConVarInt( "ns_has_agreed_to_send_token", NS_AGREED_TO_SEND_TOKEN )
-
+
if ( oldValue != 0 && oldValue != NS_AGREED_TO_SEND_TOKEN )
{
DialogData dialogData
- dialogData.header = "#DIALOG_TITLE_INSTALLED_NORTHSTAR"
+ dialogData.header = "#DIALOG_TITLE_INSTALLED_NORTHSTAR"
dialogData.image = $"rui/menu/fd_menu/upgrade_northstar_chassis"
dialogData.message = "#AUTHENTICATION_AGREEMENT_RESTART"
AddDialogButton( dialogData, "#OK" )
@@ -164,11 +164,11 @@ void function NorthstarMasterServerAuthDialogDisagree()
{
int oldValue = GetConVarInt( "ns_has_agreed_to_send_token" )
SetConVarInt( "ns_has_agreed_to_send_token", NS_DISAGREED_TO_SEND_TOKEN )
-
+
if ( oldValue != 0 && oldValue != NS_DISAGREED_TO_SEND_TOKEN )
{
DialogData dialogData
- dialogData.header = "#DIALOG_TITLE_INSTALLED_NORTHSTAR"
+ dialogData.header = "#DIALOG_TITLE_INSTALLED_NORTHSTAR"
dialogData.image = $"rui/menu/fd_menu/upgrade_northstar_chassis"
dialogData.message = "#AUTHENTICATION_AGREEMENT_RESTART"
AddDialogButton( dialogData, "#OK" )
@@ -670,4 +670,4 @@ void function UpdateTrialLabel()
void function OpenSinglePlayerDevMenu( var button )
{
AdvanceMenu( GetMenu( "SinglePlayerDevMenu" ) )
-}
+} \ 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 b294f57c..bd263f2b 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
@@ -970,6 +970,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" )
return
print( "trying to authenticate with server " + NSGetServerName( file.lastSelectedServer ) + " with password " + password )
+
NSTryAuthWithServer( file.lastSelectedServer, password )
ToggleConnectingHUD( true )
@@ -988,6 +989,18 @@ void function ThreadedAuthAndConnectToServer( string password = "" )
}
file.cancelConnection = false
+ NSSetLoading(true)
+ NSUpdateServerInfo(
+ NSGetServerID(file.lastSelectedServer),
+ NSGetServerName(file.lastSelectedServer),
+ password,
+ NSGetServerPlayerCount(file.lastSelectedServer),
+ NSGetServerMaxPlayerCount(file.lastSelectedServer),
+ NSGetServerMap(file.lastSelectedServer),
+ Localize(GetMapDisplayName(NSGetServerMap(file.lastSelectedServer))),
+ NSGetServerPlaylist(file.lastSelectedServer),
+ Localize(GetPlaylistDisplayName(NSGetServerPlaylist(file.lastSelectedServer)))
+ )
if ( NSWasAuthSuccessful() )
{
@@ -1010,6 +1023,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" )
// only actually reload if we need to since the uiscript reset on reload lags hard
if ( modsChanged )
ReloadMods()
+
NSConnectToAuthedServer()
}
else
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut
index 65a8ca9b..fb4dfcd9 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut
@@ -6,6 +6,8 @@ global function UpdatePromoData
global function UICodeCallback_GetOnPartyServer
global function UICodeCallback_MainMenuPromosUpdated
+global bool isOnMainMenu = false
+
// defining this here because it's the only place it's used rn, custom const for a hook in launcher
global const WEBBROWSER_FLAG_FORCEEXTERNAL = 1 << 1 // 2
@@ -526,6 +528,7 @@ void function OnPlayFDButton_Activate( var button ) // repurposed for launching
if ( !Hud_IsLocked( button ) )
{
SetConVarBool( "ns_is_modded_server", true )
+ SetConVarString( "communities_hostname", "" ) // disable communities due to crash exploits that are still possible through it
NSTryAuthWithLocalServer()
thread TryAuthWithLocalServer()
}
@@ -552,12 +555,12 @@ void function TryAuthWithLocalServer()
}
WaitFrame()
}
-
+
if ( NSWasAuthSuccessful() )
{
NSCompleteAuthWithLocalServer()
}
-
+
if ( GetConVarString( "mp_gamemode" ) == "solo" )
SetConVarString( "mp_gamemode", "tdm" )
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/ui_vscript.gnut b/Northstar.Client/mod/scripts/vscripts/ui/ui_vscript.gnut
new file mode 100644
index 00000000..63535bec
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/ui/ui_vscript.gnut
@@ -0,0 +1,352 @@
+
+// Events for handlers
+// UIE_CLICK
+// UIE_GET_FOCUS
+// UIE_LOSE_FOCUS
+
+global function UICodeCallback_UIInit
+global function UICodeCallback_ControllerModeChanged
+global function UICodeCallback_OnVideoOver
+global function AddUICallback_OnLevelInit
+
+global struct TabDef
+{
+ var panel
+ string title
+}
+
+global struct InputDef
+{
+ int input
+ string gamepadLabel
+ var vguiElem
+ string mouseLabel
+ bool functionref() conditionCheckFunc
+ bool lastConditionCheckResult
+ void functionref( var ) activateFunc
+ void functionref( InputDef ) updateFunc
+}
+
+global struct DialogButtonData
+{
+ string label
+ void functionref() activateFunc
+ string focusMessage
+ bool startFocused
+}
+
+global struct DialogFooterData
+{
+ string label
+ void functionref() activateFunc
+}
+
+global struct DialogMessageRuiData
+{
+ string message = ""
+ vector style1Color = <1.0, 1.0, 1.0>
+ vector style2Color = <0.5, 0.5, 0.5>
+ vector style3Color = <0.5, 0.5, 0.5>
+
+ float style1FontScale = 1.0
+ float style2FontScale = 1.0
+ float style3FontScale = 1.0
+}
+
+global struct DialogData
+{
+ var menu
+ string header
+ string message
+ DialogMessageRuiData &ruiMessage
+ array messageColor = [161, 161, 161, 255]
+ asset image
+ asset rightImage = $""
+ bool forceChoice = false
+ bool noChoice = false
+ bool noChoiceWithNavigateBack = false
+ bool showSpinner = false
+ bool showPCBackButton = false
+ float inputDisableTime = 0
+ table<int,bool> coloredButton
+ bool darkenBackground = false
+ bool useFullMessageHeight = false
+
+ array<DialogButtonData> buttonData
+ array<DialogFooterData> footerData
+}
+
+global struct MenuDef
+{
+ void functionref() initFunc
+ void functionref() openFunc
+ void functionref() closeFunc
+ void functionref() showFunc // TODO: Needs hooking up
+ void functionref() hideFunc // TODO: Needs hooking up
+ void functionref() thinkFunc
+ void functionref() navBackFunc
+ void functionref() tabChangedFunc
+ void functionref() inputModeChangedFunc
+ void functionref() entitlementsChangedFunc
+
+ array<InputDef> footerData
+ table<int, void functionref( var )> registeredInput
+
+ bool hasTabs = false
+ array<TabDef> tabsData
+ int tabIndex = 0
+
+ bool isDialog = false
+ DialogData& dialogData
+ bool isDynamicHeight = false
+
+ bool isPVEMenu = false
+
+ var lastFocus // Only used for restoring submenu focus so far
+}
+
+global struct PanelDef
+{
+ void functionref() initFunc
+ void functionref() showFunc
+ void functionref() hideFunc
+
+ string tabTitle = "Default"
+
+ array<InputDef> footerData
+ table<int, void functionref( var )> registeredInput
+
+ var defaultFocus
+}
+
+global struct PieChartEntry
+{
+ string displayName
+ float numValue
+ array<int> color = [127, 127, 127, 255]
+ float fracValue = 0.0
+}
+
+global struct PieChartData
+{
+ array<PieChartEntry> entries
+ array<int> labelColor = [46, 49, 51, 255]
+ bool timeBased = false
+ float sum = 0.0
+}
+
+global struct UIGlobals
+{
+ table menus = {}
+ array allMenus = []
+ array<var> menuStack
+ string loadingLevel = ""
+ string loadedLevel = ""
+ string previousLevel = ""
+ string previousPlaylist = ""
+ var activeMenu = null
+ bool lastMenuNavDirection = MENU_NAV_FORWARD
+ bool lobbyFromLoadingScreen = false
+ bool eventHandlersAdded = false
+ bool loadoutsInitialized = false
+ bool itemsInitialized = false
+ bool matchmaking = false
+ var dialogCloseCallback = null
+ table signalDummy = {}
+ float dialogInputEnableTime = 0.0
+ bool lobbyMenusLeftOpen = false
+ bool playingMusic = false
+ var mainMenuFocus = null
+ int announcementVersionSeen = -1
+ var lastCategoryFocus = null
+
+ int pilotSpawnLoadoutIndex = -1
+ int titanSpawnLoadoutIndex = -1
+
+ bool updatePilotSpawnLoadout = false
+ bool updateTitanSpawnLoadout = false
+
+ string editingLoadoutType = "pilot"
+ string editingLoadoutProperty = ""
+ int editingLoadoutIndex = -1
+ string editingItemRef = ""
+ int editingItemType = -1
+ var editingSubitemRef = null
+ int editingSubitemType = -1
+ var editingParentItemRef = null
+ int editingWeaponCategory = -1
+
+ int entitlementId = -1
+ string testStoreWeaponRef // TODO: Remove when done testing
+
+ bool EOGAutoAdvance = true
+ bool EOGOpenInLobby = false
+ string EOGChallengeFilter = ""
+ var eogCoopFocusedButton = null
+ var eogCoopSelectedButton = null
+ var eogScoreboardFocusedButton = null
+ bool eogNavigationButtonsRegistered = false
+
+ table<string, var> ui_ChallengeProgress = {}
+
+ int decalScrollState = 0
+
+ bool isLobby
+
+ var ConfirmMenuMessage
+ var ConfirmMenuErrorCode
+ array<DialogButtonData> dialogButtonData
+
+ bool updatingLobbyUI = false
+
+ array buttonConfigs
+ array stickConfigs
+
+ var playlistList
+
+ table< string, array > eog_challengesToShow
+ table< string, array > eog_unlocks
+
+ bool videoSettingsChanged = false
+
+ bool playingVideo = false
+ bool playingCredits = false
+
+ bool mapSupportsMenuModels = false
+ bool mapSupportsMenuModelsUpdated = false
+ bool interpolateCameraMoves = true
+ int activePresentationType = ePresentationType.INACTIVE
+ bool rotateCharacterInputRegistered = false
+
+ table<var,MenuDef> menuData
+
+ table<string, int> intVars
+ table<string, bool> boolVars
+ table<string, var> varVars
+ table<string, array<void functionref()> > varChangeFuncs
+
+ array<void functionref()> onLevelInitCallbacks
+
+ bool tabButtonsRegistered = false
+
+ table panels = {}
+ array<var> allPanels
+ table<var,PanelDef> panelData
+
+ bool sp_showAlternateMissionLog = false
+
+ int launching = eLaunching.FALSE
+ bool triedNucleusRegistration = false
+ int consoleSettingMenu = eConsoleSettingsMenu.FALSE
+
+ bool updateCachedNewItems = true
+
+ var menuToOpenFromPromoButton = null
+
+ bool isLoading = false
+
+}
+
+global UIGlobals uiGlobal
+
+global const MAINMENU_MUSIC_DELAY = 4.0
+
+
+void function UICodeCallback_UIInit()
+{
+ ScriptCompilerTest()
+
+ ShUtilityAll_Init()
+ LevelVarInit()
+
+ VPKNotifyFile( "media/intro_captions.txt" )
+
+ UtilityUI_Init()
+
+ Settings_Init() // UI script doesn't need everything in this, reorganize
+ GameModes_Init()
+ UIVars_Init()
+
+ PassivesShared_Init()
+ ChallengesShared_Init()
+ ChallengesContent_Init()
+ XP_Init()
+
+ MenuLobby_Init()
+ MenuPrivateMatch_Init()
+
+ MenuGamepadLayout_Init()
+ MenuChallenges_Init()
+ MenuEOG_Init()
+ MenuUtility_Init()
+ MenuAdvocateLetter_Init()
+ MenuCredits_Init()
+ MenuMapSelect_Init()
+
+ RegisterSignal( "LevelShutdown" )
+ RegisterSignal( "CleanupInGameMenus" )
+ RegisterSignal( "OnCloseLobbyMenu" )
+ RegisterSignal( "OnCancelConnect" )
+ RegisterSignal( "PlayVideoEnded" )
+ RegisterSignal( "ActiveMenuChanged" )
+ RegisterSignal( "LevelFinishedLoading")
+ RegisterSignal( "OpenErrorDialog" )
+ RegisterSignal( "BoughtItem" )
+
+ thread UpdateClientMenuOpenState()
+
+ InitGamepadConfigs()
+ Store_Init()
+ InitMenus()
+
+ if ( !IsSingleplayer() )
+ thread UpdateCachedLoadouts() // Needs to wait for persistent data to ready
+}
+
+void function UICodeCallback_ControllerModeChanged( bool controllerModeEnabled )
+{
+ //printt( "CONTROLLER! " + controllerModeEnabled + ", " + IsControllerModeActive() )
+
+ if ( uiGlobal.activeMenu == null )
+ return
+
+ if ( uiGlobal.menuData[ uiGlobal.activeMenu ].inputModeChangedFunc != null )
+ thread uiGlobal.menuData[ uiGlobal.activeMenu ].inputModeChangedFunc()
+
+ UpdateFooterOptions()
+
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ UpdateDialogFooterVisibility( uiGlobal.activeMenu, controllerModeEnabled )
+}
+
+void function UICodeCallback_OnVideoOver()
+{
+ SetIntroViewed( true )
+
+ Signal( uiGlobal.signalDummy, "PlayVideoEnded" )
+}
+
+void function UpdateClientMenuOpenState()
+{
+ for ( ;; )
+ {
+ WaitSignal( uiGlobal.signalDummy, "ActiveMenuChanged" )
+
+ if ( IsMultiplayer() && !IsLobby() )
+ {
+ int newState = 0
+ if ( IsDialogOnlyActiveMenu() )
+ newState = 2
+ else if ( uiGlobal.activeMenu != null)
+ newState = 1
+
+ RunMenuClientFunction( "SetMenuOpenState", newState )
+ }
+ }
+}
+
+void function AddUICallback_OnLevelInit( void functionref() callbackFunc )
+{
+ Assert( !( uiGlobal.onLevelInitCallbacks.contains( callbackFunc ) ), "Already added " + string( callbackFunc ) + " with AddUICallback_OnLevelInit" )
+ uiGlobal.onLevelInitCallbacks.append( callbackFunc )
+}