diff options
Diffstat (limited to 'Northstar.Client/mod/scripts')
4 files changed, 216 insertions, 152 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/sh_menu_models.gnut b/Northstar.Client/mod/scripts/vscripts/sh_menu_models.gnut index cd663a06..b1b97bc9 100644 --- a/Northstar.Client/mod/scripts/vscripts/sh_menu_models.gnut +++ b/Northstar.Client/mod/scripts/vscripts/sh_menu_models.gnut @@ -2,9 +2,9 @@ // Model tracking and save/Clear functions are temp. We already update the client knowledge of loadouts. Derive from that. // Move the struct off the player? -#if CLIENT && MP +//#if CLIENT && MP untyped -#endif //client && MP +//#endif //client && MP #if CLIENT const float CARD_TAG_SCALE = 0.0 // update to match same const in hud_defs.rui @@ -207,12 +207,18 @@ #endif // CLIENT && MP #if UI + struct + { + table MouseMovementCaptureFunctionsTable = {} + } file + const MOUSE_ROTATE_MULTIPLIER = 25.0 global function UpdateUIMapSupportsMenuModels global function RunMenuClientFunction global function UI_SetPresentationType + global function AddMouseMovementCaptureHandler global function UICodeCallback_MouseMovementCapture #endif // UI @@ -2892,6 +2898,18 @@ } } + void function AddMouseMovementCaptureHandler( var menu, void functionref( int, int ) func ) + { + file.MouseMovementCaptureFunctionsTable.rawset( menu, func ) + } + + void function UpdateMouseMovementCaptureFunctions( int deltaX, int deltaY ) + { + var activeMenu = GetActiveMenu() + if ( file.MouseMovementCaptureFunctionsTable.rawin( activeMenu ) ) + file.MouseMovementCaptureFunctionsTable.rawget( activeMenu )(deltaX, deltaY) + } + void function UICodeCallback_MouseMovementCapture( var capturePanel, int deltaX, int deltaY ) { float screenScaleXModifier = 1920.0 / GetScreenSize()[0] // 1920 is base screen width @@ -2901,7 +2919,7 @@ float screenScaleYModifier = 1080.0 / GetScreenSize()[1] // 1920 is base screen width float mouseYRotationDelta = deltaY * screenScaleYModifier * MOUSE_ROTATE_MULTIPLIER - UpdateMouseDeltaBuffer( deltaX, deltaY ) + UpdateMouseMovementCaptureFunctions( deltaX, deltaY ) RunMenuClientFunction( "UpdateMouseRotateDelta", mouseXRotateDelta, mouseYRotationDelta ) } 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 e1ed8991..56db0ccc 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,13 @@ global function AddNorthstarConnectWithPasswordMenu +struct +{ + var menu + var enterPasswordBox + var enterPasswordDummy + var connectButton +} file + void function AddNorthstarConnectWithPasswordMenu() { AddMenu( "ConnectWithPasswordMenu", $"resource/ui/menus/connect_password.menu", InitConnectWithPasswordMenu, "#MENU_CONNECT" ) @@ -7,24 +15,42 @@ void function AddNorthstarConnectWithPasswordMenu() void function InitConnectWithPasswordMenu() { - AddMenuEventHandler( GetMenu( "ConnectWithPasswordMenu" ), eUIEvent.MENU_OPEN, OnConnectWithPasswordMenuOpened ) - AddMenuFooterOption( GetMenu( "ConnectWithPasswordMenu" ), BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) + file.menu = GetMenu( "ConnectWithPasswordMenu" ) + + file.enterPasswordBox = Hud_GetChild( file.menu, "EnterPasswordBox") + file.enterPasswordDummy = Hud_GetChild( file.menu, "EnterPasswordBoxDummy") + file.connectButton = Hud_GetChild( file.menu, "ConnectButton") + + AddMenuEventHandler( file.menu, eUIEvent.MENU_OPEN, OnConnectWithPasswordMenuOpened ) + AddMenuFooterOption( file.menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) + + AddButtonEventHandler( file.connectButton, UIE_CLICK, ConnectWithPassword ) + + AddButtonEventHandler( file.enterPasswordBox, UIE_CHANGE, UpdatePasswordLabel ) - AddButtonEventHandler( Hud_GetChild( GetMenu( "ConnectWithPasswordMenu" ), "ConnectButton" ), UIE_CLICK, ConnectWithPassword ) RegisterButtonPressedCallback( KEY_ENTER, ConnectWithPassword ) } +void function UpdatePasswordLabel( var n ) +{ + string hiddenPSWD + for ( int i = 0; i < Hud_GetUTF8Text( file.enterPasswordBox ).len(); i++) + hiddenPSWD += "*" + Hud_SetText( file.enterPasswordDummy, hiddenPSWD ) +} + void function OnConnectWithPasswordMenuOpened() { UI_SetPresentationType( ePresentationType.KNOWLEDGEBASE_SUB ) - Hud_SetText( Hud_GetChild( GetMenu( "ConnectWithPasswordMenu" ), "Title" ), "#MENU_TITLE_CONNECT_PASSWORD" ) - Hud_SetText( Hud_GetChild( GetMenu( "ConnectWithPasswordMenu" ), "ConnectButton" ), "#MENU_CONNECT_MENU_CONNECT" ) - Hud_SetText( Hud_GetChild( GetMenu( "ConnectWithPasswordMenu" ), "EnterPasswordBox" ), "" ) + Hud_SetText( Hud_GetChild( file.menu, "Title" ), "#MENU_TITLE_CONNECT_PASSWORD" ) + Hud_SetText( file.connectButton, "#MENU_CONNECT_MENU_CONNECT" ) + Hud_SetText( file.enterPasswordBox, "" ) + Hud_SetText( file.enterPasswordDummy, "" ) } void function ConnectWithPassword( var button ) { - if ( GetTopNonDialogMenu() == GetMenu( "ConnectWithPasswordMenu" ) ) - thread ThreadedAuthAndConnectToServer( Hud_GetUTF8Text( Hud_GetChild( GetMenu( "ConnectWithPasswordMenu" ), "EnterPasswordBox" ) ) ) + if ( GetTopNonDialogMenu() == file.menu ) + thread ThreadedAuthAndConnectToServer( Hud_GetUTF8Text( Hud_GetChild( file.menu, "EnterPasswordBox" ) ) ) }
\ No newline at end of file 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 cb1535d3..cc681e95 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -4,6 +4,8 @@ global function ReloadMods struct { bool shouldReloadModsOnEnd + string currentMod + var currentButton } file void function AddNorthstarModMenu() @@ -83,9 +85,44 @@ void function SetModMenuNameText( var button ) void function OnModMenuButtonPressed( var button ) { string modName = NSGetModNames()[ int ( Hud_GetScriptID( button ) ) ] - NSSetModEnabled( modName, !NSIsModEnabled( modName ) ) - SetModMenuNameText( button ) - + if ( ( modName == "Northstar.Client" || modName == "Northstar.Coop" || modName == "Northstar.CustomServers") && NSIsModEnabled( modName ) ) + { + file.currentMod = modName + file.currentButton = button + CoreModToggleDialog( modName ) + } + else + { + NSSetModEnabled( modName, !NSIsModEnabled( modName ) ) + + SetModMenuNameText( button ) + + file.shouldReloadModsOnEnd = true + } +} + +void function CoreModToggleDialog( string mod ) +{ + DialogData dialogData + dialogData.header = "#WARNING" + dialogData.message = "#CORE_MOD_DISABLE_WARNING" + + AddDialogButton( dialogData, "#CANCEL" ) + // This can't have any arguments so we use the file struct + AddDialogButton( dialogData, "#DISABLE", DisableMod ) + + AddDialogFooter( dialogData, "#A_BUTTON_SELECT" ) + AddDialogFooter( dialogData, "#B_BUTTON_CANCEL" ) + + OpenDialog( dialogData ) +} + +void function DisableMod() +{ + NSSetModEnabled( file.currentMod, false ) + + SetModMenuNameText( file.currentButton ) + file.shouldReloadModsOnEnd = true } 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 7c3e2fae..7aadce89 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -4,12 +4,11 @@ untyped global function AddNorthstarServerBrowserMenu global function ThreadedAuthAndConnectToServer -global function UpdateMouseDeltaBuffer // Stop peeking const int BUTTONS_PER_PAGE = 15 -const float DOUBLE_CLICK_TIME_MS = 0.2 // unsure what the ideal value is +const float DOUBLE_CLICK_TIME_MS = 0.3 // unsure what the ideal value is struct { @@ -29,6 +28,17 @@ struct { string filterGamemode } filterArguments + +enum sortingBy +{ + NONE, + NAME, + PLAYERS, + MAP, + GAMEMODE, + LATENCY +} + struct { // true = alphabeticaly false = reverse bool serverName = true @@ -100,22 +110,22 @@ void function UpdatePrivateMatchModesAndMaps() { if ( filterArguments.filterMaps.find( map ) != -1 ) continue - + filterArguments.filterMaps.append( map ) - + string localized = GetMapDisplayName( map ) Hud_DialogList_AddListItem( Hud_GetChild( file.menu, "SwtBtnSelectMap" ) , localized, string( enum_ + 1 ) ) - } - + } + array<string> realModes = [ "private_match" ] realModes.extend( GetPrivateMatchModes() ) - + foreach( int enum_, string mode in realModes ) { string localized = GetGameModeDisplayName( mode ) if ( filterArguments.filterGamemodes.find( localized ) != -1 ) continue - + filterArguments.filterGamemodes.append( localized ) Hud_DialogList_AddListItem( Hud_GetChild( file.menu, "SwtBtnSelectGamemode" ) , localized, string( enum_ + 1 ) ) } @@ -125,6 +135,8 @@ void function InitServerBrowserMenu() { file.menu = GetMenu( "ServerBrowserMenu" ) + AddMouseMovementCaptureHandler( file.menu, UpdateMouseDeltaBuffer ) + // Get menu stuff file.serverButtons = GetElementsByClassname( file.menu, "ServerButton" ) file.serversName = GetElementsByClassname( file.menu, "ServerName" ) @@ -136,7 +148,7 @@ void function InitServerBrowserMenu() filterArguments.filterMaps = [ "SWITCH_ANY" ] Hud_DialogList_AddListItem( Hud_GetChild( file.menu, "SwtBtnSelectMap" ), "SWITCH_ANY", "0" ) - + filterArguments.filterGamemodes = [ "SWITCH_ANY" ] Hud_DialogList_AddListItem( Hud_GetChild( file.menu, "SwtBtnSelectGamemode" ), "SWITCH_ANY", "0" ) @@ -171,11 +183,11 @@ void function InitServerBrowserMenu() AddButtonEventHandler( Hud_GetChild( file.menu, "BtnFiltersClear"), UIE_CLICK, OnBtnFiltersClear_Activate ) - AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerNameTab"), UIE_CLICK, SortServerListByName ) - AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerPlayersTab"), UIE_CLICK, SortServerListByPlayers ) - AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerMapTab"), UIE_CLICK, SortServerListByMap ) - AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerGamemodeTab"), UIE_CLICK, SortServerListByGamemode ) - AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerLatencyTab"), UIE_CLICK, SortServerListByLatency ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerNameTab"), UIE_CLICK, SortServerListByName_Activate ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerPlayersTab"), UIE_CLICK, SortServerListByPlayers_Activate ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerMapTab"), UIE_CLICK, SortServerListByMap_Activate ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerGamemodeTab"), UIE_CLICK, SortServerListByGamemode_Activate ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerLatencyTab"), UIE_CLICK, SortServerListByLatency_Activate ) AddButtonEventHandler( Hud_GetChild( file.menu, "SwtBtnSelectMap"), UIE_CHANGE, FilterAndUpdateList ) @@ -278,10 +290,12 @@ void function UpdateListSliderHeight( float servers ) var movementCapture = Hud_GetChild( file.menu , "MouseMovementCapture" ) float maxHeight = 562.0 * (GetScreenSize()[1] / 1080.0) + float minHeight = 80.0 * (GetScreenSize()[1] / 1080.0) float height = maxHeight * (15.0 / servers ) if ( height > maxHeight ) height = maxHeight + if ( height < minHeight ) height = minHeight Hud_SetHeight( sliderButton , height ) Hud_SetHeight( sliderPanel , height ) @@ -419,36 +433,29 @@ bool function IsFilterPanelElementFocused() { var focusedElement = GetFocus(); var name = Hud_GetHudName(focusedElement); - print(name) - - // kinda sucks but just check if any of the filter elements - // has focus. would be nice to have tags or sth here - bool match = (name == "FilterPanel") || - (name == "BtnSearchLabel") || - (name == "BtnServerSearch") || - (name == "SwtBtnSelectMap") || - (name == "SwtBtnSelectGamemode") || - (name == "SwtBtnHideFull") || - (name == "SwtBtnHideEmpty") || - (name == "SwtBtnHideProtected") || - (name == "BtnFiltersClear") || - (name == "BtnDummyAfterFilterClear"); + foreach (element in GetElementsByClassname( file.menu, "FilterPanelChild")) { + if ( element == focusedElement ) return true + } - return match; + return false; } void function OnKeyTabPressed(var button) { - // toggle focus between server list and filter panel - if (IsFilterPanelElementFocused()) { - // print("Switching focus from filter panel to server list") - Hud_SetFocused(Hud_GetChild(file.menu, "BtnServer1")) - } - else { - // print("Switching focus from server list to filter panel") - Hud_SetFocused(Hud_GetChild(file.menu, "BtnServerSearch")) - HideServerInfo() + try + { + // toggle focus between server list and filter panel + if (IsFilterPanelElementFocused()) { + // print("Switching focus from filter panel to server list") + Hud_SetFocused(Hud_GetChild(file.menu, "BtnServer1")) + } + else { + // print("Switching focus from server list to filter panel") + Hud_SetFocused(Hud_GetChild(file.menu, "BtnServerSearch")) + HideServerInfo() + } } + catch ( ex ) {} } void function OnHitDummyTop(var button) { @@ -483,7 +490,7 @@ void function OnHitDummyBottom(var button) { } void function OnHitDummyAfterFilterClear(var button) { - Hud_SetFocused(Hud_GetChild(file.menu, "BtnServer1")) + Hud_SetFocused(Hud_GetChild(file.menu, "BtnServerNameTab")) } @@ -570,30 +577,31 @@ void function FilterAndUpdateList( var n ) FilterServerList() + switch ( filterDirection.sortingBy ) { - case 0: + case sortingBy.NONE: UpdateShownPage() break - case 1: + case sortingBy.NAME: filterDirection.serverName = !filterDirection.serverName - SortServerListByName(0) + SortServerListByName_Activate(0) break - case 2: + case sortingBy.PLAYERS: filterDirection.serverPlayers = !filterDirection.serverPlayers - SortServerListByPlayers(0) + SortServerListByPlayers_Activate(0) break - case 3: + case sortingBy.MAP: filterDirection.serverMap = !filterDirection.serverMap - SortServerListByMap(0) + SortServerListByMap_Activate(0) break - case 5: // 4 skipped cause it doesn't work respawn pls fix + case sortingBy.GAMEMODE: filterDirection.serverGamemode = !filterDirection.serverGamemode - SortServerListByGamemode(0) + SortServerListByGamemode_Activate(0) break - case 6: + case sortingBy.LATENCY: filterDirection.serverLatency = !filterDirection.serverLatency - SortServerListByLatency(0) + SortServerListByLatency_Activate(0) break default: printt( "How the f did you get here" ) @@ -1021,130 +1029,105 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) ////////////////////////////////////// // Shadow realm ////////////////////////////////////// -void function SortServerListByName( var button ) +int function ServerSortLogic ( serverStruct a, serverStruct b) { - filterDirection.sortingBy = 1 + var aTemp + var bTemp + + bool direction + + // We can hard code this cause adding entire columns isn't as easy + switch ( filterDirection.sortingBy ) { + case sortingBy.NAME: + aTemp = a.serverName.tolower() + bTemp = b.serverName.tolower() + direction = filterDirection.serverName + break; + case sortingBy.PLAYERS: + aTemp = a.serverPlayers + bTemp = b.serverPlayers + direction = filterDirection.serverPlayers + break; + case sortingBy.MAP: + aTemp = Localize(a.serverMap).tolower() + bTemp = Localize(b.serverMap).tolower() + direction = filterDirection.serverMap + break; + case sortingBy.GAMEMODE: + aTemp = Localize(a.serverGamemode).tolower() + bTemp = Localize(b.serverGamemode).tolower() + direction = filterDirection.serverGamemode + break; + case sortingBy.LATENCY: + aTemp = a.serverLatency + bTemp = b.serverLatency + direction = filterDirection.serverLatency + break; + default: + return 0 + } - int n = file.serversArrayFiltered.len() - 1 + int invert = direction == true ? 1 : -1 - serverStruct tempServer + if ( aTemp > bTemp ) + return 1 * invert - for ( int i = 0; i < n; i++) - { - for ( int j = 0; j < n - 1; j++) - { - if ( file.serversArrayFiltered[ j ].serverName < file.serversArrayFiltered[ j + 1 ].serverName && filterDirection.serverName || file.serversArrayFiltered[ j ].serverName > file.serversArrayFiltered[ j + 1 ].serverName && !filterDirection.serverName) - { - tempServer = file.serversArrayFiltered[ j ] - file.serversArrayFiltered[ j ] = file.serversArrayFiltered[ j + 1 ] - file.serversArrayFiltered[ j + 1 ] = tempServer - } - } - } + if ( aTemp < bTemp ) + return -1 * invert + + return 0 +} + +void function SortServerListByName_Activate ( var button ) +{ + filterDirection.sortingBy = sortingBy.NAME + + file.serversArrayFiltered.sort( ServerSortLogic ) filterDirection.serverName = !filterDirection.serverName UpdateShownPage() } -void function SortServerListByPlayers( var button ) -{ - filterDirection.sortingBy = 2 - int n = file.serversArrayFiltered.len() - 1 +void function SortServerListByPlayers_Activate( var button ) +{ + filterDirection.sortingBy = sortingBy.PLAYERS - serverStruct tempServer - - for ( int i = 0; i < n; i++) - { - for ( int j = 0; j < n - 1; j++) - { - if ( file.serversArrayFiltered[ j ].serverPlayers < file.serversArrayFiltered[ j + 1 ].serverPlayers && filterDirection.serverPlayers || file.serversArrayFiltered[ j ].serverPlayers > file.serversArrayFiltered[ j + 1 ].serverPlayers && !filterDirection.serverPlayers) - { - tempServer = file.serversArrayFiltered[ j ] - file.serversArrayFiltered[ j ] = file.serversArrayFiltered[ j + 1 ] - file.serversArrayFiltered[ j + 1 ] = tempServer - } - } - } + file.serversArrayFiltered.sort( ServerSortLogic ) filterDirection.serverPlayers = !filterDirection.serverPlayers UpdateShownPage() } -void function SortServerListByMap( var button ) +void function SortServerListByMap_Activate( var button ) { - filterDirection.sortingBy = 3 - - int n = file.serversArrayFiltered.len() - 1 + filterDirection.sortingBy = sortingBy.MAP - serverStruct tempServer - - for ( int i = 0; i < n; i++) - { - for ( int j = 0; j < n - 1; j++) - { - if ( Localize(file.serversArrayFiltered[ j ].serverMap) < Localize(file.serversArrayFiltered[ j + 1 ].serverMap) && filterDirection.serverMap || Localize(file.serversArrayFiltered[ j ].serverMap) > Localize(file.serversArrayFiltered[ j + 1 ].serverMap) && !filterDirection.serverMap) - { - tempServer = file.serversArrayFiltered[ j ] - file.serversArrayFiltered[ j ] = file.serversArrayFiltered[ j + 1 ] - file.serversArrayFiltered[ j + 1 ] = tempServer - } - } - } + file.serversArrayFiltered.sort( ServerSortLogic ) filterDirection.serverMap = !filterDirection.serverMap UpdateShownPage() } -void function SortServerListByGamemode( var button ) +void function SortServerListByGamemode_Activate( var button ) { - filterDirection.sortingBy = 5 - - int n = file.serversArrayFiltered.len() - 1 - - serverStruct tempServer + filterDirection.sortingBy = sortingBy.GAMEMODE - for ( int i = 0; i < n; i++) - { - for ( int j = 0; j < n - 1; j++) - { - if ( Localize(file.serversArrayFiltered[ j ].serverGamemode) < Localize(file.serversArrayFiltered[ j + 1 ].serverGamemode) && filterDirection.serverGamemode || Localize(file.serversArrayFiltered[ j ].serverGamemode) > Localize(file.serversArrayFiltered[ j + 1 ].serverGamemode) && !filterDirection.serverGamemode) - { - tempServer = file.serversArrayFiltered[ j ] - file.serversArrayFiltered[ j ] = file.serversArrayFiltered[ j + 1 ] - file.serversArrayFiltered[ j + 1 ] = tempServer - } - } - } + file.serversArrayFiltered.sort( ServerSortLogic ) filterDirection.serverGamemode = !filterDirection.serverGamemode UpdateShownPage() } -void function SortServerListByLatency( var button ) +void function SortServerListByLatency_Activate( var button ) { - filterDirection.sortingBy = 5 + filterDirection.sortingBy = sortingBy.LATENCY - int n = file.serversArrayFiltered.len() - 1 - - serverStruct tempServer - - for ( int i = 0; i < n; i++) - { - for ( int j = 0; j < n - 1; j++) - { - if ( file.serversArrayFiltered[ j ].serverLatency < file.serversArrayFiltered[ j + 1 ].serverLatency && filterDirection.serverLatency || file.serversArrayFiltered[ j ].serverLatency > file.serversArrayFiltered[ j + 1 ].serverLatency && !filterDirection.serverLatency) - { - tempServer = file.serversArrayFiltered[ j ] - file.serversArrayFiltered[ j ] = file.serversArrayFiltered[ j + 1 ] - file.serversArrayFiltered[ j + 1 ] = tempServer - } - } - } + file.serversArrayFiltered.sort( ServerSortLogic ) filterDirection.serverLatency = !filterDirection.serverLatency |