mirror of
https://github.com/JezuzLizard/BO2-Reimagined.git
synced 2025-06-08 06:12:17 -05:00
HUD: fix various issues with ammo counter
This commit is contained in:
parent
359d064a89
commit
3b213d381e
117
ui_mp/t6/hud/ammocounter.lua
Normal file
117
ui_mp/t6/hud/ammocounter.lua
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
CoD.AmmoCounter = {}
|
||||||
|
CoD.AmmoCounter.TextHeight = 28
|
||||||
|
CoD.AmmoCounter.LowAmmoFadeTime = 500
|
||||||
|
CoD.AmmoCounter.PulseDuration = 500
|
||||||
|
CoD.AmmoCounter.new = function (f1_arg0)
|
||||||
|
local Widget = LUI.UIElement.new(f1_arg0)
|
||||||
|
Widget:registerAnimationState("hide", {
|
||||||
|
alphaMultiplier = 0
|
||||||
|
})
|
||||||
|
Widget:registerAnimationState("show", {
|
||||||
|
alphaMultiplier = 1
|
||||||
|
})
|
||||||
|
Widget:animateToState("hide")
|
||||||
|
local f1_local1 = 36
|
||||||
|
local Widget_1 = LUI.UIElement.new({
|
||||||
|
left = -90,
|
||||||
|
top = f1_local1,
|
||||||
|
right = 10,
|
||||||
|
bottom = f1_local1 + 40,
|
||||||
|
leftAnchor = true,
|
||||||
|
topAnchor = true,
|
||||||
|
rightAnchor = false,
|
||||||
|
bottomAnchor = false
|
||||||
|
})
|
||||||
|
Widget:addElement(Widget_1)
|
||||||
|
local f1_local3 = CoD.AmmoCounter.TextHeight
|
||||||
|
Widget.ammoLabel = LUI.UIText.new({
|
||||||
|
left = -1,
|
||||||
|
top = -4,
|
||||||
|
right = 0,
|
||||||
|
bottom = 4,
|
||||||
|
leftAnchor = false,
|
||||||
|
topAnchor = true,
|
||||||
|
rightAnchor = true,
|
||||||
|
bottomAnchor = true,
|
||||||
|
alpha = 1
|
||||||
|
})
|
||||||
|
Widget.ammoLabel:setFont(CoD.fonts.Big)
|
||||||
|
Widget.ammoLabel:registerAnimationState("pulse_low", {
|
||||||
|
alpha = 1
|
||||||
|
})
|
||||||
|
Widget.ammoLabel:registerAnimationState("pulse_high", {
|
||||||
|
alpha = 0.5
|
||||||
|
})
|
||||||
|
Widget.ammoLabel:registerEventHandler("transition_complete_pulse_high", CoD.AmmoCounter.Ammo_PulseHigh)
|
||||||
|
Widget.ammoLabel:registerEventHandler("transition_complete_pulse_low", CoD.AmmoCounter.Ammo_PulseLow)
|
||||||
|
Widget_1:addElement(Widget.ammoLabel)
|
||||||
|
Widget:registerEventHandler("hud_update_refresh", CoD.AmmoCounter.UpdateVisibility)
|
||||||
|
Widget:registerEventHandler("hud_update_weapon", CoD.AmmoCounter.UpdateVisibility)
|
||||||
|
Widget:registerEventHandler("hud_update_ammo", CoD.AmmoCounter.UpdateAmmo)
|
||||||
|
return Widget
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.AmmoCounter.UpdateAmmo = function (f2_arg0, f2_arg1)
|
||||||
|
if f2_arg1.ammoInClip == 0 and f2_arg1.ammoStock == 0 and f2_arg1.lowClip ~= true then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local f2_local0 = f2_arg1.ammoInClip .. "/" .. f2_arg1.ammoStock
|
||||||
|
if f2_arg1.ammoInDWClip then
|
||||||
|
f2_local0 = f2_arg1.ammoInDWClip .. " | " .. f2_local0
|
||||||
|
end
|
||||||
|
f2_arg0.ammoLabel:setText(f2_local0)
|
||||||
|
if f2_arg1.lowClip and f2_arg0.lowAmmo ~= true then
|
||||||
|
f2_arg0.lowAmmo = true
|
||||||
|
if true == CoD.isZombie then
|
||||||
|
f2_arg0.ammoLabel:animateToState("pulse_high", CoD.AmmoCounter.LowAmmoFadeTime)
|
||||||
|
end
|
||||||
|
elseif f2_arg1.lowClip ~= true and f2_arg0.lowAmmo == true then
|
||||||
|
f2_arg0.lowAmmo = nil
|
||||||
|
if true == CoD.isZombie then
|
||||||
|
f2_arg0.ammoLabel:animateToState("default", CoD.AmmoCounter.LowAmmoFadeTime)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.AmmoCounter.ShouldHideAmmoCounter = function (f3_arg0, f3_arg1)
|
||||||
|
if f3_arg0.weapon ~= nil then
|
||||||
|
if Engine.IsWeaponType(f3_arg0.weapon, "melee") then
|
||||||
|
return true
|
||||||
|
elseif CoD.isZombie == true and (f3_arg1.inventorytype == 1 or f3_arg1.inventorytype == 2) then
|
||||||
|
return true
|
||||||
|
elseif CoD.isZombie == true and (Engine.IsWeaponType(f3_arg0.weapon, "gas") or Engine.IsOverheatWeapon(f3_arg0.weapon)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.AmmoCounter.UpdateVisibility = function (f4_arg0, f4_arg1)
|
||||||
|
local f4_local0 = f4_arg1.controller
|
||||||
|
if f4_arg1.weapon ~= nil then
|
||||||
|
f4_arg0.weapon = f4_arg1.weapon
|
||||||
|
end
|
||||||
|
if CoD.AmmoCounter.ShouldHideAmmoCounter(f4_arg0, f4_arg1) then
|
||||||
|
if f4_arg0.visible == true then
|
||||||
|
f4_arg0:animateToState("hide")
|
||||||
|
f4_arg0.visible = nil
|
||||||
|
end
|
||||||
|
f4_arg0:dispatchEventToChildren(f4_arg1)
|
||||||
|
elseif f4_arg0.visible ~= true then
|
||||||
|
f4_arg0:animateToState("show")
|
||||||
|
f4_arg0.visible = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.AmmoCounter.Ammo_PulseHigh = function (f5_arg0, f5_arg1)
|
||||||
|
if f5_arg1.interrupted ~= true then
|
||||||
|
f5_arg0:animateToState("pulse_low", CoD.AmmoCounter.LowAmmoFadeTime, true, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.AmmoCounter.Ammo_PulseLow = function (f6_arg0, f6_arg1)
|
||||||
|
if f6_arg1.interrupted ~= true then
|
||||||
|
f6_arg0:animateToState("pulse_high", CoD.AmmoCounter.LowAmmoFadeTime, false, true)
|
||||||
|
end
|
||||||
|
end
|
@ -364,6 +364,10 @@ CoD.AmmoAreaZombie.GetThreeDigits = function (f5_arg0)
|
|||||||
end
|
end
|
||||||
|
|
||||||
CoD.AmmoAreaZombie.UpdateAmmo = function (f6_arg0, f6_arg1)
|
CoD.AmmoAreaZombie.UpdateAmmo = function (f6_arg0, f6_arg1)
|
||||||
|
if f6_arg1.ammoInClip == 0 and f6_arg1.ammoStock == 0 and f6_arg1.lowClip ~= true then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local f6_local0 = #f6_arg0.ammoDigits
|
local f6_local0 = #f6_arg0.ammoDigits
|
||||||
if f6_arg0.hideAmmo then
|
if f6_arg0.hideAmmo then
|
||||||
for f6_local1 = 1, f6_local0, 1 do
|
for f6_local1 = 1, f6_local0, 1 do
|
||||||
@ -472,7 +476,7 @@ CoD.AmmoAreaZombie.UpdateFuel = function (f7_arg0, f7_arg1)
|
|||||||
end
|
end
|
||||||
|
|
||||||
CoD.AmmoAreaZombie.UpdateOverheat = function (f8_arg0, f8_arg1)
|
CoD.AmmoAreaZombie.UpdateOverheat = function (f8_arg0, f8_arg1)
|
||||||
if CoD.AmmoAreaZombie.ShouldHideAmmoCounter(f8_arg0, f8_arg1) == true then
|
if CoD.AmmoAreaZombie.ShouldHideOverheatCounter(f8_arg0, f8_arg1) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -561,6 +565,17 @@ CoD.AmmoAreaZombie.UpdateVisibility = function (f9_arg0, f9_arg1)
|
|||||||
end
|
end
|
||||||
|
|
||||||
CoD.AmmoAreaZombie.ShouldHideAmmoCounter = function (f10_arg0, f10_arg1)
|
CoD.AmmoAreaZombie.ShouldHideAmmoCounter = function (f10_arg0, f10_arg1)
|
||||||
|
if f10_arg0.weapon ~= nil then
|
||||||
|
if Engine.IsWeaponType(f10_arg0.weapon, "melee") then
|
||||||
|
return true
|
||||||
|
elseif CoD.isZombie == true and (f10_arg1.inventorytype == 1 or f10_arg1.inventorytype == 2) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.AmmoAreaZombie.ShouldHideOverheatCounter = function (f10_arg0, f10_arg1)
|
||||||
if f10_arg0.weapon ~= nil then
|
if f10_arg0.weapon ~= nil then
|
||||||
if CoD.isZombie == true and (Engine.IsWeaponType(f10_arg0.weapon, "gas") or Engine.IsOverheatWeapon(f10_arg0.weapon)) then
|
if CoD.isZombie == true and (Engine.IsWeaponType(f10_arg0.weapon, "gas") or Engine.IsOverheatWeapon(f10_arg0.weapon)) then
|
||||||
return false
|
return false
|
||||||
@ -573,7 +588,7 @@ CoD.AmmoAreaZombie.UpdateAmmoVisibility = function (f11_arg0, f11_arg1)
|
|||||||
if f11_arg1.weapon ~= nil then
|
if f11_arg1.weapon ~= nil then
|
||||||
f11_arg0.weapon = f11_arg1.weapon
|
f11_arg0.weapon = f11_arg1.weapon
|
||||||
end
|
end
|
||||||
if CoD.AmmoAreaZombie.ShouldHideAmmoCounter(f11_arg0, f11_arg1) == false then
|
if CoD.AmmoAreaZombie.ShouldHideAmmoCounter(f11_arg0, f11_arg1) then
|
||||||
for f11_local0 = 1, #f11_arg0.ammoDigits, 1 do
|
for f11_local0 = 1, #f11_arg0.ammoDigits, 1 do
|
||||||
f11_arg0.ammoDigits[f11_local0]:setAlpha(0)
|
f11_arg0.ammoDigits[f11_local0]:setAlpha(0)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user