2024-03-07 21:19:30 -05:00
|
|
|
|
|
|
|
---------------------
|
|
|
|
-- 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 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
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
local function hRRect( x, y, w, h, r )
|
|
|
|
gx, gy = hXY()
|
|
|
|
x = (x or 0) + gx
|
|
|
|
y = (y or 0) + gy
|
|
|
|
|
|
|
|
draw.RoundedBox( r, x, y, w, h, surface.GetDrawColor() )
|
|
|
|
end
|
|
|
|
|
2024-04-07 19:04:18 -04:00
|
|
|
local function hTRect( x, y, w, h )
|
|
|
|
gx, gy = hXY()
|
|
|
|
x = (x or 0) + gx
|
|
|
|
y = (y or 0) + gy
|
|
|
|
|
|
|
|
surface.DrawTexturedRect( x, y, w, h )
|
|
|
|
end
|
|
|
|
|
|
|
|
local function hTrRect( x, y, w, h, d )
|
|
|
|
gx, gy = hXY()
|
|
|
|
x = (x or 0) + gx
|
|
|
|
y = (y or 0) + gy
|
|
|
|
|
|
|
|
surface.DrawTexturedRectRotated( x, y, w, h, d )
|
|
|
|
end
|
|
|
|
|
2024-03-07 21:19:30 -05:00
|
|
|
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
|
|
|
|
|
2024-03-07 22:34:29 -05:00
|
|
|
local function hScis( x, y, w, h )
|
|
|
|
gx, gy = hXY()
|
|
|
|
x = (x or 0) + gx
|
|
|
|
y = (y or 0) + gy
|
|
|
|
|
|
|
|
render.SetScissorRect( x, y, x+w, y+h, true )
|
|
|
|
end
|
|
|
|
|
|
|
|
local function hScisoff()
|
|
|
|
render.SetScissorRect( 0, 0, 0, 0, false )
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local sizes = {
|
2024-04-06 09:30:09 -04:00
|
|
|
8, 10, 16, 24, 36, 48
|
2024-03-07 22:34:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
local function regenfonts()
|
|
|
|
for index, scale in ipairs( sizes ) do
|
|
|
|
surface.CreateFont("HUD_" .. scale, {
|
|
|
|
font = "Carbon Plus Bold",
|
|
|
|
size = scale,
|
|
|
|
weight = 0,
|
|
|
|
extended = false,
|
|
|
|
italic = false,
|
|
|
|
antialias = true,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
regenfonts()
|
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
-- local COLOR_DARK = Color( 40, 40, 80 )
|
|
|
|
-- local COLOR_BRIGHT = Color( 80, 80, 160 )
|
|
|
|
-- local COLOR_MAIN = Color( 160, 160, 240 )
|
|
|
|
|
|
|
|
local COLOR_DARK = Color( 54, 44, 39 )
|
|
|
|
local COLOR_BRIGHT = Color( 94, 84, 79 )
|
|
|
|
local COLOR_MAIN = Color( 255, 238, 169 )
|
2024-03-07 21:19:30 -05:00
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
local show_letters = {
|
|
|
|
{ "q", "w", "e", "r", "t", "y" },
|
|
|
|
{ "a", "s", "d", "f", "g", "h" },
|
|
|
|
{ "shift", "z", "x", "c", "v", "b", "n" },
|
|
|
|
{ "ctrl", "alt", "space" },
|
|
|
|
}
|
|
|
|
|
|
|
|
local translate_letters = {
|
|
|
|
["e"] = "weapon 1",
|
|
|
|
["q"] = "weapon 2",
|
|
|
|
["c"] = "grenade 1",
|
|
|
|
["z"] = "grenade 2",
|
|
|
|
["r"] = "alt 1",
|
|
|
|
["t"] = "alt 2",
|
|
|
|
["x"] = "bullrush",
|
|
|
|
["shift"] = "speed",
|
|
|
|
}
|
|
|
|
|
2024-04-07 19:04:18 -04:00
|
|
|
local xhair_dot = Material( "benny/hud/xhair/dotx.png", "mips smooth" )
|
|
|
|
local xhair_dot_shadow = Material( "benny/hud/xhair/dot_s.png", "mips smooth" )
|
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
local function commoncode( set )
|
|
|
|
for index, letter in ipairs( set ) do
|
|
|
|
local lettercode = input.GetKeyCode( letter )
|
|
|
|
local keydown = input.IsKeyDown( lettercode )
|
|
|
|
local thecolor = keydown and COLOR_MAIN or COLOR_DARK
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
local fakecolor = ColorAlpha( COLOR_BRIGHT, 60 )
|
2024-04-06 09:30:09 -04:00
|
|
|
hCol( fakecolor )
|
|
|
|
hRect( (index-1)*(60+4), 0, 60, 40, 2 )
|
|
|
|
|
|
|
|
hCol( thecolor )
|
|
|
|
hORect( (index-1)*(60+4), 0, 60, 40, 2 )
|
|
|
|
local x, y = hXY( (index-1)*(60+4) + 30, 20+3 )
|
|
|
|
draw.SimpleText( letter:upper(), "HUD_36", x, y, thecolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
|
|
|
|
|
|
|
local tlated = translate_letters[letter]
|
|
|
|
if tlated then
|
|
|
|
local x, y = hXY( (index-1)*(60+4) + 30, 20 + 6 )
|
|
|
|
draw.SimpleText( tlated, "HUD_16", x, y, thecolor, TEXT_ALIGN_CENTER )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
local fmlookup = {
|
|
|
|
[1] = "SEMI",
|
|
|
|
[math.huge] = "AUTO",
|
|
|
|
}
|
|
|
|
|
2024-03-07 21:19:30 -05:00
|
|
|
-- Drawing
|
|
|
|
function GM:HUDPaint()
|
2024-03-07 22:34:29 -05:00
|
|
|
local p = LocalPlayer()
|
|
|
|
local w, h = ScrW(), ScrH()
|
2024-03-12 18:43:31 -04:00
|
|
|
local handler = p:HandlerCheck()
|
2024-03-07 21:19:30 -05:00
|
|
|
stack = util.Stack()
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
-- S_Push( math.random( -4, 4 ), math.random( -4, 4 ) )
|
|
|
|
|
|
|
|
S_Push( 20, h - 20 - 64 )
|
2024-03-07 21:19:30 -05:00
|
|
|
hCol( COLOR_DARK )
|
2024-08-30 18:30:03 -04:00
|
|
|
hRRect( 0, 0, 328, 64, 8 )
|
2024-03-07 22:34:29 -05:00
|
|
|
|
|
|
|
local x, y = hXY( 6, 0 )
|
|
|
|
draw.SimpleText( "BENNY", "HUD_48", x, y, COLOR_MAIN )
|
2024-03-07 21:19:30 -05:00
|
|
|
|
|
|
|
hCol( COLOR_MAIN )
|
2024-08-30 18:30:03 -04:00
|
|
|
hRect( 8, 8, (320-4-4) * p:GetHealth_Blood()/1000, 40-4-4 )
|
|
|
|
hCol( COLOR_DARK )
|
|
|
|
hORect( 8+1, 8+1, (320-4-4)-2, 40-4-4-2, 1 )
|
|
|
|
|
|
|
|
hCol( COLOR_MAIN )
|
|
|
|
hScis( 8, 8, (320-4-4) * p:GetHealth_Blood()/1000, 40-4-4 )
|
|
|
|
local x, y = hXY( 10, 4 )
|
|
|
|
draw.SimpleText( "BENNY", "HUD_48", x, y, COLOR_DARK )
|
2024-03-07 22:34:29 -05:00
|
|
|
hScisoff()
|
2024-08-30 18:30:03 -04:00
|
|
|
|
|
|
|
local slen = (320-4-4-4-4-4)
|
|
|
|
hCol( COLOR_MAIN )
|
|
|
|
hRect( 8, 44, slen*0.25, 12 )
|
|
|
|
hRect( 8 + (slen*0.25+4), 44, slen*0.25, 12 )
|
|
|
|
hRect( 8 + (slen*0.25+4)*2, 44, slen*0.25, 12 )
|
|
|
|
hRect( 8 + (slen*0.25+4)*3, 44, slen*0.25, 12 )
|
|
|
|
|
|
|
|
hCol( COLOR_DARK )
|
|
|
|
hORect( 8+1, 44+1, slen*0.25 - 2, 12-2, 1 )
|
|
|
|
hORect( 8+1 + (slen*0.25+4), 44+1, slen*0.25 - 2, 12-2, 1 )
|
|
|
|
hORect( 8+1 + (slen*0.25+4)*2, 44+1, slen*0.25 - 2, 12-2, 1 )
|
|
|
|
hORect( 8+1 + (slen*0.25+4)*3, 44+1, slen*0.25 - 2, 12-2, 1 )
|
2024-03-07 21:19:30 -05:00
|
|
|
S_Pop()
|
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
if handler then
|
2024-08-30 18:30:03 -04:00
|
|
|
S_Push( 20, 20 )
|
2024-03-12 18:43:31 -04:00
|
|
|
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
|
|
|
hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK )
|
|
|
|
hRect( (i-1)*(120+10), 0, 120, 60 )
|
|
|
|
local x, y = hXY( (i-1)*(120+10), 0 )
|
2024-03-25 00:48:36 -04:00
|
|
|
draw.SimpleText( l8( v.Class.PrintName ), "HUD_24", x + 120/2, y + 60/2 - (10), COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
2024-04-06 09:30:09 -04:00
|
|
|
if v.GetClip2 then
|
|
|
|
draw.SimpleText( v:GetClip2() .. "/" .. v.Class.ClipSize2, "HUD_16", x + 10, y + 60/2 + (4), COLOR_MAIN, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
|
|
|
|
end
|
2024-04-07 19:04:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
if v.GetClip then
|
|
|
|
local drawer = ""
|
|
|
|
|
|
|
|
drawer = drawer .. v:GetClip()
|
|
|
|
drawer = drawer .. "+" .. (v:GetSlideState() == SLIDE_FORWARD and 1 or 0)
|
|
|
|
drawer = drawer .. "/"
|
|
|
|
drawer = drawer .. v.Class.ClipSize
|
|
|
|
draw.SimpleText( drawer, "HUD_16", x + 10, y + 60/2 + (16), COLOR_MAIN, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
|
|
|
|
draw.SimpleText( v:GetFiremode(), "HUD_16", x + 120 - 10, y + 60/2 + (16), COLOR_MAIN, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
|
|
|
|
end
|
2024-03-12 18:43:31 -04:00
|
|
|
end
|
|
|
|
S_Pop()
|
2024-08-30 18:30:03 -04:00
|
|
|
|
|
|
|
local wep = handler:GetActiveR()
|
|
|
|
if wep and wep.GetClip then
|
|
|
|
local Bw, Bh = 328, 160
|
|
|
|
S_Push( w - 20 - Bw, h - 20 - Bh )
|
|
|
|
hCol( COLOR_DARK )
|
|
|
|
hRRect( 0, 0, Bw, Bh, 8 )
|
|
|
|
|
|
|
|
hCol( COLOR_MAIN )
|
|
|
|
local leng = Bw-8-8
|
|
|
|
hRect( 8, 8, leng-70, 26 )
|
|
|
|
hRect( 8 + leng - 70 + 4, 8, leng-(leng-70)-4, 26 )
|
|
|
|
local x, y = hXY( 12, 6 )
|
|
|
|
draw.SimpleText( l8( wep.Class.PrintName ), "HUD_36", x, y, COLOR_DARK )
|
|
|
|
local x, y = hXY( 10 + (leng - 70) + 70/2, 11 )
|
|
|
|
local bc = wep.Class.BurstCount
|
|
|
|
draw.SimpleText( fmlookup[bc] or bc .. "RND", "HUD_24", x, y, COLOR_DARK, TEXT_ALIGN_CENTER )
|
|
|
|
|
|
|
|
S_Push( Bw - 8 - 8, Bh - 18 - 8 )
|
|
|
|
for i=0, wep.Class.ClipSize-1 do
|
|
|
|
if (wep:GetClip() + (wep:GetSlideState() == SLIDE_FORWARD and 1 or 0)) >= (i+1) then
|
|
|
|
hCol( COLOR_MAIN )
|
|
|
|
hRect( (0 - 8 - 2)*i, 0, 8, 18 )
|
|
|
|
hCol( COLOR_DARK )
|
|
|
|
hRect( (0 - 8 - 2)*i, 14, 8, 2 )
|
|
|
|
else
|
|
|
|
hCol( COLOR_BRIGHT )
|
|
|
|
hORect( (0 - 8 - 2)*i, 0, 8, 18 )
|
|
|
|
--hORect( (0 - 8 - 2)*i+1, 1, 8-2, 18-2 )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
S_Pop()
|
|
|
|
S_Pop()
|
|
|
|
end
|
2024-03-12 18:43:31 -04:00
|
|
|
end
|
2024-03-07 21:19:30 -05:00
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
if false then
|
|
|
|
S_Push( 20, h - (20 + 40 + 4 + 40 + 4 + 40) )
|
|
|
|
S_Push( 0, 0 )
|
|
|
|
commoncode( show_letters[1] )
|
|
|
|
S_Pop()
|
|
|
|
S_Push( 18, 40+4 )
|
|
|
|
commoncode( show_letters[2] )
|
|
|
|
S_Pop()
|
|
|
|
S_Push( 18+24 - (40+24), 40+4+40+4 )
|
|
|
|
commoncode( show_letters[3] )
|
|
|
|
S_Pop()
|
|
|
|
S_Push( 0, 40+4+40+4+40+4 )
|
|
|
|
commoncode( show_letters[4] )
|
|
|
|
S_Pop()
|
|
|
|
S_Pop()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
--local itemcheck = handler:ItemCheckTrace()
|
|
|
|
|
|
|
|
-- Hints
|
2024-04-06 09:30:09 -04:00
|
|
|
if true then
|
2024-08-30 18:30:03 -04:00
|
|
|
S_Push( w - 20, 20 )
|
2024-04-06 09:30:09 -04:00
|
|
|
|
|
|
|
local hints = {}
|
|
|
|
|
|
|
|
table.insert( hints, { "[SHIFT]", "DIVE" } )
|
|
|
|
table.insert( hints, { "", "INTO PRONE", "HOLD" } )
|
|
|
|
if handler:ItemR() then
|
|
|
|
table.insert( hints, { "", "- - - - - - - - - - - -" } )
|
|
|
|
table.insert( hints, { "[M1]", "FIRE" } )
|
|
|
|
table.insert( hints, { "[C]", "FIREMODE" } )
|
|
|
|
table.insert( hints, { "[E]", "THROW" } )
|
|
|
|
table.insert( hints, { "[R]", "RELOAD" } )
|
|
|
|
table.insert( hints, { "", "RETAIN MAG", "HOLD" } )
|
2024-08-30 18:30:03 -04:00
|
|
|
--elseif itemcheck.Entity:IsValid() and itemcheck.Entity.BennyItem then
|
|
|
|
-- table.insert( hints, { "", "- - - - - - - - - - - -" } )
|
|
|
|
-- table.insert( hints, { "[E]", "PICK UP" } )
|
2024-04-06 09:30:09 -04:00
|
|
|
end
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
local x, y = hXY( 0, 0 )
|
|
|
|
for i, v in ipairs( hints ) do
|
|
|
|
draw.SimpleText( v[1], "HUD_24", x - 150 + 1, y + (24*(i-1)) + 1, COLOR_DARK, TEXT_ALIGN_CENTER )
|
|
|
|
draw.SimpleText( v[2], "HUD_24", x + 1, y + (24*(i-1)) + 1, COLOR_DARK, TEXT_ALIGN_RIGHT )
|
|
|
|
if v[3] then
|
|
|
|
draw.SimpleText( v[3], "HUD_16", x - 150 + 1, y+3 + (24*(i-1)) + 1, COLOR_DARK, TEXT_ALIGN_CENTER )
|
|
|
|
end
|
|
|
|
end
|
2024-04-06 09:30:09 -04:00
|
|
|
for i, v in ipairs( hints ) do
|
2024-08-30 18:30:03 -04:00
|
|
|
draw.SimpleText( v[1], "HUD_24", x - 150, y + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER )
|
|
|
|
draw.SimpleText( v[2], "HUD_24", x, y + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_RIGHT )
|
2024-04-06 09:30:09 -04:00
|
|
|
if v[3] then
|
2024-08-30 18:30:03 -04:00
|
|
|
draw.SimpleText( v[3], "HUD_16", x - 150, y+3 + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER )
|
2024-04-06 09:30:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
S_Pop()
|
|
|
|
end
|
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
-- S_Pop()
|
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
local trac = p:GetEyeTrace().HitPos:ToScreen()
|
|
|
|
local trac2 = util.TraceLine( {
|
|
|
|
start = CamSpot(),
|
|
|
|
endpos = CamSpot() + TPSOverride:Forward()*(2^16),
|
|
|
|
filter = p,
|
|
|
|
} ).HitPos:ToScreen()
|
|
|
|
|
2024-04-07 19:04:18 -04:00
|
|
|
for i=1, 2 do
|
|
|
|
local shadowtime = i==1
|
|
|
|
local traac = shadowtime and trac2 or trac
|
2024-08-30 18:30:03 -04:00
|
|
|
local cx, cy = math.Round(traac.x), math.Round(traac.y)
|
2024-04-07 19:04:18 -04:00
|
|
|
S_Push( cx, cy )
|
|
|
|
local lol = shadowtime and 0 or 255
|
|
|
|
surface.SetDrawColor( lol, lol, lol )
|
|
|
|
surface.SetMaterial( shadowtime and xhair_dot_shadow or xhair_dot )
|
|
|
|
hTrRect( 0, 0, 64, 64, 0 )
|
|
|
|
S_Pop()
|
|
|
|
end
|
2024-04-06 09:30:09 -04:00
|
|
|
|
2024-03-07 21:19:30 -05:00
|
|
|
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
|