From e0b8ff6ca17a3c8cf8c17ebd33cf109db574dba0 Mon Sep 17 00:00:00 2001 From: Barichello Date: Mon, 17 Jan 2022 19:13:02 -0300 Subject: Fix controller prompts Closes #126 --- .../mod/scripts/vscripts/ui/controller_prompts.nut | 19 +++++++++++++++++++ .../mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 19 ++++++++++++++++--- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 2 +- .../mod/scripts/vscripts/ui/ui_utility.gnut | 2 +- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 Northstar.Client/mod/scripts/vscripts/ui/controller_prompts.nut (limited to 'Northstar.Client/mod/scripts/vscripts/ui') diff --git a/Northstar.Client/mod/scripts/vscripts/ui/controller_prompts.nut b/Northstar.Client/mod/scripts/vscripts/ui/controller_prompts.nut new file mode 100644 index 000000000..1866f0563 --- /dev/null +++ b/Northstar.Client/mod/scripts/vscripts/ui/controller_prompts.nut @@ -0,0 +1,19 @@ +global function PrependControllerPrompts + +// Returns the string that gets turned into a controller prompt image in the front-end +string function ControllerButtonToStr( int buttonID ) +{ + switch (buttonID) + { + case BUTTON_Y: + return "%[Y_BUTTON|]%" + case BUTTON_X: + return "%[X_BUTTON|]%" + } + unreachable +} + +string function PrependControllerPrompts( int buttonID, string localizationKey ) +{ + return ControllerButtonToStr( buttonID ) + " " + Localize(localizationKey) +} 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 cc681e95b..6964c29d2 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -15,7 +15,8 @@ void function AddNorthstarModMenu() void function AddNorthstarModMenu_MainMenuFooter() { - AddMenuFooterOption( GetMenu( "MainMenu" ), BUTTON_Y, "#Y_BUTTON_MENU_TITLE_MODS", "#MENU_TITLE_MODS", AdvanceToModListMenu ) + string controllerStr = PrependControllerPrompts( BUTTON_Y, "#MENU_TITLE_MODS" ) + AddMenuFooterOption( GetMenu( "MainMenu" ), BUTTON_Y, controllerStr, "#MENU_TITLE_MODS", AdvanceToModListMenu ) } void function AdvanceToModListMenu( var button ) @@ -30,8 +31,20 @@ void function InitModMenu() AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnModMenuOpened ) AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnModMenuClosed ) AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) - AddMenuFooterOption( menu, BUTTON_Y, "#Y_BUTTON_RELOAD_MODS", "#RELOAD_MODS", OnReloadModsButtonPressed ) - AddMenuFooterOption( menu, BUTTON_BACK, "#BACK_AUTHENTICATION_AGREEMENT", "#AUTHENTICATION_AGREEMENT", OnAuthenticationAgreementButtonPressed ) + AddMenuFooterOption( + menu, + BUTTON_X, + PrependControllerPrompts( BUTTON_X, "#RELOAD_MODS" ), + "#RELOAD_MODS", + OnReloadModsButtonPressed + ) + AddMenuFooterOption( + menu, + BUTTON_BACK, + PrependControllerPrompts( BUTTON_Y, "#AUTHENTICATION_AGREEMENT" ), + "#AUTHENTICATION_AGREEMENT", + OnAuthenticationAgreementButtonPressed + ) foreach ( var button in GetElementsByClassname( GetMenu( "ModListMenu" ), "ModButton" ) ) { 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 7aadce897..7c6c93fde 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -156,7 +156,7 @@ void function InitServerBrowserMenu() AddMenuEventHandler( file.menu, eUIEvent.MENU_CLOSE, OnCloseServerBrowserMenu ) AddMenuEventHandler( file.menu, eUIEvent.MENU_OPEN, OnServerBrowserMenuOpened ) AddMenuFooterOption( file.menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) - AddMenuFooterOption( file.menu, BUTTON_Y, "#Y_BUTTON_REFRESH_SERVERS", "#REFRESH_SERVERS", RefreshServers ) + AddMenuFooterOption( file.menu, BUTTON_Y, PrependControllerPrompts( BUTTON_Y, "#REFRESH_SERVERS" ), "#REFRESH_SERVERS", RefreshServers ) // Setup server buttons var width = 1120.0 * (GetScreenSize()[1] / 1080.0) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/ui_utility.gnut b/Northstar.Client/mod/scripts/vscripts/ui/ui_utility.gnut index 02d77795a..d6a7a29a9 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/ui_utility.gnut +++ b/Northstar.Client/mod/scripts/vscripts/ui/ui_utility.gnut @@ -631,4 +631,4 @@ void function Hud_SetNavUp( var buttonFrom, var buttonTo ) void function Hud_SetNavDown( var buttonFrom, var buttonTo ) { buttonFrom.SetNavDown( buttonTo ) -} \ No newline at end of file +} -- cgit v1.2.3