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

678 lines
20 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function mpPauseMenuCreateHandler( f1_arg0, f1_arg1 )
f1_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton )
if GameX.IsOnlineMatch() and not GameX.IsSplitscreen() then
f1_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addFriendsButton )
end
end
function chooseClassButtonAction( f2_arg0, f2_arg1 )
LUI.FlowManager.RequestAddMenu( f2_arg0, "class_select_main", true, f2_arg1.controller )
end
function updateDescText( f3_arg0, f3_arg1 )
f3_arg0:setText( Engine.Localize( f3_arg1.string ) )
end
function mpMapHandler( f4_arg0, f4_arg1 )
local f4_local0 = f4_arg0:getChildById( "map_mini_id" )
local f4_local1 = f4_arg0:getChildById( "map_mini_icons_id" )
if GameX.IsHardcoreMode() or Game.IsEmpJammed() or Game.GetOmnvar( "ui_hud_static" ) > 0 or Game.GetOmnvar( "ui_hud_emp_artifact" ) or Game.InKillCam() or Game.GetOmnvar( "ui_session_state" ) == "dead" then
f4_local0:animateToState( "inactive", 0 )
f4_local1:animateToState( "inactive", 0 )
else
f4_local0:animateToState( "default", 0 )
f4_local1:animateToState( "default", 0 )
end
end
function changeTeamButtonAction( f5_arg0, f5_arg1 )
LUI.FlowManager.RequestAddMenu( f5_arg0, "team_select_main", true, f5_arg1.controller )
end
function mutePlayersButtonAction( f6_arg0, f6_arg1 )
LUI.FlowManager.RequestAddMenu( f6_arg0, "popup_mute_players", true, f6_arg1.controller )
end
function optionsButtonAction( f7_arg0, f7_arg1 )
if Engine.IsConsoleGame() then
LUI.FlowManager.RequestAddMenu( f7_arg0, "mp_in_game_controls_menu", true, f7_arg1.controller )
if GameX.IsSplitscreen() then
GameX.SetOptionState( true )
f7_arg0:dispatchEventToAllOtherRoots( {
name = "refresh_options_button",
immediate = true
} )
end
else
LUI.FlowManager.RequestAddMenu( f7_arg0, "pc_controls", true, f7_arg1.controller )
end
end
function endGameButtonAction( f8_arg0, f8_arg1 )
local f8_local0 = Engine.GetDvarBool( "isMatchMakingGame" )
local f8_local1 = Engine.GetDvarBool( "sv_running" )
if f8_local0 then
LUI.FlowManager.RequestPopupMenu( f8_arg0, "popup_leave_game", true, f8_arg1.controller )
else
LUI.FlowManager.RequestPopupMenu( f8_arg0, "popup_end_game", true, f8_arg1.controller )
end
end
function checkTeamChoice( f9_arg0 )
if Engine.IsSquadVsSquadMode() then
return false
else
return Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f9_arg0, GameTypesTable.Cols.TeamChoice ) == "1"
end
end
function chooseClassCheck( f10_arg0, f10_arg1, f10_arg2 )
local f10_local0 = Game.GetPlayerTeam()
if GameX.UsesFakeLoadout() then
return true
elseif f10_arg0 == true then
return true
elseif f10_arg0 == false then
if f10_arg2 == true and (f10_local0 == Teams.allies or f10_local0 == Teams.axis) then
return true
elseif f10_arg2 == false then
return true
end
end
return false
end
function pauseMenuUpdate( f11_arg0, f11_arg1 )
if f11_arg1.value ~= true then
local f11_local0 = MBh.CloseAllMenus()
f11_local0( f11_arg0, f11_arg1 )
end
end
function optionsLockedUpdate( f12_arg0, f12_arg1 )
return GameX.IsOptionStateLocked()
end
function refreshOptionDisable( f13_arg0, f13_arg1 )
if not f13_arg0.disabled then
f13_arg0:processEvent( {
name = "disable"
} )
elseif f13_arg0.disabled then
f13_arg0:processEvent( {
name = "enable"
} )
end
end
function options_def()
local f14_local0 = GameX.GetGameMode()
local f14_local1 = Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f14_local0, GameTypesTable.Cols.ClassChoice ) == "1"
if not f14_local1 then
f14_local1 = GameX.UsesFakeLoadout()
end
local f14_local2 = checkTeamChoice( f14_local0 )
local f14_local3 = GameX.IsRankedMatch()
local f14_local4 = Engine.GetDvarBool( "splitscreen_ingame" )
local f14_local5 = Game.GetOmnvar( "ui_team_selected" )
local f14_local6 = Game.GetOmnvar( "ui_loadout_selected" )
local f14_local7 = chooseClassCheck( f14_local3, f14_local5, f14_local2 )
local self = LUI.UIVerticalList.new()
self.id = "pause_selections_Id"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = false,
rightAnchor = false,
top = GenericMenuDims.menu_top,
left = GenericMenuDims.menu_left,
bottom = GenericMenuDims.menu_bottom,
right = GenericMenuDims.menu_right,
alignment = LUI.Alignment.Top
} )
self:animateToState( "default", 0 )
self:makeFocusable()
if f14_local0 ~= "aliens" and false == CoD.IsFireTeamMode() and f14_local1 == true and f14_local7 == true and not MLG.IsMLGSpectator() then
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIGenericButton",
id = "btn_MPPause_0",
properties = {
childNum = 1,
button_text = Engine.Localize( "@LUA_MENU_CHOOSE_CLASS_CAPS" ),
button_action_func = chooseClassButtonAction
}
} )
end
if f14_local0 ~= "aliens" and false == CoD.IsFireTeamMode() and f14_local2 == true and f14_local3 == false and not MLG.IsMLGSpectator() then
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIGenericButton",
id = "btn_MPPause_1",
properties = {
childNum = 2,
button_text = Engine.Localize( "@LUA_MENU_CHANGE_TEAM_CAPS" ),
button_action_func = changeTeamButtonAction
}
} )
end
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIGenericButton",
id = "btn_MPPause_2",
disabledFunc = optionsLockedUpdate,
properties = {
childNum = 3,
button_text = Engine.Localize( "@LUA_MENU_OPTIONS_CAPS" ),
button_action_func = optionsButtonAction
},
handlers = {
refresh_options_button = refreshOptionDisable
}
} )
if GameX.IsOnlineMatch() and (not Engine.IsAliensMode() or not Game.GetOmnvar( "ui_alien_is_solo" )) and not MLG.IsMLGSpectator() then
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIGenericButton",
id = "btn_MPPause_3",
properties = {
childNum = 4,
button_text = Engine.Localize( "@LUA_MENU_MUTE_PLAYERS_CAPS" ),
button_action_func = mutePlayersButtonAction
}
} )
end
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIGenericButton",
id = "btn_MPPause_5",
properties = {
childNum = 6,
button_text = Engine.Localize( "@LUA_MENU_END_GAME_CAPS" ),
button_action_func = endGameButtonAction
}
} )
return self
end
function game_mode_def()
local f15_local0 = GameX.GetGameMode()
local f15_local1 = Engine.Localize( "@" .. Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f15_local0, GameTypesTable.Cols.Name ) .. "_CAPS" )
local f15_local2, f15_local3, f15_local4 = nil
if MatchRules.IsUsingMatchRulesData() then
f15_local4 = MatchRules.GetData( "commonOption", "scoreLimit" )
else
f15_local3 = Engine.GetDvarInt( "scr_" .. f15_local0 .. "_winlimit" )
if f15_local3 <= 1 then
f15_local4 = Engine.GetDvarInt( "scr_" .. f15_local0 .. "_scorelimit" )
else
f15_local4 = f15_local3
end
end
if f15_local4 == 0 then
f15_local2 = Engine.Localize( "@OBJECTIVES_" .. f15_local0 .. "" )
else
f15_local2 = Engine.Localize( "@OBJECTIVES_" .. f15_local0 .. "_SCORE", f15_local4 )
end
local f15_local5 = nil
if Engine.UsingSplitscreenUpscaling() then
f15_local5 = {
topAnchor = true,
leftAnchor = false,
top = GenericMenuDims.menu_top,
height = 65,
width = 350
}
else
f15_local5 = {
topAnchor = true,
leftAnchor = true,
top = 135,
left = 690,
height = 65,
width = 350
}
end
local self = LUI.UIElement.new( f15_local5 )
self.id = "gamemode_Id"
local f15_local7 = LUI.UIText.new()
f15_local7.id = "gamemode_title_Id"
f15_local7:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
top = 0,
left = 0,
height = CoD.TextSettings.BoldFont.Height,
width = 256,
font = CoD.TextSettings.BoldFont.Font,
alignment = LUI.Alignment.Left
} )
f15_local7:animateToState( "default", 0 )
f15_local7:setText( f15_local1 )
f15_local7:setTextStyle( CoD.TextStyle.Shadowed )
local f15_local8 = LUI.UIText.new()
f15_local8.id = "gamemode_desc_Id"
f15_local8:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
top = CoD.TextSettings.BoldFont.Height,
left = 0,
height = CoD.TextSettings.NormalFont.Height,
width = 350,
font = CoD.TextSettings.NormalFont.Font,
alignment = LUI.Alignment.Left,
red = Colors.primary_text_color.r,
green = Colors.primary_text_color.g,
blue = Colors.primary_text_color.b
} )
f15_local8:animateToState( "default", 0 )
f15_local8:setText( f15_local2 )
f15_local8:setTextStyle( CoD.TextStyle.Shadowed )
self:addElement( f15_local7 )
self:addElement( f15_local8 )
return self
end
function map_display_def()
local f16_local0 = Engine.Localize( "@" .. Engine.TableLookup( "mp/mapNames.csv", 0, Engine.GetDvarString( "ui_mapname" ), 2 ) )
local f16_local1 = RegisterMaterial( "hud_minimap_border" )
local f16_local2 = math.min( GenericMenuDims.menu_bottom - GenericMenuDims.menu_top - CoD.TextSettings.BoldFont.Height - 5, 350 )
local f16_local3 = f16_local2
local f16_local4 = nil
if Engine.UsingSplitscreenUpscaling() then
local self = {}
self = GameX.GetSafeZoneSize()
f16_local4 = {
topAnchor = true,
rightAnchor = true,
right = self[3],
top = GenericMenuDims.menu_top,
height = f16_local2 + 30,
width = f16_local3
}
else
f16_local4 = {
topAnchor = true,
leftAnchor = true,
top = 235,
left = 690,
height = f16_local2 + 30,
width = f16_local3
}
end
local self = LUI.UIElement.new( f16_local4 )
self.id = "map_Id"
self:registerEventHandler( "menu_create", mpMapHandler )
self:registerOmnvarHandler( "ui_session_state", mpMapHandler )
local f16_local6 = LUI.UIText.new()
f16_local6.id = "map_title_Id"
f16_local6:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
top = 0,
left = 0,
height = CoD.TextSettings.BoldFont.Height,
width = 256,
font = CoD.TextSettings.BoldFont.Font,
alignment = LUI.Alignment.Left
} )
f16_local6:animateToState( "default", 0 )
f16_local6:setText( f16_local0 )
f16_local6:setTextStyle( CoD.TextStyle.Shadowed )
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIMinimap",
id = "map_mini_id",
properties = {
compassType = CoD.CompassType.Full
},
states = {
default = {
topAnchor = true,
leftAnchor = true,
top = CoD.TextSettings.BoldFont.Height + 5,
left = 0,
height = f16_local2,
width = f16_local3,
alpha = 0.5
},
inactive = {
alpha = 0
}
}
} )
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIMinimapIcons",
id = "map_mini_icons_id",
properties = {
compassType = CoD.CompassType.Full
},
states = {
default = {
topAnchor = true,
leftAnchor = true,
top = CoD.TextSettings.BoldFont.Height + 5,
left = 0,
height = f16_local2,
width = f16_local3,
alpha = 1
},
inactive = {
alpha = 0
}
}
} )
self:addElement( f16_local6 )
return self
end
function mp_pause_menu_background_def()
local self = LUI.UIImage.new()
self.id = "pmOptionsScreenOverlay"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
bottom = 0,
right = 0,
material = RegisterMaterial( "black" ),
red = Colors.window_border_color.r,
green = Colors.window_border_color.g,
blue = Colors.window_border_color.b,
alpha = 0.5
} )
self:animateToState( "default", 0 )
return self
end
function mp_pause_menu_title_def( f18_arg0 )
local self = LUI.UIElement.new()
self.id = "mp_pause_title"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
bottom = 0,
right = 0
} )
self:animateToState( "default", 0 )
LUI.MenuBuilder.BuildAddChild( self, {
type = "generic_menu_title",
id = "mp_pause_title_text",
properties = {
menu_title = f18_arg0
}
} )
return self
end
function mp_pause_menu()
local f19_local0 = Engine.IsAliensMode()
local f19_local1 = Engine.IsSquadVsSquadMode()
local f19_local2 = Engine.Localize
local self
if f19_local0 then
self = "@ALIENS_PAUSE_CAPS"
if not self then
if f19_local1 then
self = "@LUA_MENU_PAUSE_SQUADS_CAPS"
if not self then
else
f19_local2 = f19_local2( self )
self = LUI.UIElement.new()
self.id = "mp_pause_menu_id"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
bottom = 0,
right = 0,
alpha = 1
} )
self:animateToState( "default", 0 )
self:registerAnimationState( "hidden", {
alpha = 0
} )
self:registerEventHandler( "menu_create", mpPauseMenuCreateHandler )
self:registerEventHandler( "popup_inactive", MBh.AnimateToState( "default", 0 ) )
self:registerEventHandler( "gain_focus", MBh.HandleSilently( MBh.AnimateToState( "default", 0 ) ) )
self:registerOmnvarHandler( "ui_pause_menu_show", pauseMenuUpdate )
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIWorldBlur",
id = "pmWorldBlurOverlay",
states = {
default = {
worldBlur = 5
}
}
} )
self:addElement( mp_pause_menu_background_def() )
LUI.MenuBuilder.BuildAddChild( self, {
type = "button_helper_text_main",
id = "pmhelper_text_id"
} )
if GameX.IsOnlineMatch() and not GameX.IsSplitscreen() then
LUI.MenuBuilder.BuildAddChild( self, {
type = "online_friends_widget",
id = "pmfriends_widget_id"
} )
end
local f19_local4 = LUI.UIBindButton.new()
f19_local4.id = "pmBackToGameStartButton"
local f19_local5 = f19_local4
local f19_local6 = f19_local4.registerEventHandler
local f19_local7 = "button_start"
local f19_local8 = MBh.DoMultiple
local f19_local9 = {}
local f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
local f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
f19_local5 = f19_local4
f19_local6 = f19_local4.registerEventHandler
f19_local7 = "button_select"
f19_local8 = MBh.DoMultiple
f19_local9 = {}
f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
f19_local5 = f19_local4
f19_local6 = f19_local4.registerEventHandler
f19_local7 = "button_secondary"
f19_local8 = MBh.DoMultiple
f19_local9 = {}
f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
self:addElement( mp_pause_menu_title_def( f19_local2 ) )
self:addElement( options_def() )
self:addElement( f19_local4 )
if not Engine.IsAliensMode() then
self:addElement( game_mode_def() )
self:addElement( map_display_def() )
else
self:addElement( LUI.mp_hud.AlienScoreboards.pause_menu_scoreboard() )
end
return self
end
end
self = "@LUA_MENU_PAUSE_CAPS"
end
else
if f19_local1 then
self = "@LUA_MENU_PAUSE_SQUADS_CAPS"
if not self then
else
f19_local2 = f19_local2( self )
self = LUI.UIElement.new()
self.id = "mp_pause_menu_id"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
bottom = 0,
right = 0,
alpha = 1
} )
self:animateToState( "default", 0 )
self:registerAnimationState( "hidden", {
alpha = 0
} )
self:registerEventHandler( "menu_create", mpPauseMenuCreateHandler )
self:registerEventHandler( "popup_inactive", MBh.AnimateToState( "default", 0 ) )
self:registerEventHandler( "gain_focus", MBh.HandleSilently( MBh.AnimateToState( "default", 0 ) ) )
self:registerOmnvarHandler( "ui_pause_menu_show", pauseMenuUpdate )
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIWorldBlur",
id = "pmWorldBlurOverlay",
states = {
default = {
worldBlur = 5
}
}
} )
self:addElement( mp_pause_menu_background_def() )
LUI.MenuBuilder.BuildAddChild( self, {
type = "button_helper_text_main",
id = "pmhelper_text_id"
} )
if GameX.IsOnlineMatch() and not GameX.IsSplitscreen() then
LUI.MenuBuilder.BuildAddChild( self, {
type = "online_friends_widget",
id = "pmfriends_widget_id"
} )
end
local f19_local4 = LUI.UIBindButton.new()
f19_local4.id = "pmBackToGameStartButton"
local f19_local5 = f19_local4
local f19_local6 = f19_local4.registerEventHandler
local f19_local7 = "button_start"
local f19_local8 = MBh.DoMultiple
local f19_local9 = {}
local f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
local f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
f19_local5 = f19_local4
f19_local6 = f19_local4.registerEventHandler
f19_local7 = "button_select"
f19_local8 = MBh.DoMultiple
f19_local9 = {}
f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
f19_local5 = f19_local4
f19_local6 = f19_local4.registerEventHandler
f19_local7 = "button_secondary"
f19_local8 = MBh.DoMultiple
f19_local9 = {}
f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
self:addElement( mp_pause_menu_title_def( f19_local2 ) )
self:addElement( options_def() )
self:addElement( f19_local4 )
if not Engine.IsAliensMode() then
self:addElement( game_mode_def() )
self:addElement( map_display_def() )
else
self:addElement( LUI.mp_hud.AlienScoreboards.pause_menu_scoreboard() )
end
return self
end
end
self = "@LUA_MENU_PAUSE_CAPS"
end
f19_local2 = f19_local2( self )
self = LUI.UIElement.new()
self.id = "mp_pause_menu_id"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
bottom = 0,
right = 0,
alpha = 1
} )
self:animateToState( "default", 0 )
self:registerAnimationState( "hidden", {
alpha = 0
} )
self:registerEventHandler( "menu_create", mpPauseMenuCreateHandler )
self:registerEventHandler( "popup_inactive", MBh.AnimateToState( "default", 0 ) )
self:registerEventHandler( "gain_focus", MBh.HandleSilently( MBh.AnimateToState( "default", 0 ) ) )
self:registerOmnvarHandler( "ui_pause_menu_show", pauseMenuUpdate )
LUI.MenuBuilder.BuildAddChild( self, {
type = "UIWorldBlur",
id = "pmWorldBlurOverlay",
states = {
default = {
worldBlur = 5
}
}
} )
self:addElement( mp_pause_menu_background_def() )
LUI.MenuBuilder.BuildAddChild( self, {
type = "button_helper_text_main",
id = "pmhelper_text_id"
} )
if GameX.IsOnlineMatch() and not GameX.IsSplitscreen() then
LUI.MenuBuilder.BuildAddChild( self, {
type = "online_friends_widget",
id = "pmfriends_widget_id"
} )
end
local f19_local4 = LUI.UIBindButton.new()
f19_local4.id = "pmBackToGameStartButton"
local f19_local5 = f19_local4
local f19_local6 = f19_local4.registerEventHandler
local f19_local7 = "button_start"
local f19_local8 = MBh.DoMultiple
local f19_local9 = {}
local f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
local f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
f19_local5 = f19_local4
f19_local6 = f19_local4.registerEventHandler
f19_local7 = "button_select"
f19_local8 = MBh.DoMultiple
f19_local9 = {}
f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
f19_local5 = f19_local4
f19_local6 = f19_local4.registerEventHandler
f19_local7 = "button_secondary"
f19_local8 = MBh.DoMultiple
f19_local9 = {}
f19_local10 = MBh.EmitEventToRoot( "toggle_pause_off" )
f19_local11 = MBh.CloseAllMenus()
f19_local6( f19_local5, f19_local7, f19_local8( f19_local10 ) )
self:addElement( mp_pause_menu_title_def( f19_local2 ) )
self:addElement( options_def() )
self:addElement( f19_local4 )
if not Engine.IsAliensMode() then
self:addElement( game_mode_def() )
self:addElement( map_display_def() )
else
self:addElement( LUI.mp_hud.AlienScoreboards.pause_menu_scoreboard() )
end
return self
end
LUI.MenuBuilder.registerType( "mp_pause_menu", mp_pause_menu )
LockTable( _M )