Untitled

 avatar
unknown
plain_text
a year ago
15 kB
12
Indexable
-- rawfile,ui/uieditor/menus/ZM/Widgets/ZMMapSelection_Maps.lua
require( "ui.uieditor.widgets.Lobby.Lists.ZMMaps.ZMMapsList" )
require( "ui.uieditor.widgets.Lobby.Lists.ZMMaps.ZMMapPreview" )
require( "ui.uieditor.widgets.Lobby.Lists.ZMMaps.ZMMissionTile" )
require( "ui.uieditor.widgets.DLCFreeweekend" )
require( "ui.uieditor.widgets.verticalScrollbar" )

local PreLoadFunc = function ( self, controller )
	self.preLoadImageModel = Engine.CreateModel( Engine.GetModelForController( controller ), "ZMMapSelectionPreloadImage" )
end

local PostLoadFunc = function ( f2_arg0, f2_arg1 )
	f2_arg0.StreamedImagePreloader:subscribeToModel( f2_arg0.preLoadImageModel, function ( model )
		local modelValue = Engine.GetModelValue( model )
		if modelValue and CoD.GetMapValue( modelValue, "dlc_pack", 0 ) == 7 then
			f2_arg0.StreamedImagePreloader:setImage( RegisterImage( MapNameToMapLoadingImage( modelValue ) ) )
		end
	end, false )
	LUI.OverrideFunction_CallOriginalSecond( f2_arg0, "close", function ( element )
		Engine.UnsubscribeAndFreeModel( element.preLoadImageModel )
	end )
end


CoD.ZMMapSelection_Maps = InheritFrom( LUI.UIElement )

