diff options
Diffstat (limited to 'bobthebob.testing/scripts')
4 files changed, 42 insertions, 431 deletions
diff --git a/bobthebob.testing/scripts/vscripts/lobby/sh_lobby.gnut b/bobthebob.testing/scripts/vscripts/lobby/sh_lobby.gnut deleted file mode 100644 index 24436017..00000000 --- a/bobthebob.testing/scripts/vscripts/lobby/sh_lobby.gnut +++ /dev/null @@ -1,356 +0,0 @@ -globalize_all_functions - -const string PRIVATE_MATCH_PLAYLIST = "private_match" - -struct { - array<string> modes = [ // default modes in vanilla - "aitdm", - "tdm", - "cp", - "at", - "ctf", - "lts", - "ps", - "speedball", - "mfd", - "ttdm", - "fd_easy", - "fd_normal", - "fd_hard", - "fd_master", - "fd_insane" - ] - - array<string> maps = [ // default maps in vanilla - "mp_forwardbase_kodai", - "mp_grave", - "mp_homestead", - "mp_thaw", - "mp_black_water_canal", - "mp_eden", - "mp_drydock", - "mp_crashsite3", - "mp_complex3", - "mp_angel_city", - "mp_colony02", - "mp_glitch", - "mp_relic02", - "mp_wargames", - "mp_rise", - "mp_lf_stacks", - "mp_lf_deck", - "mp_lf_meadow", - "mp_lf_traffic", - "mp_lf_township", - "mp_lf_uma" - ] -} file - -void function AddPrivateMatchMode( string mode ) -{ - if ( !file.modes.contains( mode ) ) - file.modes.append( mode ) - - #if CLIENT - // call this on ui too so the client and ui states are the same - RunUIScript( "AddPrivateMatchMode", mode ) - #endif -} - -void function AddPrivateMatchMap( string map ) -{ - if ( !file.maps.contains( map ) ) - file.maps.append( map ) - - #if CLIENT - // call this on ui too so the client and ui states are the same - RunUIScript( "AddPrivateMatchMap", map ) - #endif -} - -array<string> function GetPrivateMatchModes() -{ - //array<string> modesArray - // - //int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST ) - //for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ ) - //{ - // modesArray.append( GetPlaylistGamemodeByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex ) ) - //} - - //return modesArray - - return file.modes -} - -int function GetPrivateMatchModeIndex( string modeName ) -{ - //int indexForName = 0 - // - //int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST ) - //for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ ) - //{ - // if ( GetPlaylistGamemodeByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex ) != modeName ) - // continue - // - // indexForName = modeIndex; - // break - //} - // - //return indexForName - - return file.modes.find( modeName ) -} - - -array<string> function GetPrivateMatchMapsForMode( string modeName ) -{ - //array<string> mapsArray - // - //int modeIndex = GetPrivateMatchModeIndex( modeName ) - //int numMaps = GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, modeIndex ) - //for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ ) - //{ - // mapsArray.append( GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex, mapIndex ) ) - //} - // - //return mapsArray - - array<string> maps - - // use the private match playlist for this if the gamemode is in it already - int privatePlaylistModeIndex = GetPrivateMatchModeIndex( modeName ) - if ( privatePlaylistModeIndex < GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST ) ) - { - for ( int i = 0; i < GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, privatePlaylistModeIndex ); i++ ) - maps.append( GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, privatePlaylistModeIndex, i ) ) - } - else - { - int numMaps = GetPlaylistGamemodeByIndexMapsCount( modeName, 0 ) - for ( int i = 0; i < numMaps; i++ ) - maps.append( GetPlaylistGamemodeByIndexMapByIndex( modeName, 0, i ) ) - } - - return maps -} - -// never called -/*array<string> function GetPrivateMatchModesForMap( string mapName ) -{ - array<string> modesArray - - int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST ) - for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ ) - { - int numMaps = GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, modeIndex ) - for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ ) - { - if ( GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex, mapIndex ) != mapName ) - continue - - modesArray.append( GetPlaylistGamemodeByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex ) ) - } - } - - return modesArray -}*/ - - -string function GetPrivateMatchMapForIndex( int index ) -{ - array<string> mapsArray = GetPrivateMatchMaps() - - if ( index >= mapsArray.len() ) - return "" - - return mapsArray[index] -} - -string function GetPrivateMatchModeForIndex( int index ) -{ - array<string> modesArray = GetPrivateMatchModes() - - if ( index >= modesArray.len() ) - return "" - - return modesArray[index] -} - -int function GetPrivateMatchMapIndex( string mapName ) -{ - array<string> mapsArray = GetPrivateMatchMaps() - for ( int index = 0; index < mapsArray.len(); index++ ) - { - if ( mapsArray[index] == mapName ) - return index - } - - return 0 -} -/* -int function GetPrivateMatchModeIndex( string modeName ) -{ - array<string> modesArray = GetPrivateMatchModes() - for ( int index = 0; index < modesArray.len(); index++ ) - { - if ( modesArray[index] == modeName ) - return index - } - - return 0 -} -*/ - -array<string> function GetPrivateMatchMaps() -{ - //array<string> mapsArray - // - //int numModes = GetPlaylistGamemodesCount( PRIVATE_MATCH_PLAYLIST ) - //for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ ) - //{ - // int numMaps = GetPlaylistGamemodeByIndexMapsCount( PRIVATE_MATCH_PLAYLIST, modeIndex ) - // for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ ) - // { - // string mapName = GetPlaylistGamemodeByIndexMapByIndex( PRIVATE_MATCH_PLAYLIST, modeIndex, mapIndex ) - // if ( mapsArray.contains( mapName ) ) - // continue - // - // mapsArray.append( mapName ) - // } - //} - // - //return mapsArray - - return file.maps -} - - - -array<string> function GetPlaylistMaps( string playlistName ) -{ - array<string> mapsArray - - int numModes = GetPlaylistGamemodesCount( playlistName ) - for ( int modeIndex = 0; modeIndex < numModes; modeIndex++ ) - { - int numMaps = GetPlaylistGamemodeByIndexMapsCount( playlistName, modeIndex ) - for ( int mapIndex = 0; mapIndex < numMaps; mapIndex++ ) - { - string mapName = GetPlaylistGamemodeByIndexMapByIndex( playlistName, modeIndex, mapIndex ) - if ( mapsArray.contains( mapName ) ) - continue - - mapsArray.append( mapName ) - } - } - - return mapsArray -} - - -bool function MapSettings_SupportsTitans( string mapName ) -{ - if ( mapName.find( "mp_lf_") != null ) - return false - - if ( mapName.find( "coliseum" ) != null ) - return false; - - return true -} - -bool function MapSettings_SupportsAI( string mapName ) -{ - if ( mapName.find( "mp_lf_") != null ) - return false - - if ( mapName.find( "coliseum" ) != null ) - return false; - - return true -} - - -bool function ModeSettings_RequiresTitans( string modeName ) -{ - switch ( modeName ) - { - case "lts": - return true - } - - return false -} - -bool function ModeSettings_RequiresAI( string modeName ) -{ - switch ( modeName ) - { - case "aitdm": - case "at": - return true - } - - return false -} - -#if !CLIENT -string function PrivateMatch_GetSelectedMap() -{ - var mapIndex = level.ui.privatematch_map - string mapName = GetPrivateMatchMapForIndex( expect int(mapIndex) ) - - return mapName -} - - -string function PrivateMatch_GetSelectedMode() -{ - var modeIndex = level.ui.privatematch_mode - string modeName = GetPrivateMatchModeForIndex( expect int(modeIndex) ) - - return modeName -} -#endif - -bool function PrivateMatch_IsValidMapModeCombo( string mapName, string modeName ) -{ - array<string> mapsForMode = GetPrivateMatchMapsForMode( modeName ) - - return mapsForMode.contains( mapName ) -} - -// end private match stuff - -int function Player_GetMaxMatchmakingDelay( entity player ) -{ - // return GetCurrentPlaylistVarInt( "matchmaking_delay", 0 ) - return 300 -} - -int function Player_GetRemainingMatchmakingDelay( entity player ) -{ - int lastLeaveTime = player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME ) - - return Player_GetMaxMatchmakingDelay( player ) - (GetCurrentTimeForPersistence() - lastLeaveTime) -} - -int function Player_NextAvailableMatchmakingTime( entity player ) -{ - #if MP - int lastLeaveTime = player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME ) - if ( GetCurrentTimeForPersistence() - lastLeaveTime < Player_GetMaxMatchmakingDelay( player ) ) - { - return Player_GetRemainingMatchmakingDelay( player ) - } - #endif - - return 0 -} - -int function GetCurrentTimeForPersistence() -{ - // Returns the unix timestap offset to the timezone we want to use - return GetUnixTimestamp() + DAILY_RESET_TIME_ZONE_OFFSET * SECONDS_PER_HOUR -} diff --git a/bobthebob.testing/scripts/vscripts/sh_bobtestingfunctions_mp.gnut b/bobthebob.testing/scripts/vscripts/sh_bobtestingfunctions_mp.gnut index 124c7a54..70bc5165 100644 --- a/bobthebob.testing/scripts/vscripts/sh_bobtestingfunctions_mp.gnut +++ b/bobthebob.testing/scripts/vscripts/sh_bobtestingfunctions_mp.gnut @@ -125,4 +125,10 @@ void function TestObjectiveRUIFW() RuiDestroy( rui ) } + +void function RespawnWhy() +{ + for ( int i = 0; i < 500; i++ ) // this only works in lobby, luckily + GetLocalViewPlayer().ClientCommand( "test_clientsetplaylistvaroverride " + i + " whyyyyy" ) +} #endif
\ No newline at end of file diff --git a/bobthebob.testing/scripts/vscripts/ui/menu_map_select.nut b/bobthebob.testing/scripts/vscripts/ui/menu_map_select.nut index 7263a9fa..7ed0d177 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<var> 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<var> buttons = file.buttons - array<string> 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<var> buttons = GetElementsByClassname( GetMenu( "MapsMenu" ), "MapButtonClass" ) + array<string> 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<string> 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<string> 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<var> 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 b6bd6d38..23376781 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<string> 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 |