diff options
Diffstat (limited to 'Northstar.Client/mod')
-rw-r--r-- | Northstar.Client/mod/resource/northstar_client_localisation_english.txt | bin | 22060 -> 23456 bytes | |||
-rw-r--r-- | Northstar.Client/mod/resource/northstar_client_localisation_french.txt | bin | 23384 -> 24492 bytes | |||
-rw-r--r-- | Northstar.Client/mod/resource/northstar_client_localisation_german.txt | bin | 19418 -> 23164 bytes | |||
-rw-r--r-- | Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt | bin | 16684 -> 17334 bytes | |||
-rw-r--r-- | Northstar.Client/mod/resource/ui/menus/connect_password.menu | 36 | ||||
-rw-r--r-- | Northstar.Client/mod/resource/ui/menus/server_browser.menu | 32 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/sh_menu_models.gnut | 24 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut | 42 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 43 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 259 |
10 files changed, 272 insertions, 164 deletions
diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt Binary files differindex af8a0229..7f994e8a 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_french.txt b/Northstar.Client/mod/resource/northstar_client_localisation_french.txt Binary files differindex 2a7a82f4..65581e31 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_french.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_french.txt diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_german.txt b/Northstar.Client/mod/resource/northstar_client_localisation_german.txt Binary files differindex 3d7a7551..e35378cb 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_german.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_german.txt diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt b/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt Binary files differindex e61f9deb..c9abfc04 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_tchinese.txt diff --git a/Northstar.Client/mod/resource/ui/menus/connect_password.menu b/Northstar.Client/mod/resource/ui/menus/connect_password.menu index b5e12ad2..d2421477 100644 --- a/Northstar.Client/mod/resource/ui/menus/connect_password.menu +++ b/Northstar.Client/mod/resource/ui/menus/connect_password.menu @@ -34,7 +34,7 @@ resource/ui/menus/mods_browse.menu ControlName ImagePanel InheritProperties MenuTopBar } - + ButtonRowAnchor { ControlName Label @@ -43,7 +43,7 @@ resource/ui/menus/mods_browse.menu xpos 120 ypos 160 } - + MatchmakingStatus { ControlName CNestedPanel @@ -62,6 +62,34 @@ resource/ui/menus/mods_browse.menu ControlName TextEntry wide 700 tall 53 + zpos 1 + visible 1 + enabled 1 + textHidden 0 + editable 1 + maxchars 32 + NumericInputOnly 0 + textAlignment "east" + font DefaultBold_53 + keyboardTitle "#CONNECT_WITH_PASSWORD" + keyboardDescription "#ENTER_PASSWORD" + allowRightClickMenu 1 + allowSpecialCharacters 0 + unicode 0 + paintborder 0 + alpha 0 + + pin_to_sibling ButtonRowAnchor + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + + EnterPasswordBoxDummy + { + ControlName TextEntry + wide 700 + tall 53 + zpos 0 visible 1 enabled 1 textHidden 1 @@ -76,12 +104,12 @@ resource/ui/menus/mods_browse.menu allowSpecialCharacters 0 unicode 0 paintborder 0 - + pin_to_sibling ButtonRowAnchor pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner BOTTOM_LEFT } - + ConnectButton { ControlName RuiButton diff --git a/Northstar.Client/mod/resource/ui/menus/server_browser.menu b/Northstar.Client/mod/resource/ui/menus/server_browser.menu index 959c1b09..a02cac46 100644 --- a/Northstar.Client/mod/resource/ui/menus/server_browser.menu +++ b/Northstar.Client/mod/resource/ui/menus/server_browser.menu @@ -435,6 +435,7 @@ resource/ui/menus/mods_browse.menu pin_to_sibling BtnServerPasswordProtectedTab pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner TOP_RIGHT + navUp BtnFiltersClear navDown BtnServer1 navRight BtnServerPlayersTab } @@ -683,8 +684,9 @@ resource/ui/menus/mods_browse.menu pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner TOP_RIGHT navDown BtnServer1 - navLeft BtnServerNameTab - navRight BtnServerMapTab + navLeft BtnServerNameTab + navRight BtnServerMapTab + navUp BtnFiltersClear } BtnServerPlayers1 @@ -929,8 +931,9 @@ resource/ui/menus/mods_browse.menu pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner TOP_RIGHT navDown BtnServer1 - navLeft BtnServerPlayersTab - navRight BtnServerGamemodeTab + navLeft BtnServerPlayersTab + navRight BtnServerGamemodeTab + navUp BtnFiltersClear } BtnServerMap1 @@ -1174,8 +1177,9 @@ resource/ui/menus/mods_browse.menu pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner TOP_RIGHT navDown BtnServer1 - navLeft BtnServerMapTab - navRight BtnServerLatencyTab + navLeft BtnServerMapTab + navRight BtnServerLatencyTab + navUp BtnFiltersClear } BtnServerGamemode1 @@ -1419,8 +1423,9 @@ resource/ui/menus/mods_browse.menu pin_corner_to_sibling TOP_LEFT pin_to_sibling_corner TOP_RIGHT navDown BtnServer1 - navLeft BtnServerGamemodeTab - navLeft BtnServerJoin + navLeft BtnServerGamemodeTab + navRight BtnServerJoin + navUp BtnFiltersClear } BtnServerLatency1 @@ -2142,6 +2147,7 @@ resource/ui/menus/mods_browse.menu wide 1200 tall 153 xpos -8 + classname FilterPanelChild rui "ui/control_options_description.rpak" @@ -2159,6 +2165,8 @@ resource/ui/menus/mods_browse.menu InheritProperties RuiSmallButton labelText "#SEARCHBAR_LABEL" textAlignment west + classname FilterPanelChild + wide 500 xpos -23 ypos -16 @@ -2178,6 +2186,7 @@ resource/ui/menus/mods_browse.menu BtnServerSearch { ControlName TextEntry + classname FilterPanelChild zpos 100 // This works around input weirdness when the control is constructed by code instead of VGUI blackbox. xpos -400 ypos -5 @@ -2204,6 +2213,7 @@ resource/ui/menus/mods_browse.menu InheritProperties SwitchButton labelText "#MAP_FILTER" ConVar "filter_map" + classname FilterPanelChild wide 500 pin_to_sibling BtnSearchLabel @@ -2220,6 +2230,7 @@ resource/ui/menus/mods_browse.menu InheritProperties SwitchButton labelText "#GAMEMODE_FILTER" ConVar "filter_gamemode" + classname FilterPanelChild wide 500 pin_to_sibling SwtBtnSelectMap @@ -2236,6 +2247,7 @@ resource/ui/menus/mods_browse.menu InheritProperties SwitchButton labelText "#HIDE_FULL_FILTER" ConVar "filter_hide_full" + classname FilterPanelChild wide 500 @@ -2259,6 +2271,7 @@ resource/ui/menus/mods_browse.menu InheritProperties SwitchButton labelText "#HIDE_EMPTY_FILTER" ConVar "filter_hide_empty" + classname FilterPanelChild wide 500 @@ -2282,6 +2295,7 @@ resource/ui/menus/mods_browse.menu InheritProperties SwitchButton labelText "#HIDE_PROT_FILTER" ConVar "filter_hide_protected" + classname FilterPanelChild wide 500 list @@ -2303,6 +2317,7 @@ resource/ui/menus/mods_browse.menu ControlName RuiButton InheritProperties RuiSmallButton labelText "#CLEAR_FILTERS" + classname FilterPanelChild wide 100 xpos -17 ypos -57 @@ -2322,6 +2337,7 @@ resource/ui/menus/mods_browse.menu BtnDummyAfterFilterClear { ControlName RuiButton + classname FilterPanelChild width 0 height 0 visible 1 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 |