CoD.ZMMapSelection_Maps.new = function( menu, controller )
    local self = LUI.UIElement.new()
    self:setUseStencil( false )
    self:setClass( CoD.ZMMapSelection_Maps )
    self.id = "ZMMapSelection_Maps"
    self.soundSet = "default"
    self:setLeftRight( true, true, 0, 0 )
    self:setTopBottom( true, true, 0, 0 )
    self.anyChildUsesUpdateState = true

    --------------------------------------------------------------------
    -- MAP LIST
    --------------------------------------------------------------------

	local MapList = LUI.UIList.new( f5_local1, controller, 2, 0, nil, false, false, 0, 0, false, false )
	MapList:makeFocusable()
	MapList:setLeftRight( true, false, 64, 344 )
	MapList:setTopBottom( true, false, 134, 540 )
	MapList:setWidgetType( CoD.List1ButtonLarge_ZM )
	MapList:setVerticalCount( 12 )
	MapList:setVerticalCounter( CoD.verticalCounter )
	MapList:setVerticalScrollbar( CoD.verticalScrollbar )
	MapList:setDataSource( "ZMMapsList" )
	MapList:linkToElementModel( MapList, "disabled", true, function ( model )
		local f6_local0 = MapList
		local f6_local1 = {
			controller = controller,
			name = "model_validation",
			modelValue = Engine.GetModelValue( model ),
			modelName = "disabled"
		}
		CoD.Menu.UpdateButtonShownState( f6_local0, f5_local1, controller, Enum.LUIButton.LUI_KEY_XBA_PSCROSS )
	end )
	MapList:registerEventHandler( "list_item_gain_focus", function ( element, event )
		local f7_local0 = nil
		SetElementPropertyOnPerControllerTable( controller, "zmLobbyEEMapRef", element, "mapId" )
		UpdateElementDataSource( self, "ZMLobbyEEList" )
		SetControllerModelValue( controller, "ZMMapSelectionPreloadImage", element.mapId )
		return f7_local0
	end )
	MapList:registerEventHandler( "gain_focus", function ( element, event )
		local f8_local0 = nil
		if element.gainFocus then
			f8_local0 = element:gainFocus( event )
		elseif element.super.gainFocus then
			f8_local0 = element.super:gainFocus( event )
		end
		CoD.Menu.UpdateButtonShownState( element, f5_local1, controller, Enum.LUIButton.LUI_KEY_XBA_PSCROSS )
		CoD.Menu.UpdateButtonShownState( element, f5_local1, controller, Enum.LUIButton.LUI_KEY_XBX_PSSQUARE )
		return f8_local0
	end )
	MapList:registerEventHandler( "lose_focus", function ( element, event )
		local f9_local0 = nil
		if element.loseFocus then
			f9_local0 = element:loseFocus( event )
		elseif element.super.loseFocus then
			f9_local0 = element.super:loseFocus( event )
		end
		return f9_local0
	end )
	f5_local1:AddButtonCallbackFunction( MapList, controller, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "ENTER", function ( f10_arg0, f10_arg1, f10_arg2, f10_arg3 )
		if IsPerControllerTablePropertyValue( f10_arg2, "choosingZMPlaylist", true ) and IsElementPropertyValue( f10_arg0, "purchasable", true ) then
			OpenPurchaseMapPackConfirmation( f10_arg2, f10_arg0, "ZMMapSelect", f10_arg1 )
			return true
		elseif IsPerControllerTablePropertyValue( f10_arg2, "choosingZMPlaylist", true ) and not IsDisabled( f10_arg0, f10_arg2 ) then
			PlaylistSelected( f10_arg1, f10_arg0, f10_arg2 )
			ClearSavedState( self, f10_arg2 )
			return true
		elseif IsElementPropertyValue( f10_arg0, "purchasable", true ) then
			OpenPurchaseMapPackConfirmation( f10_arg2, f10_arg0, "ZMMapSelect", f10_arg1 )
			return true
		elseif not IsDisabled( f10_arg0, f10_arg2 ) then
			ProcessZMMapSelectListAction( self, f10_arg0, f10_arg2, f10_arg1 )
			return true
		else
			
		end
	end, function ( f11_arg0, f11_arg1, f11_arg2 )
		if IsPerControllerTablePropertyValue( f11_arg2, "choosingZMPlaylist", true ) and IsElementPropertyValue( f11_arg0, "purchasable", true ) then
			CoD.Menu.SetButtonLabel( f11_arg1, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "MENU_SELECT" )
			return true
		elseif IsPerControllerTablePropertyValue( f11_arg2, "choosingZMPlaylist", true ) and not IsDisabled( f11_arg0, f11_arg2 ) then
			CoD.Menu.SetButtonLabel( f11_arg1, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "MENU_SELECT" )
			return true
		elseif IsElementPropertyValue( f11_arg0, "purchasable", true ) then
			CoD.Menu.SetButtonLabel( f11_arg1, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "MENU_SELECT" )
			return true
		elseif not IsDisabled( f11_arg0, f11_arg2 ) then
			CoD.Menu.SetButtonLabel( f11_arg1, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "MENU_SELECT" )
			return true
		else
			return false
		end
	end, false )
	f5_local1:AddButtonCallbackFunction( MapList, controller, Enum.LUIButton.LUI_KEY_XBX_PSSQUARE, nil, function ( f12_arg0, f12_arg1, f12_arg2, f12_arg3 )
		if IsDvarValueEqualTo( "ui_freeDLC1", "1" ) and ShouldShowDLCWidget( f12_arg2, "mp_rise" ) and IsElementPropertyValue( f12_arg0, "purchasable", true ) then
			OpenPurchaseMapPackConfirmation( f12_arg2, f12_arg0, "ZMMapSelect", f12_arg1 )
			return true
		else
			
		end
	end, function ( f13_arg0, f13_arg1, f13_arg2 )
		if IsDvarValueEqualTo( "ui_freeDLC1", "1" ) and ShouldShowDLCWidget( f13_arg2, "mp_rise" ) and IsElementPropertyValue( f13_arg0, "purchasable", true ) then
			CoD.Menu.SetButtonLabel( f13_arg1, Enum.LUIButton.LUI_KEY_XBX_PSSQUARE, "" )
			return false
		else
			return false
		end
	end, false )
	self:addElement( MapList )
	self.MapList = MapList

    --------------------------------------------------------------------
    -- MAP PREVIEW
    --------------------------------------------------------------------
    local MapPreview = CoD.ZMMapPreview.new( menu, controller )
	MapPreview:setLeftRight( true, false, 450.38, 1216 )
	MapPreview:setTopBottom( true, false, 131, 453 )
    self:addElement( MapPreview )
    self.MapPreview = MapPreview

    --------------------------------------------------------------------
    -- MISSION TITLE
    --------------------------------------------------------------------
	local MissionBriefTitle = LUI.UIText.new()
	MissionBriefTitle:setLeftRight( true, false, 469.38, 802.34 )
	MissionBriefTitle:setTopBottom( true, false, 469.84, 493.84 )
	--MissionBriefTitle:setText( Engine.Localize( "MENU_MISSION_BRIEFING_CAPS" ) )
	MissionBriefTitle:setText( Engine.Localize( "^9[^5PZM^9]^7 PEG^9A^7SUS ^1ZOMBIE ^9MOD" ) )
	MissionBriefTitle:setTTF( "fonts/RefrigeratorDeluxe-Regular.ttf" )
	MissionBriefTitle:setAlignment( Enum.LUIAlignment.LUI_ALIGNMENT_LEFT )
	MissionBriefTitle:setAlignment( Enum.LUIAlignment.LUI_ALIGNMENT_TOP )
	self:addElement( MissionBriefTitle )
	self.MissionBriefTitle = MissionBriefTitle

    --------------------------------------------------------------------
    -- MISSION TEXT
    --------------------------------------------------------------------
	local MissionBriefText = CoD.verticalScrollingTextBox.new( f5_local1, controller )
	MissionBriefText:setLeftRight( true, false, 469.38, 1211 )
	MissionBriefText:setTopBottom( true, false, 503.23, 675.23 )
	MissionBriefText.textBox:setTTF( "fonts/RefrigeratorDeluxe-Regular.ttf" )
	MissionBriefText.textBox:setAlignment( Enum.LUIAlignment.LUI_ALIGNMENT_LEFT )
	self:addElement( MissionBriefText )
	self.MissionBriefText = MissionBriefText

    --------------------------------------------------------------------
    -- MAP BANNER / TILE
    --------------------------------------------------------------------
    local Banner = LUI.UIImage.new()
	Banner:setLeftRight( true, false, 450.38, 1216 )
	Banner:setTopBottom( true, false, 395.5, 453 )
	Banner:setRGB( 0, 0, 0 )
	Banner:setAlpha( 0.7 )
	self:addElement( Banner )
	self.Banner = Banner

	local ZMMissionTile = CoD.ZMMissionTile.new( f5_local1, controller )
	ZMMissionTile:setLeftRight( true, false, 463.38, 757.34 )
	ZMMissionTile:setTopBottom( true, false, 405, 444 )
	self:addElement( ZMMissionTile )
	self.ZMMissionTile = ZMMissionTile

    --------------------------------------------------------------------
    -- PLAY COUNT
    --------------------------------------------------------------------
	local PlayCount = LUI.UIText.new()
	PlayCount:setLeftRight( true, false, 876.04, 1211 )
	PlayCount:setTopBottom( true, false, 375.5, 394.5 )
	PlayCount:setTTF( "fonts/UnitedSansSmCdMd.ttf" )
	PlayCount:setAlignment( Enum.LUIAlignment.LUI_ALIGNMENT_RIGHT )
	PlayCount:setAlignment( Enum.LUIAlignment.LUI_ALIGNMENT_TOP )
	self:addElement( PlayCount )
	self.PlayCount = PlayCount

    --------------------------------------------------------------------
    -- DLC FREE WEEKEND (Optional)
    --------------------------------------------------------------------

	local DLCFreeweekend = CoD.DLC_Free_weekend.new( f5_local1, controller )
	DLCFreeweekend:setLeftRight( true, false, 74, 447.87 )
	DLCFreeweekend:setTopBottom( true, false, 494, 660 )
	DLCFreeweekend.DLCFreeTitleAndText.Title:setText( Engine.Localize( "MENU_DLC1_TRY_AWAKENING_FREE" ) )
	DLCFreeweekend.DLCFreeTitleAndText.Body:setText( Engine.Localize( "MENU_DLC1_ZM_TRY_AWAKENING_FREE_DESC" ) )
	DLCFreeweekend:mergeStateConditions( {
		{
			stateName = "Visible",
			condition = function ( menu, element, event )
				local f14_local0 = IsDvarValueEqualTo( "ui_freeDLC1", "1" )
				if f14_local0 then
					f14_local0 = ShouldShowDLCWidget( controller, "mp_rise" )
					if f14_local0 then
						f14_local0 = IsPerControllerTablePropertyValue( controller, "choosingZMPlaylist", true )
					end
				end
				return f14_local0
			end
		}
	} )
	self:addElement( DLCFreeweekend )
	self.DLCFreeweekend = DLCFreeweekend

	local ZMLobbyEEList = LUI.UIList.new( f5_local1, controller, -8, 0, nil, false, false, 0, 0, false, false )
	ZMLobbyEEList:makeFocusable()
	ZMLobbyEEList:setLeftRight( false, true, -331.49, -63.49 )
	ZMLobbyEEList:setTopBottom( false, true, -324, -264 )
	ZMLobbyEEList:setAlpha( 0.9 )
	ZMLobbyEEList:setWidgetType( CoD.ZMLobbyEEWidget )
	ZMLobbyEEList:setHorizontalCount( 5 )
	ZMLobbyEEList:setSpacing( -8 )
	ZMLobbyEEList:setDataSource( "ZMLobbyEEMapSelect" )
	self:addElement( ZMLobbyEEList )
	self.ZMLobbyEEList = ZMLobbyEEList

	
    --------------------------------------------------------------------
    -- STREAMED IMAGE PRELOADED
    --------------------------------------------------------------------
	local StreamedImagePreloader = LUI.UIImage.new()
	StreamedImagePreloader:setLeftRight( true, false, 1280, 1408 )
	StreamedImagePreloader:setTopBottom( true, false, 351.75, 479.75 )
	StreamedImagePreloader:setAlpha( 0 )
	StreamedImagePreloader:setupUIStreamedImage( 0 )
	self:addElement( StreamedImagePreloader )
	self.StreamedImagePreloader = StreamedImagePreloader
    --------------------------------------------------------------------
    -- MODEL LINKING (dynamic updates)
    --------------------------------------------------------------------
    -- Link selected map from MapList to other UI elements
    
	MapPreview:linkToElementModel( MapList, "Image", true, function ( model )
		local Image = Engine.GetModelValue( model )
		if Image then
			MapPreview:setImage( RegisterImage( MapImageToModPreview( Image ) ) )
		end
	end )
	MissionBriefText:linkToElementModel( MapList, "mapDescription", true, function ( model )
		local mapDescription = Engine.GetModelValue( model )
		if mapDescription then
			MissionBriefText.textBox:setText( Engine.Localize( mapDescription ) )
		end
	end )
	PlayCount:linkToElementModel( MapList, "playingCount", true, function ( model )
		local playingCount = Engine.GetModelValue( model )
		if playingCount then
			PlayCount:setText( Engine.Localize( playingCount ) )
		end
	end )
	ZMMissionTile:linkToElementModel( MapList, "mapName", true, function ( model )
		local mapName = Engine.GetModelValue( model )
		if mapName then
			ZMMissionTile.MapName:setText( Engine.Localize( mapName ) )
		end
	end )
	MapList.navigation = {
		right = ZMLobbyEEList
	}
	ZMLobbyEEList.navigation = {
		left = MapList
	}
	self.clipsPerState = {
		DefaultState = {
			DefaultClip = function ()
				self:setupElementClipCounter( 2 )
				Banner:completeAnimation()
				self.Banner:setAlpha( 0.65 )
				self.clipFinished( Banner, {} )
				PlayCount:completeAnimation()
				self.PlayCount:setAlpha( 1 )
				self.clipFinished( PlayCount, {} )
			end
		},
		Playlists = {
			DefaultClip = function ()
				self:setupElementClipCounter( 2 )
				Banner:completeAnimation()
				self.Banner:setAlpha( 0.65 )
				self.clipFinished( Banner, {} )
				PlayCount:completeAnimation()
				self.PlayCount:setAlpha( 1 )
				self.clipFinished( PlayCount, {} )
			end
		}
	}
	self:mergeStateConditions( {
		{
			stateName = "Playlists",
			condition = function ( menu, element, event )
				return IsPerControllerTablePropertyValue( controller, "choosingZMPlaylist", true )
			end
		}
	} )
	CoD.Menu.AddNavigationHandler( f5_local1, self, controller )
	f5_local1:AddButtonCallbackFunction( self, controller, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE, nil, function ( f22_arg0, f22_arg1, f22_arg2, f22_arg3 )
		GoBack( self, f22_arg2 )
		return true
	end, function ( f23_arg0, f23_arg1, f23_arg2 )
		CoD.Menu.SetButtonLabel( f23_arg1, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE, "MENU_BACK" )
		return true
	end, false )
	MapList.id = "MapList"
	MenuFrame:setModel( self.buttonModel, controller )
	ZMLobbyEEList.id = "ZMLobbyEEList"
	self:processEvent( {
		name = "menu_loaded",
		controller = controller
	} )
	self:processEvent( {
		name = "update_state",
		menu = f5_local1
	} )
	if not self:restoreState() then
		self.MapList:processEvent( {
			name = "gain_focus",
			controller = controller
	} )

end

    LUI.OverrideFunction_CallOriginalSecond( self, "close", function( element )
        element.MapList:close()
        element.MapPreview:close()
        element.MissionBriefTitle:close()
        element.MissionBriefText:close()
		element.Banner:close()
		element.ZMMissionTile:close()
        element.PlayCount:close()
        element.DLCFreeweekend:close()
		Engine.UnsubscribeAndFreeModel( Engine.GetModel( Engine.GetModelForController( controller ), "ZMMapSelection_Maps.buttonPrompts" ) )
    end )

	if PostLoadFunc then
		PostLoadFunc( self, controller )
	end

    return self
end
Editor is loading...
Leave a Comment