2014-10-02 08:49:54 +08:00
|
|
|
local PANEL = {}
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local matGlow = Material("sprites/glow04_noz")
|
|
|
|
local texDownEdge = surface.GetTextureID("gui/gradient_down")
|
2014-10-02 08:49:54 +08:00
|
|
|
local colHealth = Color(0, 0, 0, 240)
|
2018-05-02 06:32:59 +08:00
|
|
|
local function ContentsPaint(self, w, h)
|
|
|
|
local lp = MySelf
|
2014-10-02 08:49:54 +08:00
|
|
|
if lp:IsValid() then
|
2018-05-02 06:32:59 +08:00
|
|
|
local screenscale = BetterScreenScale()
|
2014-10-02 08:49:54 +08:00
|
|
|
local health = math.max(lp:Health(), 0)
|
|
|
|
local healthperc = math.Clamp(health / lp:GetMaxHealthEx(), 0, 1)
|
2018-05-02 06:32:59 +08:00
|
|
|
local wid, hei = 300 * screenscale, 18 * screenscale
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
colHealth.r = (1 - healthperc) * 180
|
|
|
|
colHealth.g = healthperc * 180
|
2018-05-02 06:32:59 +08:00
|
|
|
colHealth.b = 0
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local x = 18 * screenscale
|
|
|
|
local y = 115 * screenscale
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local subwidth = healthperc * wid
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
draw.SimpleTextBlurry(health, "ZSHUDFont", x + wid + 12 * screenscale, y + 8 * screenscale, colHealth, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetDrawColor(0, 0, 0, 230)
|
|
|
|
surface.DrawRect(x, y, wid, hei)
|
2014-11-07 13:03:40 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetDrawColor(colHealth.r * 0.6, colHealth.g * 0.6, colHealth.b, 160)
|
|
|
|
surface.SetTexture(texDownEdge)
|
|
|
|
surface.DrawTexturedRect(x + 2, y + 1, subwidth - 4, hei - 2)
|
|
|
|
surface.SetDrawColor(colHealth.r * 0.6, colHealth.g * 0.6, colHealth.b, 30)
|
|
|
|
surface.DrawRect(x + 2, y + 1, subwidth - 4, hei - 2)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetMaterial(matGlow)
|
|
|
|
surface.SetDrawColor(255, 255, 255, 255)
|
|
|
|
surface.DrawTexturedRect(x + 2 + subwidth - 6, y + 1 - hei/2, 4, hei * 2)
|
2014-11-07 13:03:40 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local phantomhealth = math.max(lp:GetPhantomHealth(), 0)
|
|
|
|
healthperc = math.Clamp(phantomhealth / lp:GetMaxHealthEx(), 0, 1)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
colHealth.r = 100
|
|
|
|
colHealth.g = 90
|
|
|
|
colHealth.b = 80
|
|
|
|
local phantomwidth = healthperc * wid
|
2014-11-07 13:03:40 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetDrawColor(colHealth.r, colHealth.g, colHealth.b, 160)
|
|
|
|
surface.SetTexture(texDownEdge)
|
|
|
|
surface.DrawTexturedRect(x + 2 + subwidth - 4, y + 1, phantomwidth, hei - 2)
|
|
|
|
surface.SetDrawColor(colHealth.r, colHealth.g, colHealth.b, 30)
|
|
|
|
surface.DrawRect(x + 2 + subwidth - 4, y + 1, phantomwidth, hei - 2)
|
2014-11-07 13:03:40 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
if lp:Team() == TEAM_HUMAN then
|
|
|
|
local bloodarmor = lp:GetBloodArmor()
|
|
|
|
if bloodarmor > 0 then
|
|
|
|
x = 78 * screenscale
|
|
|
|
y = 142 * screenscale
|
|
|
|
wid, hei = 240 * screenscale, 14 * screenscale
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
healthperc = math.Clamp(bloodarmor / (lp.MaxBloodArmor or 10), 0, 1)
|
|
|
|
colHealth.r = 50 + healthperc * 205
|
|
|
|
colHealth.g = 0
|
|
|
|
colHealth.b = (1 - healthperc) * 50
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
subwidth = healthperc * wid
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
draw.SimpleTextBlurry(bloodarmor, "ZSHUDFontSmall", x + wid + 12 * screenscale, y + 8 * screenscale, colHealth, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetDrawColor(0, 0, 0, 230)
|
|
|
|
surface.DrawRect(x, y, wid, hei)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetDrawColor(colHealth.r * 0.6, colHealth.g * 0.6, colHealth.b, 160)
|
|
|
|
surface.SetTexture(texDownEdge)
|
|
|
|
surface.DrawTexturedRect(x + 2, y + 1, subwidth - 4, hei - 2)
|
|
|
|
surface.SetDrawColor(colHealth.r * 0.5, colHealth.g * 0.5, colHealth.b, 30)
|
|
|
|
surface.DrawRect(x + 2, y + 1, subwidth - 4, hei - 2)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetMaterial(matGlow)
|
|
|
|
surface.SetDrawColor(255, 255, 255, 255)
|
|
|
|
surface.DrawTexturedRect(x + 2 + subwidth - 6, y + 1 - hei/2, 4, hei * 2)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
function PANEL:Init()
|
|
|
|
self:DockMargin(0, 0, 0, 0)
|
|
|
|
self:DockPadding(0, 0, 0, 0)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local contents = vgui.Create("Panel", self)
|
|
|
|
contents:Dock(FILL)
|
|
|
|
contents.Paint = ContentsPaint
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
self:ParentToHUD()
|
|
|
|
self:InvalidateLayout()
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
function PANEL:PerformLayout()
|
|
|
|
local screenscale = BetterScreenScale()
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
self:SetSize(screenscale * 500, screenscale * 168)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
self:AlignLeft()
|
|
|
|
self:AlignBottom()
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local matGradientLeft = CreateMaterial("gradient-l", "UnlitGeneric", {["$basetexture"] = "vgui/gradient-l", ["$vertexalpha"] = "1", ["$vertexcolor"] = "1", ["$ignorez"] = "1", ["$nomip"] = "1"})
|
|
|
|
function PANEL:Paint(w, h)
|
|
|
|
local y = h * 0.6
|
|
|
|
h = h - y
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
surface.SetDrawColor(0, 0, 0, 180)
|
|
|
|
surface.DrawRect(0, y, w * 0.4, h + 1)
|
|
|
|
surface.SetMaterial(matGradientLeft)
|
|
|
|
surface.DrawTexturedRect(w * 0.4, y, w * 0.6, h + 1)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
--surface.DrawLine(0, y, w, y)
|
|
|
|
surface.SetDrawColor(0, 0, 0, 250)
|
|
|
|
surface.SetMaterial(matGradientLeft)
|
|
|
|
surface.DrawTexturedRect(0, y, w, 1)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
return true
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
vgui.Register("ZSHealthArea", PANEL, "Panel")
|