@@ -71,6 +71,7 @@ struct {
71
71
float serverSelectedTimeLast = 0
72
72
// array<string> serverButtons
73
73
int serverButtonFocusedID = 0
74
+ bool usingArrowKeys = false
74
75
bool shouldFocus = true
75
76
76
77
bool cancelConnection = false
@@ -235,6 +236,8 @@ void function InitServerBrowserMenu()
235
236
Hud_SetWidth ( button , width )
236
237
}
237
238
239
+ AddButtonEventHandler ( Hud_GetChild ( file. menu , " BtnServerNameTab" ), UIE_GET_FOCUS, OnServerButtonFocused )
240
+
238
241
239
242
240
243
AddButtonEventHandler ( Hud_GetChild ( file. menu , " BtnServerJoin" ), UIE_CLICK, OnServerSelected )
@@ -343,26 +346,51 @@ void function OnCloseServerBrowserMenu()
343
346
344
347
void function OnKeyUpArrowSelected ( var button )
345
348
{
349
+ file. usingArrowKeys = true
350
+
351
+ if ( file. serverButtonFocusedID == 0 && file. lastSelectedServer == 0 )
352
+ {
353
+ Hud_SetFocused ( Hud_GetChild (file. menu , " BtnServerNameTab" ) )
354
+ }
355
+
356
+
346
357
DisplayFocusedServerInfo (file. serverButtonFocusedID )
347
358
359
+
360
+
361
+ // file.lastSelectedServer = 999
362
+
348
363
if ( file. serverButtonFocusedID != 0 ) return
364
+
349
365
file. scrollOffset -= 1
350
- if (file. scrollOffset < 0 ) file. scrollOffset = 0
366
+ if (file. scrollOffset < 0 ) file. scrollOffset = 0
351
367
352
- // printt("Up arrow ", scriptID)
353
368
354
369
UpdateShownPage ()
355
370
UpdateListSliderPosition ( serversArrayFiltered. len () )
356
371
}
357
372
358
373
void function OnKeyDownArrowSelected ( var button )
359
374
{
375
+ file. usingArrowKeys = true
376
+ if (file. serverButtonFocusedID == 14 && file. lastSelectedServer == serversArrayFiltered. len ()- 1 )
377
+ {
378
+ Hud_SetFocused ( Hud_GetChild (file. menu , " BtnFiltersClear" ) )
379
+ }
380
+
360
381
DisplayFocusedServerInfo (file. serverButtonFocusedID )
361
382
383
+ // file.lastSelectedServer = 999
384
+
362
385
if ( file. serverButtonFocusedID != 14 ) return
363
386
file. scrollOffset += 1
364
- if (file. scrollOffset + BUTTONS_PER_PAGE > serversArrayFiltered. len ()) file. scrollOffset = serversArrayFiltered. len () - BUTTONS_PER_PAGE
365
- // printt("Down arrow ", scriptID)
387
+ if (file. scrollOffset + BUTTONS_PER_PAGE > serversArrayFiltered. len ())
388
+ {
389
+ file. scrollOffset = serversArrayFiltered. len () - BUTTONS_PER_PAGE
390
+ }
391
+ printt (" 1: " , file. lastSelectedServer )
392
+ printt (" 2: " , file. serverButtonFocusedID )
393
+
366
394
367
395
UpdateShownPage ()
368
396
UpdateListSliderPosition ( serversArrayFiltered. len () )
@@ -872,13 +900,13 @@ void function OnServerButtonFocused( var button )
872
900
873
901
void function OnServerFocused ( var button )
874
902
{
903
+ file. usingArrowKeys = false
875
904
DisplayFocusedServerInfo (int ( Hud_GetScriptID ( button ) ))
876
905
}
877
906
878
907
void function DisplayFocusedServerInfo ( int scriptID )
879
908
{
880
- if ( scriptID == 999 ) return
881
-
909
+ if ( file. lastSelectedServer == 999 || scriptID == 999 ) return
882
910
883
911
if ( NSIsRequestingServerList () || NSGetServerCount () == 0 || file. serverListRequestFailed )
884
912
return
@@ -892,14 +920,14 @@ void function DisplayFocusedServerInfo( int scriptID )
892
920
if (file. lastSelectedServer == serverIndex) sameServer = true
893
921
894
922
895
- file. lastSelectedServer = serverIndex
896
-
897
923
file. serverSelectedTimeLast = file. serverSelectedTime
898
924
file. serverSelectedTime = Time ()
899
925
900
- printt (file. serverSelectedTime - file. serverSelectedTimeLast ," ;" , file. lastSelectedServer ," ;" , serverIndex, " ;" ,sameServer)
926
+ printt (file. serverSelectedTime - file. serverSelectedTimeLast ," ;" , file. lastSelectedServer ," ;" , file. serverButtonFocusedID , " ;" ,sameServer)
927
+
928
+ file. lastSelectedServer = serverIndex
901
929
902
- if ((file. serverSelectedTime - file. serverSelectedTimeLast < DOUBLE_CLICK_TIME_MS) && sameServer )
930
+ if ((file. serverSelectedTime - file. serverSelectedTimeLast < DOUBLE_CLICK_TIME_MS) && sameServer && ! file . usingArrowKeys )
903
931
OnServerSelected (0 )
904
932
905
933
0 commit comments