From 07b7eafd5c1845c70510b695446c23973fed1d4d Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Wed, 7 Jul 2021 22:25:59 +0100 Subject: add fra, featured modes and some private lobby v2 stuff --- .../scripts/vscripts/ui/menu_map_select.nut | 108 +++++++-------------- .../scripts/vscripts/ui/menu_mode_select.nut | 3 +- 2 files changed, 36 insertions(+), 75 deletions(-) (limited to 'bobthebob.testing/scripts/vscripts/ui') diff --git a/bobthebob.testing/scripts/vscripts/ui/menu_map_select.nut b/bobthebob.testing/scripts/vscripts/ui/menu_map_select.nut index 7263a9faf..7ed0d1773 100644 --- a/bobthebob.testing/scripts/vscripts/ui/menu_map_select.nut +++ b/bobthebob.testing/scripts/vscripts/ui/menu_map_select.nut @@ -5,16 +5,9 @@ global function MenuMapSelect_Init global function InitMapsMenu -const int MAPS_PER_PAGE = 21 - -const MAP_LIST_VISIBLE_ROWS = 21 -const MAP_LIST_SCROLL_SPEED = 0 - struct { - var menu = null - array buttons - int numMapButtonsOffScreen - int mapListScrollState = 0 + int mapsPerPage = 21 + int currentMapPage } file // note: this does have a scrolling system in vanilla, but it's honestly really weird and jank and i don't like it @@ -27,8 +20,7 @@ function MenuMapSelect_Init() void function InitMapsMenu() { - file.menu = GetMenu( "MapsMenu" ) - var menu = file.menu + var menu = GetMenu( "MapsMenu" ) AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnOpenMapsMenu ) AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnCloseMapsMenu ) @@ -36,13 +28,9 @@ void function InitMapsMenu() AddEventHandlerToButtonClass( menu, "MapButtonClass", UIE_GET_FOCUS, MapButton_Focused ) AddEventHandlerToButtonClass( menu, "MapButtonClass", UIE_LOSE_FOCUS, MapButton_LostFocus ) AddEventHandlerToButtonClass( menu, "MapButtonClass", UIE_CLICK, MapButton_Activate ) - //AddEventHandlerToButtonClass( menu, "MapListScrollUpClass", UIE_CLICK, OnMapListScrollUp_Activate ) - //AddEventHandlerToButtonClass( menu, "MapListScrollDownClass", UIE_CLICK, OnMapListScrollDown_Activate ) AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT" ) AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) - - file.buttons = GetElementsByClassname( menu, "MapButtonClass" ) AddMenuFooterOption( menu, BUTTON_SHOULDER_LEFT, "#PRIVATE_MATCH_PAGE_PREV", "#PRIVATE_MATCH_PAGE_PREV", CycleModesBack, IsNorthstarServer ) AddMenuFooterOption( menu, BUTTON_SHOULDER_RIGHT, "#PRIVATE_MATCH_PAGE_NEXT", "#PRIVATE_MATCH_PAGE_NEXT", CycleModesForward, IsNorthstarServer ) @@ -50,19 +38,27 @@ void function InitMapsMenu() void function OnOpenMapsMenu() { - array buttons = file.buttons - array mapsArray = GetPrivateMatchMaps() + if ( IsNorthstarServer() ) + file.mapsPerPage = 15 + else + file.mapsPerPage = 21 + + UpdateVisibleMaps() +} - file.numMapButtonsOffScreen = int( max( mapsArray.len() - MAP_LIST_VISIBLE_ROWS, 0 ) ) -// Assert( file.numMapButtonsOffScreen >= 0 ) +void function UpdateVisibleMaps() +{ + array buttons = GetElementsByClassname( GetMenu( "MapsMenu" ), "MapButtonClass" ) + array mapsArray = GetPrivateMatchMaps() foreach ( button in buttons ) { int buttonID = int( Hud_GetScriptID( button ) ) + int mapID = buttonID + ( file.currentMapPage * file.mapsPerPage ) - if ( buttonID >= 0 && buttonID < mapsArray.len() ) + if ( buttonID < file.mapsPerPage && mapID < GetPrivateMatchMaps().len() ) { - string name = mapsArray[buttonID] + string name = mapsArray[ mapID ] SetButtonRuiText( button, GetMapDisplayName( name ) ) Hud_SetEnabled( button, true ) @@ -86,36 +82,30 @@ void function OnOpenMapsMenu() Hud_SetEnabled( button, false ) } - if ( buttonID == level.ui.privatematch_map ) + if ( mapID == level.ui.privatematch_map ) { printt( buttonID, mapsArray[buttonID] ) Hud_SetFocused( button ) } } - - //RegisterButtonPressedCallback( MOUSE_WHEEL_UP, OnMapListScrollUp_Activate ) - //RegisterButtonPressedCallback( MOUSE_WHEEL_DOWN, OnMapListScrollDown_Activate ) } void function OnCloseMapsMenu() { - //DeregisterButtonPressedCallback( MOUSE_WHEEL_UP, OnMapListScrollUp_Activate ) - //DeregisterButtonPressedCallback( MOUSE_WHEEL_DOWN, OnMapListScrollDown_Activate ) - Signal( uiGlobal.signalDummy, "OnCloseMapsMenu" ) } void function MapButton_Focused( var button ) { - int buttonID = int( Hud_GetScriptID( button ) ) + int mapID = int( Hud_GetScriptID( button ) ) + ( file.currentMapPage * file.mapsPerPage ) - var menu = file.menu + var menu = GetMenu( "MapsMenu" ) var nextMapImage = Hud_GetChild( menu, "NextMapImage" ) var nextMapName = Hud_GetChild( menu, "NextMapName" ) var nextMapDesc = Hud_GetChild( menu, "NextMapDesc" ) array mapsArray = GetPrivateMatchMaps() - string mapName = mapsArray[buttonID] + string mapName = mapsArray[ mapID ] asset mapImage = GetMapImageForMapName( mapName ) RuiSetImage( Hud_GetRui( nextMapImage ), "basicImage", mapImage ) @@ -128,36 +118,24 @@ void function MapButton_Focused( var button ) else Hud_SetText( nextMapDesc, GetMapDisplayDesc( mapName ) ) - // Update window scrolling if we highlight a map not in view - int minScrollState = int( clamp( buttonID - (MAP_LIST_VISIBLE_ROWS - 1), 0, file.numMapButtonsOffScreen ) ) - int maxScrollState = int( clamp( buttonID, 0, file.numMapButtonsOffScreen ) ) - - if ( file.mapListScrollState < minScrollState ) - file.mapListScrollState = minScrollState - if ( file.mapListScrollState > maxScrollState ) - file.mapListScrollState = maxScrollState - - UpdateMapListScroll() } void function MapButton_LostFocus( var button ) { - HandleLockedCustomMenuItem( file.menu, button, [], true ) + HandleLockedCustomMenuItem( GetMenu( "MapsMenu" ), button, [], true ) } void function MapButton_Activate( var button ) { if ( Hud_IsLocked( button ) ) - { return - } if ( !AmIPartyLeader() && GetPartySize() > 1 ) return array mapsArray = GetPrivateMatchMaps() int mapID = int( Hud_GetScriptID( button ) ) - string mapName = mapsArray[mapID] + string mapName = mapsArray[ mapID + ( file.currentMapPage * file.mapsPerPage ) ] printt( mapName, mapID ) @@ -165,36 +143,20 @@ void function MapButton_Activate( var button ) CloseActiveMenu() } - -void function OnMapListScrollUp_Activate( var button ) -{ - file.mapListScrollState-- - if ( file.mapListScrollState < 0 ) - file.mapListScrollState = 0 - - UpdateMapListScroll() -} - -void function OnMapListScrollDown_Activate( var button ) +void function CycleModesBack( var button ) { - file.mapListScrollState++ - if ( file.mapListScrollState > file.numMapButtonsOffScreen ) - file.mapListScrollState = file.numMapButtonsOffScreen - - UpdateMapListScroll() + if ( file.currentMapPage == 0 ) + return + + file.currentMapPage-- + UpdateVisibleMaps() } -function UpdateMapListScroll() +void function CycleModesForward( var button ) { - array buttons = file.buttons - local basePos = buttons[0].GetBasePos() - local offset = buttons[0].GetHeight() * file.mapListScrollState - - buttons[0].SetPos( basePos[0], basePos[1] - offset ) + if ( ( file.currentMapPage + 1 ) * file.mapsPerPage >= GetPrivateMatchMaps().len() ) + return + + file.currentMapPage++ + UpdateVisibleMaps() } - -void function CycleModesBack( var button ) -{} - -void function CycleModesForward( var button ) -{} diff --git a/bobthebob.testing/scripts/vscripts/ui/menu_mode_select.nut b/bobthebob.testing/scripts/vscripts/ui/menu_mode_select.nut index b6bd6d386..233767816 100644 --- a/bobthebob.testing/scripts/vscripts/ui/menu_mode_select.nut +++ b/bobthebob.testing/scripts/vscripts/ui/menu_mode_select.nut @@ -2,7 +2,6 @@ global function InitModesMenu struct { int currentModePage - } file const int MODES_PER_PAGE = 15 @@ -105,7 +104,7 @@ void function ModeButton_Click( var button ) int modeID = int( Hud_GetScriptID( button ) ) + ( file.currentModePage * MODES_PER_PAGE ) array modesArray = GetPrivateMatchModes() - string modeName = modesArray[mapID] + string modeName = modesArray[ modeID ] // on modded servers set us to the first map for that mode automatically // need this for coliseum mainly which is literally impossible to select without this -- cgit v1.2.3