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

141 lines
4.6 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function UpdateSpectator( f1_arg0, f1_arg1 )
local f1_local0 = f1_arg0:getChildById( "spectatorPlayerCard" )
local f1_local1 = Game.GetPlayerstateClientnum()
if f1_local0.current_client_num ~= f1_local1 then
local f1_local2 = f1_local0:getFirstDescendentById( "playerCardBg" )
local f1_local3 = f1_local0:getFirstDescendentById( "playerCardPatchBg" )
local f1_local4 = f1_local0:getFirstDescendentById( "playerCardPatch" )
local f1_local5 = f1_local0:getFirstDescendentById( "playerCardQuipText" )
local f1_local6 = f1_local0:getFirstDescendentById( "playerCardClanTagText" )
local f1_local7 = f1_local0:getFirstDescendentById( "playerCardRankIcon" )
local f1_local8 = f1_local0:getFirstDescendentById( "playerCardRankText" )
local f1_local9 = f1_local0:getFirstDescendentById( "playerCardNameText" )
local f1_local10 = nil
if f1_local1 ~= -1 then
f1_local10 = Game.GetPlayerScoreInfo( f1_local1 )
end
if f1_local10 and f1_local1 ~= Game.GetPlayerClientnum() then
f1_local8:setText( "" )
if f1_local10.rank then
f1_local8:setText( f1_local10.rank + 1 )
end
local f1_local11 = f1_local10.name or ""
f1_local6:setText( "" )
if Engine.IsConsoleGame() and string.sub( f1_local11, 1, 1 ) == "[" then
local f1_local12 = string.find( f1_local11, "]" )
if f1_local12 then
f1_local6:setText( string.sub( f1_local11, 1, f1_local12 ) )
f1_local11 = string.sub( f1_local11, f1_local12 + 1 )
end
end
f1_local9:setText( f1_local11 )
if f1_local10.rankIcon then
CoD.SetMaterial( f1_local7, f1_local10.rankIcon )
end
local f1_local12 = Game.GetPlayerCard( f1_local1 )
CoD.SetMaterial( f1_local2, RegisterMaterial( Engine.TableLookup( BackgroundsTable.File, BackgroundsTable.Cols.Ref, f1_local12.background, BackgroundsTable.Cols.CardImage ) ) )
CoD.SetMaterial( f1_local3, RegisterMaterial( Engine.TableLookup( PatchBackingsTable.File, PatchBackingsTable.Cols.Ref, f1_local12.patchBacking, PatchBackingsTable.Cols.CardImage ) ) )
CoD.SetMaterial( f1_local4, RegisterMaterial( Engine.TableLookup( PatchesTable.File, PatchesTable.Cols.Ref, f1_local12.patch, PatchesTable.Cols.CardImage ) ) )
f1_local5:setText( Engine.Localize( Engine.TableLookup( PatchesTable.File, PatchesTable.Cols.Ref, f1_local12.patch, PatchesTable.Cols.Quip ) ) )
local f1_local13 = MBh.AnimateSequence( {
{
"default",
0
},
{
"opening",
150
},
{
"active",
150
}
} )
f1_local13( f1_local0 )
else
f1_local0:animateToState( "default", 0 )
end
f1_local0.current_client_num = f1_local1
end
end
LUI.MenuBuilder.registerType( "spectatorHudDef", function ()
local self = LUI.UIElement.new()
self.id = "spectatorHud"
self:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = true,
bottomAnchor = true,
rightAnchor = true,
top = 0,
left = 0,
bottom = 0,
right = 0
} )
self:animateToState( "default", 0 )
self:registerEventHandler( "hud_refresh", UpdateSpectator )
local f2_local1 = LUI.UIText.new()
f2_local1.id = "spectatorTextId"
f2_local1:setText( Engine.Localize( "@LUA_MENU_SPECTATING_CAPS" ) )
f2_local1:setTextStyle( CoD.TextStyle.Shadowed )
f2_local1:registerAnimationState( "default", {
topAnchor = true,
leftAnchor = false,
bottomAnchor = false,
rightAnchor = false,
top = 60,
left = -512,
height = CoD.TextSettings.HudEuroBigFont.Height,
right = 512,
font = CoD.TextSettings.HudEuroBigFont.Font,
alpha = 0.6
} )
f2_local1:animateToState( "default", 0 )
local f2_local2 = LUI.UIElement.new()
f2_local2.id = "spectatorPlayerCard"
f2_local2:registerAnimationState( "default", {
topAnchor = false,
leftAnchor = false,
bottomAnchor = true,
rightAnchor = false,
bottom = -60,
left = -512,
height = 64,
width = 256,
alpha = 0
} )
f2_local2:animateToState( "default", 0 )
f2_local2:registerAnimationState( "active", {
topAnchor = false,
leftAnchor = false,
bottomAnchor = true,
rightAnchor = false,
bottom = -60,
left = -128,
height = 64,
width = 256,
alpha = 1
} )
f2_local2:registerAnimationState( "opening", {
topAnchor = false,
leftAnchor = false,
bottomAnchor = true,
rightAnchor = false,
bottom = -60,
left = -118,
height = 64,
width = 256,
alpha = 1
} )
f2_local2:addElement( LUI.mp_hud.PlayerCardHud.playerCardHudDef() )
self:addElement( f2_local1 )
self:addElement( f2_local2 )
self:addElement( LUI.mp_hud.Hints.spectatorControlsDef() )
return self
end )
LockTable( _M )