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

603 lines
19 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function CacEditWeaponStatsInfoMeter( f1_arg0, f1_arg1, f1_arg2 )
local f1_local0 = Cac.Layout.CacWeaponMeter.offset_max * f1_arg1 / 100
if f1_arg2 < 0 then
f1_local0 = LUI.clamp( f1_local0 + Cac.Layout.CacWeaponMeter.offset_max * f1_arg2 / 100, 0, Cac.Layout.CacWeaponMeter.offset_max )
end
f1_arg0:registerAnimationState( "meter", {
right = f1_local0
} )
f1_arg0:animateToState( "meter", 100 )
end
function CacEditWeaponStatsInfoViewingMeter( f2_arg0, f2_arg1 )
local f2_local0 = f2_arg0.properties
local f2_local1 = nil
if f2_arg1.viewingWeapon then
f2_local1 = f2_arg1.viewingWeapon
else
f2_local1 = Cac.GetWeapon( f2_arg1.controller, f2_arg1.squadLocation, f2_arg1.squadMemberIndex, f2_arg1.classLocation, f2_arg1.slot, f2_arg1.weaponIndex )
end
local f2_local2 = 0
if f2_local1 then
f2_local2 = f2_local0.CacWeaponStatFunc( f2_local1 )
if f2_local2 == nil or f2_local2 == "" then
f2_local2 = 0
end
end
local f2_local3 = 0
if not f2_arg1.viewingWeapon then
local f2_local4 = nil
if f2_arg1.viewingAttach0 then
f2_local4 = f2_arg1.viewingAttach0
else
f2_local4 = Cac.GetAttachment( f2_arg1.controller, f2_arg1.squadLocation, f2_arg1.squadMemberIndex, f2_arg1.classLocation, f2_arg1.slot, f2_arg1.weaponIndex, 0 )
end
local f2_local5 = nil
if f2_arg1.viewingAttach1 then
f2_local5 = f2_arg1.viewingAttach1
else
f2_local5 = Cac.GetAttachment( f2_arg1.controller, f2_arg1.squadLocation, f2_arg1.squadMemberIndex, f2_arg1.classLocation, f2_arg1.slot, f2_arg1.weaponIndex, 1 )
end
local f2_local6 = nil
if f2_arg1.viewingAttach2 then
f2_local6 = f2_arg1.viewingAttach2
else
f2_local6 = Cac.GetAttachment( f2_arg1.controller, f2_arg1.squadLocation, f2_arg1.squadMemberIndex, f2_arg1.classLocation, f2_arg1.slot, f2_arg1.weaponIndex, 2 )
end
if f2_local4 and f2_local4 ~= "none" then
f2_local3 = f2_local3 + f2_local0.CacWeaponAttachStatFunc( f2_local4, f2_local1 )
end
if f2_local5 and f2_local5 ~= "none" then
f2_local3 = f2_local3 + f2_local0.CacWeaponAttachStatFunc( f2_local5, f2_local1 )
end
if f2_local6 and f2_local6 ~= "none" then
f2_local3 = f2_local3 + f2_local0.CacWeaponAttachStatFunc( f2_local6, f2_local1 )
end
end
CacEditWeaponStatsInfoMeter( f2_arg0, f2_local2, f2_local3 )
end
function CacEditWeaponStatsInfoEquippedMeter( f3_arg0, f3_arg1 )
local f3_local0 = f3_arg0.properties
local f3_local1 = Cac.GetWeapon( f3_arg1.controller, f3_arg1.squadLocation, f3_arg1.squadMemberIndex, f3_arg1.classLocation, f3_arg1.slot, f3_arg1.weaponIndex )
if f3_local1 then
local f3_local2 = f3_local0.CacWeaponStatFunc( f3_local1 )
if f3_local2 == nil or f3_local2 == "" then
f3_local2 = 0
end
local f3_local3 = Cac.GetAttachment( f3_arg1.controller, f3_arg1.squadLocation, f3_arg1.squadMemberIndex, f3_arg1.classLocation, f3_arg1.slot, f3_arg1.weaponIndex, 0 )
local f3_local4 = Cac.GetAttachment( f3_arg1.controller, f3_arg1.squadLocation, f3_arg1.squadMemberIndex, f3_arg1.classLocation, f3_arg1.slot, f3_arg1.weaponIndex, 1 )
local f3_local5 = Cac.GetAttachment( f3_arg1.controller, f3_arg1.squadLocation, f3_arg1.squadMemberIndex, f3_arg1.classLocation, f3_arg1.slot, f3_arg1.weaponIndex, 2 )
local f3_local6 = 0
if f3_local3 and f3_local3 ~= "none" then
f3_local6 = f3_local6 + f3_local0.CacWeaponAttachStatFunc( f3_local3, f3_local1 )
end
if f3_local4 and f3_local4 ~= "none" then
f3_local6 = f3_local6 + f3_local0.CacWeaponAttachStatFunc( f3_local4, f3_local1 )
end
if f3_local5 and f3_local5 ~= "none" then
f3_local6 = f3_local6 + f3_local0.CacWeaponAttachStatFunc( f3_local5, f3_local1 )
end
CacEditWeaponStatsInfoMeter( f3_arg0, f3_local2, f3_local6 )
end
end
function CacEditWeaponStatsInfoAttachmentMeter( f4_arg0, f4_arg1, f4_arg2, f4_arg3, f4_arg4 )
local f4_local0 = Colors.cac_weapon_meter_main.r
local f4_local1 = Colors.cac_weapon_meter_main.g
local f4_local2 = Colors.cac_weapon_meter_main.b
local f4_local3 = 1
local f4_local4 = LUI.clamp( Cac.Layout.CacWeaponMeter.offset_max * f4_arg1 / 100, 0, Cac.Layout.CacWeaponMeter.offset_max )
if f4_arg2 < 0 then
if f4_arg4 then
f4_local0 = Colors.cac_weapon_meter_worse_dark.r
f4_local1 = Colors.cac_weapon_meter_worse_dark.g
f4_local2 = Colors.cac_weapon_meter_worse_dark.b
else
f4_local0 = Colors.cac_weapon_meter_worse.r
f4_local1 = Colors.cac_weapon_meter_worse.g
f4_local2 = Colors.cac_weapon_meter_worse.b
end
f4_local3 = 1
elseif f4_arg2 > 0 then
if f4_arg4 then
f4_local0 = Colors.cac_weapon_meter_better_dark.r
f4_local1 = Colors.cac_weapon_meter_better_dark.g
f4_local2 = Colors.cac_weapon_meter_better_dark.b
else
f4_local0 = Colors.cac_weapon_meter_better.r
f4_local1 = Colors.cac_weapon_meter_better.g
f4_local2 = Colors.cac_weapon_meter_better.b
end
f4_local3 = 1
f4_local4 = LUI.clamp( f4_local4 + Cac.Layout.CacWeaponMeter.offset_max * f4_arg2 / 100, 0, Cac.Layout.CacWeaponMeter.offset_max )
else
f4_local3 = 0
end
f4_arg0:registerAnimationState( "meter", {
right = f4_local4,
red = f4_local0,
green = f4_local1,
blue = f4_local2,
alpha = f4_local3
} )
f4_arg0:animateToState( "meter", 100 )
local f4_local5 = f4_arg0:getChildById( "generic_border_id" )
if f4_local5 then
f4_local5:registerAnimationState( "meter", {
alpha = 1
} )
end
end
function CacEditWeaponStatsInfoViewingAttachmentMeter( f5_arg0, f5_arg1 )
local f5_local0 = f5_arg0.properties
local f5_local1, f5_local2 = nil
if f5_arg1.viewingWeapon then
f5_local1 = f5_arg1.viewingWeapon
f5_local2 = Cac.GetWeapon( f5_arg1.controller, f5_arg1.squadLocation, f5_arg1.squadMemberIndex, f5_arg1.classLocation, f5_arg1.slot, f5_arg1.weaponIndex )
else
f5_local1 = Cac.GetWeapon( f5_arg1.controller, f5_arg1.squadLocation, f5_arg1.squadMemberIndex, f5_arg1.classLocation, f5_arg1.slot, f5_arg1.weaponIndex )
end
local f5_local3 = 0
if f5_local1 then
f5_local3 = f5_local0.CacWeaponStatFunc( f5_local1 )
if f5_local3 == nil or f5_local3 == "" then
f5_local3 = 0
end
end
local f5_local4 = nil
if f5_local2 then
f5_local4 = f5_local0.CacWeaponStatFunc( f5_local2 )
if f5_local4 == nil or f5_local4 == "" then
f5_local4 = 0
end
end
local f5_local5 = nil
if f5_arg1.viewingAttach0 then
f5_local5 = f5_arg1.viewingAttach0
else
f5_local5 = Cac.GetAttachment( f5_arg1.controller, f5_arg1.squadLocation, f5_arg1.squadMemberIndex, f5_arg1.classLocation, f5_arg1.slot, f5_arg1.weaponIndex, 0 )
end
local f5_local6 = nil
if f5_arg1.viewingAttach1 then
f5_local6 = f5_arg1.viewingAttach1
else
f5_local6 = Cac.GetAttachment( f5_arg1.controller, f5_arg1.squadLocation, f5_arg1.squadMemberIndex, f5_arg1.classLocation, f5_arg1.slot, f5_arg1.weaponIndex, 1 )
end
local f5_local7 = nil
if f5_arg1.viewingAttach2 then
f5_local7 = f5_arg1.viewingAttach2
else
f5_local7 = Cac.GetAttachment( f5_arg1.controller, f5_arg1.squadLocation, f5_arg1.squadMemberIndex, f5_arg1.classLocation, f5_arg1.slot, f5_arg1.weaponIndex, 2 )
end
local f5_local8 = 0
if f5_local5 and f5_local5 ~= "none" then
f5_local8 = f5_local8 + f5_local0.CacWeaponAttachStatFunc( f5_local5, f5_local1 )
end
if f5_local6 and f5_local6 ~= "none" then
f5_local8 = f5_local8 + f5_local0.CacWeaponAttachStatFunc( f5_local6, f5_local1 )
end
if f5_local7 and f5_local7 ~= "none" then
f5_local8 = f5_local8 + f5_local0.CacWeaponAttachStatFunc( f5_local7, f5_local1 )
end
CacEditWeaponStatsInfoAttachmentMeter( f5_arg0, f5_local3, f5_local8, f5_local4 )
end
function CacEditWeaponStatsInfoEquippedAttachmentMeter( f6_arg0, f6_arg1 )
local f6_local0 = f6_arg0.properties
local f6_local1 = Cac.GetWeapon( f6_arg1.controller, f6_arg1.squadLocation, f6_arg1.squadMemberIndex, f6_arg1.classLocation, f6_arg1.slot, f6_arg1.weaponIndex )
if f6_local1 then
local f6_local2 = f6_local0.CacWeaponStatFunc( f6_local1 )
if f6_local2 == nil or f6_local2 == "" then
f6_local2 = 0
end
local f6_local3 = Cac.GetAttachment( f6_arg1.controller, f6_arg1.squadLocation, f6_arg1.squadMemberIndex, f6_arg1.classLocation, f6_arg1.slot, f6_arg1.weaponIndex, 0 )
local f6_local4 = Cac.GetAttachment( f6_arg1.controller, f6_arg1.squadLocation, f6_arg1.squadMemberIndex, f6_arg1.classLocation, f6_arg1.slot, f6_arg1.weaponIndex, 1 )
local f6_local5 = Cac.GetAttachment( f6_arg1.controller, f6_arg1.squadLocation, f6_arg1.squadMemberIndex, f6_arg1.classLocation, f6_arg1.slot, f6_arg1.weaponIndex, 2 )
local f6_local6 = 0
if f6_local3 and f6_local3 ~= "none" then
f6_local6 = f6_local6 + f6_local0.CacWeaponAttachStatFunc( f6_local3, f6_local1 )
end
if f6_local4 and f6_local4 ~= "none" then
f6_local6 = f6_local6 + f6_local0.CacWeaponAttachStatFunc( f6_local4, f6_local1 )
end
if f6_local5 and f6_local5 ~= "none" then
f6_local6 = f6_local6 + f6_local0.CacWeaponAttachStatFunc( f6_local5, f6_local1 )
end
CacEditWeaponStatsInfoAttachmentMeter( f6_arg0, f6_local2, f6_local6, nil, true )
end
end
function CacWeaponStatCompare( f7_arg0, f7_arg1 )
if f7_arg1.viewingWeapon then
f7_arg0:animateToState( "statcompare", 0 )
else
f7_arg0:animateToState( "statview", 0 )
end
end
function cac_weapon_info_pane_stat()
return {
type = "UIElement",
properties = {
statTitle = "Title",
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = false,
left = 50,
right = 0,
top = 0,
bottom = 30
}
},
children = {
{
type = "UIVerticalList",
properties = {
statTitle = MBh.Property( "statTitle" ),
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 4,
right = 0,
top = 2,
bottom = 0,
spacing = 1
},
statcompare = {
spacing = 1
},
statview = {
spacing = 9
}
},
handlers = {
refresh_info_pane = CacWeaponStatCompare
},
children = {
{
type = "UIHorizontalList",
id = "viewing_meter",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" ),
statTitle = MBh.Property( "statTitle" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = 0,
top = 0,
bottom = 14,
spacing = 12
}
},
children = {
{
type = "UIText",
properties = {
text = MBh.Property( "statTitle" ),
statTitle = MBh.Property( "statTitle" )
},
states = {
default = {
alignment = LUI.Alignment.Right,
leftAnchor = true,
rightAnchor = false,
topAnchor = false,
bottomAnchor = false,
left = 0,
right = 97,
top = -0.5 * CoD.TextSettings.SmallFont.Height + 4,
bottom = 0.5 * CoD.TextSettings.SmallFont.Height + 4,
font = CoD.TextSettings.SmallFont.Font,
red = Colors.cac_sub_popup_text.r,
green = Colors.cac_sub_popup_text.g,
blue = Colors.cac_sub_popup_text.b,
alpha = 1
}
},
handlers = {
refresh_info_pane = CacViewingMeterText
}
},
{
type = "UIElement",
id = "large_meter_id",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0
}
},
children = {
{
type = "UIImage",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = Cac.Layout.CacWeaponMeter.left,
right = Cac.Layout.CacWeaponMeter.left,
top = Cac.Layout.CacWeaponMeter.top,
bottom = Cac.Layout.CacWeaponMeter.bottom,
material = RegisterMaterial( "white" ),
red = Colors.cac_weapon_meter_main.r,
green = Colors.cac_weapon_meter_main.g,
blue = Colors.cac_weapon_meter_main.b,
alpha = 1
},
statcompare = {
alpha = 0
},
statview = {
alpha = 1
}
},
handlers = {
refresh_info_pane = MBh.DoMultiple( {
CacEditWeaponStatsInfoViewingAttachmentMeter,
CacWeaponStatCompare
} )
}
},
{
type = "UIImage",
id = "large_front_bar_id",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = true,
left = Cac.Layout.CacWeaponMeter.left,
right = Cac.Layout.CacWeaponMeter.left,
top = Cac.Layout.CacWeaponMeter.top,
bottom = Cac.Layout.CacWeaponMeter.bottom,
material = RegisterMaterial( "white" ),
red = Colors.white.r,
green = Colors.white.g,
blue = Colors.white.b,
alpha = 1
}
},
handlers = {
refresh_info_pane = CacEditWeaponStatsInfoViewingMeter
}
}
}
}
}
},
{
type = "UIHorizontalList",
id = "equipped_meter",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" ),
statTitle = MBh.Property( "statTitle" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = false,
left = 109,
right = 0,
top = 0,
bottom = 6,
spacing = 12
},
statcompare = {
alpha = 1
},
statview = {
alpha = 0
}
},
handlers = {
refresh_info_pane = CacWeaponStatCompare
},
children = {
{
type = "UIElement",
id = "equipped_select_overflow_meter",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0
}
},
children = {
{
type = "UIImage",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = Cac.Layout.CacWeaponMeter.left,
right = Cac.Layout.CacWeaponMeter.left,
top = 0,
bottom = -Cac.Layout.CacWeaponMeter.bottom,
material = RegisterMaterial( "white" ),
red = Colors.cac_weapon_meter_main.r,
green = Colors.cac_weapon_meter_main.g,
blue = Colors.cac_weapon_meter_main.b,
alpha = 1
}
},
handlers = {
refresh_info_pane = CacEditWeaponStatsInfoEquippedAttachmentMeter
}
},
{
type = "UIImage",
properties = {
CacWeaponStatFunc = MBh.Property( "CacWeaponStatFunc" ),
CacWeaponAttachStatFunc = MBh.Property( "CacWeaponAttachStatFunc" )
},
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = Cac.Layout.CacWeaponMeter.left,
right = Cac.Layout.CacWeaponMeter.left,
top = 0,
bottom = -Cac.Layout.CacWeaponMeter.bottom,
material = RegisterMaterial( "white" ),
red = Cac.Swatches.highlight.r,
green = Cac.Swatches.highlight.g,
blue = Cac.Swatches.highlight.b,
alpha = 1
}
},
handlers = {
refresh_info_pane = CacEditWeaponStatsInfoEquippedMeter
}
}
}
}
}
}
}
}
}
}
end
function cac_weapon_info_pane_stats_page()
return {
type = "cac_basic_info_pane_page",
children = {
{
type = "UIVerticalList",
id = "cac_weapon_info_pane_stats",
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 2,
bottom = 0,
spacing = 0
}
},
children = {
{
type = "cac_weapon_info_pane_stat",
id = "weapon_stats_info_1",
properties = {
statTitle = Cac.WeaponStatTypes.Accuracy.Title,
CacWeaponStatFunc = Cac.GetWeaponAccuracy,
CacWeaponAttachStatFunc = Cac.GetAttachmentAccuracy
}
},
{
type = "cac_weapon_info_pane_stat",
id = "weapon_stats_info_2",
properties = {
statTitle = Cac.WeaponStatTypes.Damage.Title,
CacWeaponStatFunc = Cac.GetWeaponDamage,
CacWeaponAttachStatFunc = Cac.GetAttachmentDamage
}
},
{
type = "cac_weapon_info_pane_stat",
id = "weapon_stats_info_3",
properties = {
statTitle = Cac.WeaponStatTypes.Range.Title,
CacWeaponStatFunc = Cac.GetWeaponRange,
CacWeaponAttachStatFunc = Cac.GetAttachmentRange
}
},
{
type = "cac_weapon_info_pane_stat",
id = "weapon_stats_info_4",
properties = {
statTitle = Cac.WeaponStatTypes.FireRate.Title,
CacWeaponStatFunc = Cac.GetWeaponFireRate,
CacWeaponAttachStatFunc = Cac.GetAttachmentFireRate
}
},
{
type = "cac_weapon_info_pane_stat",
id = "weapon_stats_info_5",
properties = {
statTitle = Cac.WeaponStatTypes.Mobility.Title,
CacWeaponStatFunc = Cac.GetWeaponMobility,
CacWeaponAttachStatFunc = Cac.GetAttachmentMobility
}
}
}
}
}
}
end
LUI.MenuBuilder.registerDef( "cac_weapon_info_pane_stats_page", cac_weapon_info_pane_stats_page )
LUI.MenuBuilder.registerDef( "cac_weapon_info_pane_stat", cac_weapon_info_pane_stat )
LockTable( _M )