diff options
Diffstat (limited to 'Northstar.Client')
6 files changed, 1046 insertions, 96 deletions
diff --git a/Northstar.Client/mod.json b/Northstar.Client/mod.json index ec6a2f77..1a2b5c01 100644 --- a/Northstar.Client/mod.json +++ b/Northstar.Client/mod.json @@ -27,6 +27,10 @@ { "Name": "filter_mods", "DefaultValue": "0" + }, + { + "Name": "filter_map_hide_locked", + "DefaultValue": "0" } ], "Scripts": [ diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt index ae84e7c4..e23e3ab2 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt @@ -300,5 +300,8 @@ Press Yes if you agree to this. This choice can be changed in the mods menu at a "SHOW_ALL" "All" "SHOW_ONLY_ENABLED" "Only Enabled" "SHOW_ONLY_DISABLED" "Only Disabled" + + // Maps menu + "HIDE_LOCKED" "Hide locked" } } diff --git a/Northstar.Client/mod/resource/ui/menus/map_select.menu b/Northstar.Client/mod/resource/ui/menus/map_select.menu new file mode 100644 index 00000000..01c69fd8 --- /dev/null +++ b/Northstar.Client/mod/resource/ui/menus/map_select.menu @@ -0,0 +1,402 @@ +resource/ui/menus/map_select.menu +{ + menu + { + ControlName Frame + xpos 0 + ypos 0 + zpos 3 + wide f0 + tall f0 + autoResize 0 + visible 1 + enabled 1 + pinCorner 0 + PaintBackgroundType 0 + infocus_bgcolor_override "0 0 0 0" + outoffocus_bgcolor_override "0 0 0 0" + + Vignette + { + ControlName ImagePanel + InheritProperties MenuVignette + } + + MenuTitle + { + ControlName Label + InheritProperties MenuTitle + labelText "#SELECT_MAP" + } + + ButtonRowAnchor + { + ControlName Label + labelText "" + + xpos 96 + ypos 160 + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + MapsGridPanel + { + ControlName CNestedPanel + zpos 200 + wide 803 + tall 728 + visible 1 + controlSettingsFile "resource/ui/menus/panels/map_grid.res" + + pin_to_sibling ButtonRowAnchor + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_LEFT + } + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + FilterPanel + { + ControlName RuiPanel + wide 904 + tall 114 + xpos 96 + ypos 828 + + rui "ui/control_options_description.rpak" + + visible 1 + } + + BtnSearchLabel + { + ControlName RuiButton + InheritProperties RuiSmallButton + labelText "#SEARCHBAR_LABEL" + textAlignment west + classname FilterPanelChild + + wide 500 + xpos -17 + ypos -17 + + wrap 1 + visible 1 + zpos 998 + + pin_to_sibling FilterPanel + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_LEFT + } + + BtnMapsSearch + { + ControlName TextEntry + classname FilterPanelChild + zpos 999 + xpos -400 + ypos -5 + wide 390 + tall 30 + textHidden 0 + editable 1 + font Default_21 + allowRightClickMenu 0 + allowSpecialCharacters 0 + unicode 0 + + pin_to_sibling BtnSearchLabel + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + + + SwtBtnHideLocked + { + ControlName RuiButton + InheritProperties SwitchButton + labelText "#HIDE_LOCKED" + ConVar "filter_map_hide_locked" + classname FilterPanelChild + wide 500 + zpos 998 + + list + { + "#NO" 0 + "#YES" 1 + } + + pin_to_sibling BtnSearchLabel + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + + BtnFiltersClear + { + ControlName RuiButton + InheritProperties RuiSmallButton + labelText "#CLEAR_FILTERS" + wide 100 + xpos -17 + ypos -57 + zpos 90 + + scriptID 1999 + + pin_to_sibling FilterPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner BOTTOM_RIGHT + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + MapDetailsPanel + { + ControlName RuiPanel + xpos 1002 + ypos 160 + tall 782 + wide 810 + rui "ui/control_options_description.rpak" + wrap 1 + visible 1 + zpos -1 + } + + NextMapImage + { + ControlName RuiPanel + wide 500 + tall 288 + visible 1 + scaleImage 1 + zpos 0 + + // Hud_GetRui() requires this to work + rui "ui/basic_menu_image.rpak" + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_LEFT + } + + NextMapName + { + ControlName Label + pin_to_sibling NextMapImage + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_LEFT + + labelText "testname" + + xpos -12 + ypos -10 + zpos 1 + + auto_wide_tocontents 1 + auto_tall_tocontents 1 + font Default_43_DropShadow + allcaps 1 + fgcolor_override "255 255 255 255" + } + + NextMapCreator + { + ControlName Label + pin_to_sibling NextMapImage + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + + labelText "Creator: your mom" + + xpos 12 + ypos -12 + zpos 1 + + auto_wide_tocontents 1 + auto_tall_tocontents 1 + font Default_28_DropShadow + fgcolor_override "255 255 255 255" + + visible 0 + } + + NextMapVersion + { + ControlName Label + pin_to_sibling NextMapCreator + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + + labelText "Version: 0.0.0" + + xpos 0 + ypos 0 + zpos 1 + + auto_wide_tocontents 1 + auto_tall_tocontents 1 + font Default_28_DropShadow + fgcolor_override "255 255 255 255" + + visible 0 + } + + NextMapDescription + { + ControlName Label + textAlignment north + tall 500 + wide 460 + ypos -300 + xpos -20 + + labelText "testdescription" + + wrap 1 + visible 1 + zpos -1 + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_LEFT + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + BtnMapGridUpArrowPanel + { + ControlName RuiPanel + wide 40 + tall 40 + xpos 2 + + rui "ui/control_options_description.rpak" + + visible 1 + zpos -1 + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + + BtnMapGridUpArrow + { + ControlName RuiButton + InheritProperties RuiSmallButton + //labelText "A" + wide 40 + tall 40 + xpos 2 + zpos 999 + + image "vgui/hud/white" + drawColor "255 255 255 128" + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + + BtnMapGridDownArrow + { + ControlName RuiButton + InheritProperties RuiSmallButton + //labelText "V" + wide 40 + tall 40 + xpos 2 + ypos -626 + zpos 999 + + image "vgui/hud/white" + drawColor "255 255 255 128" + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + + BtnMapGridDownArrowPanel + { + ControlName RuiPanel + wide 40 + tall 40 + xpos 2 + ypos -626 + + rui "ui/control_options_description.rpak" + + visible 1 + zpos -1 + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + + BtnMapGridSlider + { + ControlName RuiButton + InheritProperties RuiSmallButton + //labelText "V" + wide 40 + tall 582 + xpos 2 + ypos -42 + zpos 0 + + image "vgui/hud/white" + drawColor "255 255 255 128" + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + + BtnMapGridSliderPanel + { + ControlName RuiPanel + wide 40 + tall 582 + xpos 2 + ypos -42 + + rui "ui/control_options_description.rpak" + + visible 1 + zpos -1 + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + + MouseMovementCapture + { + ControlName CMouseMovementCapturePanel + wide 40 + tall 582 + xpos 2 + ypos -42 + zpos 1 + + pin_to_sibling MapDetailsPanel + pin_corner_to_sibling TOP_RIGHT + pin_to_sibling_corner TOP_LEFT + } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + FooterButtons + { + ControlName CNestedPanel + InheritProperties FooterButtons + } + } +} diff --git a/Northstar.Client/mod/resource/ui/menus/panels/map_grid.res b/Northstar.Client/mod/resource/ui/menus/panels/map_grid.res new file mode 100644 index 00000000..3853faa1 --- /dev/null +++ b/Northstar.Client/mod/resource/ui/menus/panels/map_grid.res @@ -0,0 +1,201 @@ +"resource/ui/menus/panels/map_grid.res" +{ + GridButton0x0 + { + ControlName CNestedPanel + wide 286 + tall 165 + + Classname MapGridButtons + scriptID 0 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + } + + GridButton1x0 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 1 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x0 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton2x0 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 2 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton1x0 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton0x1 + { + ControlName CNestedPanel + wide 286 + tall 165 + ypos 2 + + Classname MapGridButtons + scriptID 3 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x0 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + + GridButton1x1 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 4 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x1 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton2x1 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 5 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton1x1 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton0x2 + { + ControlName CNestedPanel + wide 286 + tall 165 + ypos 2 + + Classname MapGridButtons + scriptID 6 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x1 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + + GridButton1x2 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 7 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x2 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton2x2 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 8 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton1x2 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton0x3 + { + ControlName CNestedPanel + wide 286 + tall 165 + ypos 2 + + Classname MapGridButtons + scriptID 9 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x2 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner BOTTOM_LEFT + } + + GridButton1x3 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 10 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton0x3 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } + + GridButton2x3 + { + ControlName CNestedPanel + wide 286 + tall 165 + xpos 2 + + Classname MapGridButtons + scriptID 11 + + controlSettingsFile "resource/ui/menus/panels/map_grid_button.res" + + pin_to_sibling GridButton1x3 + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_RIGHT + } +}
\ No newline at end of file diff --git a/Northstar.Client/mod/resource/ui/menus/panels/map_grid_button.res b/Northstar.Client/mod/resource/ui/menus/panels/map_grid_button.res new file mode 100644 index 00000000..3a8a915a --- /dev/null +++ b/Northstar.Client/mod/resource/ui/menus/panels/map_grid_button.res @@ -0,0 +1,90 @@ +"resource/ui/menus/panels/map_grid_button.res" +{ + MapImage + { + ControlName RuiPanel + wide 286 + tall 165 + visible 1 + scaleImage 1 + zpos 0 + + // Hud_GetRui() requires this to work + rui "ui/basic_menu_image.rpak" + } + + MapName + { + ControlName Label + zpos 2 + wide 286 + xpos 4 + ypos -4 + + labelText "forwardbase kodaiiiiii" + use_proportional_insets 1 + textinsetx 2 + font Default_21_DropShadow + allcaps 1 + fgcolor_override "255 255 255 255" + + pin_to_sibling MapImage + pin_corner_to_sibling BOTTOM_RIGHT + pin_to_sibling_corner BOTTOM_RIGHT + } + + MapNameBackground + { + ControlName RuiPanel + wide 286 + tall 34 + + rui "ui/knowledgebase_panel.rpak" + + visible 1 + zpos 1 + + pin_to_sibling MapImage + pin_corner_to_sibling BOTTOM_RIGHT + pin_to_sibling_corner BOTTOM_RIGHT + } + + MapButton + { + ControlName RuiButton + InheritProperties RuiSmallButton + wide 286 + tall 165 + } + + MapNameLockedForeground + { + ControlName RuiPanel + wide 286 + tall 165 + + rui "ui/knowledgebase_panel.rpak" + + visible 0 + zpos 5 + + //bgcolor_override "255 255 255 255" + //fgcolor_override "255 255 255 255" + + pin_to_sibling MapImage + pin_corner_to_sibling TOP_LEFT + pin_to_sibling_corner TOP_LEFT + } + + MapLockedImage + { + ControlName ImagePanel + xpos 71 + ypos 0 // 18 to center vertically, looks weird tho + wide 108 + tall 108 + visible 0 + scaleImage 1 + image "ui/menu/common/locked_icon" + } +}
\ No newline at end of file diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_map_select.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_map_select.nut index 29daf0a8..edaf582e 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_map_select.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_map_select.nut @@ -5,163 +5,413 @@ global function MenuMapSelect_Init global function InitMapsMenu + +const int BUTTONS_PER_PAGE = 4 + + +struct { + int deltaX = 0 + int deltaY = 0 +} mouseDeltaBuffer + struct { int mapsPerPage = 21 int currentMapPage + + array< var > gridButtons + array< string > mapsArrayFiltered + + int scrollOffset = 0 + + var menu } file -// note: this does have a scrolling system in vanilla, but it's honestly really weird and jank and i don't like it -// so for parity with menu_mode_select i'm removing it in favour of a page system -function MenuMapSelect_Init() + + + +void function MenuMapSelect_Init() { RegisterSignal( "OnCloseMapsMenu" ) } void function InitMapsMenu() { - var menu = GetMenu( "MapsMenu" ) + file.menu = GetMenu( "MapsMenu" ) + + AddMouseMovementCaptureHandler( file.menu, UpdateMouseDeltaBuffer ) + + + AddMenuEventHandler( file.menu, eUIEvent.MENU_CLOSE, OnCloseMapsMenu ) + AddMenuEventHandler( file.menu, eUIEvent.MENU_OPEN, OnOpenMapsMenu ) + + + + AddMenuFooterOption( file.menu, BUTTON_A, "#A_BUTTON_SELECT" ) + AddMenuFooterOption( file.menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) + + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnMapGridUpArrow"), UIE_CLICK, OnUpArrowSelected ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnMapGridDownArrow"), UIE_CLICK, OnDownArrowSelected ) + + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnFiltersClear"), UIE_CLICK, OnBtnFiltersClear_Activate ) + + AddButtonEventHandler( Hud_GetChild( file.menu, "SwtBtnHideLocked"), UIE_CHANGE, OnFiltersChanged ) + AddButtonEventHandler( Hud_GetChild( file.menu, "BtnMapsSearch"), UIE_CHANGE, OnFiltersChanged ) + + RuiSetString( Hud_GetRui( Hud_GetChild( file.menu, "SwtBtnhideLocked")), "buttonText", "") + + file.gridButtons = GetElementsByClassname( file.menu, "MapGridButtons" ) + + // uhh + foreach ( var mapButton in file.gridButtons ) + { + var button = Hud_GetChild( mapButton, "MapButton" ) + AddButtonEventHandler( button, UIE_CLICK, MapButton_Activate ) + AddButtonEventHandler( button, UIE_GET_FOCUS, MapButton_Focus ) + } + + + FilterMapsArray() +} - AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnOpenMapsMenu ) - AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnCloseMapsMenu ) - AddEventHandlerToButtonClass( menu, "MapButtonClass", UIE_GET_FOCUS, MapButton_Focused ) - AddEventHandlerToButtonClass( menu, "MapButtonClass", UIE_LOSE_FOCUS, MapButton_LostFocus ) - AddEventHandlerToButtonClass( menu, "MapButtonClass", UIE_CLICK, MapButton_Activate ) +// https://youtu.be/VHi2wKBKBc4 - AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT" ) - AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" ) +void function OnCloseMapsMenu() +{ + Signal( uiGlobal.signalDummy, "OnCloseMapsMenu" ) - 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 ) + try + { + DeregisterButtonPressedCallback(MOUSE_WHEEL_UP , OnScrollUp) + DeregisterButtonPressedCallback(MOUSE_WHEEL_DOWN , OnScrollDown) + //DeregisterButtonPressedCallback(KEY_TAB , OnKeyTabPressed) + } + catch ( ex ) {} } void function OnOpenMapsMenu() { - if ( IsNorthstarServer() ) - file.mapsPerPage = 15 - else - file.mapsPerPage = 21 + RefreshList() + + RegisterButtonPressedCallback(MOUSE_WHEEL_UP , OnScrollUp) + RegisterButtonPressedCallback(MOUSE_WHEEL_DOWN , OnScrollDown) + //RegisterButtonPressedCallback(KEY_TAB , OnKeyTabPressed) +} - UpdateVisibleMaps() +void function RefreshList() +{ + file.scrollOffset = 0 + FilterMapsArray() + UpdateMapsGrid() + if ( file.mapsArrayFiltered.len() != 0 ) + UpdateMapsInfo( file.mapsArrayFiltered[0] ) + UpdateListSliderHeight() + UpdateListSliderPosition() + UpdateNextMapInfo() } -void function UpdateVisibleMaps() +void function OnFiltersChanged( var button ) { - array<var> buttons = GetElementsByClassname( GetMenu( "MapsMenu" ), "MapButtonClass" ) - array<string> mapsArray = GetPrivateMatchMaps() + FilterMapsArray() + RefreshList() +} + +void function MapButton_Activate( var button ) +{ + if ( !AmIPartyLeader() && GetPartySize() > 1 ) + return + + int mapID = int( Hud_GetScriptID( Hud_GetParent( button ) ) ) + string mapName = file.mapsArrayFiltered[ mapID + file.scrollOffset * 3 ] + + if ( IsLocked( mapName ) ) + return + + printt( mapName, mapID ) - foreach ( button in buttons ) + UpdateMapsInfo( mapName ) + ClientCommand( "SetCustomMap " + mapName ) + CloseActiveMenu() +} + +void function MapButton_Focus( var button ) +{ + int mapID = int( Hud_GetScriptID( Hud_GetParent( button ) ) ) + string mapName = file.mapsArrayFiltered[ mapID + file.scrollOffset * 3 ] + + UpdateMapsInfo( mapName ) +} + +void function OnBtnFiltersClear_Activate( var button ) +{ + Hud_SetText( Hud_GetChild( file.menu, "BtnMapsSearch" ), "" ) + + SetConVarInt( "filter_map_hide_locked", 0 ) + + RefreshList() +} + +void function UpdateMapsInfo( string map ) +{ + RuiSetImage( Hud_GetRui( Hud_GetChild( file.menu, "NextMapImage" ) ), "basicImage", GetMapImageForMapName( map ) ) + Hud_SetText( Hud_GetChild( file.menu, "NextMapDescription" ), GetMapDisplayDesc( map ) ) + Hud_SetText( Hud_GetChild( file.menu, "NextMapName" ), GetMapDisplayName( map ) ) +} + +void function UpdateNextMapInfo() +{ + array< string > mapsArray = file.mapsArrayFiltered + + if( !mapsArray.len() ) + return + + var nextMapName = Hud_GetChild( file.menu, "NextMapName" ) + Hud_SetText( nextMapName, GetMapDisplayName( mapsArray[ 0 ] ) ) +} + +void function UpdateMapsGrid() +{ + HideAllMapButtons() + + array< string > mapsArray = file.mapsArrayFiltered + + + int trueOffset = file.scrollOffset * 3 + + foreach ( int _index, var element in file.gridButtons ) { - int buttonID = int( Hud_GetScriptID( button ) ) - int mapID = buttonID + ( file.currentMapPage * file.mapsPerPage ) + if ( ( _index + trueOffset ) >= mapsArray.len() ) return + + var mapImage = Hud_GetChild( element, "MapImage" ) + var mapName = Hud_GetChild( element, "MapName" ) + + string name = mapsArray[ _index + trueOffset ] + + RuiSetImage( Hud_GetRui( mapImage ), "basicImage", GetMapImageForMapName( name ) ) + Hud_SetText( mapName, GetMapDisplayName( name ) ) + + if ( IsLocked( name ) ) + LockMapButton( element ) + + MakeMapButtonVisible( element ) + } +} - if ( buttonID < file.mapsPerPage && mapID < GetPrivateMatchMaps().len() ) - { - string name = mapsArray[ mapID ] - - bool sp = name.find( "sp_" ) == 0 - if ( sp ) - SetButtonRuiText( button, Localize( "#PRIVATE_MATCH_SINGLEPLAYER_LEVEL", Localize( GetMapDisplayName( name ) ) ) ) - else - SetButtonRuiText( button, GetMapDisplayName( name ) ) - Hud_SetEnabled( button, true ) - - if ( IsItemInEntitlementUnlock( name ) && IsValid( GetUIPlayer() ) ) - { - if ( IsItemLocked( GetUIPlayer(), name ) && GetCurrentPlaylistVarInt( name + "_available" , 0 ) == 0 ) - { - SetButtonRuiText( button, Localize( "#MAP_LOCKED", Localize( GetMapDisplayName( name ) ) ) ) - } - } - - bool mapSupportsMode = PrivateMatch_IsValidMapModeCombo( name, PrivateMatch_GetSelectedMode() ) - Hud_SetLocked( button, !mapSupportsMode ) - - if ( !mapSupportsMode && !sp ) - SetButtonRuiText( button, Localize( "#PRIVATE_MATCH_UNAVAILABLE", Localize( GetMapDisplayName( name ) ) ) ) - } - else +void function FilterMapsArray() +{ + file.mapsArrayFiltered.clear() + + string searchTerm = Hud_GetUTF8Text( Hud_GetChild( file.menu, "BtnMapsSearch" ) ) + + bool useSearch = searchTerm != "" + + bool hideLocked = bool( GetConVarInt( "filter_map_hide_locked" ) ) + + foreach ( string map in GetPrivateMatchMaps() ) + { + bool containsTerm = Localize( GetMapDisplayName( map ) ).tolower().find( searchTerm.tolower() ) == null ? false : true + + if ( hideLocked && !IsLocked( map ) && ( useSearch == true ? containsTerm : true ) ) { - SetButtonRuiText( button, "" ) - Hud_SetEnabled( button, false ) + file.mapsArrayFiltered.append( map ) } - - if ( mapID == level.ui.privatematch_map ) + else if ( !hideLocked && ( useSearch == true ? containsTerm : true ) ) { - printt( buttonID, mapsArray[buttonID] ) - Hud_SetFocused( button ) + file.mapsArrayFiltered.append( map ) } } } -void function OnCloseMapsMenu() +void function HideAllMapButtons() { - Signal( uiGlobal.signalDummy, "OnCloseMapsMenu" ) + foreach ( var element in file.gridButtons ) + { + Hud_SetVisible( element, false ) + + var mapButton = Hud_GetChild( element, "MapButton" ) + var mapFG = Hud_GetChild( element, "MapNameLockedForeground" ) + + Hud_SetLocked( mapButton, false ) + Hud_SetVisible( mapFG, false ) + } } -void function MapButton_Focused( var button ) +// :trol: +void function MakeMapButtonVisible( var element ) { - int mapID = int( Hud_GetScriptID( button ) ) + ( file.currentMapPage * file.mapsPerPage ) + Hud_SetVisible( element, true ) +} - var menu = GetMenu( "MapsMenu" ) - var nextMapImage = Hud_GetChild( menu, "NextMapImage" ) - var nextMapName = Hud_GetChild( menu, "NextMapName" ) - var nextMapDesc = Hud_GetChild( menu, "NextMapDesc" ) +void function LockMapButton( var element ) +{ + var mapButton = Hud_GetChild( element, "MapButton" ) + var mapFG = Hud_GetChild( element, "MapNameLockedForeground" ) + + Hud_SetVisible( mapButton, true ) + Hud_SetVisible( mapFG, true ) +} - array<string> mapsArray = GetPrivateMatchMaps() - string mapName = mapsArray[ mapID ] +bool function IsLocked( string map ) +{ + + bool sp = map.find( "sp_" ) == 0 + if ( sp ) + return true - asset mapImage = GetMapImageForMapName( mapName ) - RuiSetImage( Hud_GetRui( nextMapImage ), "basicImage", mapImage ) - Hud_SetText( nextMapName, GetMapDisplayName( mapName ) ) + if ( IsItemInEntitlementUnlock( map ) && IsValid( GetUIPlayer() ) ) + { + if ( IsItemLocked( GetUIPlayer(), map ) && GetCurrentPlaylistVarInt( map + "_available" , 0 ) == 0 ) + { + return true + } + } + + return false +} - string modeName = PrivateMatch_GetSelectedMode() - bool mapSupportsMode = PrivateMatch_IsValidMapModeCombo( mapName, modeName ) - if ( !mapSupportsMode ) - Hud_SetText( nextMapDesc, Localize( "#PRIVATE_MATCH_MAP_NO_MODE_SUPPORT", Localize( GetMapDisplayName( mapName ) ), Localize( GetGameModeDisplayName( modeName ) ) ) ) - else - Hud_SetText( nextMapDesc, GetMapDisplayDesc( mapName ) ) +////////////////////////////// +// Slider +////////////////////////////// +void function UpdateMouseDeltaBuffer(int x, int y) +{ + mouseDeltaBuffer.deltaX += x + mouseDeltaBuffer.deltaY += y + SliderBarUpdate() } -void function MapButton_LostFocus( var button ) +void function FlushMouseDeltaBuffer() { - HandleLockedCustomMenuItem( GetMenu( "MapsMenu" ), button, [], true ) + mouseDeltaBuffer.deltaX = 0 + mouseDeltaBuffer.deltaY = 0 } -void function MapButton_Activate( var button ) + +void function SliderBarUpdate() { - if ( Hud_IsLocked( button ) ) + if ( file.mapsArrayFiltered.len() <= BUTTONS_PER_PAGE || file.mapsArrayFiltered.len() <= 12 ) + { + FlushMouseDeltaBuffer() return + } - if ( !AmIPartyLeader() && GetPartySize() > 1 ) - return + var sliderButton = Hud_GetChild( file.menu , "BtnMapGridSlider" ) + var sliderPanel = Hud_GetChild( file.menu , "BtnMapGridSliderPanel" ) + var movementCapture = Hud_GetChild( file.menu , "MouseMovementCapture" ) - array<string> mapsArray = GetPrivateMatchMaps() - int mapID = int( Hud_GetScriptID( button ) ) - string mapName = mapsArray[ mapID + ( file.currentMapPage * file.mapsPerPage ) ] + Hud_SetFocused(sliderButton) - printt( mapName, mapID ) + float minYPos = -42.0 * (GetScreenSize()[1] / 1080.0) + float maxHeight = 582.0 * (GetScreenSize()[1] / 1080.0) + float maxYPos = minYPos - (maxHeight - Hud_GetHeight( sliderPanel )) + float useableSpace = ( maxHeight - Hud_GetHeight( sliderPanel )) - ClientCommand( "SetCustomMap " + mapName ) - CloseActiveMenu() + float jump = minYPos - ( useableSpace / ( file.mapsArrayFiltered.len() / 3 + 1 )) + + // got local from official respaw scripts, without untyped throws an error + local pos = Hud_GetPos(sliderButton)[1] + local newPos = pos - mouseDeltaBuffer.deltaY + FlushMouseDeltaBuffer() + + if ( newPos < maxYPos ) newPos = maxYPos + if ( newPos > minYPos ) newPos = minYPos + + Hud_SetPos( sliderButton , 2, newPos ) + Hud_SetPos( sliderPanel , 2, newPos ) + Hud_SetPos( movementCapture , 2, newPos ) + + file.scrollOffset = -int( ( (newPos - minYPos) / useableSpace ) * ( file.mapsArrayFiltered.len() / 3 + 1 - BUTTONS_PER_PAGE) ) + UpdateMapsGrid() } -void function CycleModesBack( var button ) +void function UpdateListSliderHeight() { - if ( file.currentMapPage == 0 ) - return + var sliderButton = Hud_GetChild( file.menu , "BtnMapGridSlider" ) + var sliderPanel = Hud_GetChild( file.menu , "BtnMapGridSliderPanel" ) + var movementCapture = Hud_GetChild( file.menu , "MouseMovementCapture" ) - file.currentMapPage-- - UpdateVisibleMaps() + float maps = float ( file.mapsArrayFiltered.len() / 3 ) + + float maxHeight = 582.0 * (GetScreenSize()[1] / 1080.0) + float minHeight = 80.0 * (GetScreenSize()[1] / 1080.0) + + float height = maxHeight * ( float( BUTTONS_PER_PAGE ) / maps ) + + if ( height > maxHeight ) height = maxHeight + if ( height < minHeight ) height = minHeight + + Hud_SetHeight( sliderButton , height ) + Hud_SetHeight( sliderPanel , height ) + Hud_SetHeight( movementCapture , height ) } -void function CycleModesForward( var button ) + +void function UpdateListSliderPosition() { - if ( ( file.currentMapPage + 1 ) * file.mapsPerPage >= GetPrivateMatchMaps().len() ) + if ( file.mapsArrayFiltered.len() == 12 ) return - file.currentMapPage++ - UpdateVisibleMaps() + var sliderButton = Hud_GetChild( file.menu , "BtnMapGridSlider" ) + var sliderPanel = Hud_GetChild( file.menu , "BtnMapGridSliderPanel" ) + var movementCapture = Hud_GetChild( file.menu , "MouseMovementCapture" ) + + float maps = float ( file.mapsArrayFiltered.len() / 3 + 1 ) + + float minYPos = -42.0 * (GetScreenSize()[1] / 1080.0) + float useableSpace = (582.0 * (GetScreenSize()[1] / 1080.0) - Hud_GetHeight( sliderPanel )) + + float jump = minYPos - ( useableSpace / ( maps - float( BUTTONS_PER_PAGE ) ) * file.scrollOffset ) + + //jump = jump * (GetScreenSize()[1] / 1080.0) + + if ( jump > minYPos ) jump = minYPos + + Hud_SetPos( sliderButton , 2, jump ) + Hud_SetPos( sliderPanel , 2, jump ) + Hud_SetPos( movementCapture , 2, jump ) +} + +void function OnDownArrowSelected( var button ) +{ + if ( file.mapsArrayFiltered.len() <= BUTTONS_PER_PAGE || file.mapsArrayFiltered.len() <= 12 ) return + file.scrollOffset += 1 + if ((file.scrollOffset + BUTTONS_PER_PAGE) * 3 > file.mapsArrayFiltered.len()) { + file.scrollOffset = (file.mapsArrayFiltered.len() - BUTTONS_PER_PAGE * 3) / 3 + 1 + } + UpdateMapsGrid() + UpdateListSliderPosition() + printt(file.scrollOffset) } + + +void function OnUpArrowSelected( var button ) +{ + file.scrollOffset -= 1 + if (file.scrollOffset < 0) { + file.scrollOffset = 0 + } + UpdateMapsGrid() + UpdateListSliderPosition() +} + +void function OnScrollDown( var button ) +{ + if ( file.mapsArrayFiltered.len() <= BUTTONS_PER_PAGE || file.mapsArrayFiltered.len() <= 12 ) return + file.scrollOffset += 2 + if ((file.scrollOffset + BUTTONS_PER_PAGE) * 3 > file.mapsArrayFiltered.len()) { + file.scrollOffset = (file.mapsArrayFiltered.len() - BUTTONS_PER_PAGE * 3) / 3 + 1 + } + UpdateMapsGrid() + UpdateListSliderPosition() +} + +void function OnScrollUp( var button ) +{ + file.scrollOffset -= 2 + if (file.scrollOffset < 0) { + file.scrollOffset = 0 + } + UpdateMapsGrid() + UpdateListSliderPosition() +}
\ No newline at end of file |