892 lines
27 KiB
Lua
892 lines
27 KiB
Lua
local f0_local0 = module
|
|
local f0_local1, f0_local2 = ...
|
|
f0_local0( f0_local1, package.seeall )
|
|
CoD.PrintModuleLoad( _NAME )
|
|
MOTD_WIDTH = 892
|
|
MOTD_HEIGHT = 590
|
|
MOTD_ANIM_DELTA = 600
|
|
MOTD_ANIM_TIME_MS = 100
|
|
MOTD_IMAGE_TOP_INDENT = 90
|
|
MOTD_IMAGE_LEFT_INDENT = 58
|
|
MOTD_IMAGE_SIZE = 340
|
|
MOTD_TEXT_TOP_INDENT = MOTD_IMAGE_TOP_INDENT
|
|
MOTD_TEXT_LEFT_INTENT = 490
|
|
MOTD_TEXT_WIDTH = 367
|
|
MOTD_UPSELL_MENU_CONTINUE_EVENT = 0
|
|
MOTD_UPSELL_OPEN_STORE_EVENT = 1
|
|
MOTD_UPSELL_MAX_EVENT_RECORDED = 2
|
|
MOTDLayoutType = {
|
|
DEFAULT = 0,
|
|
VOTING = 1
|
|
}
|
|
function UpsellAction( f1_arg0, f1_arg1 )
|
|
f1_arg0:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
exitMotd = true,
|
|
controller = f1_arg1.controller,
|
|
upsellEvent = MOTD_UPSELL_OPEN_STORE_EVENT
|
|
} )
|
|
Sns.OpenStoreMenu( f1_arg1.controller, "upsell_menu", true )
|
|
end
|
|
|
|
function RecordUpsellMenuAction( f2_arg0, f2_arg1 )
|
|
local f2_local0 = (Engine.GetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_recent_updated_record" ) + 1) % MOTD_UPSELL_MAX_EVENT_RECORDED
|
|
Engine.SetUpsellMenuCloseTimestamp()
|
|
local f2_local1 = Engine.GetUpsellMenuViewTime()
|
|
if f2_local0 == 0 then
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_view_time_0", f2_local1 )
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_action_0", f2_arg1 )
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_open_timestamp_0", Engine.GetUpsellMenuOpenTimestamp() )
|
|
else
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_view_time_1", f2_local1 )
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_action_1", f2_arg1 )
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_open_timestamp_1", Engine.GetUpsellMenuOpenTimestamp() )
|
|
end
|
|
Engine.SetPlayerDataReservedInt( f2_arg0, CoD.StatsGroup.Common, "sp_upsell_recent_updated_record", f2_local0 )
|
|
end
|
|
|
|
function CodAnywhereAction( f3_arg0, f3_arg1 )
|
|
f3_arg0:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
exitMotd = true,
|
|
controller = f3_arg1.controller
|
|
} )
|
|
OpenCoDAnywhere( f3_arg1.controller )
|
|
end
|
|
|
|
function OpenStoreAction( f4_arg0, f4_arg1 )
|
|
LUI.FlowManager.RequestLeaveMenu( f4_arg0 )
|
|
Sns.OpenStoreMenu( f4_arg1.controller, "motd" )
|
|
end
|
|
|
|
motdLayouts = {
|
|
welcomeFounder = {
|
|
title = Engine.Localize( "@LUA_MENU_WELCOME_FOUNDER_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_WELCOME_FOUNDER_MESSAGE" ),
|
|
image = "image_motd_founder"
|
|
},
|
|
welcomeSoldier = {
|
|
title = Engine.Localize( "@LUA_MENU_WELCOME_SOLDIER_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_WELCOME_SOLDIER_MESSAGE" ),
|
|
image = "image_motd_soldier"
|
|
},
|
|
welcomeNoob = {
|
|
title = Engine.Localize( "@LUA_MENU_WELCOME_NOOB_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_WELCOME_NOOB_MESSAGE" ),
|
|
image = "image_motd_new_guy"
|
|
},
|
|
seasonPassUpsell = {
|
|
title = Engine.Localize( "@LUA_MENU_SEASON_PASS_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_SEASON_PASS_MESSAGE" ),
|
|
image = "image_motd_season_pass",
|
|
additional_buttons = {
|
|
{
|
|
helperTextRef = "button_alt1",
|
|
eventAction = "button_alt1",
|
|
label = Engine.Localize( "@LUA_MENU_PURCHASE_NOW" ),
|
|
handler = UpsellAction,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
}
|
|
}
|
|
},
|
|
festiveUpsell = {
|
|
title = Engine.Localize( "@LUA_MENU_FESTIVE_UPSELL_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_FESTIVE_UPSELL_MSG" ),
|
|
image = "image_motd_holiday",
|
|
additional_buttons = {
|
|
{
|
|
helperTextRef = "button_alt1",
|
|
eventAction = "button_alt1",
|
|
label = Engine.Localize( "@LUA_MENU_FREE" ),
|
|
handler = UpsellAction,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
}
|
|
}
|
|
},
|
|
wolfpackUpsell = {
|
|
title = Engine.Localize( "@LUA_MENU_WOLF_UPSELL_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_WOLF_UPSELL_MSG" ),
|
|
image = "image_motd_wolfskin",
|
|
additional_buttons = {
|
|
{
|
|
helperTextRef = "button_alt1",
|
|
eventAction = "button_alt1",
|
|
label = Engine.Localize( "@LUA_MENU_PURCHASE_NOW" ),
|
|
handler = UpsellAction,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
}
|
|
}
|
|
},
|
|
codAnywhereUpsell = {
|
|
title = Engine.Localize( "@LUA_MENU_MOTD_CODA_PLEASE_REGISTER_TITLE" ),
|
|
message = Engine.Localize( "@LUA_MENU_MOTD_CODA_PLEASE_REGISTER_MESSAGE" ),
|
|
image = "image_motd_cod_account_generic",
|
|
additional_buttons = {
|
|
{
|
|
helperTextRef = "button_alt1",
|
|
eventAction = "button_alt1",
|
|
label = Engine.Localize( "@LUA_MENU_COD_ANYWHERE_CREATE_ACCOUNT" ),
|
|
handler = CodAnywhereAction,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
}
|
|
}
|
|
},
|
|
downloadReminder = {
|
|
title = Engine.Localize( "@LUA_MENU_MP_MOTD_DOWNLOAD_PURCHASED_DLC_CAPS" ),
|
|
message = function ()
|
|
return GetDownloadReminderMessage()
|
|
end,
|
|
image = "image_motd_season_pass"
|
|
},
|
|
motd = {
|
|
title = Engine.Localize( "@LUA_MENU_MOTD_CAPS" ),
|
|
message = function ()
|
|
return Engine.GetDvarString( "motd" )
|
|
end,
|
|
image = "iotd_image",
|
|
additional_buttons = {
|
|
{
|
|
helperTextRef = "button_alt1",
|
|
eventAction = "button_alt1",
|
|
label = Engine.Localize( "@MPUI_OPEN_STORE" ),
|
|
handler = OpenStoreAction,
|
|
enabled = function ()
|
|
return Engine.GetDvarInt( "motd_store_link" ) == 1
|
|
end
|
|
}
|
|
}
|
|
},
|
|
voting = {
|
|
type = MOTDLayoutType.VOTING,
|
|
title = Engine.Localize( "@LUA_MENU_MP_MOTD_VOTING_TITLE" ),
|
|
message = function ()
|
|
return GetVotingPageHeader()
|
|
end,
|
|
button_action_text = Engine.Localize( "@LUA_MENU_MP_MOTD_VOTING_SKIP" ),
|
|
additional_buttons = {
|
|
{
|
|
helperTextRef = "button_dpad_left",
|
|
eventAction = "button_left",
|
|
label = Engine.Localize( "@LUA_MENU_MP_MOTD_VOTING_ITEM_HELPER", 1 ),
|
|
handler = function ( f13_arg0, f13_arg1 )
|
|
CastVoteForItem( f13_arg1.controller, 0 )
|
|
f13_arg0:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
controller = f13_arg1.controller,
|
|
upsellEvent = MOTD_UPSELL_MENU_CONTINUE_EVENT
|
|
} )
|
|
end,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
},
|
|
{
|
|
helperTextRef = "button_dpad_up",
|
|
eventAction = "button_up",
|
|
label = Engine.Localize( "@LUA_MENU_MP_MOTD_VOTING_ITEM_HELPER", 2 ),
|
|
handler = function ( f15_arg0, f15_arg1 )
|
|
CastVoteForItem( f15_arg1.controller, 1 )
|
|
f15_arg0:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
controller = f15_arg1.controller,
|
|
upsellEvent = MOTD_UPSELL_MENU_CONTINUE_EVENT
|
|
} )
|
|
end,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
},
|
|
{
|
|
helperTextRef = "button_dpad_right",
|
|
eventAction = "button_right",
|
|
label = Engine.Localize( "@LUA_MENU_MP_MOTD_VOTING_ITEM_HELPER", 3 ),
|
|
handler = function ( f17_arg0, f17_arg1 )
|
|
CastVoteForItem( f17_arg1.controller, 2 )
|
|
f17_arg0:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
controller = f17_arg1.controller,
|
|
upsellEvent = MOTD_UPSELL_MENU_CONTINUE_EVENT
|
|
} )
|
|
end,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
},
|
|
{
|
|
helperTextRef = "button_dpad_down",
|
|
eventAction = "button_down",
|
|
label = Engine.Localize( "@LUA_MENU_MP_MOTD_VOTING_ITEM_HELPER", 4 ),
|
|
handler = function ( f19_arg0, f19_arg1 )
|
|
CastVoteForItem( f19_arg1.controller, 3 )
|
|
f19_arg0:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
controller = f19_arg1.controller,
|
|
upsellEvent = MOTD_UPSELL_MENU_CONTINUE_EVENT
|
|
} )
|
|
end,
|
|
enabled = function ()
|
|
return true
|
|
end
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function UpdateActionText( f21_arg0, f21_arg1 )
|
|
f21_arg0:processEvent( {
|
|
name = "add_button_helper_text",
|
|
button_ref = Engine.IsConsoleGame() and "button_action" or "button_secondary",
|
|
helper_text = f21_arg1,
|
|
side = "left",
|
|
clickable = true
|
|
} )
|
|
end
|
|
|
|
function UpdateAdditionalButtons( f22_arg0, f22_arg1 )
|
|
if not f22_arg1 then
|
|
return
|
|
end
|
|
for f22_local0 = 1, #f22_arg1, 1 do
|
|
if f22_arg1[f22_local0].enabled() then
|
|
f22_arg0:processEvent( {
|
|
name = "add_button_helper_text",
|
|
button_ref = f22_arg1[f22_local0].helperTextRef,
|
|
helper_text = f22_arg1[f22_local0].label,
|
|
side = "left",
|
|
clickable = true
|
|
} )
|
|
f22_arg0:dispatchEventToRoot( {
|
|
name = "update_button_handler",
|
|
eventAction = f22_arg1[f22_local0].eventAction,
|
|
newHandler = f22_arg1[f22_local0].handler,
|
|
immediate = true
|
|
} )
|
|
end
|
|
end
|
|
end
|
|
|
|
function motdContinueFunc( f23_arg0, f23_arg1 )
|
|
local f23_local0 = f23_arg0.properties
|
|
local f23_local1 = ""
|
|
if f23_local0.layout then
|
|
f23_local1 = f23_local0.layout
|
|
end
|
|
if f23_local1 == "seasonPassUpsell" and f23_arg1.upsellEvent then
|
|
RecordUpsellMenuAction( f23_arg1.controller, f23_arg1.upsellEvent )
|
|
end
|
|
local f23_local2 = nil
|
|
if f23_local0 and f23_local0.layoutQueue and #f23_local0.layoutQueue >= 1 and not f23_arg1.exitMotd then
|
|
f23_local2 = table.remove( f23_local0.layoutQueue, 1 )
|
|
f23_local0.layout = f23_local2
|
|
local f23_local3 = MOTDLayoutType.DEFAULT
|
|
if motdLayouts[f23_local2] and motdLayouts[f23_local2].type then
|
|
f23_local3 = motdLayouts[f23_local2].type
|
|
end
|
|
f23_arg0:processEvent( {
|
|
name = "update_layout_type",
|
|
layout_type = f23_local3
|
|
} )
|
|
if f23_local2 == "seasonPassUpsell" then
|
|
Engine.SetUpsellMenuOpenTimestamp()
|
|
end
|
|
if motdLayouts[f23_local2] and motdLayouts[f23_local2].title then
|
|
f23_arg0:processEvent( {
|
|
name = "update_title",
|
|
title_text = motdLayouts[f23_local2].title
|
|
} )
|
|
end
|
|
if motdLayouts[f23_local2] and motdLayouts[f23_local2].message then
|
|
local f23_local4 = motdLayouts[f23_local2].message
|
|
if type( f23_local4 ) == "function" then
|
|
f23_local4 = motdLayouts[f23_local2].message()
|
|
end
|
|
f23_arg0:processEvent( {
|
|
name = "motd_update_message",
|
|
message = f23_local4
|
|
} )
|
|
end
|
|
if motdLayouts[f23_local2] and motdLayouts[f23_local2].image then
|
|
if motdLayouts[f23_local2].image == "iotd_image" then
|
|
f23_arg0:processEvent( {
|
|
name = "show_iotd_image"
|
|
} )
|
|
else
|
|
f23_arg0:processEvent( {
|
|
name = "show_custom_image",
|
|
image = motdLayouts[f23_local2].image
|
|
} )
|
|
end
|
|
end
|
|
f23_arg0:processEvent( {
|
|
name = "clear_button_helper_text",
|
|
side = "left"
|
|
} )
|
|
local f23_local4 = Engine.Localize( "@MENU_CONTINUE" )
|
|
if motdLayouts[f23_local2] and motdLayouts[f23_local2].button_action_text then
|
|
f23_local4 = motdLayouts[f23_local2].button_action_text
|
|
end
|
|
UpdateActionText( f23_arg0, f23_local4 )
|
|
if motdLayouts[f23_local2] and motdLayouts[f23_local2].additional_buttons then
|
|
UpdateAdditionalButtons( f23_arg0, motdLayouts[f23_local2].additional_buttons )
|
|
end
|
|
else
|
|
f23_arg0:processEvent( {
|
|
name = "exit_transition"
|
|
} )
|
|
if f23_arg1.controller then
|
|
Engine.ExecNow( "uploadstats", f23_arg1.controller )
|
|
end
|
|
end
|
|
end
|
|
|
|
function motd_main( f24_arg0, f24_arg1, f24_arg2 )
|
|
local f24_local0 = f24_arg1 or {}
|
|
local f24_local1, f24_local2, f24_local3, f24_local4 = nil
|
|
if f24_local0.layoutQueue and #f24_local0.layoutQueue >= 1 then
|
|
f24_local1 = table.remove( f24_local0.layoutQueue, 1 )
|
|
elseif f24_local0.layout then
|
|
f24_local1 = f24_local0.layout
|
|
end
|
|
local f24_local5
|
|
if f24_local1 then
|
|
f24_local5 = motdLayouts[f24_local1].title
|
|
if not f24_local5 then
|
|
f24_local5 = f24_local0.title
|
|
if not f24_local5 then
|
|
f24_local5 = ""
|
|
end
|
|
end
|
|
else
|
|
f24_local5 = f24_local0.title
|
|
if not f24_local5 then
|
|
f24_local5 = ""
|
|
end
|
|
end
|
|
local f24_local6
|
|
if f24_local1 then
|
|
f24_local6 = motdLayouts[f24_local1].message
|
|
if not f24_local6 then
|
|
f24_local6 = f24_local0.message
|
|
if not f24_local6 then
|
|
f24_local6 = ""
|
|
end
|
|
end
|
|
else
|
|
f24_local6 = f24_local0.message
|
|
if not f24_local6 then
|
|
f24_local6 = ""
|
|
end
|
|
end
|
|
local f24_local7
|
|
if f24_local1 then
|
|
f24_local7 = motdLayouts[f24_local1].image
|
|
if not f24_local7 then
|
|
f24_local7 = f24_local0.image
|
|
if not f24_local7 then
|
|
f24_local7 = "white"
|
|
end
|
|
end
|
|
else
|
|
f24_local7 = f24_local0.image
|
|
if not f24_local7 then
|
|
f24_local7 = "white"
|
|
end
|
|
end
|
|
if type( f24_local6 ) == "function" then
|
|
f24_local6 = motdLayouts[f24_local1].message()
|
|
end
|
|
local self = LUI.UIElement.new()
|
|
self.id = "the_root_id"
|
|
self:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0
|
|
} )
|
|
self:animateToState( "default" )
|
|
local f24_local9 = LUI.UIImage.new()
|
|
f24_local9.id = "dimOverlay_id"
|
|
f24_local9:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0,
|
|
material = RegisterMaterial( "white" ),
|
|
red = 0.1,
|
|
green = 0.14,
|
|
blue = 0.16,
|
|
alpha = 0
|
|
} )
|
|
f24_local9:registerAnimationState( "visible", {
|
|
alpha = 0.85
|
|
} )
|
|
f24_local9:animateToState( "default" )
|
|
f24_local9:animateToState( "visible", MOTD_ANIM_TIME_MS )
|
|
self:addElement( f24_local9 )
|
|
local f24_local10 = LUI.UIElement.new()
|
|
f24_local10.id = "motd_root"
|
|
f24_local10.properties = {
|
|
layoutQueue = f24_local0.layoutQueue,
|
|
layout = f24_local1
|
|
}
|
|
f24_local10:registerAnimationState( "default0", {
|
|
leftAnchor = false,
|
|
rightAnchor = false,
|
|
topAnchor = false,
|
|
bottomAnchor = false,
|
|
left = -MOTD_WIDTH / 2,
|
|
right = MOTD_WIDTH / 2,
|
|
top = -MOTD_HEIGHT / 2,
|
|
bottom = MOTD_HEIGHT / 2,
|
|
alpha = 0
|
|
} )
|
|
f24_local10:registerAnimationState( "visible", {
|
|
leftAnchor = false,
|
|
rightAnchor = false,
|
|
topAnchor = false,
|
|
bottomAnchor = false,
|
|
left = -MOTD_WIDTH / 2,
|
|
right = MOTD_WIDTH / 2,
|
|
top = -MOTD_HEIGHT / 2,
|
|
bottom = MOTD_HEIGHT / 2,
|
|
alpha = 1
|
|
} )
|
|
f24_local10:registerAnimationState( "exit", {
|
|
alpha = 0
|
|
} )
|
|
f24_local10:registerEventHandler( "motd_continue", motdContinueFunc )
|
|
f24_local10:registerEventHandler( "menu_create", MBh.AnimateToState( "visible", MOTD_ANIM_TIME_MS ) )
|
|
f24_local10:registerEventHandler( "exit_transition", MBh.AnimateToStateWithEvent( "exit", MOTD_ANIM_TIME_MS ) )
|
|
f24_local10:registerEventHandler( "transition_complete_exit", MBh.LeaveMenu() )
|
|
f24_local10:animateToState( "default0" )
|
|
self:addElement( f24_local10 )
|
|
local f24_local11 = LUI.MenuGenerics.generic_drop_shadow( nil, {
|
|
offset_shadow = 0,
|
|
alpha = 0.35
|
|
} )
|
|
f24_local11.id = "motd_root_ds"
|
|
f24_local10:addElement( f24_local11 )
|
|
local f24_local12 = LUI.MenuGenerics.generic_menu_titlebar( nil, {
|
|
title_bar_text = f24_local5,
|
|
fill_alpha = 1
|
|
} )
|
|
f24_local12.id = "motd_title_bar"
|
|
f24_local10:addElement( f24_local12 )
|
|
local f24_local13 = LUI.MenuGenerics.generic_menu_background( nil, {
|
|
fill_alpha = 1
|
|
} )
|
|
f24_local13.id = "bkg1_id"
|
|
f24_local10:addElement( f24_local13 )
|
|
local f24_local14 = motd_default_view_element( f24_local6, f24_local7 )
|
|
f24_local14.id = "motd_default_view_id"
|
|
f24_local10:addElement( f24_local14 )
|
|
local f24_local15 = motd_vote_view_element( f24_local6 )
|
|
f24_local15.id = "motd_vote_view_id"
|
|
f24_local10:addElement( f24_local15 )
|
|
if Engine.IsConsoleGame() then
|
|
local f24_local16 = LUI.UIButton.new()
|
|
f24_local16.id = "continuebutton_id"
|
|
f24_local16:registerAnimationState( "default", {
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
left = 0,
|
|
right = 0,
|
|
top = 0,
|
|
bottom = 0
|
|
} )
|
|
f24_local16:registerEventHandler( "button_action", function ( element, event )
|
|
element:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
controller = event.controller,
|
|
upsellEvent = MOTD_UPSELL_MENU_CONTINUE_EVENT
|
|
} )
|
|
end )
|
|
f24_local16:animateToState( "default" )
|
|
f24_local10:addElement( f24_local16 )
|
|
end
|
|
LUI.MenuBuilder.BuildAddChild( f24_local10, {
|
|
type = "UIElement",
|
|
id = "help_padding",
|
|
states = {
|
|
default = {
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
left = 1,
|
|
right = -1,
|
|
top = 0,
|
|
bottom = -1
|
|
}
|
|
},
|
|
children = {
|
|
{
|
|
type = "button_helper_text_main",
|
|
id = "help_texts",
|
|
properties = {
|
|
left_inset = 10,
|
|
top_margin = GenericFooterDims.TopMargin_WithoutBackground,
|
|
background_alpha = 0,
|
|
hideAlienBar = true
|
|
},
|
|
handlers = {
|
|
menu_create = function ( f26_arg0, f26_arg1 )
|
|
local f26_local0 = Engine.Localize( "@MENU_CONTINUE" )
|
|
if motdLayouts[f24_local1] and motdLayouts[f24_local1].button_action_text then
|
|
f26_local0 = motdLayouts[f24_local1].button_action_text
|
|
end
|
|
UpdateActionText( f26_arg0, f26_local0 )
|
|
if motdLayouts[f24_local1] and motdLayouts[f24_local1].additional_buttons then
|
|
UpdateAdditionalButtons( f26_arg0, motdLayouts[f24_local1].additional_buttons )
|
|
end
|
|
end
|
|
}
|
|
}
|
|
}
|
|
} )
|
|
local f24_local16 = LUI.UIImage.new()
|
|
f24_local16.id = "horizontal_line_id"
|
|
f24_local16:registerAnimationState( "default", {
|
|
material = RegisterMaterial( "white" ),
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
left = 1,
|
|
right = -1,
|
|
top = MOTD_HEIGHT - 43,
|
|
bottom = MOTD_HEIGHT - 42,
|
|
red = Colors.generic_button_border_color.r,
|
|
green = Colors.generic_button_border_color.g,
|
|
blue = Colors.generic_button_border_color.b,
|
|
alpha = 1
|
|
} )
|
|
f24_local16:animateToState( "default" )
|
|
f24_local10:addElement( f24_local16 )
|
|
local f24_local17 = LUI.UIBindButton.new()
|
|
f24_local17.id = "back"
|
|
f24_local17:registerEventHandler( "update_button_handler", function ( element, event )
|
|
if event.eventAction and event.newHandler then
|
|
f24_local17:registerEventHandler( event.eventAction, event.newHandler )
|
|
end
|
|
end )
|
|
if not Engine.IsConsoleGame() then
|
|
f24_local17:registerEventHandler( "button_secondary", function ( element, event )
|
|
element:dispatchEventToParent( {
|
|
name = "motd_continue",
|
|
controller = event.controller
|
|
} )
|
|
end )
|
|
end
|
|
f24_local10:addElement( f24_local17 )
|
|
return self
|
|
end
|
|
|
|
function motd_default_view_element( menu, controller )
|
|
local self = LUI.UIElement.new()
|
|
self.id = "motd_default_view_root_id"
|
|
self:registerAnimationState( "default", {
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0,
|
|
alpha = 1
|
|
} )
|
|
self:registerAnimationState( "hidden", {
|
|
alpha = 0
|
|
} )
|
|
self:animateToState( "default" )
|
|
self:registerEventHandler( "update_layout_type", function ( element, event )
|
|
local f30_local0 = element
|
|
local f30_local1 = element.animateToState
|
|
local f30_local2 = event.layout_type
|
|
local f30_local3 = MOTDLayoutType.DEFAULT
|
|
f30_local1( f30_local0, REG6 and "default" or "hidden", 0 )
|
|
end )
|
|
local f29_local1 = LUI.UIText.new()
|
|
f29_local1.id = "motdMessageText_id"
|
|
f29_local1:registerAnimationState( "default", {
|
|
alignment = LUI.Alignment.Left,
|
|
font = CoD.TextSettings.NormalFont.Font,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
left = MOTD_TEXT_LEFT_INTENT,
|
|
right = MOTD_TEXT_LEFT_INTENT + MOTD_TEXT_WIDTH,
|
|
top = MOTD_TEXT_TOP_INDENT,
|
|
bottom = MOTD_TEXT_TOP_INDENT + CoD.TextSettings.NormalFont.Height
|
|
} )
|
|
f29_local1:registerEventHandler( "motd_update_message", function ( element, event )
|
|
if event.message then
|
|
element:setText( event.message )
|
|
end
|
|
end )
|
|
f29_local1:setText( menu )
|
|
f29_local1:animateToState( "default" )
|
|
self:addElement( f29_local1 )
|
|
local f29_local2 = LUI.UIElement.new()
|
|
f29_local2.id = "image_layout_container_id"
|
|
f29_local2:registerAnimationState( "default", {
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
left = MOTD_IMAGE_LEFT_INDENT,
|
|
top = MOTD_IMAGE_TOP_INDENT,
|
|
height = MOTD_IMAGE_SIZE + 2,
|
|
width = MOTD_IMAGE_SIZE + 2
|
|
} )
|
|
f29_local2:animateToState( "default" )
|
|
self:addElement( f29_local2 )
|
|
local f29_local3 = LUI.MenuGenerics.generic_drop_shadow( nil, {
|
|
offset_shadow = -3
|
|
} )
|
|
f29_local2.id = "motd_image_ds"
|
|
f29_local2:addElement( f29_local3 )
|
|
local f29_local4 = LUI.UIImage.new()
|
|
f29_local4.id = "motd_image_border"
|
|
f29_local4:registerAnimationState( "default", CoD.ColorizeState( Colors.generic_button_border_color, {
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0,
|
|
material = RegisterMaterial( "white" )
|
|
} ) )
|
|
f29_local4:animateToState( "default" )
|
|
f29_local2:addElement( f29_local4 )
|
|
local f29_local5 = LUI.UIImage.new()
|
|
f29_local5.id = "custom_image_id"
|
|
f29_local5:registerAnimationState( "default", {
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
left = 1,
|
|
right = -1,
|
|
top = 1,
|
|
bottom = -1,
|
|
alpha = 1
|
|
} )
|
|
f29_local5:registerAnimationState( "hidden", {
|
|
alpha = 0
|
|
} )
|
|
f29_local5:registerEventHandler( "show_custom_image", function ( element, event )
|
|
element:animateToState( "default" )
|
|
if event.image then
|
|
element:setImage( RegisterMaterial( event.image ) )
|
|
end
|
|
end )
|
|
f29_local5:registerEventHandler( "show_iotd_image", function ( element, event )
|
|
element:animateToState( "hidden" )
|
|
end )
|
|
if controller == "iotd_image" then
|
|
f29_local5:animateToState( "hidden" )
|
|
else
|
|
f29_local5:animateToState( "default" )
|
|
f29_local5:setImage( RegisterMaterial( controller ) )
|
|
end
|
|
f29_local2:addElement( f29_local5 )
|
|
local f29_local6 = LUI.MenuBuilder.BuildAddChild( f29_local4, {
|
|
type = "UIOwnerdraw",
|
|
id = "motd_iotd_id",
|
|
properties = {
|
|
ownerDraw = CoD.Ownerdraw.UIIOTD
|
|
},
|
|
states = {
|
|
default = {
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
left = 1,
|
|
right = -1,
|
|
top = 1,
|
|
bottom = -1,
|
|
alpha = 1
|
|
},
|
|
hidden = {
|
|
alpha = 0
|
|
}
|
|
},
|
|
handlers = {
|
|
show_iotd_image = MBh.AnimateToState( "default" ),
|
|
show_custom_image = MBh.AnimateToState( "hidden" )
|
|
}
|
|
} )
|
|
if controller ~= "iotd_image" then
|
|
f29_local6:animateToState( "hidden" )
|
|
end
|
|
local f29_local7 = LUI.UIImage.new()
|
|
f29_local7.id = "vertLine_line_id"
|
|
f29_local7:registerAnimationState( "default", {
|
|
material = RegisterMaterial( "white" ),
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
left = 446,
|
|
right = 447,
|
|
top = 90,
|
|
bottom = -160,
|
|
red = Colors.generic_button_border_color.r,
|
|
green = Colors.generic_button_border_color.g,
|
|
blue = Colors.generic_button_border_color.b,
|
|
alpha = 1
|
|
} )
|
|
f29_local7:animateToState( "default" )
|
|
self:addElement( f29_local7 )
|
|
return self
|
|
end
|
|
|
|
function motd_vote_view_element( f34_arg0 )
|
|
local f34_local0 = CoD.CreateState( 0, 0, 0, 0, CoD.AnchorTypes.All )
|
|
f34_local0.alpha = 0
|
|
local self = LUI.UIElement.new( f34_local0 )
|
|
self.id = "motd_vote_view_root_id"
|
|
f34_local0.alpha = 1
|
|
self:registerAnimationState( "visible", f34_local0 )
|
|
self:registerEventHandler( "update_layout_type", function ( element, event )
|
|
local f35_local0 = element
|
|
local f35_local1 = element.animateToState
|
|
local f35_local2 = event.layout_type
|
|
local f35_local3 = MOTDLayoutType.VOTING
|
|
f35_local1( f35_local0, REG6 and "visible" or "default", 0 )
|
|
end )
|
|
f34_local0 = CoD.CreateState( 10, 40, -10, 40 + CoD.TextSettings.NormalFont.Height, CoD.AnchorTypes.TopLeftRight )
|
|
CoD.ColorizeState( Colors.primary_text_color, f34_local0 )
|
|
f34_local0.alignment = LUI.Alignment.Center
|
|
f34_local0.font = CoD.TextSettings.NormalFont.Font
|
|
local f34_local2 = LUI.UIText.new( f34_local0 )
|
|
f34_local2.id = "motd_vote_view_header_text_id"
|
|
f34_local2:setText( f34_arg0 )
|
|
f34_local2:registerEventHandler( "motd_update_message", function ( element, event )
|
|
if event.message then
|
|
element:setText( event.message )
|
|
end
|
|
end )
|
|
self:addElement( f34_local2 )
|
|
self:addElement( VotingItemFactory( 0, "motd_vote_item_1", 82, 226 ) )
|
|
self:addElement( VotingItemFactory( 1, "motd_vote_item_2", 326, 75 ) )
|
|
self:addElement( VotingItemFactory( 2, "motd_vote_item_3", 570, 226 ) )
|
|
self:addElement( VotingItemFactory( 3, "motd_vote_item_4", 326, 375 ) )
|
|
local f34_local3 = 32
|
|
local f34_local4 = f34_local3 / 2
|
|
f34_local0 = CoD.CreateState( 414, 273, 478, 337, CoD.AnchorTypes.TopLeft )
|
|
f34_local0.material = RegisterMaterial( "alien_cash_dpad" )
|
|
local f34_local5 = LUI.UIImage.new( f34_local0 )
|
|
f34_local5.id = "motd_vote_view_dpad_id"
|
|
self:addElement( f34_local5 )
|
|
f34_local0 = CoD.CreateState( -f34_local3, -f34_local4, 0, f34_local4, CoD.AnchorTypes.Left )
|
|
f34_local0.material = RegisterMaterial( "cont_arrow_lt" )
|
|
local f34_local6 = LUI.UIImage.new( f34_local0 )
|
|
f34_local6.id = "motd_vote_view_left_arrow_id"
|
|
f34_local5:addElement( f34_local6 )
|
|
f34_local0 = CoD.CreateState( 0, -f34_local4, f34_local3, f34_local4, CoD.AnchorTypes.Right )
|
|
f34_local0.material = RegisterMaterial( "cont_arrow_rt" )
|
|
local f34_local7 = LUI.UIImage.new( f34_local0 )
|
|
f34_local7.id = "motd_vote_view_right_arrow_id"
|
|
f34_local5:addElement( f34_local7 )
|
|
f34_local0 = CoD.CreateState( -f34_local4, -f34_local3, f34_local4, 0, CoD.AnchorTypes.Top )
|
|
f34_local0.material = RegisterMaterial( "cont_arrow_up" )
|
|
local f34_local8 = LUI.UIImage.new( f34_local0 )
|
|
f34_local8.id = "motd_vote_view_up_arrow_id"
|
|
f34_local5:addElement( f34_local8 )
|
|
f34_local0 = CoD.CreateState( -f34_local4, 0, f34_local4, f34_local3, CoD.AnchorTypes.Bottom )
|
|
f34_local0.material = RegisterMaterial( "cont_arrow_down" )
|
|
local f34_local9 = LUI.UIImage.new( f34_local0 )
|
|
f34_local9.id = "motd_vote_view_down_arrow_id"
|
|
f34_local5:addElement( f34_local9 )
|
|
return self
|
|
end
|
|
|
|
function VotingItemFactory( f37_arg0, f37_arg1, f37_arg2, f37_arg3 )
|
|
local f37_local0 = 220
|
|
local f37_local1 = 124
|
|
local f37_local2 = 10
|
|
local f37_local3 = 8
|
|
local self = LUI.UIElement.new( CoD.CreateState( f37_arg2, f37_arg3, f37_arg2 + f37_local0 + f37_local2 * 2, f37_arg3 + 160, CoD.AnchorTypes.TopLeft ) )
|
|
self.id = f37_arg1
|
|
self:registerEventHandler( "check_vote_image_download_status", function ( element, event )
|
|
local f38_local0 = Engine.GetVoteItemFileID( GetActiveVoteIndex(), f37_arg0 )
|
|
if IsVoteImageDownloaded( f38_local0 ) then
|
|
if element.loadingWidget then
|
|
element.loadingWidget:close()
|
|
end
|
|
element.loadingWidget = nil
|
|
if element.timerElem then
|
|
element.timerElem:close()
|
|
end
|
|
element.timerElem = nil
|
|
if element.image then
|
|
element.image:setImage( Engine.GetVoteImageHandle( f38_local0 ) )
|
|
element.image:animateToState( "visible", 0 )
|
|
end
|
|
end
|
|
end )
|
|
local f37_local5 = CoD.CreateState( 0, f37_local3, 0, f37_local3 + CoD.TextSettings.BoldFont.Height, CoD.AnchorTypes.TopLeftRight )
|
|
f37_local5.alignment = LUI.Alignment.Center
|
|
f37_local5.font = CoD.TextSettings.BoldFont.Font
|
|
local f37_local6 = LUI.UIText.new( f37_local5 )
|
|
f37_local6.id = "voting_item_header_id"
|
|
f37_local6:setText( GetVotingItemHeader( f37_arg0 ) )
|
|
self:addElement( f37_local6 )
|
|
f37_local5 = CoD.CreateState( -f37_local0 / 2, -f37_local1 - f37_local3, f37_local0 / 2, -f37_local3, CoD.AnchorTypes.Bottom )
|
|
f37_local5.alpha = 0
|
|
self.image = LUI.UIImage.new( f37_local5 )
|
|
self.image:registerAnimationState( "visible", {
|
|
alpha = 1
|
|
} )
|
|
self.image.id = "voting_item_image_id"
|
|
self:addElement( self.image )
|
|
self.loadingWidget = LUI.MenuBuilder.buildItems( {
|
|
type = "generic_loading_widget",
|
|
id = "voting_item_loading_id",
|
|
states = {
|
|
default = {
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0
|
|
}
|
|
}
|
|
}, {}, image )
|
|
self:addElement( self.loadingWidget )
|
|
self.timerElem = LUI.UITimer.new( 500, "check_vote_image_download_status", "voting_image_timer", false, self )
|
|
self.timerElem.id = "voting_item_timer_id"
|
|
self:addElement( self.timerElem )
|
|
return self
|
|
end
|
|
|
|
LUI.MenuBuilder.registerType( "motd_main", motd_main )
|
|
LockTable( _M )
|