Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile("TTTHUD.lua")
- resource.AddFile( "resource/fonts/Aero_Matics_Display.ttf" )
- resource.AddFile( "materials/fc_ttthud/fc_ttthud_health.png" )
- resource.AddFile( "materials/fc_ttthud/fc_ttthud_health_small.png" )
- resource.AddFile( "materials/fc_ttthud/fc_ttthud_armor.png" )
- resource.AddFile( "materials/fc_ttthud/fc_ttthud_armor_small.png" )
- else
- hook.Add("PostGamemodeLoaded", "FC_HUD", function()
- FC_HUD = {}
- ------------------
- -- CONFIG START --
- ------------------
- FC_HUD.TeamBasedHP = false
- FC_HUD.DefaultTargetInfo = false
- FC_HUD.LargerStatus = false
- FC_HUD.ColoredRoleBack = false
- FC_HUD.ColoredRoleText = false
- FC_HUD.ShowOnlyHP = false
- ------------------
- -- CONFIG START --
- ------------------
- surface.CreateFont( "FC_HUD_10", { font = "Aero Matics Display Regular", antialias = true, size = 10 } )
- surface.CreateFont( "FC_HUD_20", { font = "Aero Matics Display Regular", antialias = true, size = 20 } )
- surface.CreateFont( "FC_HUD_30", { font = "Aero Matics Display Regular", antialias = true, size = 30 } )
- surface.CreateFont( "FC_HUD_40", { font = "Aero Matics Display Regular", antialias = true, size = 40 } )
- FC_HUD.White = Material("vgui/white")
- FC_HUD.SmallHP = Material("fc_ttthud/fc_ttthud_health_small.png")
- FC_HUD.BigHP = Material("fc_ttthud/fc_ttthud_health.png")
- FC_HUD.SmallAR = Material("fc_ttthud/fc_ttthud_armor_small.png")
- FC_HUD.BigAR = Material("fc_ttthud/fc_ttthud_armor.png")
- FC_HUD.LastHP = nil
- FC_HUD.HPFallout = {}
- -- speeds
- local insert = table.insert
- -- clamp func, to prevent going outside of the square
- local function clamp(v) if (v > 1) then return 1 else return v end end
- local function NiceUV(x, y, w, h, perc, flipped)
- if flipped then
- if (prec == 0) then return {} end
- local tbl = {} -- our pizza
- insert(tbl, {x = x, y = y, u = 0.5, v = 0.5}) -- add center point in the middle to make a pizza shape
- -- v = up/down
- -- u = left/right
- -- top right, first we move from the middle to the right
- if (perc >= 315) then
- insert(tbl, {x = x + w - clamp((perc - 315) / 45) * w, y = y - h, u = 1 - clamp((perc - 315) / 45) / 2, v = 0})
- end
- -- down right, then from right corner to bottom, it's easier in 90's
- if (perc >= 225) then
- insert(tbl, {x = x + w, y = y + h - clamp((perc - 225) / 90) * h * 2, u = 1, v = 1 - clamp((perc - 225) / 90)})
- end
- -- down left
- if (perc >= 135) then
- insert(tbl, {x = x - w + clamp((perc - 135) / 90) * h * 2, y = y + h, u = clamp((perc - 135) / 90), v = 1})
- end
- -- top left, and from bottom to up!
- if (perc >= 45) then
- insert(tbl, {x = x - w, y = y - h + clamp((perc - 45) / 90) * h * 2, u = 0, v = clamp((perc - 45) / 90)})
- end
- -- top center, now go back to close our pizza up. We dont need to do an if here, as this is the last peice of this godly meal.
- insert(tbl, {x = x - clamp(perc / 45) * w, y = y - h, u = 0.5 - clamp(perc / 45) / 2, v = 0})
- insert(tbl, {x = x, y = y - h, u = 0.5, v = 0}) -- add our startpoint for the pizza
- -- aparently, we got a full pizza! lets return this lovly meal.
- return tbl
- else
- local tbl = {} -- our pizza
- insert(tbl, {x = x, y = y, u = 0.5, v = 0.5}) -- add center point in the middle to make a pizza shape
- insert(tbl, {x = x, y = y - h, u = 0.5, v = 0}) -- add our startpoint for the pizza
- -- v = up/down
- -- u = left/right
- -- top right, first we move from the middle to the right
- if (perc > 45) then insert(tbl, {x = x + w, y = y - h, u = 1, v = 0})
- else insert(tbl, {x = x + perc / 45 * w, y = y - h, u = 0.5 + clamp(perc / 45) / 2, v = 0}) return tbl
- end
- -- down right, then from right corner to bottom, it's easier in 90's
- perc = perc - 45 -- remove the perc, this makes math easier later on
- if (perc > 90) then
- insert(tbl, {x = x + w, y = y + h, u = 1, v = 1})
- else
- insert(tbl, {x = x + w, y = y - h + perc / 90 * h * 2, u = 1, v = clamp(perc / 90)}) return tbl
- end
- -- down left, then from right to left
- perc = perc - 90
- if (perc > 90) then
- insert(tbl, {x = x - w, y = y + h, u = 0, v = 1})
- else
- insert(tbl, {x = x + w - perc / 90 * h * 2, y = y + h, u = 1 - clamp(perc / 90), v = 1}) return tbl
- end
- -- top left, and from bottom to up!
- perc = perc - 90
- if (perc > 90) then
- insert(tbl, {x = x - w, y = y - h, u = 0, v = 0})
- else
- insert(tbl, {x = x - w, y = y + h - perc / 90 * h * 2, u = 0, v = 1 - clamp(perc / 90)}) return tbl
- end
- -- top center, now go back to close our pizza up. We dont need to do an if here, as this is the last peice of this godly meal.
- perc = perc - 90
- insert(tbl, {x = x - w + perc / 45 * w, y = y - h, u = clamp(perc / 45) / 2, v = 0})
- -- aparently, we got a full pizza! lets return this lovly meal.
- return tbl
- end
- end
- function CreateBorderedCircle(x, y, size, border, perc, addrot, parts)
- local sin = math.sin
- local cos = math.cos
- local rad = math.rad
- local parts = parts or 100
- local tbl = {}
- local onerad = rad(360) / parts
- local fixpos = rad(90)
- local ret = false
- local ending = perc * 3.6 * (parts / 360)
- local innersize = size - border
- local i = 0
- if (addrot != nil) then
- fixpos = fixpos + rad(addrot)
- end
- while(true) do
- if (not ret) then
- -- outside
- table.insert(tbl, {
- x = x - cos(i * onerad - fixpos) * innersize,
- y = y + sin(i * onerad - fixpos) * innersize
- })
- i = i + 1
- if (i > ending) then
- ret = true
- i = i - 1
- end
- else
- -- inside
- table.insert(tbl, {
- x = x - cos(i * onerad - fixpos) * size,
- y = y + sin(i * onerad - fixpos) * size
- })
- i = i - 1
- if (i < 0) then
- table.insert(tbl, {
- x = x + cos(fixpos) * size,
- y = y + sin(fixpos) * size
- })
- break
- end
- end
- end
- return tbl
- end
- function DrawCorrectFuckingPoly(tbl, fade)
- local len = #tbl
- for i = 1, #tbl do
- if fade and (i < 5 or i >= (len-5)) then
- local col = i / 5
- if i > len/2 then
- col = (len-i-1) / 5
- end
- surface.SetDrawColor( 175 * col, 225 * col, 100 * col, 200 * col )
- elseif fade then
- surface.SetDrawColor( 175, 225, 100, 200 )
- end
- surface.DrawPoly({tbl[i], tbl[len - (i - 1)], tbl[len - i]})
- surface.DrawPoly({tbl[i], tbl[i + 1], tbl[len - i]})
- end
- end
- local roundstate_string = {
- [ROUND_WAIT] = "round_wait",
- [ROUND_PREP] = "round_prep",
- [ROUND_ACTIVE] = "round_active",
- [ROUND_POST] = "round_post"
- }
- local role_string = {
- ["innocent"] = Color(170,225,100,200),
- ["traitor"] = Color(205,60,40,200),
- ["detective"] = Color(115,180,200,200),
- ["round"] = Color(200,200,200,200)
- }
- local role_string_2 = {
- ["innocent"] = Color(150,205,80,200),
- ["traitor"] = Color(180,40,20,200),
- ["detective"] = Color(95,160,180,200),
- ["round"] = Color(180,180,180,200)
- }
- local function GetAmmo()
- local ply = LocalPlayer()
- local weap = ply:GetActiveWeapon()
- if !IsValid(weap) or not ply:Alive() then return -1 end
- local ammo_inv = weap:Ammo1() or 0
- local ammo_clip = weap:Clip1() or 0
- local ammo_max = weap.Primary.ClipSize or 0
- local ammo_invmax = weap.Primary.ClipMax or 0
- return ammo_clip, ammo_max, ammo_inv, ammo_invmax
- end
- local GetPTranslation = LANG.GetParamTranslation
- local GetRaw = LANG.GetRawTranslation
- local key_params = {usekey = Key("+use", "USE"), walkkey = Key("+walk", "WALK")}
- local ClassHint = {
- prop_ragdoll = {
- name= "corpse",
- hint= "corpse_hint",
- fmt = function(ent, txt) return GetPTranslation(txt, key_params) end
- }
- };
- ---- "T" indicator above traitors
- local indicator_mat = Material("VGUI/ttt/sprite_traitor")
- local indicator_col = Color(255, 255, 255, 130)
- local client, plys, ply, pos, dir, tgt
- local GetPlayers = player.GetAll
- local propspec_outline = Material("models/props_combine/portalball001_sheet")
- local function DrawPropSpecLabels(client)
- if (not client:IsSpec()) and (GetRoundState() != ROUND_POST) then return end
- surface.SetFont("TabLarge")
- local tgt = nil
- local scrpos = nil
- local text = nil
- local w = 0
- for _, ply in pairs(player.GetAll()) do
- if ply:IsSpec() then
- surface.SetTextColor(220,200,0,120)
- tgt = ply:GetObserverTarget()
- if IsValid(tgt) and tgt:GetNWEntity("spec_owner", nil) == ply then
- scrpos = tgt:GetPos():ToScreen()
- else
- scrpos = nil
- end
- else
- local _, healthcolor = util.HealthToString(ply:Health())
- surface.SetTextColor(clr(healthcolor))
- scrpos = ply:EyePos()
- scrpos.z = scrpos.z + 20
- scrpos = scrpos:ToScreen()
- end
- if scrpos and (not IsOffScreen(scrpos)) then
- text = ply:Nick()
- w, _ = surface.GetTextSize(text)
- surface.SetTextPos(scrpos.x - w / 2, scrpos.y)
- surface.DrawText(text)
- end
- end
- end
- ---- Crosshair affairs
- surface.CreateFont("TargetIDSmall2", {font = "TargetID",
- size = 16,
- weight = 1000})
- local minimalist = CreateConVar("ttt_minimal_targetid", "0", FCVAR_ARCHIVE)
- local magnifier_mat = Material("icon16/magnifier.png")
- local ring_tex = surface.GetTextureID("effects/select_ring")
- local rag_color = Color(200,200,200,255)
- local GetLang = LANG.GetUnsafeLanguageTable
- if FC_HUD.DefaultTargetInfo == false then
- GAMEMODE.HUDDrawTargetID = function()
- local client = LocalPlayer()
- local L = GetLang()
- DrawPropSpecLabels(client)
- local trace = client:GetEyeTrace(MASK_SHOT)
- local ent = trace.Entity
- if (not IsValid(ent)) or ent.NoTarget then return end
- -- some bools for caching what kind of ent we are looking at
- local target_traitor = false
- local target_detective = false
- local target_corpse = false
- local text = nil
- local color = COLOR_WHITE
- -- if a vehicle, we identify the driver instead
- if IsValid(ent:GetNWEntity("ttt_driver", nil)) then
- ent = ent:GetNWEntity("ttt_driver", nil)
- if ent == client then return end
- end
- local cls = ent:GetClass()
- local minimal = minimalist:GetBool()
- local hint = (not minimal) and (ent.TargetIDHint or ClassHint[cls])
- if ent:IsPlayer() then
- if ent:GetNWBool("disguised", false) then
- client.last_id = nil
- if client:IsTraitor() or client:IsSpec() then
- text = ent:Nick() .. L.target_disg
- else
- -- Do not show anything
- return
- end
- color = COLOR_RED
- else
- text = ent:Nick()
- client.last_id = ent
- end
- -- in minimalist targetID, colour nick with health level
- if minimal then
- _, color = util.HealthToString(ent:Health())
- end
- if client:IsTraitor() and GAMEMODE.round_state == ROUND_ACTIVE then
- target_traitor = ent:IsTraitor()
- end
- target_detective = ent:IsDetective()
- elseif cls == "prop_ragdoll" then
- -- only show this if the ragdoll has a nick, else it could be a mattress
- if CORPSE.GetPlayerNick(ent, false) == false then return end
- target_corpse = true
- if CORPSE.GetFound(ent, false) or not DetectiveMode() then
- text = CORPSE.GetPlayerNick(ent, "A Terrorist")
- else
- text = L.target_unid
- color = COLOR_YELLOW
- end
- elseif not hint then
- -- Not something to ID and not something to hint about
- return
- end
- local x_orig = ScrW() / 2.0
- local x = x_orig
- local y = ScrH() / 2.0
- local w, h = 0,0 -- text width/height, reused several times
- if target_traitor or target_detective then
- surface.SetTexture(ring_tex)
- if target_traitor then
- surface.SetDrawColor(255, 0, 0, 200)
- else
- surface.SetDrawColor(0, 0, 255, 220)
- end
- surface.DrawTexturedRect(x-32, y-32, 64, 64)
- end
- y = y + 30
- local font = "FC_HUD_20"
- surface.SetFont( font )
- -- Draw main title, ie. nickname
- if text then
- w1, h1 = surface.GetTextSize( string.upper(text) )
- w2, h2 = surface.GetTextSize( string.upper(text) )
- x = x - w1 / 2
- local width = w1 + 32
- surface.SetDrawColor( 0, 0, 0, 200 )
- surface.SetMaterial( FC_HUD.White )
- local tab = CreateBorderedCircle((ScrW()-width)/2 + 14, ScrH()/2 + 30 + 14, 10, 10, 100, 0, 20)
- DrawCorrectFuckingPoly(tab)
- if ent:IsPlayer() then
- if LocalPlayer():IsTraitor() and ent:IsTraitor() then
- surface.SetDrawColor( role_string["traitor"] )
- elseif ent:IsDetective() then
- surface.SetDrawColor( role_string["detective"] )
- else
- surface.SetDrawColor( role_string["innocent"] )
- end
- else
- surface.SetDrawColor( role_string["round"] )
- end
- local tab = CreateBorderedCircle((ScrW()-width)/2 + 14, ScrH()/2 + 30 + 14, 8, 8, 100, 0, 20)
- DrawCorrectFuckingPoly(tab)
- draw.RoundedBox(2, (ScrW()-width)/2 + 26, ScrH()/2 + 34, w1 + 4, h1, Color(0,0,0,200))
- draw.SimpleText( string.upper(text), "FC_HUD_20", (ScrW()-width)/2 + 28, ScrH()/2 + 44, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- -- for ragdolls searched by detectives, add icon
- /*if ent.search_result and client:IsDetective() then
- -- if I am detective and I know a search result for this corpse, then I
- -- have searched it or another detective has
- surface.SetMaterial(magnifier_mat)
- surface.SetDrawColor(200, 200, 255, 255)
- surface.DrawTexturedRect(x + w + 5, y, 16, 16)
- end*/
- y = y + h + 4
- end
- -- Minimalist target ID only draws a health-coloured nickname, no hints, no
- -- karma, no tag
- if minimal then return end
- -- Draw subtitle: health or type
- local clr = rag_color
- if ent:IsPlayer() then
- text, clr = util.HealthToString(ent:Health())
- -- HealthToString returns a string id, need to look it up
- text = L[text]
- elseif hint then
- text = GetRaw(hint.name) or hint.name
- else
- return
- end
- font = "TargetIDSmall2"
- surface.SetFont( font )
- w, h = surface.GetTextSize( text )
- x = x_orig - w / 2
- //draw.SimpleText( text, font, x+1, y+1, COLOR_BLACK )
- //draw.SimpleText( text, font, x, y, clr )
- font = "TargetIDSmall"
- surface.SetFont( font )
- local h_karma, h_hint, h_karma_color, h_hint_color = "", "", Color(255,255,255,200), Color(255,255,255,200)
- -- Draw second subtitle: karma
- if ent:IsPlayer() and KARMA.IsEnabled() then
- text, clr = util.KarmaToString(ent:GetBaseKarma())
- text = L[text]
- w, h = surface.GetTextSize( text )
- y = y + h + 5
- x = x_orig - w / 2
- h_karma = text
- h_karma_color = clr
- end
- -- Draw key hint
- if hint and hint.hint then
- if not hint.fmt then
- text = GetRaw(hint.hint) or hint.hint
- else
- text = hint.fmt(ent, hint.hint)
- end
- w, h = surface.GetTextSize(text)
- x = x_orig - w / 2
- y = y + h + 5
- h_hint = text
- elseif ent:IsPlayer() and ent.sb_tag then
- h_hint = LANG.GetTranslation(ent.sb_tag.txt) or ""
- h_hint_color = ent.sb_tag.color
- end
- surface.SetFont( "FC_HUD_20" )
- w1, h1 = surface.GetTextSize( string.upper(h_karma) )
- w2, h2 = surface.GetTextSize( string.upper(h_hint) )
- local addw, addh = 0, 0
- if ent:IsPlayer() and ent:Alive() then
- addw = 48
- addh = 24
- if FC_HUD.ShowOnlyHP then w1, w2 = -4, -4 end
- end
- local width = math.max(w1, w2) + 4 + addw
- draw.RoundedBox(2, (ScrW()-width)/2, ScrH()/2 + 58, width, 24 + addh, Color(0,0,0,200))
- if ent:IsPlayer() and ent:Alive() then
- local y1,y2 = ScrH()/2 + 70, ScrH()/2 + 94
- if h_karma == "" then y2 = ScrH()/2 + 82 end
- if h_hint == "" then y1 = ScrH()/2 + 82 end
- if !FC_HUD.ShowOnlyHP then
- draw.SimpleText( string.upper(h_karma), "FC_HUD_20", (ScrW()-width)/2 + 48, y1, h_karma_color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- draw.SimpleText( string.upper(h_hint), "FC_HUD_20", (ScrW()-width)/2 + 48, y2, h_hint_color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
- end
- surface.SetDrawColor( 255, 0, 0, 200 )
- surface.SetMaterial( FC_HUD.White )
- local parts = NiceUV((ScrW()-width)/2 + 24, ScrH()/2 + 82, 32, 32, math.Clamp(ent:Health(), 0, 100) / 100 * 360, true )
- surface.SetMaterial( FC_HUD.SmallHP )
- if FC_HUD.TeamBasedHP and (target_traitor or target_detective) then
- if target_traitor then
- surface.SetDrawColor( role_string["traitor"] )
- else
- surface.SetDrawColor( role_string["detective"] )
- end
- else
- surface.SetDrawColor( role_string["innocent"] )
- end
- surface.SetDrawColor(160, 205, 95, 200)
- surface.DrawPoly(parts)
- if ent:Armor() > 0 then
- local parts = NiceUV((ScrW()-width)/2 + 24, ScrH()/2 + 82, 32, 32, math.Clamp(ent:Armor(), 0, 100) / 100 * 360, true )
- surface.SetMaterial( FC_HUD.SmallAR )
- surface.SetDrawColor(255,255,255,200)
- surface.DrawPoly(parts)
- end
- else
- draw.SimpleText( string.upper(h_hint), "FC_HUD_20", ScrW()/2, ScrH()/2 + 70, h_hint_color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
- end
- text = nil
- end
- end
- local delay = 0.075
- local showtime = 3
- local margin = 10
- local width = 350
- local height = 22
- local barcorner = surface.GetTextureID( "gui/corner8" )
- local col_active = {
- tip = {
- [ROLE_INNOCENT] = role_string["innocent"],
- [ROLE_TRAITOR] = role_string["traitor"],
- [ROLE_DETECTIVE] = role_string["detective"]
- },
- bg = Color(0, 0, 0, 250),
- text_empty = Color(200, 20, 20, 255),
- text_empty_2 = Color(200, 200, 20, 255),
- text = Color(255, 255, 255, 255),
- shadow = 255
- };
- local col_dark = {
- tip = {
- [ROLE_INNOCENT] = role_string_2["innocent"],
- [ROLE_TRAITOR] = role_string_2["traitor"],
- [ROLE_DETECTIVE] = role_string_2["detective"]
- },
- bg = Color(0, 0, 0, 200),
- text_empty = Color(200, 20, 20, 100),
- text_empty_2 = Color(200, 200, 20, 100),
- text = Color(255, 255, 255, 100),
- shadow = 100
- };
- -- Draw a bar in the style of the the weapon pickup ones
- local round = math.Round
- function WSWITCH:DrawBarBg(x, y, w, h, col)
- draw.RoundedBoxEx( 2, x + 20, y - 15, w - 20, 30, col.bg, false, true, false, true )
- draw.RoundedBoxEx( 2, x, y - 15, 20, 30, Color(255,255,255,200), true, false, true, false )
- end
- local TryTranslation = LANG.TryTranslation
- function WSWITCH:DrawWeapon(x, y, c, wep)
- if not IsValid(wep) then return false end
- local name = TryTranslation(wep:GetPrintName() or wep.PrintName or "...")
- local cl1, am1 = wep:Clip1(), wep:Ammo1()
- local ammo = false
- -- Clip1 will be -1 if a melee weapon
- -- Ammo1 will be false if weapon has no owner (was just dropped)
- if cl1 != -1 and am1 != false then
- ammo = Format("%i + %02i", cl1, am1)
- end
- -- Slot
- local spec = {text=wep.Slot+1, font="FC_HUD_30", pos={x+4, y}, yalign=TEXT_ALIGN_CENTER, yalign=TEXT_ALIGN_CENTER, color=c.text}
- draw.SimpleText( wep.Slot + 1, "FC_HUD_30", x+10, y, Color(0,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Name
- spec.text = string.upper(name)
- spec.pos[1] = x + 10 + height
- draw.Text(spec)
- local clip, max, inv, invmax = wep:Clip1() or 0, wep.Primary.ClipSize or 0, wep:Ammo1() or 0, wep.ClipMax or 0
- if clip != -1 then
- local col1, col2 = c.text, c.text
- if clip == 0 then
- col1 = c.text_empty
- elseif clip/max <= 0.25 then
- col1 = c.text_empty_2
- end
- if inv == 0 then
- col2 = c.text_empty
- elseif inv/invmax <= 0.25 then
- col2 = c.text_empty_2
- end
- if clip < 10 then
- clip = "0"..clip
- end
- if inv < 10 then
- inv = "0"..inv
- end
- local w, h = draw.SimpleText(inv, "FC_HUD_30", ScrW() - margin*3, y, col2, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
- local w2, h2 = draw.SimpleText("+", "FC_HUD_30", ScrW() - margin*3 - w - 4, y, c.text, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
- draw.SimpleText(clip, "FC_HUD_30", ScrW() - margin*3 - w - w2 - 8, y, col1, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
- end
- return true
- end
- function WSWITCH:Draw(client)
- if not self.Show then return end
- local weps = self.WeaponCache
- local x = ScrW() - width - margin*2
- local y = ScrH() - (#weps * (height + margin))
- local col = col_dark
- for k, wep in pairs(weps) do
- if self.Selected == k then
- col = col_active
- else
- col = col_dark
- end
- self:DrawBarBg(x, y, width, height, col)
- if not self:DrawWeapon(x, y, col, wep) then
- self:UpdateWeaponCache()
- return
- end
- y = y + height + margin
- end
- end
- function GAMEMODE:HUDDrawPickupHistory()
- if (GAMEMODE.PickupHistory == nil) then return end
- local x, y = ScrW() - GAMEMODE.PickupHistoryWide - 20, GAMEMODE.PickupHistoryTop
- local tall = 0
- local wide = 0
- for k, v in pairs( GAMEMODE.PickupHistory ) do
- if v.time < CurTime() then
- if (v.y == nil) then v.y = y end
- v.x = x
- v.y = (v.y*5 + y) / 6
- local delta = (v.time + v.holdtime) - CurTime()
- delta = delta / v.holdtime
- delta = math.Clamp( delta, 0, 1 )
- local nam = v.name
- if v.amount then
- nam = v.name.." ["..v.amount.."]"
- end
- nam = string.upper(nam)
- surface.SetFont("FC_HUD_20")
- local fw, fh = surface.GetTextSize(v.name)
- local fw2 = 0
- if v.amount then
- fw2 = surface.GetTextSize(" ["..v.amount.."]")
- fw = fw + fw2
- end
- local clampw = 0
- local al = 0
- if delta >= 0.85 then
- clampw = 0
- elseif delta < 0.85 and delta > 0.8 then
- clampw = fw * ( 1 - ((delta - 0.8)*20) )
- elseif delta > 0.2 then
- clampw = fw * 1
- elseif delta <= 0.2 and delta > 0.15 then
- clampw = fw * ((delta - 0.15)*20)
- elseif delta <= 0.1 then
- clampw = 0
- end
- if delta > 0.9 then
- al = 1 - ((delta - 0.9) * 10)
- elseif delta < 0.1 then
- al = (delta) * 10
- else
- al = 1
- end
- local boxw = math.max( clampw, 0 )
- draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y - 18, boxw + 20, 24, Color(0,0,0,200 * al) )
- draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y - 18, 6, 2, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y - 16, 2, 4, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y + 4, 6, 2, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y, 2, 4, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 26, v.y - 18, 6, 2, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 22, v.y - 16, 2, 4, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 26, v.y + 4, 6, 2, Color(255,255,255,200 * al) )
- draw.RoundedBox( 0, ScrW() - 22, v.y, 2, 4, Color(255,255,255,200 * al) )
- render.SetScissorRect( ScrW() - 40 - boxw + 10, v.y - 18, ScrW() - 30, v.y + 6, true )
- draw.SimpleText( v.name, "FC_HUD_20", ScrW() - 30 - fw2, v.y - (v.height/2), Color( 255, 255, 255, 200 * al ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
- if v.amount then
- draw.SimpleText( " ["..v.amount.."]", "FC_HUD_20", ScrW() - 30, v.y - (v.height/2), Color( 255, 255, 255, 200 * al ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
- end
- render.SetScissorRect( ScrW() - 40 - boxw, v.y - 18, boxw, 24, false )
- y = y + (v.height + 16)
- tall = tall + v.height + 18
- wide = math.Max( wide, v.width + v.height + 24 )
- if delta == 0 then GAMEMODE.PickupHistory[k] = nil end
- end
- end
- GAMEMODE.PickupHistoryTop = (GAMEMODE.PickupHistoryTop * 5 + ( ScrH() * 0.75 - tall ) / 2 ) / 6
- GAMEMODE.PickupHistoryWide = (GAMEMODE.PickupHistoryWide * 5 + wide) / 6
- end
- GAMEMODE.HUDPaint = function()
- local client = LocalPlayer()
- GAMEMODE:HUDDrawTargetID()
- MSTACK:Draw(client)
- if (not client:Alive()) or client:Team() == TEAM_SPEC then
- return
- end
- RADAR:Draw(client)
- TBHUD:Draw(client)
- WSWITCH:Draw(client)
- VOICE.Draw(client)
- DISGUISE.Draw(client)
- GAMEMODE:HUDDrawPickupHistory()
- end
- hook.Add("HUDPaint", "FC_HUD", function()
- local y = ScrH()
- local L = LANG.GetUnsafeLanguageTable()
- local is_haste = HasteMode() and GetRoundState() == ROUND_ACTIVE
- local is_traitor = LocalPlayer():IsTraitor() or !LocalPlayer():Alive()
- local endtime = GetGlobalFloat("ttt_round_end", 0) - CurTime()
- local overtime = false
- local text
- local color = Color(255,255,255,200)
- -- Time displays differently depending on whether haste mode is on,
- -- whether the player is traitor or not, and whether it is overtime.
- if is_haste then
- local hastetime = GetGlobalFloat("ttt_haste_end", 0) - CurTime()
- if hastetime < 0 then
- if (not is_traitor) or (math.ceil(CurTime()) % 7 <= 2) then
- -- innocent or blinking "overtime"
- text = L.overtime
- overtime = true
- else
- -- traitor and not blinking "overtime" right now, so standard endtime display
- text = string.ToMinutesSeconds(math.max(0, endtime))
- color = Color(255,0,0,200)
- end
- else
- -- still in starting period
- local t = hastetime
- if is_traitor and math.ceil(CurTime()) % 6 < 2 then
- t = endtime
- color = Color(255,0,0,200)
- end
- text = string.ToMinutesSeconds(math.max(0, t))
- end
- else
- -- bog standard time when haste mode is off (or round not active)
- text = string.ToMinutesSeconds(math.max(0, endtime))
- end
- if LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR and GetRoundState() != ROUND_WAIT then
- draw.RoundedBox(2, 20, y - 114, 94, 94, Color(0,0,0,200))
- if FC_HUD.LastHP == nil then FC_HUD.LastHP = LocalPlayer():Health() end
- if LocalPlayer():Health() != FC_HUD.LastHP then
- local tab = {}
- tab.time = CurTime() + 0.5
- tab.last = FC_HUD.LastHP
- tab.new = LocalPlayer():Health()
- table.insert(FC_HUD.HPFallout, tab)
- print("NEW", FC_HUD.LastHP, LocalPlayer():Health())
- end
- for k, v in pairs(FC_HUD.HPFallout) do
- if CurTime() >= v.time then
- FC_HUD.HPFallout[k] = nil
- continue
- end
- local parts = NiceUV(67, y - 67, 64, 64, math.Clamp(v.last, 0, 100) / 100 * 360, true )
- local alpha = (v.time - CurTime()) * 510
- surface.SetMaterial( FC_HUD.BigHP )
- surface.SetDrawColor( 205, 0, 0, alpha )
- surface.DrawPoly(parts)
- end
- FC_HUD.LastHP = LocalPlayer():Health()
- surface.SetDrawColor( 255, 0, 0, 200 )
- surface.SetMaterial( FC_HUD.White )
- local parts = NiceUV(67, y - 67, 64, 64, math.Clamp(LocalPlayer():Health(), 0, 100) / 100 * 360, true )
- surface.SetMaterial( FC_HUD.BigHP )
- if FC_HUD.TeamBasedHP then
- surface.SetDrawColor( role_string[string.lower(LocalPlayer():GetRoleString())] or role_string["innocent"])
- else
- if LocalPlayer():Health() >= 25 then
- surface.SetDrawColor(role_string["innocent"])
- else
- surface.SetDrawColor(role_string["traitor"])
- end
- end
- surface.DrawPoly(parts)
- if LocalPlayer():HasEquipment(EQUIP_ARMOR) then
- local parts = NiceUV(67, y - 67, 64, 64, 360, true )
- surface.SetMaterial( FC_HUD.BigAR )
- surface.SetDrawColor(255, 255, 255, 200)
- surface.DrawPoly(parts)
- end
- draw.SimpleText(LocalPlayer():Health(), "FC_HUD_40", 67, y - 67, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- draw.RoundedBoxEx(2, 118, y - 114, 20, 30, Color(255,255,255,200), true, false, true, false)
- draw.RoundedBoxEx(2, 138, y - 114, 120, 30, Color(0,0,0,200), false, true, false, true)
- surface.SetMaterial( FC_HUD.White )
- local tab = CreateBorderedCircle(128, y - 99, 8, 8, 85, 0, 10)
- surface.SetDrawColor( 0, 0, 0, 200 )
- surface.SetMaterial( FC_HUD.White )
- DrawCorrectFuckingPoly(tab)
- draw.SimpleText(text, "FC_HUD_30", 198, y - 99, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- local y2 = 0
- //if LocalPlayer():IsActiveTraitor() or LocalPlayer():IsActiveDetective() then
- draw.RoundedBoxEx(2, 138, y - 82 + y2, 120, 30, Color(0,0,0,200), false, true, false, true)
- draw.RoundedBoxEx(2, 118, y - 82 + y2, 20, 30, Color(255,255,255,200), true, false, true, false)
- draw.SimpleText("$", "FC_HUD_20", 128, y - 67 + y2, Color(0,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- local cred = LocalPlayer():GetCredits()
- draw.SimpleText(cred.." CREDITS", "FC_HUD_30", 198, y - 67 + y2, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- y2 = 32
- //end
- local clip, max, inv, invmax = GetAmmo()
- if clip != -1 then
- draw.RoundedBoxEx(2, 138, y - 82 + y2, 120, 30, Color(0,0,0,200), false, true, false, true)
- local col1, col2 = Color(255,255,255,200), Color(255,255,255,200)
- if clip == 0 then
- col1 = Color(200,20,20,200)
- elseif clip/max <= 0.25 then
- col1 = Color(200,200,20,200)
- end
- if inv == 0 then
- col2 = Color(200,20,20,200)
- elseif inv/invmax <= 0.25 then
- col2 = Color(200,200,20,200)
- end
- if clip < 10 then
- clip = "0"..clip
- end
- if inv < 10 then
- inv = "0"..inv
- end
- draw.SimpleText("+", "FC_HUD_30", 198, y - 67 + y2, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- draw.SimpleText(clip, "FC_HUD_30", 198 - 8, y - 67 + y2, col1, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
- draw.SimpleText(inv, "FC_HUD_30", 198 + 10, y - 67 + y2, col2, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- draw.RoundedBoxEx(2, 118, y - 82 + y2, 20, 30, Color(255,255,255,200), true, false, true, false)
- surface.SetDrawColor( 0, 0, 0, 200 )
- surface.SetMaterial( FC_HUD.White )
- local tab = CreateBorderedCircle(128, y - 67 + y2, 8, 8, 100, 0, 10)
- surface.SetMaterial( FC_HUD.White )
- DrawCorrectFuckingPoly(tab)
- draw.RoundedBox(0, 126, y - 75 + y2, 4, 16, Color(255,255,255,200))
- draw.RoundedBox(0, 120, y - 69 + y2, 16, 4, Color(255,255,255,200))
- end
- y = y - 130
- else
- surface.SetFont("FC_HUD_20")
- local text = ""
- local punch = false
- local w, h = surface.GetTextSize( text )
- w = w + 16
- local tgt = LocalPlayer():GetObserverTarget()
- if IsValid(tgt) and tgt:IsPlayer() then
- text = string.upper(tgt:Nick())
- w, h = surface.GetTextSize( text )
- w = w + 16
- elseif IsValid(tgt) and tgt:GetNWEntity("spec_owner", nil) == LocalPlayer() then
- punch = true
- text = string.upper((LANG.GetUnsafeLanguageTable().punch_title or "PUNCH-O-METER"))
- w, h = surface.GetTextSize( text )
- w = w + 16
- else
- text = string.upper(string.Interp(LANG.GetUnsafeLanguageTable().spec_help, { usekey = Key("+use", "USE") }))
- w, h = surface.GetTextSize( text )
- w = w + 16
- end
- draw.RoundedBox(0, ScrW()/2 - w/2, 20, w, 30, Color(0,0,0,200))
- draw.RoundedBox(0, ScrW()/2 - w/2 + 2, 20, 6, 2, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 - w/2, 20, 2, 8, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 - w/2 + 2, 48, 6, 2, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 - w/2, 42, 2, 8, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 + w/2 - 8, 20, 6, 2, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 + w/2 - 2, 20, 2, 8, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 + w/2 - 8, 48, 6, 2, Color(255,255,255,200))
- draw.RoundedBox(0, ScrW()/2 + w/2 - 2, 42, 2, 8, Color(255,255,255,200))
- if punch then
- punches = LocalPlayer():GetNWFloat("specpunches", 0)
- local w2 = (w-4) * punches
- render.SetScissorRect( ScrW()/2 - w/2, 20, ScrW()/2 - w/2 + w2, 50, true )
- draw.RoundedBox( 0, ScrW()/2 - w/2 + 4, 24, w - 8, 22, Color(255,255,255,200) )
- draw.SimpleText( text, "FC_HUD_20", ScrW()/2, 35, Color(0,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
- render.SetScissorRect( ScrW()/2 - w/2, 20, 0, 50, false )
- render.SetScissorRect( ScrW()/2 - w/2 + w2, 20, ScrW()/2 + w/2 - 4, 50, true )
- draw.SimpleText( text, "FC_HUD_20", ScrW()/2, 35, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
- render.SetScissorRect( ScrW()/2 - w/2, 20, 0, 50, false )
- else
- draw.SimpleText( text, "FC_HUD_20", ScrW()/2, 35, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
- end
- y = y - 30
- end
- local t = ""
- local col = role_string["round"]
- if GetRoundState() == ROUND_WAIT or LocalPlayer():Alive() == false or LocalPlayer():Team() == TEAM_SPECTATOR then
- else
- text = ""
- end
- if GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR then
- t = L[ LocalPlayer():GetRoleStringRaw() ]
- col = role_string[ LocalPlayer():GetRoleStringRaw() ]
- text = ""
- else
- t = L[ roundstate_string[GetRoundState()] ]
- end
- surface.SetDrawColor( 0, 0, 0, 200 )
- local mul = 0
- local font = "FC_HUD_20"
- if FC_HUD.LargerStatus then
- mul = 4
- font = "FC_HUD_30"
- end
- surface.SetMaterial( FC_HUD.White )
- local tab = CreateBorderedCircle(30, y - mul, 10 + mul, 10 + mul, 100, 0, 20)
- surface.SetMaterial( FC_HUD.White )
- DrawCorrectFuckingPoly(tab)
- surface.SetDrawColor( col )
- surface.SetMaterial( FC_HUD.White )
- local tab = CreateBorderedCircle(30, y - mul, 8 + mul, 8 + mul, 100, 0, 20)
- surface.SetMaterial( FC_HUD.White )
- DrawCorrectFuckingPoly(tab)
- surface.SetFont(font)
- local w, h = surface.GetTextSize(string.upper(t))
- local w2, h2 = surface.GetTextSize(string.upper(text))
- local w3 = 0
- if text != "" then
- w3 = surface.GetTextSize(" - ")
- end
- local BoxCol = Color(0,0,0,200)
- if FC_HUD.ColoredRoleBack and GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR then
- if LocalPlayer():IsActiveTraitor() then
- BoxCol = Color(150, 0, 0, 200)
- elseif LocalPlayer():IsActiveDetective() then
- BoxCol = Color(0, 0, 150, 200)
- else
- BoxCol = Color(0, 150, 0, 200)
- end
- end
- local TextColor = Color(255,255,255,200)
- if FC_HUD.ColoredRoleText and GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR then
- if LocalPlayer():IsActiveTraitor() then
- TextColor = role_string["traitor"]
- elseif LocalPlayer():IsActiveDetective() then
- TextColor = role_string["detective"]
- else
- TextColor = role_string["innocent"]
- end
- end
- draw.RoundedBox(2, 50 - 2, y-10 - mul * 2, w + 8 + w2 + w3, 20 + mul * 2, BoxCol)
- local xz, yz = draw.SimpleText(string.upper(t), font, 52, y - mul, TextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- if text != "" then
- xz = draw.SimpleText(" - ", font, 52 + xz, y - mul, TextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) + xz
- end
- draw.SimpleText(string.upper(text), font, 52 + xz, y - mul, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
- end)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement