diff options
author | Kami Kaze <joscha.vack@vi-solutions.de> | 2022-04-11 00:15:22 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2022-04-12 23:12:28 +0200 |
commit | 4f69b13b09a272bbbd818e182816b7ac4d0e73ee (patch) | |
tree | 191eaac4b99ae4059a8b6783ff148efef48fac37 /Northstar.Client/mod | |
parent | 936b66298a2666394c407419b1eb6310201b6153 (diff) | |
download | NorthstarMods-4f69b13b09a272bbbd818e182816b7ac4d0e73ee.tar.gz NorthstarMods-4f69b13b09a272bbbd818e182816b7ac4d0e73ee.zip |
Server Browser: QOL and hide server info if no server focused (#295)
* Serverbrowser QOL + Minor Fixes
* Fix server info hidden on mouse hover
* Retain focus on connect + cancel
Diffstat (limited to 'Northstar.Client/mod')
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_connect_password.nut | 2 | ||||
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 50 |
2 files changed, 50 insertions, 2 deletions
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 56db0ccc..b5a2e9b6 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 @@ -47,6 +47,8 @@ void function OnConnectWithPasswordMenuOpened() Hud_SetText( file.connectButton, "#MENU_CONNECT_MENU_CONNECT" ) Hud_SetText( file.enterPasswordBox, "" ) Hud_SetText( file.enterPasswordDummy, "" ) + Hud_SetFocused( file.enterPasswordBox ) + } void function ConnectWithPassword( var button ) 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 bd263f2b..6bffe8bb 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -399,6 +399,8 @@ void function OnCloseServerBrowserMenu() DeregisterButtonPressedCallback(MOUSE_WHEEL_UP , OnScrollUp) DeregisterButtonPressedCallback(MOUSE_WHEEL_DOWN , OnScrollDown) DeregisterButtonPressedCallback(KEY_TAB , OnKeyTabPressed) + DeregisterButtonPressedCallback(KEY_ENTER, OnEnterPressed) + DeregisterButtonPressedCallback(KEY_R, OnKeyRPressed) } catch ( ex ) {} } @@ -425,6 +427,8 @@ void function OnServerBrowserMenuOpened() RegisterButtonPressedCallback(MOUSE_WHEEL_UP , OnScrollUp) RegisterButtonPressedCallback(MOUSE_WHEEL_DOWN , OnScrollDown) RegisterButtonPressedCallback(KEY_TAB , OnKeyTabPressed) + RegisterButtonPressedCallback(KEY_ENTER, OnEnterPressed) + RegisterButtonPressedCallback(KEY_R, OnKeyRPressed) } //////////////////////////// @@ -448,11 +452,9 @@ 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() } @@ -482,6 +484,7 @@ void function OnHitDummyBottom(var button) { // was at bottom already file.scrollOffset = file.serversArrayFiltered.len() - BUTTONS_PER_PAGE Hud_SetFocused(Hud_GetChild(file.menu, "BtnServerSearch")) + HideServerInfo() } else { // only update if list position changed UpdateShownPage() @@ -518,6 +521,46 @@ void function OnUpArrowSelected( var button ) UpdateListSliderPosition( file.serversArrayFiltered.len() ) } +//////////////////////// +// Key Callbacks +//////////////////////// +void function OnEnterPressed(arg) +{ + // only trigger if a server is focused + if (IsServerButtonFocused()) + { + OnServerSelected(0) + } +} + +void function OnKeyRPressed(arg) +{ + if (!IsSearchBarFocused()) + { + RefreshServers(0); + } +} + +bool function IsServerButtonFocused() +{ + var focusedElement = GetFocus(); + var name = Hud_GetHudName(focusedElement); + + foreach (element in GetElementsByClassname( file.menu, "ServerButton")) + { + if ( element == focusedElement ) + return true + } + + + return false; +} + +bool function IsSearchBarFocused() +{ + return Hud_GetChild( file.menu, "BtnServerSearch") == GetFocus() +} + //////////////////////////// // Unused @@ -577,6 +620,7 @@ void function FilterAndUpdateList( var n ) file.scrollOffset = 0 UpdateListSliderPosition( file.serversArrayFiltered.len() ) + HideServerInfo() FilterServerList() @@ -985,6 +1029,8 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) if (file.cancelConnection) { file.cancelConnection = false + // re-focus server list + Hud_SetFocused( Hud_GetChild( file.menu, "BtnServer" + (file.serverButtonFocusedID + 1)) ) return } |