517 lines
15 KiB
Lua
517 lines
15 KiB
Lua
local f0_local0 = module
|
|
local f0_local1, f0_local2 = ...
|
|
f0_local0( f0_local1, package.seeall )
|
|
CoD.PrintModuleLoad( _NAME )
|
|
function PrivatePartyHostSetupMapAction( f1_arg0, f1_arg1 )
|
|
LUI.FlowManager.RequestAddMenu( f1_arg0, "mapsetup_menu_main", true, f1_arg1.controller, false, {
|
|
rotationAllowed = not Engine.IsAliensMode()
|
|
} )
|
|
end
|
|
|
|
function SetupMapAction( f2_arg0, f2_arg1 )
|
|
local f2_local0 = {
|
|
rotationAllowed = false
|
|
}
|
|
LUI.FlowManager.RequestAddMenu( f2_arg0, "mapsetup_menu_main", true, f2_arg1.controller, false )
|
|
end
|
|
|
|
function SetupModeAction( f3_arg0, f3_arg1 )
|
|
if SvS.IsSvS() then
|
|
LUI.FlowManager.RequestAddMenu( f3_arg0, "settings_recipe_choosetype_squads", true, f3_arg1.controller )
|
|
else
|
|
LUI.FlowManager.RequestAddMenu( f3_arg0, "popup_recipesetup_modes", true, f3_arg1.controller )
|
|
end
|
|
end
|
|
|
|
function SetupOptionsAction( f4_arg0, f4_arg1 )
|
|
LUI.FlowManager.RequestAddMenu( f4_arg0, "settings_recipe_rules_base", true, f4_arg1.controller, false )
|
|
end
|
|
|
|
function GameSetupMenuCreate( f5_arg0, f5_arg1 )
|
|
MatchRules.SetUsingMatchRulesData( 1 )
|
|
if Lobby.IsInPrivateParty() and Lobby.IsPrivatePartyHost() then
|
|
Lobby.StopIntermissionTimer()
|
|
end
|
|
local f5_local0 = Engine.GetFirstActiveController()
|
|
if f5_arg0.properties.exclusiveController then
|
|
f5_local0 = f5_arg0.properties.exclusiveController
|
|
end
|
|
Engine.SetOldLocalVarBool( f5_local0, "lui_gamesetup_menu", false )
|
|
f5_arg0:processEvent( {
|
|
name = "add_button_helper_text",
|
|
button_ref = "button_secondary",
|
|
helper_text = Engine.Localize( "@LUA_MENU_BACK" ),
|
|
side = "left",
|
|
clickable = true
|
|
} )
|
|
if not Engine.IsAliensMode() then
|
|
f5_arg0:processEvent( {
|
|
name = "add_button_helper_text",
|
|
button_ref = "button_alt1",
|
|
helper_text = Engine.Localize( "@LUA_MENU_RECIPE_SAVE_CUSTOM" ) or "",
|
|
side = "left",
|
|
clickable = true
|
|
} )
|
|
end
|
|
MLG.Refresh( f5_arg0 )
|
|
end
|
|
|
|
function JIPButtonDisplayText()
|
|
if Engine.GetDvarInt( "sv_privateClients" ) == Engine.GetDvarInt( "party_maxPlayers" ) then
|
|
return Engine.Localize( "@LUA_MENU_NOTALLOWED" )
|
|
else
|
|
return Engine.Localize( "@LUA_MENU_ALLOWED" )
|
|
end
|
|
end
|
|
|
|
function JIPHandleOptionToggle()
|
|
Engine.Exec( "xtogprivateslots; xsessionupdate;" )
|
|
end
|
|
|
|
function IntermissionButtonDisplayText()
|
|
if Lobby.IsUsingIntermissionTimer() then
|
|
return Engine.Localize( "@LUA_MENU_ENABLED" )
|
|
else
|
|
return Engine.Localize( "@LUA_MENU_DISABLED" )
|
|
end
|
|
end
|
|
|
|
function IntermissionHandleOptionToggle()
|
|
if Lobby.IsUsingIntermissionTimer() then
|
|
Lobby.UseIntermissionTimer( false )
|
|
else
|
|
Lobby.UseIntermissionTimer( true )
|
|
end
|
|
end
|
|
|
|
function SaveRecipeToMyModes( f10_arg0, f10_arg1 )
|
|
if not Engine.IsAliensMode() then
|
|
MatchRules.OpenSelectionMenu( f10_arg1.controller, {
|
|
savedMode = "save",
|
|
menuAction = "save",
|
|
menu_title = Engine.Localize( "@LUA_MENU_MY_MODES" ),
|
|
return_menu = "gamesetup_menu_main"
|
|
} )
|
|
end
|
|
end
|
|
|
|
function SaveToVaultAction( f11_arg0, f11_arg1 )
|
|
Engine.ExecNow( "incnosplitscreencontrol popup_recipesetup", f11_arg1.controller )
|
|
LUI.FlowManager.RequestOldMenu( f11_arg0, "popup_recipesetup", true )
|
|
end
|
|
|
|
function LoadFromHistoryAction( f12_arg0, f12_arg1 )
|
|
MatchRules.LoadDataFromHistory( 0 )
|
|
f12_arg0:dispatchEventToRoot( {
|
|
name = "content_refresh",
|
|
dispatchChildren = true
|
|
} )
|
|
end
|
|
|
|
function SaveToHistoryAction( f13_arg0, f13_arg1 )
|
|
MatchRules.SaveDataToHistory()
|
|
end
|
|
|
|
function SaveToPlayer0Action( f14_arg0, f14_arg1 )
|
|
MatchRules.SaveDataToPlayer( 0 )
|
|
end
|
|
|
|
function LoadFromPlayer0Action( f15_arg0, f15_arg1 )
|
|
MatchRules.LoadDataFromPlayer( 0 )
|
|
f15_arg0:dispatchEventToRoot( {
|
|
name = "content_refresh",
|
|
dispatchChildren = true
|
|
} )
|
|
end
|
|
|
|
function SaveToPlayer2Action( f16_arg0, f16_arg1 )
|
|
MatchRules.SaveDataToPlayer( 2 )
|
|
end
|
|
|
|
function LoadFromPlayer2Action( f17_arg0, f17_arg1 )
|
|
MatchRules.LoadDataFromPlayer( 2 )
|
|
f17_arg0:dispatchEventToRoot( {
|
|
name = "content_refresh",
|
|
dispatchChildren = true
|
|
} )
|
|
end
|
|
|
|
function SaveDefaultsAction( f18_arg0, f18_arg1 )
|
|
for f18_local0 = 0, 5, 1 do
|
|
MatchRules.SetData( "defaultClasses", "axis", f18_local0, "class", "inUse", false )
|
|
MatchRules.SetData( "defaultClasses", "allies", f18_local0, "class", "inUse", false )
|
|
MatchRules.SetData( "defaultClasses", "axis", f18_local0, "class", "name", "" )
|
|
MatchRules.SetData( "defaultClasses", "allies", f18_local0, "class", "name", "" )
|
|
end
|
|
MatchRules.SaveMatchRulesDataDefault()
|
|
end
|
|
|
|
function SaveForPlaylistAction( f19_arg0, f19_arg1 )
|
|
MatchRules.SaveMatchRulesDataDefault()
|
|
end
|
|
|
|
function ModeButtonDisplayFunc()
|
|
if SvS.IsSvS() then
|
|
local f20_local0 = MatchRules.GetData( "gametype" )
|
|
if f20_local0 == "horde" then
|
|
return Lobby.GameTypeNameAbbreviated()
|
|
else
|
|
return Engine.Localize( Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f20_local0, GameTypesTable.Cols.WargameName ) )
|
|
end
|
|
else
|
|
return Lobby.GameTypeNameAbbreviated()
|
|
end
|
|
end
|
|
|
|
function GameSetupMenuOptionsFeeder( f21_arg0 )
|
|
local f21_local0 = Engine.Localize( "@LUA_MENU_MAP_CAPS" )
|
|
local f21_local1 = SetupMapAction
|
|
if Lobby.IsInPrivateParty() and Lobby.IsPrivatePartyHost() then
|
|
f21_local0 = Engine.Localize( "@LUA_MENU_MAPS_CAPS" )
|
|
f21_local1 = PrivatePartyHostSetupMapAction
|
|
end
|
|
local f21_local2 = "None"
|
|
if Lobby.IsInPrivateParty() and MatchRules.IsUsingCustomMapRotation() then
|
|
f21_local2 = Engine.Localize( "@LUA_MENU_ROTATION" )
|
|
else
|
|
f21_local2 = Lobby.GetMapName()
|
|
end
|
|
local f21_local3 = {}
|
|
if not Engine.IsAliensMode() then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "maps_button_id",
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Info,
|
|
button_text = f21_local0,
|
|
button_display_func = function ()
|
|
return f21_local2
|
|
end,
|
|
button_action_func = f21_local1
|
|
}
|
|
}
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "mode_button_id",
|
|
disabled = MLG.AreMLGRulesEnabled(),
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Info,
|
|
button_text = Engine.Localize( "@LUA_MENU_MODE_CAPS" ),
|
|
button_display_func = ModeButtonDisplayFunc,
|
|
button_action_func = SetupModeAction
|
|
},
|
|
handlers = {
|
|
mlg_enabled = MBh.EmitEvent( {
|
|
name = "disable"
|
|
} ),
|
|
mlg_disabled = MBh.EmitEvent( {
|
|
name = "enable"
|
|
} )
|
|
}
|
|
}
|
|
end
|
|
if not Engine.IsAliensMode() or Engine.IsDevelopmentBuild() and Engine.GetDvarString( "showAliensOptions" ) == "1" then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "options_button_id",
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Info,
|
|
button_text = Engine.Localize( "@LUA_MENU_OPTIONS_CAPS" ),
|
|
button_display_func = function ()
|
|
local f23_local0 = "PATCH_MENU_MATCHRULES_CUSTOM"
|
|
if MLG.AreMLGRulesEnabled() then
|
|
f23_local0 = "PATCH_MENU_MATCHRULES_MLG"
|
|
elseif MatchRules.AreMatchRulesDefaultFromFF() then
|
|
f23_local0 = "PATCH_MENU_MATCHRULES_DEFAULT"
|
|
end
|
|
return Engine.Localize( f23_local0 )
|
|
end,
|
|
button_action_func = SetupOptionsAction
|
|
},
|
|
handlers = {
|
|
mlg_enabled = MBh.EmitEvent( {
|
|
name = "content_refresh"
|
|
} ),
|
|
mlg_disabled = MBh.EmitEvent( {
|
|
name = "content_refresh"
|
|
} )
|
|
}
|
|
}
|
|
end
|
|
if Lobby.IsInPrivateParty() and Lobby.IsPrivatePartyHost() and not Engine.IsAliensMode() and Lobby.GetPartyPrivacy() >= 0 then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "privacy_button_id",
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Select,
|
|
button_text = Engine.Localize( "@PATCH_MENU_PARTY_PRIVACY_CAPS" ),
|
|
button_display_func = function ( f24_arg0, f24_arg1 )
|
|
return Engine.Localize( Lobby.PrivacySettings.Texts[Lobby.GetPartyPrivacy()] )
|
|
end,
|
|
button_left_func = function ( f25_arg0, f25_arg1 )
|
|
local f25_local0 = Lobby.GetPartyPrivacy() - 1
|
|
if f25_local0 < Lobby.PrivacySettings.Min then
|
|
f25_local0 = Lobby.PrivacySettings.Max
|
|
end
|
|
Lobby.SetPartyPrivacy( f25_local0 )
|
|
end,
|
|
button_right_func = function ( f26_arg0, f26_arg1 )
|
|
local f26_local0 = Lobby.GetPartyPrivacy() + 1
|
|
if Lobby.PrivacySettings.Max < f26_local0 then
|
|
f26_local0 = Lobby.PrivacySettings.Min
|
|
end
|
|
Lobby.SetPartyPrivacy( f26_local0 )
|
|
end
|
|
}
|
|
}
|
|
end
|
|
if Lobby.IsInPrivateParty() and Lobby.IsPrivatePartyHost() and not Engine.IsAliensMode() and Lobby.GetPlayerLimit() >= 0 then
|
|
local f21_local4 = 2
|
|
local f21_local5 = 18
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "limit_button_id",
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Select,
|
|
button_text = Engine.Localize( "@PATCH_MENU_PLAYER_LIMIT_CAPS" ),
|
|
button_display_func = function ( f27_arg0, f27_arg1 )
|
|
return Lobby.GetPlayerLimit()
|
|
end,
|
|
button_left_func = function ( f28_arg0, f28_arg1 )
|
|
local f28_local0 = Lobby.GetPlayerLimit() - 1
|
|
if f28_local0 < f21_local4 then
|
|
f28_local0 = f21_local5
|
|
end
|
|
Lobby.SetPlayerLimit( f28_local0 )
|
|
end,
|
|
button_right_func = function ( f29_arg0, f29_arg1 )
|
|
local f29_local0 = Lobby.GetPlayerLimit() + 1
|
|
if f21_local5 < f29_local0 then
|
|
f29_local0 = f21_local4
|
|
end
|
|
Lobby.SetPlayerLimit( f29_local0 )
|
|
end
|
|
}
|
|
}
|
|
end
|
|
if not Engine.GetDvarBool( "systemlink" ) and Engine.GetDvarBool( "onlinegame" ) and not f21_arg0.isSoloMode then
|
|
if Engine.IsConsoleGame() then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "jip_button_id",
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Select,
|
|
button_text = Engine.Localize( "@LUA_MENU_JIP_CAPS" ),
|
|
button_display_func = JIPButtonDisplayText,
|
|
button_left_func = JIPHandleOptionToggle,
|
|
button_right_func = JIPHandleOptionToggle
|
|
},
|
|
handlers = {
|
|
refresh_jip_button_text = function ( f30_arg0, f30_arg1 )
|
|
local f30_local0 = JIPButtonDisplayText()
|
|
local f30_local1 = f30_arg0:getFirstDescendentById( "content_text_label" )
|
|
f30_local1:setText( f30_local0 )
|
|
end
|
|
},
|
|
children = {
|
|
{
|
|
type = "UITimer",
|
|
id = "jip_button_refresh_timer_id",
|
|
properties = {
|
|
event = "refresh_jip_button_text",
|
|
interval = 100,
|
|
disposable = false,
|
|
broadcastToRoot = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
elseif Engine.GetDvarBool( "xblive_privatematch" ) then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "password_button_id",
|
|
disabled = not AreWePrivatePartyHost(),
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Info,
|
|
button_text = Engine.Localize( "PATCH_MENU_CHANGE_PASSWORD_CAPS" ),
|
|
button_display_func = function ()
|
|
local f31_local0 = Engine.GetDvarString( "privateMatch_serverPassword" )
|
|
if f31_local0 then
|
|
f31_local0 = Engine.GetDvarString( "privateMatch_serverPassword" ) ~= ""
|
|
end
|
|
local f31_local1
|
|
if f31_local0 then
|
|
f31_local1 = Engine.Localize( "PATCH_MENU_PASSWORD_SET" )
|
|
if not f31_local1 then
|
|
|
|
else
|
|
return f31_local1
|
|
end
|
|
end
|
|
f31_local1 = Engine.Localize( "MENU_NONE" )
|
|
end,
|
|
button_action_func = function ( f32_arg0, f32_arg1 )
|
|
Engine.ExecNow( "setfromdvar ui_password privateMatch_serverPassword" )
|
|
Engine.OpenScreenKeyboard( f32_arg1.controller, Engine.Localize( "MENU_PASSWORD" ), Engine.GetDvarString( "ui_password" ) or "", Lobby.PasswordLength, false, false, CoD.KeyboardInputTypes.Password )
|
|
end
|
|
},
|
|
handlers = {
|
|
text_input_complete = function ( f33_arg0, f33_arg1 )
|
|
if f33_arg1.text then
|
|
Engine.SetDvarString( "privateMatch_serverPassword", f33_arg1.text )
|
|
f33_arg0:processEvent( {
|
|
name = "content_refresh"
|
|
} )
|
|
end
|
|
end
|
|
}
|
|
}
|
|
end
|
|
end
|
|
if Lobby.IsInPrivateParty() and Lobby.IsPrivatePartyHost() and not Engine.IsAliensMode() then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "intermission_button_id",
|
|
properties = {
|
|
variant = GenericButtonSettings.Variants.Select,
|
|
button_text = Engine.Localize( "@LUA_MENU_INTERMISSION_CAPS" ),
|
|
button_display_func = IntermissionButtonDisplayText,
|
|
button_left_func = IntermissionHandleOptionToggle,
|
|
button_right_func = IntermissionHandleOptionToggle
|
|
}
|
|
}
|
|
end
|
|
if Engine.IsDevelopmentBuild() then
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "save_defaults_button_id",
|
|
properties = {
|
|
button_text = "Save for Default to devkit",
|
|
button_action_func = SaveDefaultsAction,
|
|
height = 28
|
|
}
|
|
}
|
|
f21_local3[#f21_local3 + 1] = {
|
|
type = "UIGenericButton",
|
|
id = "save_for_playlist_button_id",
|
|
properties = {
|
|
button_text = "Save for Playlist/MLG to devkit",
|
|
button_action_func = SaveForPlaylistAction,
|
|
height = 28
|
|
}
|
|
}
|
|
end
|
|
return f21_local3
|
|
end
|
|
|
|
function gamesetup_menu_main()
|
|
return {
|
|
type = "UIElement",
|
|
id = "gamesetup_menu_main_root",
|
|
properties = {
|
|
isSoloMode = false
|
|
},
|
|
states = {
|
|
default = {
|
|
topAnchor = true,
|
|
bottomAnchor = true,
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
top = 0,
|
|
bottom = 0,
|
|
left = 0,
|
|
right = 0
|
|
}
|
|
},
|
|
handlers = {
|
|
menu_create = GameSetupMenuCreate,
|
|
update_timer = MLG.Refresh
|
|
},
|
|
children = {
|
|
{
|
|
type = "UITimer",
|
|
id = "update_timer",
|
|
properties = {
|
|
event = "update_timer",
|
|
disposable = false,
|
|
interval = 200
|
|
}
|
|
},
|
|
{
|
|
type = "generic_menu_title",
|
|
id = "system_link_menu_title",
|
|
properties = {
|
|
menu_title = Engine.Localize( "@LUA_MENU_GAME_SETUP_CAPS" )
|
|
}
|
|
},
|
|
{
|
|
type = "gamesetup_menu_options",
|
|
id = "gamesetup_menu_options_id",
|
|
properties = {
|
|
isSoloMode = MBh.Property( "isSoloMode" )
|
|
},
|
|
childrenFeeder = GameSetupMenuOptionsFeeder,
|
|
handlers = {
|
|
mode_changed = function ( f35_arg0, f35_arg1 )
|
|
f35_arg0:processEvent( {
|
|
name = "content_refresh",
|
|
dispatchChildren = true
|
|
} )
|
|
end
|
|
|
|
}
|
|
},
|
|
{
|
|
type = "UIBindButton",
|
|
id = "gamesetup_bind_buttons_id",
|
|
handlers = {
|
|
button_secondary = MBh.LeaveMenu(),
|
|
button_start = function ( f36_arg0, f36_arg1 )
|
|
MLG.Toggle( f36_arg0:getParent(), f36_arg1 )
|
|
end
|
|
|
|
}
|
|
},
|
|
{
|
|
type = "button_helper_text_main",
|
|
id = "gamesetup_button_helper_text_id"
|
|
},
|
|
{
|
|
type = "online_friends_widget",
|
|
id = "online_friends_widget_id"
|
|
},
|
|
{
|
|
type = "UIBindButton",
|
|
id = "save_recipe_bind",
|
|
handlers = {
|
|
button_alt1 = SaveRecipeToMyModes
|
|
}
|
|
}
|
|
}
|
|
}
|
|
end
|
|
|
|
function gamesetup_menu_options()
|
|
return {
|
|
type = "UIVerticalList",
|
|
focusable = true,
|
|
states = {
|
|
default = {
|
|
alignment = LUI.Alignment.Top,
|
|
leftAnchor = true,
|
|
rightAnchor = false,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
left = GenericMenuDims.menu_left,
|
|
right = GenericMenuDims.menu_right_wide,
|
|
top = GenericMenuDims.menu_top,
|
|
bottom = GenericMenuDims.menu_bottom
|
|
}
|
|
}
|
|
}
|
|
end
|
|
|
|
LUI.MenuBuilder.registerDef( "gamesetup_menu_main", gamesetup_menu_main )
|
|
LUI.MenuBuilder.registerDef( "gamesetup_menu_options", gamesetup_menu_options )
|
|
LockTable( _M )
|