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

520 lines
13 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
f0_local0 = Engine.Localize( "@LUA_MENU_WINNING" )
f0_local1 = Engine.Localize( "@LUA_MENU_LOSING" )
f0_local2 = Engine.Localize( "@LUA_MENU_TIED" )
local f0_local3 = Engine.Localize( "@" .. Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, Engine.GetDvarString( "ui_gametype" ), GameTypesTable.Cols.Name ) )
local f0_local4 = 215
local f0_local5 = 10
local f0_local6 = 22
local f0_local7 = 22
local f0_local8 = 250
local f0_local9 = 10000
function SetTextAndAnimateSequenceIfChanged( f1_arg0, f1_arg1, f1_arg2, f1_arg3 )
if f1_arg0.current_state ~= f1_arg2 then
f1_arg0:setText( f1_arg1 )
local f1_local0 = MBh.AnimateSequence( f1_arg3 )
f1_local0( f1_arg0 )
f1_arg0.current_state = f1_arg2
end
end
local f0_local10 = {
{
"default",
0
},
{
"slide_in",
250
}
}
local f0_local11 = {
winning = {
text = f0_local0,
status = "winning",
anim = {
{
"default",
0
},
{
"slide_in",
250
},
{
"winning",
250
}
}
},
losing = {
text = f0_local1,
status = "losing",
anim = {
{
"default",
0
},
{
"slide_in",
250
},
{
"losing",
250
}
}
},
tied = {
text = f0_local2,
status = "tied",
anim = {
{
"default",
0
},
{
"slide_in",
250
},
{
"tied",
250
}
}
}
}
local f0_local12 = function ( f2_arg0 )
local self = LUI.UIText.new()
self.id = f2_arg0.id or nil
self:setupUIBindText( f2_arg0.dataSource )
self:registerAnimationState( "default", {
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottom = f2_arg0.bottom,
height = f2_arg0.height,
font = f2_arg0.font,
alignment = f2_arg0.alignment
} )
self:animateToState( "default", 0 )
return self
end
local f0_local13 = function ( f3_arg0 )
local self = LUI.UIHorizontalList.new()
self.id = f3_arg0.id or nil
self:registerAnimationState( "default", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = false,
bottom = f3_arg0.bottom or 0,
left = f3_arg0.left or 0,
height = f3_arg0.height
} )
self:animateToState( "default", 0 )
if f3_arg0.startcap ~= nil then
local f3_local1 = LUI.UIImage.new()
f3_local1.id = "start_cap"
f3_local1:registerAnimationState( "default", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
bottom = 0,
left = 0,
width = f3_arg0.startcap.width,
height = f3_arg0.imageHeight,
material = RegisterMaterial( f3_arg0.startcap.material )
} )
f3_local1:animateToState( "default", 0 )
self:addElement( f3_local1 )
end
local f3_local1 = LUI.UIImage.new()
f3_local1.id = "middle"
f3_local1:setupUIScorebar( f3_arg0.dataSource )
f3_local1.m_maxScore = f3_arg0.maxScore
f3_local1.m_maxWidth = f3_arg0.maxWidth - (f3_arg0.startcap and f3_arg0.startcap.width or 0) - (f3_arg0.endcap and f3_arg0.endcap.width or 0)
f3_local1:registerAnimationState( "default", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
bottom = 0,
height = f3_arg0.imageHeight,
material = RegisterMaterial( f3_arg0.material )
} )
f3_local1:animateToState( "default", 0 )
self:addElement( f3_local1 )
if f3_arg0.endcap ~= nil then
local f3_local2 = LUI.UIImage.new()
f3_local2.id = "end_cap"
f3_local2:registerAnimationState( "default", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
bottom = 0,
left = 0,
width = f3_arg0.endcap.width,
height = f3_arg0.imageHeight,
material = RegisterMaterial( f3_arg0.endcap.material )
} )
f3_local2:animateToState( "default", 0 )
self:addElement( f3_local2 )
end
return self
end
local f0_local14 = function ()
if GameX.gameModeIsFFA() then
local f4_local0 = Game.GetPlayerScoreRanking() or 0
if f4_local0 > 1 then
local f4_local1 = GameX.GetPlayerScoreInfoAtRankForGameMode( Teams.free, 1, GameX.GetGameMode() )
local f4_local2 = GameX.GetPlayerScoreInfoAtRankForGameMode( Teams.free, f4_local0, GameX.GetGameMode() )
if f4_local1.score == f4_local2.score then
return "tied"
else
return "losing"
end
end
local f4_local1 = Game.GetPlayerName()
local f4_local2 = Game.GetPlayerScore()
local f4_local3 = Game.GetPlayerTeam()
local f4_local4 = Game.GetNumPlayersOnTeam( f4_local3 )
local f4_local5 = false
for f4_local6 = 1, f4_local4, 1 do
local f4_local9 = Game.GetPlayerScoreInfoAtRank( f4_local3, f4_local6 )
if f4_local9 and f4_local9.name ~= f4_local1 then
f4_local5 = f4_local9.score == f4_local2
if f4_local5 then
break
end
end
end
if f4_local5 then
return "tied"
end
return "winning"
else
local f4_local0 = Game.GetPlayerTeam()
local f4_local1 = GameX.GetPlayerOpposingTeam()
local f4_local2 = Game.GetTeamScore( f4_local0 ) or 0
local f4_local3 = Game.GetTeamScore( f4_local1 ) or 0
if f4_local3 < f4_local2 then
return "winning"
elseif f4_local2 < f4_local3 then
return "losing"
elseif f4_local2 == f4_local3 then
return "tied"
else
return nil
end
end
end
local f0_local15 = function ( f5_arg0, f5_arg1 )
if f5_arg0.current_match_status ~= f5_arg1 then
local f5_local0 = f5_arg0:getChildById( "cycle_text_timer" )
f5_local0:reset()
end
end
local f0_local16 = function ( f6_arg0, f6_arg1 )
local f6_local0 = f6_arg0
if f6_arg0.id ~= "score_info_text" then
local f6_local1 = f6_arg0:getParent()
f6_local0 = f6_local1:getChildById( "score_info_text" )
end
if f6_local0.current_score_info == nil then
f6_local0.current_score_info = "game_mode"
f6_local0.current_match_status = "tied"
SetTextAndAnimateSequenceIfChanged( f6_local0, f0_local3, "game_mode", f0_local10 )
return
elseif f6_arg1.name == "cycle_text" then
if f6_local0.current_score_info ~= "game_mode" then
f6_local0.current_score_info = "game_mode"
else
f6_local0.current_score_info = "win_lose_tie"
end
end
if f6_local0.current_score_info == "game_mode" then
if f6_arg1.name == "cycle_text" then
SetTextAndAnimateSequenceIfChanged( f6_local0, f0_local3, "game_mode", f0_local10 )
else
local f6_local1 = f0_local14()
if f6_local1 ~= f6_local0.current_match_status then
SetTextAndAnimateSequenceIfChanged( f6_local0, f0_local11[f6_local1].text, f0_local11[f6_local1].status, f0_local11[f6_local1].anim )
f6_local0.current_match_status = f0_local11[f6_local1].status
end
end
else
local f6_local1 = f0_local14()
SetTextAndAnimateSequenceIfChanged( f6_local0, f0_local11[f6_local1].text, f0_local11[f6_local1].status, f0_local11[f6_local1].anim )
f0_local15( f6_local0, f0_local11[f6_local1].status )
f6_local0.current_match_status = f0_local11[f6_local1].status
end
end
LUI.MenuBuilder.registerType( "teamScoresHudDef", function ()
local f7_local0 = RegisterMaterial( "hud_scorebar_bg" )
local f7_local1 = Engine.GetDvarInt( "ui_scorelimit" )
local self = LUI.UIElement.new()
self.id = "teamScoresId"
self:registerAnimationState( "default", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = false,
bottom = -10,
left = -18,
height = 128,
width = 0,
alpha = 0
} )
self:animateToState( "default", 0 )
self:registerAnimationState( "active", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = false,
bottom = -10,
left = -18,
height = 128,
width = 512,
alpha = 1
} )
self:registerAnimationState( "opening", {
topAnchor = false,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = false,
bottom = -10,
left = -18,
height = 128,
width = 552,
alpha = 1
} )
self:registerEventHandler( "hud_on", MBh.AnimateSequence( {
{
"default",
0
},
{
"opening",
f0_local8 / 2
},
{
"active",
f0_local8 / 2
}
} ) )
local f7_local3 = LUI.UIImage.new()
f7_local3.id = "teamScoresBgId"
f7_local3:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
material = f7_local0
} )
f7_local3:animateToState( "default", 0 )
local f7_local4 = LUI.UIElement.new()
f7_local4.id = "teamScoresFriendlyScore"
f7_local4:registerAnimationState( "default", {
bottomAnchor = true,
leftAnchor = true,
bottom = -27,
left = 58,
height = CoD.TextSettings.HudDigitalBigFont.Height,
width = 40
} )
f7_local4:animateToState( "default", 0 )
local f7_local5 = LUI.UIText.new()
f7_local5.id = "teamScoresFriendlyScoreBg"
f7_local5:setText( "8888" )
f7_local5:registerAnimationState( "default", {
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottom = 0,
height = CoD.TextSettings.HudDigitalBigFont.Height,
font = CoD.TextSettings.HudDigitalBigFont.Font,
alignment = LUI.Alignment.Right,
red = 0,
green = 0,
blue = 0,
alpha = 0.25
} )
f7_local5:animateToState( "default", 0 )
f7_local4:addElement( f7_local5 )
f7_local4:addElement( f0_local12( {
id = "friendlyTeamScoreNum",
dataSource = "TeamScoreFriendly",
bottom = 0,
height = CoD.TextSettings.HudDigitalBigFont.Height,
font = CoD.TextSettings.HudDigitalBigFont.Font,
alignment = LUI.Alignment.Right
} ) )
local f7_local6 = LUI.UIElement.new()
f7_local6.id = "teamScoresEnemyScore"
f7_local6:registerAnimationState( "default", {
bottomAnchor = true,
leftAnchor = true,
bottom = -3,
left = 58,
height = CoD.TextSettings.HudDigitalNormalFont.Height,
width = 40
} )
f7_local6:animateToState( "default", 0 )
local f7_local7 = LUI.UIText.new()
f7_local7.id = "teamScoresEnemyScoreBg"
f7_local7:setText( "8888" )
f7_local7:registerAnimationState( "default", {
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottom = 0,
height = CoD.TextSettings.HudDigitalNormalFont.Height,
font = CoD.TextSettings.HudDigitalNormalFont.Font,
alignment = LUI.Alignment.Right,
red = 0,
green = 0,
blue = 0,
alpha = 0.25
} )
f7_local7:animateToState( "default", 0 )
f7_local6:addElement( f7_local7 )
f7_local6:addElement( f0_local12( {
id = "enemyTeamScoreNum",
dataSource = "TeamScoreEnemy",
bottom = 0,
height = CoD.TextSettings.HudDigitalNormalFont.Height,
font = CoD.TextSettings.HudDigitalNormalFont.Font,
alignment = LUI.Alignment.Right
} ) )
local f7_local8 = LUI.UIVerticalList.new()
f7_local8.id = "teamScoreBars"
f7_local8:registerAnimationState( "default", {
bottomAnchor = true,
leftAnchor = true,
bottom = 10,
left = 101,
height = 50,
width = 200,
spacing = 5
} )
f7_local8:animateToState( "default", 0 )
f7_local8:addElement( f0_local13( {
id = "friendlyTeamScorebar",
dataSource = "TeamScoreFriendly",
bottom = 0,
left = 0,
height = 17,
maxScore = f7_local1,
material = "hud_scorebar_min_cyan",
maxWidth = f0_local4,
imageHeight = f0_local7,
endcap = {
material = "hud_scorebar_cap_cyan",
width = f0_local6
}
} ) )
f7_local8:addElement( f0_local13( {
id = "enemyTeamScorebar",
dataSource = "TeamScoreEnemy",
bottom = 0,
left = 0,
height = 17,
maxScore = f7_local1,
material = "hud_scorebar_min_orange",
maxWidth = f0_local4 - 12,
imageHeight = f0_local7,
endcap = {
material = "hud_scorebar_cap_orange",
width = f0_local6
}
} ) )
local f7_local9 = LUI.UIText.new()
f7_local9.id = "score_info_text"
f7_local9:setText( "" )
f7_local9:setTextStyle( CoD.TextStyle.Shadowed )
f7_local9:registerAnimationState( "default", {
leftAnchor = true,
bottomAnchor = true,
bottom = -10,
left = 500,
height = CoD.TextSettings.HudEuroMedSmallFont.Height,
font = CoD.TextSettings.HudEuroMedSmallFont.Font,
alignment = LUI.Alignment.Left,
red = Colors.white.r,
green = Colors.white.g,
blue = Colors.white.b,
alpha = 0
} )
f7_local9:animateToState( "default", 0 )
f7_local9:registerAnimationState( "slide_in", {
leftAnchor = true,
bottomAnchor = true,
bottom = -10,
left = 315,
height = CoD.TextSettings.HudEuroMedSmallFont.Height,
font = CoD.TextSettings.HudEuroMedSmallFont.Font,
red = Colors.white.r,
green = Colors.white.g,
blue = Colors.white.b,
alpha = 1
} )
f7_local9:registerAnimationState( "winning", {
red = Colors.cyan.r,
green = Colors.cyan.g,
blue = Colors.cyan.b
} )
f7_local9:registerAnimationState( "losing", {
red = Colors.orange.r,
green = Colors.orange.g,
blue = Colors.orange.b
} )
f7_local9:registerAnimationState( "tied", {
red = Colors.white.r,
green = Colors.white.g,
blue = Colors.white.b
} )
f7_local9:registerAnimationState( "blink_off", {
alpha = 0
} )
f7_local9:registerAnimationState( "blink_on", {
alpha = 1
} )
f7_local9:registerEventHandler( "cycle_text", f0_local16 )
local f7_local10 = {
event = "cycle_text",
group = "hud",
interval = f0_local9
}
local f7_local11 = LUI.UITimer.new( f7_local10.interval, f7_local10.event, f7_local10.group )
f7_local11.id = "cycle_text_timer"
f7_local9:addElement( f7_local11 )
local f7_local12 = LUI.UIElement.new()
f7_local12:setupUIIntWatch( "TeamScoreFriendly" )
f7_local12.id = "friendly_score_watch"
f7_local12:registerEventHandler( "int_watch_alert", f0_local16 )
local f7_local13 = LUI.UIElement.new()
f7_local13:setupUIIntWatch( "TeamScoreEnemy" )
f7_local13.id = "enemy_score_watch"
f7_local13:registerEventHandler( "int_watch_alert", f0_local16 )
f7_local3:addElement( f7_local4 )
f7_local3:addElement( f7_local6 )
f7_local3:addElement( f7_local8 )
f7_local3:addElement( f7_local9 )
f7_local3:addElement( f7_local12 )
f7_local3:addElement( f7_local13 )
f7_local3:addElement( LUI.MenuBuilder.buildItems( {
type = "timersHudDef"
}, f7_local3.properties, f7_local3 ) )
self:addElement( f7_local3 )
return self
end )
LockTable( _M )