103 lines
1.7 KiB
Lua
103 lines
1.7 KiB
Lua
|
|
---------------------
|
|
-- Your Name is Benny
|
|
---------------------
|
|
|
|
-- Stack related
|
|
local function xy( x, y )
|
|
return {x, y}
|
|
end
|
|
|
|
local function hXY( x, y )
|
|
local rx, ry = 0, 0
|
|
for key, value in ipairs(stack) do
|
|
rx = rx + value[1]
|
|
ry = ry + value[2]
|
|
end
|
|
if x then rx = rx + x end
|
|
if y then ry = ry + y end
|
|
return rx, ry
|
|
end
|
|
|
|
local function S_Push( x, y )
|
|
stack:Push( xy( x, y ) )
|
|
end
|
|
|
|
local function S_Pop( x, y )
|
|
stack:Pop()
|
|
end
|
|
|
|
|
|
local function hCol( r, g, b, a )
|
|
return surface.SetDrawColor( r, g, b, a )
|
|
end
|
|
|
|
local function hCoo( col )
|
|
return col
|
|
end
|
|
|
|
local function hRect( x, y, w, h )
|
|
gx, gy = hXY()
|
|
x = (x or 0) + gx
|
|
y = (y or 0) + gy
|
|
|
|
surface.DrawRect( x, y, w, h )
|
|
end
|
|
|
|
local function hORect( x, y, w, h, r )
|
|
gx, gy = hXY()
|
|
x = (x or 0) + gx
|
|
y = (y or 0) + gy
|
|
|
|
surface.DrawOutlinedRect( x, y, w, h, r )
|
|
end
|
|
|
|
local COLOR_DARK = Color( 40, 40, 80 )
|
|
local COLOR_BRIGHT = Color( 80, 80, 160 )
|
|
local COLOR_MAIN = Color( 160, 160, 240 )
|
|
|
|
-- Drawing
|
|
function GM:HUDPaint()
|
|
stack = util.Stack()
|
|
|
|
-- Centered
|
|
S_Push( ScrW()/2, ScrH()/2 )
|
|
|
|
-- Push Top, Centered Health
|
|
S_Push( -320/2, -440 )
|
|
|
|
hCol( COLOR_DARK )
|
|
hRect( 0, 0, 320, 30 )
|
|
|
|
hCol( COLOR_MAIN )
|
|
hRect( 2, 2, 320-2-2, 30-2-2 )
|
|
S_Pop()
|
|
|
|
|
|
S_Pop()
|
|
if stack:Size() != 0 then print("Stack unfinished.") end
|
|
return
|
|
end
|
|
|
|
|
|
-- Not drawing
|
|
local hide = {
|
|
["CHudHealth"] = true,
|
|
["CHudBattery"] = true,
|
|
["CHudAmmo"] = true,
|
|
["CHudSecondaryAmmo"] = true,
|
|
["CHudDamageIndicator"] = true,
|
|
["CHudCloseCaption"] = true,
|
|
["CHudCrosshair"] = true,
|
|
["CHudSuitPower"] = true,
|
|
["CHUDQuickInfo"] = true,
|
|
["CHudZoom"] = true,
|
|
}
|
|
|
|
function GM:HUDShouldDraw( name )
|
|
if hide[ name ] then
|
|
return false
|
|
else
|
|
return true
|
|
end
|
|
end |