151 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			151 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
local f0_local0 = module
 | 
						|
local f0_local1, f0_local2 = ...
 | 
						|
f0_local0( f0_local1, package.seeall )
 | 
						|
CoD.PrintModuleLoad( _NAME )
 | 
						|
function CanSomeoneAccessFriendslist()
 | 
						|
	for f1_local0 = 0, Engine.GetMaxControllerCount() - 1, 1 do
 | 
						|
		if Engine.HasActiveLocalClient( f1_local0 ) and Engine.UserCanAccessFriendsList( f1_local0 ) then
 | 
						|
			return true
 | 
						|
		end
 | 
						|
	end
 | 
						|
	return false
 | 
						|
end
 | 
						|
 | 
						|
function online_friends_widget( f2_arg0, f2_arg1 )
 | 
						|
	if not f2_arg1 then
 | 
						|
		f2_arg1 = {}
 | 
						|
	end
 | 
						|
	local self = LUI.UIElement.new( {
 | 
						|
		topAnchor = false,
 | 
						|
		bottomAnchor = true,
 | 
						|
		leftAnchor = false,
 | 
						|
		rightAnchor = true,
 | 
						|
		bottom = -35,
 | 
						|
		right = -100,
 | 
						|
		width = 50,
 | 
						|
		height = 36,
 | 
						|
		alpha = 1
 | 
						|
	} )
 | 
						|
	self:registerAnimationState( "disabled", {
 | 
						|
		alpha = 0
 | 
						|
	} )
 | 
						|
	self.id = "online_friends_widget"
 | 
						|
	self:registerEventHandler( "show_widget", function ( element, event )
 | 
						|
		local f3_local0 = element:getParent()
 | 
						|
		if f3_local0 then
 | 
						|
			local f3_local1 = LUI.ButtonHelperText.CommonEvents.addFriendsButton
 | 
						|
			f3_local1.ignorePopups = f2_arg1.ignorePopups
 | 
						|
			f3_local0:processEvent( f3_local1 )
 | 
						|
			element:animateToState( "default", 100 )
 | 
						|
			if Engine.IsXB3() or not Engine.IsConsoleGame() then
 | 
						|
				Engine.ExecNow( "friends_widget_refresh" )
 | 
						|
			end
 | 
						|
		end
 | 
						|
	end )
 | 
						|
	self:registerEventHandler( "hide_widget", function ( element, event )
 | 
						|
		local f4_local0 = element:getParent()
 | 
						|
		if f4_local0 then
 | 
						|
			local f4_local1 = LUI.ButtonHelperText.CommonEvents.removeFriendsButton
 | 
						|
			f4_local1.dispatchChildren = true
 | 
						|
			f4_local0:processEvent( f4_local1 )
 | 
						|
			element:animateToState( "disabled", 0 )
 | 
						|
		end
 | 
						|
	end )
 | 
						|
	self:registerEventHandler( "live_connection", function ( element, event )
 | 
						|
		if event.signed_in == nil then
 | 
						|
			local f5_local0 = Engine.IsNetworkConnected()
 | 
						|
			if f5_local0 then
 | 
						|
				f5_local0 = Engine.IsUserSignedInToLive()
 | 
						|
			end
 | 
						|
			event.signed_in = f5_local0
 | 
						|
		end
 | 
						|
		if event.signed_in and CanSomeoneAccessFriendslist() then
 | 
						|
			element:processEvent( {
 | 
						|
				name = "show_widget"
 | 
						|
			} )
 | 
						|
		else
 | 
						|
			element:processEvent( {
 | 
						|
				name = "hide_widget"
 | 
						|
			} )
 | 
						|
		end
 | 
						|
	end )
 | 
						|
	self:registerEventHandler( "network_connection", function ( element, event )
 | 
						|
		if not event.plugged_in then
 | 
						|
			element:processEvent( {
 | 
						|
				name = "hide_widget"
 | 
						|
			} )
 | 
						|
		elseif Engine.IsUserSignedInToLive() then
 | 
						|
			element:processEvent( {
 | 
						|
				name = "show_widget"
 | 
						|
			} )
 | 
						|
		end
 | 
						|
	end )
 | 
						|
	self:registerEventHandler( "menu_create", function ( element, event )
 | 
						|
		element:processEvent( {
 | 
						|
			name = "live_connection"
 | 
						|
		} )
 | 
						|
	end )
 | 
						|
	local f2_local1 = LUI.UIBindButton.new()
 | 
						|
	f2_local1.id = "friends_bind_buttons_id"
 | 
						|
	f2_local1:registerEventHandler( "button_alt2", function ( element, event )
 | 
						|
		if Engine.IsNetworkConnected() and Engine.IsUserSignedInToLive( event.controller ) then
 | 
						|
			local f8_local0 = Engine.UserCanAccessFriendsList( event.controller )
 | 
						|
			local f8_local1 = Engine.IsUserAGuest( event.controller )
 | 
						|
			if f8_local0 and not f8_local1 then
 | 
						|
				if Engine.InFrontend() then
 | 
						|
					LUI.FlowManager.RequestPopupMenu( element, "popup_friends", true, event.controller, false, {} )
 | 
						|
				else
 | 
						|
					LUI.FlowManager.RequestAddMenu( element, "popup_friends", true, event.controller, false, {} )
 | 
						|
				end
 | 
						|
			elseif f8_local1 then
 | 
						|
				LUI.FlowManager.RequestPopupMenu( element, "mp_no_guest_popup", false, event.controller, false )
 | 
						|
			elseif Engine.IsPS3() and event.controller ~= 0 then
 | 
						|
				LUI.FlowManager.RequestPopupMenu( element, "mp_wrong_controller_popup", false, event.controller, false )
 | 
						|
			end
 | 
						|
		end
 | 
						|
		return true
 | 
						|
	end )
 | 
						|
	self:addElement( f2_local1 )
 | 
						|
	local f2_local2 = LUI.UIImage.new
 | 
						|
	local f2_local3 = {
 | 
						|
		topAnchor = false,
 | 
						|
		bottomAnchor = false,
 | 
						|
		leftAnchor = true,
 | 
						|
		rightAnchor = false,
 | 
						|
		top = -5,
 | 
						|
		bottom = 5,
 | 
						|
		left = 0,
 | 
						|
		right = 10,
 | 
						|
		material = RegisterMaterial( "widg_triangle" )
 | 
						|
	}
 | 
						|
	if not Engine.InFrontend() then
 | 
						|
		local f2_local4 = Engine.GetDvarBool( "dedicated_dhclient" )
 | 
						|
		local f2_local5 = 0.7
 | 
						|
	end
 | 
						|
	f2_local3.alpha = f2_local4 and f2_local5 or 0.25
 | 
						|
	f2_local3.zRot = -135
 | 
						|
	f2_local2 = f2_local2( f2_local3 )
 | 
						|
	f2_local2.id = "friends_triangle_id"
 | 
						|
	self:addElement( f2_local2 )
 | 
						|
	if Friends then
 | 
						|
		f2_local3 = LUI.UIText.new( CoD.ColorizeState( Colors.frontend_hilite, {
 | 
						|
			topAnchor = false,
 | 
						|
			bottomAnchor = false,
 | 
						|
			leftAnchor = false,
 | 
						|
			rightAnchor = true,
 | 
						|
			left = 0,
 | 
						|
			right = 0,
 | 
						|
			height = CoD.TextSettings.BigFont.Height,
 | 
						|
			font = CoD.TextSettings.BigFont.Font,
 | 
						|
			alignment = LUI.Alignment.Right
 | 
						|
		} ) )
 | 
						|
		f2_local3.id = "friends_number_text"
 | 
						|
		f2_local3:setupUIBindText( "CountOnlineFriends" )
 | 
						|
		self:addElement( f2_local3 )
 | 
						|
	end
 | 
						|
	return self
 | 
						|
end
 | 
						|
 | 
						|
LUI.MenuBuilder.registerType( "online_friends_widget", online_friends_widget )
 | 
						|
LockTable( _M )
 |