iw6-lui/lui/mp_menus/mplobbynavigation.dec.lua
2024-09-12 17:25:45 +02:00

726 lines
20 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function DefaultLobbyTitleUpdateStub( f1_arg0, f1_arg1 )
end
function DefaultShouldDisableSlideRightFunc( f2_arg0, f2_arg1 )
return false
end
function LobbyNavigationFeeder( f3_arg0 )
local f3_local0 = {}
local f3_local1 = f3_arg0:lobbyNavigationPages()
local f3_local2 = #f3_local1
for f3_local3 = 1, f3_local2, 1 do
local f3_local6 = f3_local1[f3_local3].title or ""
local f3_local7 = f3_local1[f3_local3].title_update_func or DefaultLobbyTitleUpdateStub
assert( f3_local1[f3_local3].element )
assert( f3_local1[f3_local3].element.id )
f3_local0[#f3_local0 + 1] = {
type = "UIElement",
id = "lobby_navigation_slide_button_" .. f3_local3,
properties = {
pageIndex = f3_local3,
pageCount = f3_local2,
aliensSoloMode = f3_arg0.aliensSoloMode,
isDisabled = false,
elementId = f3_local1[f3_local3].element.id,
should_disable_slide_right_func = function ( f4_arg0, f4_arg1 )
local f4_local0 = f4_arg0:getChildById( f4_arg0.properties.elementId )
if f4_local0.properties and f4_local0.properties.should_disable_slide_right_func then
return f4_local0.properties:should_disable_slide_right_func( f4_arg1 )
else
return false
end
end
},
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = false,
top = 0,
bottom = 0,
left = 0,
right = 640
}
},
handlers = {
page_disable = function ( f5_arg0, f5_arg1 )
f5_arg0.properties.isDisabled = true
f5_arg0:dispatchEventToParent( {
name = "refresh_arrows",
immediate = true
} )
end,
page_enable = function ( f6_arg0, f6_arg1 )
f6_arg0.properties.isDisabled = false
f6_arg0:dispatchEventToParent( {
name = "refresh_arrows",
immediate = true
} )
end
},
children = {
{
type = "generic_menu_title",
id = "mp_lobby_title_text_id",
properties = {
menu_title = f3_local1[f3_local3].title,
disableLobbyStatus = true,
additional_handlers = {
lobby_page_left = function ( f7_arg0, f7_arg1 )
local f7_local0 = f7_arg1.animTime or 0
f7_arg0:processEvent( {
name = "menu_title_show",
preAnimTime = f7_local0 * 0.5,
animTime = f7_local0 * 0.5
} )
end,
lobby_page_right = function ( f8_arg0, f8_arg1 )
f8_arg0:processEvent( {
name = "menu_title_hide",
preAnimTime = (f8_arg1.animTime or 0) * 0.5,
animTime = 0
} )
end,
lobby_page_leave = function ( f9_arg0, f9_arg1 )
local f9_local0 = f9_arg1.animTime or 0
f9_arg0:processEvent( {
name = "menu_title_hide",
preAnimTime = f9_local0 * 0.5,
animTime = f9_local0 * 0.5
} )
end
}
},
handlers = {
lobby_update_title = f3_local7,
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
}
},
f3_local1[f3_local3].element
}
}
end
return f3_local0
end
function HandleLobbyNavigationPagesCreate( f10_arg0, f10_arg1 )
local f10_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f10_arg0 )
if not f10_local0.focusedPage then
f10_local0.focusedPage = 1
elseif f10_local0.focusedPage > 2 then
f10_local0.focusedPage = 2
f10_arg0:processEvent( {
name = "refocus_member_list",
inFocus = true
} )
end
local f10_local1 = f10_arg0.properties:lobbyNavigationPages()
for f10_local2 = 1, #f10_local1, 1 do
local f10_local5 = -1 * (f10_local2 - 1) * 640
f10_arg0:registerAnimationState( "slide_" .. f10_local2, {
leftAnchor = true,
rightAnchor = false,
left = f10_local5,
right = f10_local5 + 1280
} )
f10_arg0:registerEventHandler( "transition_complete_slide_" .. f10_local2, HandleLobbyNavigationTransitionComplete )
end
f10_arg0:animateToState( "slide_" .. f10_local0.focusedPage, 0, true )
local f10_local2 = f10_arg0:getFirstChild()
while f10_local2 do
if f10_local2.properties.pageIndex == f10_local0.focusedPage then
f10_local2:processEvent( {
name = "lobby_page_left",
dispatchChildren = true
} )
f10_local2:processEvent( {
name = "lobby_page_enter",
dispatchChildren = true
} )
elseif f10_local2.properties.pageIndex == f10_local0.focusedPage + 1 then
f10_local2:processEvent( {
name = "lobby_page_right",
dispatchChildren = true
} )
f10_local2:processEvent( {
name = "lobby_page_enter",
dispatchChildren = true
} )
else
f10_local2:processEvent( {
name = "lobby_page_leave",
dispatchChildren = true
} )
end
f10_local2 = f10_local2:getNextSibling()
end
end
function HandleLobbyNavigationRefreshArrows( f11_arg0, f11_arg1 )
local f11_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f11_arg0 )
local f11_local1 = f11_arg0.properties:lobbyNavigationPages()
local f11_local2 = f11_arg0:getParent()
if f11_local0.focusedPage <= 1 then
f11_local2:processEvent( {
name = "lobby_arrow_lt_hide"
} )
else
f11_local2:processEvent( {
name = "lobby_arrow_lt_show"
} )
end
local f11_local3 = false
local f11_local4 = f11_arg0:getFirstChild()
while f11_local4 do
if f11_local4.properties.pageIndex == f11_local0.focusedPage + 1 then
if f11_local4.properties.isDisabled or f11_local4.properties.should_disable_slide_right_func and f11_local4.properties:should_disable_slide_right_func( f11_arg1.controller ) then
f11_local3 = true
break
end
f11_local3 = false
end
f11_local4 = f11_local4:getNextSibling()
end
if not f11_local3 then
if #f11_local1 - 1 <= f11_local0.focusedPage then
f11_local3 = true
else
f11_local3 = false
end
end
if f11_local3 then
f11_local2:processEvent( {
name = "lobby_arrow_rt_hide"
} )
else
f11_local2:processEvent( {
name = "lobby_arrow_rt_show"
} )
end
end
function HandleLobbyNavigationSlideLeft( f12_arg0, f12_arg1 )
local f12_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f12_arg0 )
if f12_local0.animating then
return
elseif f12_arg0.properties.slideDisabled then
return
elseif not isNavMenuOnTop() then
return
end
local f12_local1 = f12_arg0.properties:lobbyNavigationPages()
if f12_local0.focusedPage > 1 then
local f12_local2 = false
local f12_local3 = f12_arg0:getFirstChild()
while f12_local3 do
if f12_local3.properties.pageIndex == f12_local0.focusedPage - 1 then
f12_local2 = f12_local3.properties.isDisabled
end
end
if not f12_local2 then
f12_local0.animating = true
f12_arg0:animateToState( "slide_" .. f12_local0.focusedPage - 1, 200, true )
local f12_local4 = f12_arg0:getFirstChild()
while f12_local4 do
if f12_local4.properties.pageIndex == f12_local0.focusedPage then
f12_local4:processEvent( {
name = "lobby_page_right",
animTime = 200,
dispatchChildren = true
} )
f12_local4:processEvent( {
name = "lose_focus"
} )
elseif f12_local4.properties.pageIndex == f12_local0.focusedPage - 1 then
f12_local4:processEvent( {
name = "lobby_page_enter",
animTime = 200,
controller = f12_arg1.controller,
dispatchChildren = true
} )
f12_local4:processEvent( {
name = "lobby_page_left",
animTime = 200,
dispatchChildren = true
} )
elseif f12_local4.properties.pageIndex == f12_local0.focusedPage + 1 then
f12_local4:processEvent( {
name = "lobby_page_leave",
animTime = 200,
controller = f12_arg1.controller,
dispatchChildren = true
} )
end
f12_local4 = f12_local4:getNextSibling()
end
f12_local0.focusedPage = f12_local0.focusedPage - 1
local f12_local5 = f12_arg0:getFirstChild()
while f12_local5 do
if f12_local5.properties.pageIndex == f12_local0.focusedPage then
f12_local5:processEvent( {
name = "gain_focus"
} )
end
f12_local5 = f12_local5:getNextSibling()
end
f12_arg0:processEvent( {
name = "refresh_arrows"
} )
else
end
f12_local3 = f12_local3:getNextSibling()
elseif not Engine.IsConsoleGame() then
local f12_local2 = f12_arg0:getFirstChild()
if not f12_local2:isInFocus() then
f12_local2 = f12_arg0:getFirstChild()
while f12_local2 do
if f12_local2.properties.pageIndex == f12_local0.focusedPage + 1 then
f12_local2:processEvent( {
name = "lose_focus"
} )
end
f12_local2 = f12_local2:getNextSibling()
end
f12_local2 = f12_arg0:getFirstChild()
while f12_local2 do
if f12_local2.properties.pageIndex == f12_local0.focusedPage then
f12_local2:processEvent( {
name = "gain_focus"
} )
end
f12_local2 = f12_local2:getNextSibling()
end
end
end
end
function HandleLobbyNavigationSlideRight( f13_arg0, f13_arg1 )
local f13_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f13_arg0 )
if f13_local0.animating then
return
elseif f13_arg0.properties.slideDisabled then
return
elseif not isNavMenuOnTop() then
return
elseif f13_local0.focusedPage < #f13_arg0.properties:lobbyNavigationPages() - 1 then
local f13_local1 = false
local f13_local2 = f13_arg0:getFirstChild()
while f13_local2 do
if f13_local2.properties.pageIndex == f13_local0.focusedPage + 1 then
f13_local1 = f13_local2.properties.should_disable_slide_right_func and (f13_local2.properties.isDisabled or f13_local2.properties:should_disable_slide_right_func( f13_arg1.controller ))
end
end
if not f13_local1 then
f13_local0.animating = true
f13_arg0:animateToState( "slide_" .. f13_local0.focusedPage + 1, 200, true )
local f13_local3 = f13_arg0:getFirstChild()
while f13_local3 do
if f13_local3.properties.pageIndex == f13_local0.focusedPage + 1 then
f13_local3:processEvent( {
name = "lobby_page_left",
animTime = 200,
dispatchChildren = true
} )
elseif f13_local3.properties.pageIndex == f13_local0.focusedPage + 2 then
f13_local3:processEvent( {
name = "lobby_page_enter",
animTime = 200,
controller = f13_arg1.controller,
dispatchChildren = true
} )
f13_local3:processEvent( {
name = "lobby_page_right",
animTime = 200,
dispatchChildren = true
} )
elseif f13_local3.properties.pageIndex == f13_local0.focusedPage then
f13_local3:processEvent( {
name = "lobby_page_leave",
animTime = 200,
controller = f13_arg1.controller,
dispatchChildren = true
} )
f13_local3:processEvent( {
name = "lose_focus"
} )
end
f13_local3 = f13_local3:getNextSibling()
end
f13_local0.focusedPage = f13_local0.focusedPage + 1
local f13_local4 = f13_arg0:getFirstChild()
while f13_local4 do
if f13_local4.properties.pageIndex == f13_local0.focusedPage then
f13_local4:processEvent( {
name = "gain_focus"
} )
end
f13_local4 = f13_local4:getNextSibling()
end
f13_arg0:processEvent( {
name = "refresh_arrows",
controller = f13_arg1.controller
} )
else
end
f13_local2 = f13_local2:getNextSibling()
end
end
function HandleLobbyNavigationSlideEnable( f14_arg0, f14_arg1 )
f14_arg0.properties.slideDisabled = false
end
function HandleLobbyNavigationSlideDisable( f15_arg0, f15_arg1 )
f15_arg0.properties.slideDisabled = true
end
function HandleLobbyNavigationGamepadButton( f16_arg0, f16_arg1 )
if f16_arg0.properties.slideDisabled then
f16_arg0:dispatchEventToChildren( f16_arg1 )
return false
end
local f16_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f16_arg0 )
if f16_arg1.down == true then
if f16_arg1.button == "left" then
if f16_local0.animating then
return true
end
f16_arg0:processEvent( {
name = "lobby_slide_left",
controller = f16_arg1.controller,
dispatchChildren = true
} )
elseif f16_arg1.button == "right" then
if f16_local0.animating then
return true
end
f16_arg0:processEvent( {
name = "lobby_slide_right",
controller = f16_arg1.controller,
dispatchChildren = true
} )
end
end
return LUI.UIElement.GamepadButton( f16_arg0, f16_arg1 )
end
function HandleLobbyNavigationTransitionComplete( f17_arg0, f17_arg1 )
local f17_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f17_arg0 )
f17_local0.animating = false
if f17_local0.force_press_lobby_navigation_arrow_right_btn == true then
f17_local0.force_press_lobby_navigation_arrow_right_btn = false
Kinect.PressMenuButton( "lobby_navigation_arrow_right_btn" )
end
end
function HandleLobbyArrowLeft( f18_arg0, f18_arg1 )
local f18_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f18_arg0:getParent() )
local f18_local1 = f18_arg0.properties:lobbyNavigationPages()
if f18_local0.focusedPage > 1 then
f18_arg0:dispatchEventToRoot( {
name = "lobby_slide_left",
focusedPage = f18_local0.focusedPage,
dispatchChildren = true
} )
end
end
function HandleLobbyArrowRight( f19_arg0, f19_arg1 )
local f19_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f19_arg0:getParent() )
if f19_local0.focusedPage < #f19_arg0.properties:lobbyNavigationPages() - 1 then
f19_arg0:dispatchEventToRoot( {
name = "lobby_slide_right",
focusedPage = f19_local0.focusedPage,
dispatchChildren = true
} )
end
end
function HandleLobbyNavigationCreate( f20_arg0, f20_arg1 )
local f20_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f20_arg0 )
f20_local0.animating = false
f20_arg0:processEvent( {
name = "refresh_arrows"
} )
end
function HandleLobbyNavigationListGainFocus( f21_arg0, f21_arg1 )
local f21_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f21_arg0 )
local f21_local1 = f21_arg0:getFirstChild()
while f21_local1 do
if f21_local1.properties.pageIndex == f21_local0.focusedPage then
f21_local1:processEvent( {
name = "gain_focus"
} )
break
end
f21_local1 = f21_local1:getNextSibling()
end
end
function HandleLobbyNavigationListLoseFocus( f22_arg0, f22_arg1 )
local f22_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f22_arg0 )
local f22_local1 = f22_arg0:getFirstChild()
while f22_local1 do
if f22_local1.properties.pageIndex == f22_local0.focusedPage then
f22_local1:processEvent( {
name = "lose_focus"
} )
end
if not Engine.IsConsoleGame() and f22_local1.properties.pageIndex == f22_local0.focusedPage + 1 then
f22_local1:processEvent( {
name = "lose_focus"
} )
end
f22_local1 = f22_local1:getNextSibling()
end
end
function HandleArrowOnOver( f23_arg0, f23_arg1 )
if isNavMenuOnTop() and f23_arg1.focusType == FocusType.MouseOver then
f23_arg0:dispatchEventToRoot( {
name = "lobby_slide_enable",
dispatchChildren = true
} )
end
end
function lobby_navigation()
return {
type = "UIElement",
id = "lobby_navigation_id",
properties = {
lobbyNavigationPages = function ( f25_arg0 )
return {}
end
,
aliensSoloMode = false
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0
}
},
handlers = {
menu_create = HandleLobbyNavigationCreate
},
children = {
{
type = "UIHorizontalList",
id = "lobby_navigation_list_id",
properties = {
lobbyNavigationPages = MBh.Property( "lobbyNavigationPages" ),
aliensSoloMode = MBh.Property( "aliensSoloMode" ),
noWrap = true,
slideDisabled = false
},
states = {
default = {
alignment = LUI.Alignment.Left,
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0,
alpha = 1
},
hidden = {
alpha = 0
}
},
handlers = {
menu_create = HandleLobbyNavigationPagesCreate,
gamepad_button = HandleLobbyNavigationGamepadButton,
lobby_slide_left = HandleLobbyNavigationSlideLeft,
lobby_slide_right = HandleLobbyNavigationSlideRight,
lobby_slide_enable = HandleLobbyNavigationSlideEnable,
lobby_slide_disable = HandleLobbyNavigationSlideDisable,
refresh_arrows = HandleLobbyNavigationRefreshArrows,
gain_focus = HandleLobbyNavigationListGainFocus,
lose_focus = HandleLobbyNavigationListLoseFocus,
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
},
childrenFeeder = LobbyNavigationFeeder
},
{
type = "UIButton",
id = "lobby_navigation_arrow_left_btn",
properties = {
lobbyNavigationPages = MBh.Property( "lobbyNavigationPages" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 75,
right = 91,
top = 57,
bottom = 73
},
pan = MBh.BaseState( "default", {
left = 70,
right = 86
} )
},
handlers = {
menu_create = MBh.AnimateLoop( {
{
"pan",
500,
true,
true
},
{
"default",
500,
true,
true
}
} ),
button_action = HandleLobbyArrowLeft,
button_over = HandleArrowOnOver,
lobby_arrow_lt_show = MBh.EmitEvent( "enable" ),
lobby_arrow_lt_hide = MBh.EmitEvent( "disable" )
},
children = {
{
type = "UIImage",
id = "lobby_navigation_arrow_left",
states = {
default = {
material = RegisterMaterial( "widg_lobby_arrow" ),
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = true,
left = 16,
right = 0,
top = 0,
bottom = 0,
alpha = 0.5
},
over = {
alpha = 1
},
hidden = {
alpha = 0
}
},
handlers = {
button_over = MBh.AnimateToState( "over" ),
button_up = MBh.AnimateToState( "default" ),
button_disable = MBh.AnimateToState( "hidden" ),
button_over_disable = MBh.AnimateToState( "hidden" ),
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
}
}
}
},
{
type = "UIButton",
id = "lobby_navigation_arrow_right_btn",
properties = {
lobbyNavigationPages = MBh.Property( "lobbyNavigationPages" )
},
states = {
default = {
leftAnchor = false,
rightAnchor = true,
topAnchor = true,
bottomAnchor = false,
left = -91,
right = -75,
top = 57,
bottom = 73
},
pan = MBh.BaseState( "default", {
left = -86,
right = -70
} )
},
handlers = {
menu_create = MBh.AnimateLoop( {
{
"pan",
500,
true,
true
},
{
"default",
500,
true,
true
}
} ),
button_action = HandleLobbyArrowRight,
button_over = HandleArrowOnOver,
lobby_arrow_rt_show = MBh.EmitEvent( "enable" ),
lobby_arrow_rt_hide = MBh.EmitEvent( "disable" )
},
children = {
{
type = "UIImage",
id = "lobby_navigation_arrow_right",
states = {
default = {
material = RegisterMaterial( "widg_lobby_arrow" ),
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0,
alpha = 0.5
},
over = {
alpha = 1
},
hidden = {
alpha = 0
}
},
handlers = {
button_over = MBh.AnimateToState( "over" ),
button_up = MBh.AnimateToState( "default" ),
button_disable = MBh.AnimateToState( "hidden" ),
button_over_disable = MBh.AnimateToState( "hidden" ),
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
}
}
}
}
}
}
end
LUI.MenuBuilder.registerDef( "lobby_navigation", lobby_navigation )
LockTable( _M )