Skip to content
This repository was archived by the owner on Jan 10, 2022. It is now read-only.

Commit 8fda5bc

Browse files
author
F1F7Y
committed
Arrow nav improvements
1 parent 3c262e3 commit 8fda5bc

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

mod/resource/ui/menus/server_browser.menu

+15-10
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ resource/ui/menus/mods_browse.menu
426426
xpos -4
427427
ypos -1
428428

429-
scriptID 1
429+
scriptID 999
430430

431431
pin_to_sibling BtnServerPasswordProtectedTab
432432
pin_corner_to_sibling TOP_LEFT
@@ -673,7 +673,7 @@ resource/ui/menus/mods_browse.menu
673673
wide 104
674674
xpos 4
675675

676-
scriptID 1
676+
scriptID 999
677677

678678
pin_to_sibling BtnServerNameTab
679679
pin_corner_to_sibling TOP_LEFT
@@ -918,7 +918,7 @@ resource/ui/menus/mods_browse.menu
918918
wide 140
919919
xpos 4
920920

921-
scriptID 1
921+
scriptID 999
922922

923923
pin_to_sibling BtnServerPlayersTab
924924
pin_corner_to_sibling TOP_LEFT
@@ -1163,7 +1163,7 @@ resource/ui/menus/mods_browse.menu
11631163
wide 150
11641164
xpos 4
11651165

1166-
scriptID 1
1166+
scriptID 999
11671167

11681168
pin_to_sibling BtnServerMapTab
11691169
pin_corner_to_sibling TOP_LEFT
@@ -1408,7 +1408,7 @@ resource/ui/menus/mods_browse.menu
14081408
wide 110
14091409
xpos 4
14101410

1411-
scriptID 1
1411+
scriptID 999
14121412

14131413
pin_to_sibling BtnServerGamemodeTab
14141414
pin_corner_to_sibling TOP_LEFT
@@ -1766,6 +1766,7 @@ resource/ui/menus/mods_browse.menu
17661766
pin_corner_to_sibling TOP_LEFT
17671767
pin_to_sibling_corner TOP_LEFT
17681768
navRight BtnServerJoin
1769+
navDown BtnServer2
17691770
}
17701771
BtnServer2
17711772
{
@@ -2185,7 +2186,6 @@ resource/ui/menus/mods_browse.menu
21852186
pin_to_sibling BtnSearchLabel
21862187
pin_corner_to_sibling TOP_LEFT
21872188
pin_to_sibling_corner BOTTOM_LEFT
2188-
21892189
}
21902190
SwtBtnSelectGamemode
21912191
{
@@ -2198,7 +2198,6 @@ resource/ui/menus/mods_browse.menu
21982198
pin_to_sibling SwtBtnSelectMap
21992199
pin_corner_to_sibling TOP_LEFT
22002200
pin_to_sibling_corner BOTTOM_LEFT
2201-
22022201
}
22032202

22042203
SwtBtnHideFull
@@ -2219,7 +2218,6 @@ resource/ui/menus/mods_browse.menu
22192218
pin_to_sibling BtnSearchLabel
22202219
pin_corner_to_sibling TOP_LEFT
22212220
pin_to_sibling_corner TOP_RIGHT
2222-
22232221
}
22242222
SwtBtnHideEmpty
22252223
{
@@ -2269,9 +2267,14 @@ resource/ui/menus/mods_browse.menu
22692267
ypos -57
22702268
zpos 90
22712269

2270+
scriptID 999
2271+
22722272
pin_to_sibling FilterPanel
22732273
pin_corner_to_sibling TOP_RIGHT
22742274
pin_to_sibling_corner BOTTOM_RIGHT
2275+
2276+
navUp BtnServer15
2277+
navRight BtnServerJoin
22752278
}
22762279
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
22772280

@@ -2486,12 +2489,14 @@ resource/ui/menus/mods_browse.menu
24862489
ypos -57
24872490
zpos 90
24882491

2489-
scriptID 1
2492+
scriptID 999
24902493

24912494
pin_to_sibling ServerDetailsPanel
24922495
pin_corner_to_sibling TOP_RIGHT
24932496
pin_to_sibling_corner BOTTOM_RIGHT
2494-
navLeft BtnServer1
2497+
2498+
navUp BtnServer15
2499+
navLeft BtnFiltersClear
24952500
}
24962501

24972502
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut

+38-10
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct {
7171
float serverSelectedTimeLast = 0
7272
//array<string> serverButtons
7373
int serverButtonFocusedID = 0
74+
bool usingArrowKeys = false
7475
bool shouldFocus = true
7576

7677
bool cancelConnection = false
@@ -235,6 +236,8 @@ void function InitServerBrowserMenu()
235236
Hud_SetWidth( button , width )
236237
}
237238

239+
AddButtonEventHandler( Hud_GetChild( file.menu , "BtnServerNameTab" ), UIE_GET_FOCUS, OnServerButtonFocused )
240+
238241

239242

240243
AddButtonEventHandler( Hud_GetChild( file.menu, "BtnServerJoin"), UIE_CLICK, OnServerSelected )
@@ -343,26 +346,51 @@ void function OnCloseServerBrowserMenu()
343346

344347
void function OnKeyUpArrowSelected( var button )
345348
{
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+
346357
DisplayFocusedServerInfo(file.serverButtonFocusedID)
347358

359+
360+
361+
//file.lastSelectedServer = 999
362+
348363
if ( file.serverButtonFocusedID != 0) return
364+
349365
file.scrollOffset -= 1
350-
if (file.scrollOffset < 0) file.scrollOffset = 0
366+
if (file.scrollOffset < 0) file.scrollOffset = 0
351367

352-
//printt("Up arrow ", scriptID)
353368

354369
UpdateShownPage()
355370
UpdateListSliderPosition( serversArrayFiltered.len() )
356371
}
357372

358373
void function OnKeyDownArrowSelected( var button )
359374
{
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+
360381
DisplayFocusedServerInfo(file.serverButtonFocusedID)
361382

383+
//file.lastSelectedServer = 999
384+
362385
if ( file.serverButtonFocusedID != 14) return
363386
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+
366394

367395
UpdateShownPage()
368396
UpdateListSliderPosition( serversArrayFiltered.len() )
@@ -872,13 +900,13 @@ void function OnServerButtonFocused( var button )
872900

873901
void function OnServerFocused( var button )
874902
{
903+
file.usingArrowKeys = false
875904
DisplayFocusedServerInfo(int ( Hud_GetScriptID( button ) ))
876905
}
877906

878907
void function DisplayFocusedServerInfo( int scriptID )
879908
{
880-
if ( scriptID == 999 ) return
881-
909+
if ( file.lastSelectedServer == 999 || scriptID == 999 ) return
882910

883911
if ( NSIsRequestingServerList() || NSGetServerCount() == 0 || file.serverListRequestFailed )
884912
return
@@ -892,14 +920,14 @@ void function DisplayFocusedServerInfo( int scriptID )
892920
if (file.lastSelectedServer == serverIndex) sameServer = true
893921

894922

895-
file.lastSelectedServer = serverIndex
896-
897923
file.serverSelectedTimeLast = file.serverSelectedTime
898924
file.serverSelectedTime = Time()
899925

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
901929

902-
if ((file.serverSelectedTime - file.serverSelectedTimeLast < DOUBLE_CLICK_TIME_MS) && sameServer )
930+
if ((file.serverSelectedTime - file.serverSelectedTimeLast < DOUBLE_CLICK_TIME_MS) && sameServer && !file.usingArrowKeys)
903931
OnServerSelected(0)
904932

905933

0 commit comments

Comments
 (0)