MatchRules.OpenSelectionMenu = function ( f1_arg0, f1_arg1 ) MatchRules.SelectSaveDevice( f1_arg0 ) if Engine.UserIsGuest( f1_arg0 ) then LUI.FlowManager.RequestPopupMenu( self, "recipe_save_failed_no_guests_popup", false, f1_arg0, false ) elseif not Engine.HasSaveDevice( f1_arg0 ) then LUI.FlowManager.RequestPopupMenu( self, "recipe_save_failed_no_device_popup", false, f1_arg0, false ) else Engine.ExecNow( "incnosplitscreencontrol menu_RECIPE_SELECT" ) LUI.FlowManager.RequestAddMenu( self, "savedmode_select_main", true, f1_arg0, false, f1_arg1 ) end end local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function ModeButtonFeeder( f2_arg0 ) local f2_local0 = {} local f2_local1 = MatchRules.GetSavedModeMax() local f2_local2 = Engine.Localize( "@MPUI_EMPTY" ) for f2_local3 = 0, f2_local1 - 1, 1 do local f2_local6 = MatchRules.GetMetaData( f2_arg0.savedMode, f2_local3, "name" ) local f2_local7 if f2_local6 ~= nil and f2_local6 ~= "" then f2_local7 = false else f2_local7 = true end local f2_local8 = MatchRules.GetMetaData( f2_arg0.savedMode, f2_local3, "rawgametype" ) local f2_local9 = false local f2_local10 = false if SvS.IsSvS() and f2_local8 and not (Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f2_local8, GameTypesTable.Cols.TeamChoice ) == "1") and f2_local8 ~= "horde" then f2_local9 = true end if f2_local7 then f2_local6 = f2_local2 end f2_local10 = f2_local7 or f2_local9 if f2_arg0.savedMode == "save" and f2_arg0.menuAction == "save" then f2_local10 = false end f2_local0[#f2_local0 + 1] = { type = "UIGenericButton", id = "savedmode_" .. f2_local3, disabled = f2_local10, properties = { button_text = f2_local6, button_over_func = MBh.EmitEventToRoot( { name = "update_selection", savedMode = f2_arg0.savedMode, idx = f2_local3, showVaultText = true } ), button_action_func = MBh.EmitEventToRoot( { name = "select_mode", savedMode = f2_arg0.savedMode, idx = f2_local3, menuAction = f2_arg0.menuAction } ), button_over_disable_func = MBh.EmitEventToRoot( { name = "update_selection", savedMode = f2_arg0.savedMode, idx = -1, showVaultText = false } ) } } end return f2_local0 end function ModeDetailFeeder( f3_arg0 ) local f3_local0 = {} local f3_local1 = MatchRules.GetSavedModeMax() for f3_local2 = 0, f3_local1 - 1, 1 do f3_local0[#f3_local0 + 1] = { type = "savedmode_details_widget", id = "savedmode_" .. f3_local2 .. "_details", properties = { time_text = MatchRules.GetMetaData( f3_arg0.savedMode, f3_local2, "timestamp" ), type_text = MatchRules.GetMetaData( f3_arg0.savedMode, f3_local2, "gametype" ) } } end return f3_local0 end function SaveModeItem( f4_arg0, f4_arg1 ) if MatchRules.SaveDataToPlayer( f4_arg0.properties.callback_params.saveToSlot ) then LUI.FlowManager.RequestLeaveMenuByName( "savedmode_select_main" ) end end function savedmode_confirm_overwrite_popup() return { type = "generic_yesno_popup", id = "mode_select_confirm_overwrite_popup_id", properties = { popup_title = Engine.Localize( "@MENU_ONLINEVAULT_CONFIRM_OVERWRITE" ), message_text = Engine.Localize( "@MENU_OVERWRITE_EXISTING_FILE" ), callback_params = { saveToSlot = -1 }, yes_action = SaveModeItem } } end function SelectMode( f6_arg0, f6_arg1 ) local f6_local0 = MatchRules.GetData( "gametype" ) local f6_local1 = f6_arg1.idx if f6_arg1.savedMode == "save" then if f6_arg1.menuAction == "save" then local f6_local2 = MatchRules.GetMetaData( f6_arg1.savedMode, f6_local1, "name" ) local f6_local3 if f6_local2 ~= nil and f6_local2 ~= "" then f6_local3 = false else f6_local3 = true end if f6_local3 then if not MatchRules.SaveDataToPlayer( f6_local1 ) then return end else LUI.FlowManager.RequestPopupMenu( f6_arg0, "savedmode_confirm_overwrite_popup", true, f6_arg1.controller, false, { callback_params = { saveToSlot = f6_local1 } } ) return end elseif f6_arg1.menuAction == "load" then MatchRules.LoadDataFromPlayer( f6_local1 ) end elseif f6_arg1.savedMode == "history" then MatchRules.LoadDataFromHistory( f6_local1 ) end FixTeamLimitsAndDifficultiesIfNecessary( f6_local0, MatchRules.GetData( "gametype" ) ) if SvS.IsSvS() then MatchRules.SetData( "commonOption", "allowCustomClasses", false ) end local f6_local3 = MatchRules.GetData( "mlgVersion" ) ~= "" if f6_local3 ~= MLG.AreMLGRulesEnabled() then MLG.SetUsingMLGRules( f6_local3 ) end LUI.FlowManager.RequestRestoreMenu( f6_arg0, "gamesetup_menu_main", true, f6_arg1.controller, true ) end function UpdateSelection( f7_arg0, f7_arg1 ) local f7_local0 = f7_arg1.idx local f7_local1 = LUI.FlowManager.GetMenuScopedDataFromElement( f7_arg0 ) f7_local1.mode = f7_arg1.savedMode f7_local1.index = f7_local0 f7_arg0:dispatchEventToRoot( { name = "stop_pulse", dispatchChildren = true, immediate = true } ) if f7_local0 >= 0 then local f7_local2 = f7_arg0:getFirstDescendentById( "savedmode_" .. f7_local0 .. "_details" ) if f7_local2 then f7_local2:processEvent( { name = "play_pulse", dispatchChildren = true } ) end end end function SaveToVault( f8_arg0, f8_arg1 ) local f8_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f8_arg0 ) if f8_local0.index and f8_local0.index >= 0 then if f8_local0.mode == "history" then MatchRules.LoadDataFromHistory( f8_local0.index ) else MatchRules.LoadDataFromPlayer( f8_local0.index ) end LUI.FlowManager.RequestAddMenu( f8_arg0, "online_vault_main", true, f8_arg1.controller, false, { vaultMode = "save", vaultCategory = "cgm", menu_title = Engine.Localize( "@MPUI_ONLINE_VAULT" ) } ) end end function SaveToMyModes( f9_arg0, f9_arg1 ) local f9_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f9_arg0 ) if f9_local0.index and f9_local0.index >= 0 and f9_local0.mode == "history" then local f9_local1 = MatchRules.GetData() MatchRules.OpenSelectionMenu( f9_arg1.controller, { vaultMode = "save", vaultCategory = "cgm", menu_title = Engine.Localize( "@LUA_MENU_MY_MODES" ) } ) end end function OnCreate( f10_arg0, f10_arg1 ) f10_arg0:clearSavedState() f10_arg0:dispatchEventToRoot( { name = "add_button_helper_text", button_ref = "button_secondary", helper_text = Engine.Localize( "@LUA_MENU_BACK" ), side = "left", clickable = true, immediate = true } ) end function savedmode_details_widget() return { type = "UIElement", states = { default = { topAnchor = true, bottomAnchor = false, leftAnchor = true, rightAnchor = false, top = 0, bottom = GenericButtonDims.button_height + 13.5, left = 0, right = 0 } }, properties = { time_text = "", type_text = "" }, children = { { type = "UIText", id = "mapsetup_timestamp", properties = { text = MBh.Property( "time_text" ) }, states = { default = { left = 0, top = 0, width = 200, height = CoD.TextSettings.NormalFont.Height, font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = 1 }, dark = { red = Colors.secondary_text_color.r, green = Colors.secondary_text_color.g, blue = Colors.secondary_text_color.b, alpha = 1 } }, handlers = { play_pulse = MBh.AnimateLoop( { { "dark", 400 }, { "default", 400 } } ), stop_pulse = MBh.AnimateToState( "default", 0 ) } }, { type = "UIText", id = "savedmode_gametype", properties = { text = MBh.Property( "type_text" ) }, states = { default = { left = 220, top = 0, width = 480, height = CoD.TextSettings.NormalFont.Height, font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, red = Colors.white.r, green = Colors.white.g, blue = Colors.white.b, alpha = 1 }, dark = { red = Colors.secondary_text_color.r, green = Colors.secondary_text_color.g, blue = Colors.secondary_text_color.b, alpha = 1 } }, handlers = { play_pulse = MBh.AnimateLoop( { { "dark", 400 }, { "default", 400 } } ), stop_pulse = MBh.AnimateToState( "default", 0 ) } } } } end function savedmode_select_main() return { type = "UIElement", id = "savedmode_select_root", properties = { menu_title = Engine.Localize( "@LUA_MENU_RECENT_MODES" ), savedMode = "history", menuAction = "load" }, states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0 } }, handlers = { menu_create = OnCreate, select_mode = SelectMode, update_selection = UpdateSelection }, children = { { type = "generic_menu_title", id = "savedmode_select_title_text_id", properties = { menu_title = MBh.Property( "menu_title" ) } }, { type = "UIVerticalList", id = "savedmode_select_modelist_id", focusable = true, states = { default = { alignment = LUI.Alignment.Top, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = GenericMenuDims.menu_left, right = GenericMenuDims.menu_right, top = GenericMenuDims.menu_top, bottom = GenericMenuDims.menu_bottom } }, properties = { savedMode = MBh.Property( "savedMode" ), menuAction = MBh.Property( "menuAction" ) }, childrenFeeder = ModeButtonFeeder }, { type = "UIVerticalList", id = "savedmode_details_list_id", focusable = false, states = { default = { alignment = LUI.Alignment.Top, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = false, left = 520, right = 0, top = GenericMenuDims.menu_top - 12, bottom = GenericMenuDims.menu_bottom } }, properties = { savedMode = MBh.Property( "savedMode" ) }, childrenFeeder = ModeDetailFeeder }, { type = "UIBindButton", id = "savedmode_bind_buttons", handlers = { button_secondary = MBh.LeaveMenu() } }, { type = "button_helper_text_main", id = "savedmode_button_helper_text_id" }, { type = "online_friends_widget", id = "online_friends_widget_id" } } } end LUI.MenuBuilder.registerDef( "savedmode_select_main", savedmode_select_main ) LUI.MenuBuilder.registerDef( "savedmode_details_widget", savedmode_details_widget ) LUI.MenuBuilder.registerDef( "savedmode_confirm_overwrite_popup", savedmode_confirm_overwrite_popup ) LUI.FlowManager.RegisterStackPushBehaviour( "savedmode_select_main", function () MatchRules.ClearMetaDataCache() end ) LUI.FlowManager.RegisterStackPopBehaviour( "savedmode_select_main", function () Engine.ExecNow( "decnosplitscreencontrol menu_RECIPE_SELECT" ) end ) LockTable( _M )