local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( "Registering " .. _NAME ) CommonEvents = { addBackButton = { name = "add_button_helper_text", button_ref = "button_secondary", helper_text = Engine.Localize( "@LUA_MENU_BACK" ), side = "left", clickable = true, priority = -1000 }, addActionButton = { name = "add_button_helper_text", button_ref = "button_action", helper_text = Engine.Localize( "@MENU_CONTINUE" ), side = "left", clickable = true, priority = -1000 }, addFriendsButton = { name = "add_button_helper_text", button_ref = "button_alt2", helper_text = Engine.Localize( "@LUA_MENU_FRIENDS" ), side = "right", clickable = true, width = 190, priority = -1000 }, removeFriendsButton = { name = "add_button_helper_text", button_ref = "button_alt2", helper_text = "" }, addGameSummaryButton = { name = "add_button_helper_text", button_ref = "button_select", helper_text = Engine.Localize( "@LUA_MENU_MATCH_SUMMARY" ), side = "left", clickable = true }, addAcceptButton = { name = "add_button_helper_text", button_ref = "button_alt1", helper_text = Engine.Localize( "@LUA_MENU_ACCEPT" ), side = "left", clickable = true, priority = -1000 }, addDeclineButton = { name = "add_button_helper_text", button_ref = "button_secondary", helper_text = Engine.Localize( "@LUA_MENU_DECLINE" ), side = "left", clickable = true, priority = -1000 }, addLeftButton = { name = "add_button_helper_text", button_ref = "button_shoulderl", helper_text = Engine.Localize( "@LUA_MENU_PREV_PAGE" ), side = "left", clickable = true, priority = -1000 }, addRightButton = { name = "add_button_helper_text", button_ref = "button_shoulderr", helper_text = Engine.Localize( "@LUA_MENU_NEXT_PAGE" ), side = "left", clickable = true, priority = -1000 } } function AddHelperTextObject( f1_arg0, f1_arg1 ) assert( f1_arg1.button_ref ) assert( f1_arg1.helper_text ) local f1_local0 = nil if f1_arg1.side and f1_arg1.side == "left" then f1_local0 = f1_arg0:getChildById( "left_button_helper_list_id" ) else f1_local0 = f1_arg0:getChildById( "right_button_helper_list_id" ) end assert( f1_local0 ) local f1_local1 = f1_arg1.button_ref .. "_id" local f1_local2 = f1_local0:getChildById( f1_local1 ) if f1_local2 and f1_arg1.helper_text ~= f1_local2.currentText then f1_local2:close() f1_local2 = nil end if not f1_local2 and f1_arg1.helper_text ~= "" then local f1_local3 = helper_text_item( ButtonMap[f1_arg1.button_ref], f1_arg1.helper_text, f1_arg1.button_ref2 and ButtonMap[f1_arg1.button_ref2] or nil, f1_arg1.width, f1_arg1.priority, f1_arg1.ignorePopups or false, f1_arg1.customEvent or nil, f1_arg1.customEventTarget or nil, f1_arg1.useAnimIntro or nil, f1_arg1.flash or nil ) f1_local3.id = f1_local1 if f1_arg1.clickable == true and ButtonMap[f1_arg1.button_ref] then f1_local3.triggers_event = f1_arg1.button_ref end if Engine.IsConsoleGame() then f1_local3:makeNotFocusable() end f1_local0:addElement( f1_local3 ) end return true end function ClearHelperTextObjects( f2_arg0, f2_arg1 ) if not f2_arg1.side then DebugPrint( "WARNING: clear_button_helper_text event sent without specifying the desired side. Ignoring..." ) return end local f2_local0 = nil if f2_arg1.side == "left" then f2_local0 = f2_arg0:getChildById( "left_button_helper_list_id" ) else f2_local0 = f2_arg0:getChildById( "right_button_helper_list_id" ) end assert( f2_local0 ) f2_local0:closeChildren() return true end function sendButtonEvent( f3_arg0, f3_arg1 ) if f3_arg0.triggers_event and f3_arg1.mouse == true then local f3_local0 = { name = "gamepad_button", immediate = true, down = true } assert( ButtonMap[f3_arg0.triggers_event].raw_button ) f3_local0.button = ButtonMap[f3_arg0.triggers_event].raw_button f3_local0.controller = f3_arg1.controller f3_arg0:dispatchEventToRoot( f3_local0 ) end end function sendCustomEvent( f4_arg0, f4_arg1 ) customEvent = f4_arg1.customEvent eventTarget = f4_arg1.eventTarget eventTarget:processEvent( customEvent ) end function getButtonPosition( f5_arg0, f5_arg1, f5_arg2 ) local f5_local0 = Engine.IsConsoleGame() if not f5_local0 then f5_local0 = Engine.IsGamepadEnabled() == 1 end local f5_local1 if f5_local0 then f5_local1 = 32 if not f5_local1 then else local f5_local2, f5_local3 = nil if f5_arg0 then if f5_local0 and f5_arg0.string then f5_local2 = Engine.Localize( f5_arg0.string ) .. " " if f5_arg1 and f5_arg1.string then f5_local3 = " " .. Engine.Localize( f5_arg1.string ) end elseif f5_arg0.keyboard_string then f5_local2 = Engine.Localize( f5_arg0.keyboard_string ) .. " " if f5_arg1 and f5_arg1.keyboard_string then f5_local3 = " " .. Engine.Localize( f5_arg1.keyboard_string ) end end end return f5_local2, f5_local3, f5_local1 end end f5_local1 = f5_arg2.Height end function getButtonWidth( f6_arg0, f6_arg1, f6_arg2, f6_arg3, f6_arg4, f6_arg5, f6_arg6, f6_arg7 ) local f6_local0 = f6_arg7 local f6_local1 = 0 local f6_local2 = 0 local f6_local3 = 0 local f6_local4, f6_local5, f6_local6, f6_local7 = nil if f6_arg0 then local f6_local8, f6_local9, f6_local10, f6_local11 = GetTextDimensions( f6_arg3, f6_arg6.Font, f6_arg5 ) f6_local7 = f6_local11 f6_local6 = f6_local10 f6_local5 = f6_local9 f6_local1 = f6_local6 - f6_local8 end local f6_local8, f6_local9, f6_local10, f6_local11 = GetTextDimensions( f6_arg2, f6_arg6.Font, f6_arg6.Height ) f6_local7 = f6_local11 f6_local6 = f6_local10 f6_local5 = f6_local9 f6_local3 = f6_local6 - f6_local8 if f6_arg1 then f6_local8, f6_local9, f6_local10, f6_local11 = GetTextDimensions( f6_arg4, f6_arg6.Font, f6_arg5 ) f6_local7 = f6_local11 f6_local6 = f6_local10 f6_local5 = f6_local9 f6_local2 = f6_local6 - f6_local8 end if not f6_arg7 then f6_local0 = 20 + f6_local1 + f6_local3 + f6_local2 end return f6_local0, f6_local1, f6_local2, f6_local3 end function helper_text_item( f7_arg0, f7_arg1, f7_arg2, f7_arg3, f7_arg4, f7_arg5, f7_arg6, f7_arg7, f7_arg8, f7_arg9 ) local f7_local0 = CoD.TextSettings.SmallFont local f7_local1, f7_local2, f7_local3 = getButtonPosition( f7_arg0, f7_arg2, f7_local0 ) local f7_local4, f7_local5, f7_local6, f7_local7 = getButtonWidth( f7_arg0, f7_arg2, f7_arg1, f7_local1, f7_local2, f7_local3, f7_local0, f7_arg3 ) local self = LUI.UIButton.new() self.id = "helper_text_item" self:registerAnimationState( "default", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = f7_local4, top = 0, bottom = 0 } ) self:animateToState( "default" ) self.m_disableNavigation = true self.m_requireFocusType = FocusType.MouseOver if f7_arg6 then assert( f7_arg7 ) self:registerEventHandler( "button_action", function ( element, event ) f7_arg7:processEvent( f7_arg6 ) end ) else self:registerEventHandler( "button_action", sendButtonEvent ) end self:registerEventHandler( "rebind", function ( element, event ) if event.buttonLeft and event.buttonLeft == f7_arg0 then element.m_ignoreMouseFocus = nil end end ) self:registerEventHandler( "refresh_button_helper", function ( element, event ) local f10_local0, f10_local1, f10_local2 = getButtonPosition( f7_arg0, f7_arg2, f7_local0 ) local f10_local3 = getButtonWidth( f7_arg0, f7_arg2, f7_arg1, f10_local0, f10_local1, f10_local2, f7_local0, f7_arg3 ) element:registerAnimationState( "refreshed", { leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = true, left = 0, right = f7_local4, top = 0, bottom = 0 } ) element:animateToState( "refreshed" ) end ) if f7_arg5 then self:registerEventHandler( "popup_active", nil ) self:registerEventHandler( "popup_inactive", nil ) end if f7_local1 then local f7_local9 = LUI.UIText.new() f7_local9.id = "left" f7_local9:setText( f7_local1 ) f7_local9:registerAnimationState( "default", CoD.ColorizeState( Colors.frontend_hilite, { font = f7_local0.Font, alignment = LUI.Alignment.Left, topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = 0, right = 0, top = -f7_local3 / 2, bottom = f7_local3 / 2 } ) ) f7_local9:animateToState( "default" ) f7_local9:registerEventHandler( "refresh_button_helper", function ( element, event ) local f11_local0, f11_local1, f11_local2 = getButtonPosition( f7_arg0, f7_arg2, f7_local0 ) element:setText( f11_local0 ) element:registerAnimationState( "default", CoD.ColorizeState( Colors.frontend_hilite, { font = f7_local0.Font, alignment = LUI.Alignment.Left, topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = 0, right = 0, top = -f11_local2 / 2, bottom = f11_local2 / 2 } ) ) element:animateToState( "default" ) end ) self:addElement( f7_local9 ) end local f7_local9 = LUI.UIText.new() f7_local9.properties = {} f7_local9.id = "helper_text_text" f7_local9:setText( f7_arg1 ) f7_local9:registerAnimationState( "default", CoD.ColorizeState( Colors.cac_label_text, { topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = f7_local5, right = 0, top = -f7_local0.Height / 2, bottom = f7_local0.Height / 2, font = f7_local0.Font, alignment = LUI.Alignment.Left } ) ) f7_local9:registerAnimationState( "anim_intro", CoD.ColorizeState( Colors.cac_label_text, { topAnchor = false, bottomAnchor = false, leftAnchor = false, rightAnchor = false, left = 0, right = 0, top = 0, bottom = 0, font = f7_local0.Font, alignment = LUI.Alignment.Left } ) ) f7_local9:registerAnimationState( "over", CoD.ColorizeState( Colors.white ) ) f7_local9.properties.animLoop = MBh.AnimateLoop( { { "default", 500 }, { "flash", 500 } } ) if f7_arg8 then f7_local9:animateToState( "anim_intro" ) else f7_local9:animateToState( "default" ) end if f7_arg9 then f7_local9:registerAnimationState( "flash", CoD.ColorizeState( Colors.frontend_hilite ) ) f7_local9.properties:animLoop() end local f7_local10 = f7_local9 local f7_local11 = f7_local9.registerEventHandler local f7_local12 = "button_up" local f7_local13 if f7_arg9 then f7_local13 = f7_local9.properties.animLoop if not f7_local13 then else f7_local11( f7_local10, f7_local12, f7_local13 ) f7_local9:registerEventHandler( "button_over", MBh.AnimateToState( "over" ) ) f7_local9:registerEventHandler( "refresh_button_helper", function ( element, event ) local f12_local0, f12_local1, f12_local2 = getButtonPosition( f7_arg0, f7_arg2, f7_local0 ) local f12_local3, f12_local4 = getButtonWidth( f7_arg0, f7_arg2, f7_arg1, f12_local0, f12_local1, f12_local2, f7_local0, f7_arg3 ) element:registerAnimationState( "default", CoD.ColorizeState( Colors.cac_label_text, { topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = f12_local4, right = 0, top = -f7_local0.Height / 2, bottom = f7_local0.Height / 2, font = f7_local0.Font, alignment = LUI.Alignment.Left } ) ) element:animateToState( "default" ) end ) self.currentText = f7_arg1 self:addElement( f7_local9 ) if f7_local2 then f7_local11 = LUI.UIText.new() f7_local11.id = "right" f7_local11:setText( f7_local2 ) f7_local11:registerAnimationState( "default", CoD.ColorizeState( Colors.frontend_hilite, { font = f7_local0.Font, alignment = LUI.Alignment.Left, topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = f7_local5 + f7_local7, right = 0, top = -f7_local3 / 2, bottom = f7_local3 / 2 } ) ) f7_local11:registerEventHandler( "refresh_button_helper", function ( element, event ) local f13_local0, f13_local1, f13_local2 = getButtonPosition( f7_arg0, f7_arg2, f7_local0 ) local f13_local3, f13_local4 = getButtonWidth( f7_arg0, f7_arg2, f7_arg1, f13_local0, f13_local1, f13_local2, f7_local0, f7_arg3 ) element:registerAnimationState( "default", CoD.ColorizeState( Colors.frontend_hilite, { font = f7_local0.Font, alignment = LUI.Alignment.Left, topAnchor = false, bottomAnchor = false, leftAnchor = true, rightAnchor = true, left = f13_local4 + f7_local7, right = 0, top = -f13_local2 / 2, bottom = f13_local2 / 2 } ) ) element:animateToState( "default" ) end ) f7_local11:animateToState( "default" ) self:addElement( f7_local11 ) end if f7_arg4 then self:setPriority( f7_arg4 ) end return self end end f7_local13 = MBh.AnimateToState( "default" ) end function button_helper_text_main() return { type = "UIElement", id = "button_helper_text_main_id", properties = { left_inset = 100, right_inset = -75, top_margin = GenericFooterDims.TopMargin_WithBackground, bottom_margin = -35, height = GenericFooterDims.Height, spacing = 12, background_alpha = 1, hideAlienBar = false }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = false, bottomAnchor = true, left = 0, right = 0, top = MBh.Property( "top_margin" ), bottom = 0, alpha = 1 }, hidden = { alpha = 0 } }, handlers = { show_button_helper_text = MBh.AnimateToState( "default" ), hide_button_helper_text = MBh.AnimateToState( "hidden" ) }, children = { { type = "UIImage", id = "black_bar", states = { default = { leftAnchor = true, topAnchor = false, rightAnchor = true, bottomAnchor = true, left = 0, top = 0, right = 0, height = 300, red = 0, green = 0, blue = 0, alpha = MBh.Property( "background_alpha" ), material = RegisterMaterial( "white" ) } } }, { type = "UIImage", id = "button_helper_background_id", properties = { background_alpha = MBh.Property( "background_alpha" ) }, states = { default = { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = true, top = -25, height = 128, left = 0, right = 0, material = RegisterMaterial( "bkgd_title_bar" ), zRot = 180, alpha = MBh.Property( "background_alpha" ) } } }, { type = "UIImage", id = "button_helper_background_alien_id", properties = { hideAlienBar = MBh.Property( "hideAlienBar" ), background_alpha = MBh.Property( "background_alpha" ) }, states = { default = { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = true, top = -8, bottom = 22, left = 0, right = 0, material = Engine.IsAliensMode() and RegisterMaterial( "box_alien_header_footer" ) or RegisterMaterial( "white" ), alpha = 0 }, show = { alpha = MBh.Property( "background_alpha" ) } }, handlers = { menu_create = function ( f15_arg0, f15_arg1 ) if Engine.IsAliensMode() and not f15_arg0.properties.hideAlienBar then f15_arg0:animateToState( "show", 0 ) end end } }, { type = "UIText", id = "build_number_text", properties = { text = Engine.GetBuildNumber(), background_alpha = MBh.Property( "background_alpha" ) }, states = { default = CoD.ColorizeState( Colors.build_number, { leftAnchor = false, rightAnchor = true, topAnchor = false, bottomAnchor = true, left = 0, right = -70, bottom = -22, height = CoD.TextSettings.TinyFont.Height, font = CoD.TextSettings.TinyFont.Font, alignment = LUI.Alignment.Right, alpha = 0 } ), visible = { alpha = MBh.Property( "background_alpha" ) } }, handlers = { menu_create = function ( f16_arg0, f16_arg1 ) if Engine.InFrontend() and Engine.IsMultiplayer() then f16_arg0:animateToState( "visible" ) end end } }, { type = "UIText", id = "ds_text", properties = { text = "", background_alpha = MBh.Property( "background_alpha" ) }, states = { default = CoD.ColorizeState( Colors.build_number, { leftAnchor = false, rightAnchor = true, topAnchor = false, bottomAnchor = true, left = 0, right = -70, bottom = -10, height = CoD.TextSettings.TinyFont.Height, font = CoD.TextSettings.TinyFont.Font, alignment = LUI.Alignment.Right, alpha = 0 } ), visible = { alpha = MBh.Property( "background_alpha" ) } }, handlers = { menu_create = MBh.EmitEvent( "update_ds_text" ), update_ds_text = function ( f17_arg0, f17_arg1 ) if Engine.GetDvarBool( "ds_info_enable" ) then f17_arg0:animateToState( "visible" ) f17_arg0:setText( Engine.GetDvarString( "ds_info" ) or "" ) else f17_arg0:animateToState( "default" ) end end }, children = { { type = "UITimer", id = "ds_text_refresh_timer", properties = { event = { name = "update_ds_text" }, interval = 1000 } } } }, { type = "UIElement", id = "container", properties = { height = MBh.Property( "height" ), spacing = MBh.Property( "spacing" ), left_inset = MBh.Property( "left_inset" ), right_inset = MBh.Property( "right_inset" ) }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 0, right = 0, top = 10, height = MBh.Property( "height" ) } }, children = { { type = "UIHorizontalList", id = "left_button_helper_list_id", properties = { spacing = MBh.Property( "spacing" ), left_inset = MBh.Property( "left_inset" ) }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = MBh.Property( "left_inset" ), right = 0, top = 0, bottom = 0, alignment = LUI.Alignment.Left, spacing = MBh.Property( "spacing" ) } } }, { type = "UIHorizontalList", id = "right_button_helper_list_id", properties = { spacing = MBh.Property( "spacing" ), right_inset = MBh.Property( "right_inset" ) }, states = { default = { leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = MBh.Property( "right_inset" ), top = 0, bottom = 0, alignment = LUI.Alignment.Right, spacing = MBh.Property( "spacing" ) } } } }, handlers = { add_button_helper_text = AddHelperTextObject, clear_button_helper_text = ClearHelperTextObjects } } } } end LUI.MenuBuilder.registerDef( "button_helper_text_main", button_helper_text_main ) LockTable( _M )