SHOW:
|
|
- or go back to the newest paste.
| 1 | if SERVER then | |
| 2 | AddCSLuaFile("TTTHUD.lua")
| |
| 3 | resource.AddFile( "resource/fonts/Aero_Matics_Display.ttf" ) | |
| 4 | - | resource.AddSingleFile( "resource/fonts/Aero_Matics_Display.ttf" ) |
| 4 | + | resource.AddFile( "materials/fc_ttthud/fc_ttthud_health.png" ) |
| 5 | - | resource.AddSingleFile( "materials/fc_ttthud/fc_ttthud_health.png" ) |
| 5 | + | resource.AddFile( "materials/fc_ttthud/fc_ttthud_health_small.png" ) |
| 6 | - | resource.AddSingleFile( "materials/fc_ttthud/fc_ttthud_health_small.png" ) |
| 6 | + | resource.AddFile( "materials/fc_ttthud/fc_ttthud_armor.png" ) |
| 7 | - | resource.AddSingleFile( "materials/fc_ttthud/fc_ttthud_armor.png" ) |
| 7 | + | resource.AddFile( "materials/fc_ttthud/fc_ttthud_armor_small.png" ) |
| 8 | - | resource.AddSingleFile( "materials/fc_ttthud/fc_ttthud_armor_small.png" ) |
| 8 | + | |
| 9 | ||
| 10 | hook.Add("PostGamemodeLoaded", "FC_HUD", function()
| |
| 11 | ||
| 12 | FC_HUD = {}
| |
| 13 | ||
| 14 | ------------------ | |
| 15 | -- CONFIG START -- | |
| 16 | ------------------ | |
| 17 | ||
| 18 | FC_HUD.TeamBasedHP = false | |
| 19 | FC_HUD.DefaultTargetInfo = false | |
| 20 | FC_HUD.LargerStatus = false | |
| 21 | FC_HUD.ColoredRoleBack = false | |
| 22 | FC_HUD.ColoredRoleText = false | |
| 23 | FC_HUD.ShowOnlyHP = false | |
| 24 | ||
| 25 | ------------------ | |
| 26 | -- CONFIG START -- | |
| 27 | ------------------ | |
| 28 | ||
| 29 | surface.CreateFont( "FC_HUD_10", { font = "Aero Matics Display Regular", antialias = true, size = 10 } )
| |
| 30 | surface.CreateFont( "FC_HUD_20", { font = "Aero Matics Display Regular", antialias = true, size = 20 } )
| |
| 31 | surface.CreateFont( "FC_HUD_30", { font = "Aero Matics Display Regular", antialias = true, size = 30 } )
| |
| 32 | surface.CreateFont( "FC_HUD_40", { font = "Aero Matics Display Regular", antialias = true, size = 40 } )
| |
| 33 | ||
| 34 | FC_HUD.White = Material("vgui/white")
| |
| 35 | FC_HUD.SmallHP = Material("fc_ttthud/fc_ttthud_health_small.png")
| |
| 36 | FC_HUD.BigHP = Material("fc_ttthud/fc_ttthud_health.png")
| |
| 37 | FC_HUD.SmallAR = Material("fc_ttthud/fc_ttthud_armor_small.png")
| |
| 38 | FC_HUD.BigAR = Material("fc_ttthud/fc_ttthud_armor.png")
| |
| 39 | ||
| 40 | FC_HUD.LastHP = nil | |
| 41 | FC_HUD.HPFallout = {}
| |
| 42 | ||
| 43 | -- speeds | |
| 44 | local insert = table.insert | |
| 45 | ||
| 46 | -- clamp func, to prevent going outside of the square | |
| 47 | local function clamp(v) if (v > 1) then return 1 else return v end end | |
| 48 | ||
| 49 | local function NiceUV(x, y, w, h, perc, flipped) | |
| 50 | ||
| 51 | if flipped then | |
| 52 | ||
| 53 | if (prec == 0) then return {} end
| |
| 54 | ||
| 55 | local tbl = {} -- our pizza
| |
| 56 | insert(tbl, {x = x, y = y, u = 0.5, v = 0.5}) -- add center point in the middle to make a pizza shape
| |
| 57 | ||
| 58 | -- v = up/down | |
| 59 | -- u = left/right | |
| 60 | ||
| 61 | -- top right, first we move from the middle to the right | |
| 62 | if (perc >= 315) then | |
| 63 | insert(tbl, {x = x + w - clamp((perc - 315) / 45) * w, y = y - h, u = 1 - clamp((perc - 315) / 45) / 2, v = 0})
| |
| 64 | end | |
| 65 | ||
| 66 | -- down right, then from right corner to bottom, it's easier in 90's | |
| 67 | if (perc >= 225) then | |
| 68 | insert(tbl, {x = x + w, y = y + h - clamp((perc - 225) / 90) * h * 2, u = 1, v = 1 - clamp((perc - 225) / 90)})
| |
| 69 | end | |
| 70 | ||
| 71 | -- down left | |
| 72 | if (perc >= 135) then | |
| 73 | insert(tbl, {x = x - w + clamp((perc - 135) / 90) * h * 2, y = y + h, u = clamp((perc - 135) / 90), v = 1})
| |
| 74 | end | |
| 75 | ||
| 76 | -- top left, and from bottom to up! | |
| 77 | if (perc >= 45) then | |
| 78 | insert(tbl, {x = x - w, y = y - h + clamp((perc - 45) / 90) * h * 2, u = 0, v = clamp((perc - 45) / 90)})
| |
| 79 | end | |
| 80 | ||
| 81 | -- 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. | |
| 82 | insert(tbl, {x = x - clamp(perc / 45) * w, y = y - h, u = 0.5 - clamp(perc / 45) / 2, v = 0})
| |
| 83 | ||
| 84 | insert(tbl, {x = x, y = y - h, u = 0.5, v = 0}) -- add our startpoint for the pizza
| |
| 85 | ||
| 86 | -- aparently, we got a full pizza! lets return this lovly meal. | |
| 87 | return tbl | |
| 88 | ||
| 89 | else | |
| 90 | ||
| 91 | local tbl = {} -- our pizza
| |
| 92 | insert(tbl, {x = x, y = y, u = 0.5, v = 0.5}) -- add center point in the middle to make a pizza shape
| |
| 93 | insert(tbl, {x = x, y = y - h, u = 0.5, v = 0}) -- add our startpoint for the pizza
| |
| 94 | ||
| 95 | -- v = up/down | |
| 96 | -- u = left/right | |
| 97 | ||
| 98 | -- top right, first we move from the middle to the right | |
| 99 | if (perc > 45) then insert(tbl, {x = x + w, y = y - h, u = 1, v = 0})
| |
| 100 | else insert(tbl, {x = x + perc / 45 * w, y = y - h, u = 0.5 + clamp(perc / 45) / 2, v = 0}) return tbl
| |
| 101 | end | |
| 102 | ||
| 103 | -- down right, then from right corner to bottom, it's easier in 90's | |
| 104 | perc = perc - 45 -- remove the perc, this makes math easier later on | |
| 105 | if (perc > 90) then | |
| 106 | insert(tbl, {x = x + w, y = y + h, u = 1, v = 1})
| |
| 107 | else | |
| 108 | insert(tbl, {x = x + w, y = y - h + perc / 90 * h * 2, u = 1, v = clamp(perc / 90)}) return tbl
| |
| 109 | end | |
| 110 | ||
| 111 | -- down left, then from right to left | |
| 112 | perc = perc - 90 | |
| 113 | if (perc > 90) then | |
| 114 | insert(tbl, {x = x - w, y = y + h, u = 0, v = 1})
| |
| 115 | else | |
| 116 | insert(tbl, {x = x + w - perc / 90 * h * 2, y = y + h, u = 1 - clamp(perc / 90), v = 1}) return tbl
| |
| 117 | end | |
| 118 | ||
| 119 | -- top left, and from bottom to up! | |
| 120 | perc = perc - 90 | |
| 121 | if (perc > 90) then | |
| 122 | insert(tbl, {x = x - w, y = y - h, u = 0, v = 0})
| |
| 123 | else | |
| 124 | insert(tbl, {x = x - w, y = y + h - perc / 90 * h * 2, u = 0, v = 1 - clamp(perc / 90)}) return tbl
| |
| 125 | end | |
| 126 | ||
| 127 | -- 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. | |
| 128 | perc = perc - 90 | |
| 129 | insert(tbl, {x = x - w + perc / 45 * w, y = y - h, u = clamp(perc / 45) / 2, v = 0})
| |
| 130 | ||
| 131 | -- aparently, we got a full pizza! lets return this lovly meal. | |
| 132 | return tbl | |
| 133 | end | |
| 134 | end | |
| 135 | ||
| 136 | function CreateBorderedCircle(x, y, size, border, perc, addrot, parts) | |
| 137 | ||
| 138 | local sin = math.sin | |
| 139 | local cos = math.cos | |
| 140 | local rad = math.rad | |
| 141 | ||
| 142 | local parts = parts or 100 | |
| 143 | ||
| 144 | local tbl = {}
| |
| 145 | local onerad = rad(360) / parts | |
| 146 | local fixpos = rad(90) | |
| 147 | local ret = false | |
| 148 | local ending = perc * 3.6 * (parts / 360) | |
| 149 | local innersize = size - border | |
| 150 | local i = 0 | |
| 151 | ||
| 152 | if (addrot != nil) then | |
| 153 | fixpos = fixpos + rad(addrot) | |
| 154 | end | |
| 155 | ||
| 156 | while(true) do | |
| 157 | if (not ret) then | |
| 158 | -- outside | |
| 159 | table.insert(tbl, {
| |
| 160 | x = x - cos(i * onerad - fixpos) * innersize, | |
| 161 | y = y + sin(i * onerad - fixpos) * innersize | |
| 162 | }) | |
| 163 | ||
| 164 | i = i + 1 | |
| 165 | ||
| 166 | if (i > ending) then | |
| 167 | ret = true | |
| 168 | i = i - 1 | |
| 169 | end | |
| 170 | else | |
| 171 | -- inside | |
| 172 | table.insert(tbl, {
| |
| 173 | x = x - cos(i * onerad - fixpos) * size, | |
| 174 | y = y + sin(i * onerad - fixpos) * size | |
| 175 | }) | |
| 176 | ||
| 177 | i = i - 1 | |
| 178 | ||
| 179 | if (i < 0) then | |
| 180 | table.insert(tbl, {
| |
| 181 | x = x + cos(fixpos) * size, | |
| 182 | y = y + sin(fixpos) * size | |
| 183 | }) | |
| 184 | ||
| 185 | break | |
| 186 | end | |
| 187 | end | |
| 188 | end | |
| 189 | ||
| 190 | return tbl | |
| 191 | end | |
| 192 | ||
| 193 | function DrawCorrectFuckingPoly(tbl, fade) | |
| 194 | local len = #tbl | |
| 195 | ||
| 196 | for i = 1, #tbl do | |
| 197 | ||
| 198 | if fade and (i < 5 or i >= (len-5)) then | |
| 199 | local col = i / 5 | |
| 200 | ||
| 201 | if i > len/2 then | |
| 202 | col = (len-i-1) / 5 | |
| 203 | end | |
| 204 | ||
| 205 | surface.SetDrawColor( 175 * col, 225 * col, 100 * col, 200 * col ) | |
| 206 | elseif fade then | |
| 207 | surface.SetDrawColor( 175, 225, 100, 200 ) | |
| 208 | end | |
| 209 | ||
| 210 | surface.DrawPoly({tbl[i], tbl[len - (i - 1)], tbl[len - i]})
| |
| 211 | surface.DrawPoly({tbl[i], tbl[i + 1], tbl[len - i]})
| |
| 212 | end | |
| 213 | end | |
| 214 | ||
| 215 | local roundstate_string = {
| |
| 216 | [ROUND_WAIT] = "round_wait", | |
| 217 | [ROUND_PREP] = "round_prep", | |
| 218 | [ROUND_ACTIVE] = "round_active", | |
| 219 | [ROUND_POST] = "round_post" | |
| 220 | } | |
| 221 | ||
| 222 | local role_string = {
| |
| 223 | ["innocent"] = Color(170,225,100,200), | |
| 224 | ["traitor"] = Color(205,60,40,200), | |
| 225 | ["detective"] = Color(115,180,200,200), | |
| 226 | ["round"] = Color(200,200,200,200) | |
| 227 | } | |
| 228 | ||
| 229 | local role_string_2 = {
| |
| 230 | ["innocent"] = Color(150,205,80,200), | |
| 231 | ["traitor"] = Color(180,40,20,200), | |
| 232 | ["detective"] = Color(95,160,180,200), | |
| 233 | ["round"] = Color(180,180,180,200) | |
| 234 | } | |
| 235 | ||
| 236 | local function GetAmmo() | |
| 237 | local ply = LocalPlayer() | |
| 238 | local weap = ply:GetActiveWeapon() | |
| 239 | if !IsValid(weap) or not ply:Alive() then return -1 end | |
| 240 | ||
| 241 | local ammo_inv = weap:Ammo1() or 0 | |
| 242 | local ammo_clip = weap:Clip1() or 0 | |
| 243 | local ammo_max = weap.Primary.ClipSize or 0 | |
| 244 | local ammo_invmax = weap.Primary.ClipMax or 0 | |
| 245 | ||
| 246 | return ammo_clip, ammo_max, ammo_inv, ammo_invmax | |
| 247 | end | |
| 248 | ||
| 249 | local GetPTranslation = LANG.GetParamTranslation | |
| 250 | local GetRaw = LANG.GetRawTranslation | |
| 251 | ||
| 252 | local key_params = {usekey = Key("+use", "USE"), walkkey = Key("+walk", "WALK")}
| |
| 253 | ||
| 254 | local ClassHint = {
| |
| 255 | prop_ragdoll = {
| |
| 256 | name= "corpse", | |
| 257 | hint= "corpse_hint", | |
| 258 | ||
| 259 | fmt = function(ent, txt) return GetPTranslation(txt, key_params) end | |
| 260 | } | |
| 261 | }; | |
| 262 | ||
| 263 | ---- "T" indicator above traitors | |
| 264 | ||
| 265 | local indicator_mat = Material("VGUI/ttt/sprite_traitor")
| |
| 266 | local indicator_col = Color(255, 255, 255, 130) | |
| 267 | ||
| 268 | local client, plys, ply, pos, dir, tgt | |
| 269 | local GetPlayers = player.GetAll | |
| 270 | ||
| 271 | local propspec_outline = Material("models/props_combine/portalball001_sheet")
| |
| 272 | ||
| 273 | ||
| 274 | local function DrawPropSpecLabels(client) | |
| 275 | if (not client:IsSpec()) and (GetRoundState() != ROUND_POST) then return end | |
| 276 | ||
| 277 | surface.SetFont("TabLarge")
| |
| 278 | ||
| 279 | local tgt = nil | |
| 280 | local scrpos = nil | |
| 281 | local text = nil | |
| 282 | local w = 0 | |
| 283 | for _, ply in pairs(player.GetAll()) do | |
| 284 | if ply:IsSpec() then | |
| 285 | surface.SetTextColor(220,200,0,120) | |
| 286 | ||
| 287 | tgt = ply:GetObserverTarget() | |
| 288 | ||
| 289 | if IsValid(tgt) and tgt:GetNWEntity("spec_owner", nil) == ply then
| |
| 290 | ||
| 291 | scrpos = tgt:GetPos():ToScreen() | |
| 292 | else | |
| 293 | scrpos = nil | |
| 294 | end | |
| 295 | else | |
| 296 | local _, healthcolor = util.HealthToString(ply:Health()) | |
| 297 | surface.SetTextColor(clr(healthcolor)) | |
| 298 | ||
| 299 | scrpos = ply:EyePos() | |
| 300 | scrpos.z = scrpos.z + 20 | |
| 301 | ||
| 302 | scrpos = scrpos:ToScreen() | |
| 303 | end | |
| 304 | ||
| 305 | if scrpos and (not IsOffScreen(scrpos)) then | |
| 306 | text = ply:Nick() | |
| 307 | w, _ = surface.GetTextSize(text) | |
| 308 | ||
| 309 | surface.SetTextPos(scrpos.x - w / 2, scrpos.y) | |
| 310 | surface.DrawText(text) | |
| 311 | end | |
| 312 | end | |
| 313 | end | |
| 314 | ||
| 315 | ||
| 316 | ---- Crosshair affairs | |
| 317 | ||
| 318 | surface.CreateFont("TargetIDSmall2", {font = "TargetID",
| |
| 319 | size = 16, | |
| 320 | weight = 1000}) | |
| 321 | ||
| 322 | local minimalist = CreateConVar("ttt_minimal_targetid", "0", FCVAR_ARCHIVE)
| |
| 323 | ||
| 324 | local magnifier_mat = Material("icon16/magnifier.png")
| |
| 325 | local ring_tex = surface.GetTextureID("effects/select_ring")
| |
| 326 | ||
| 327 | local rag_color = Color(200,200,200,255) | |
| 328 | ||
| 329 | local GetLang = LANG.GetUnsafeLanguageTable | |
| 330 | ||
| 331 | if FC_HUD.DefaultTargetInfo == false then | |
| 332 | ||
| 333 | GAMEMODE.HUDDrawTargetID = function() | |
| 334 | local client = LocalPlayer() | |
| 335 | ||
| 336 | local L = GetLang() | |
| 337 | ||
| 338 | DrawPropSpecLabels(client) | |
| 339 | ||
| 340 | local trace = client:GetEyeTrace(MASK_SHOT) | |
| 341 | local ent = trace.Entity | |
| 342 | if (not IsValid(ent)) or ent.NoTarget then return end | |
| 343 | ||
| 344 | -- some bools for caching what kind of ent we are looking at | |
| 345 | local target_traitor = false | |
| 346 | local target_detective = false | |
| 347 | local target_corpse = false | |
| 348 | ||
| 349 | local text = nil | |
| 350 | local color = COLOR_WHITE | |
| 351 | ||
| 352 | -- if a vehicle, we identify the driver instead | |
| 353 | if IsValid(ent:GetNWEntity("ttt_driver", nil)) then
| |
| 354 | ent = ent:GetNWEntity("ttt_driver", nil)
| |
| 355 | ||
| 356 | if ent == client then return end | |
| 357 | end | |
| 358 | ||
| 359 | local cls = ent:GetClass() | |
| 360 | local minimal = minimalist:GetBool() | |
| 361 | local hint = (not minimal) and (ent.TargetIDHint or ClassHint[cls]) | |
| 362 | ||
| 363 | if ent:IsPlayer() then | |
| 364 | if ent:GetNWBool("disguised", false) then
| |
| 365 | client.last_id = nil | |
| 366 | ||
| 367 | if client:IsTraitor() or client:IsSpec() then | |
| 368 | text = ent:Nick() .. L.target_disg | |
| 369 | else | |
| 370 | -- Do not show anything | |
| 371 | return | |
| 372 | end | |
| 373 | ||
| 374 | color = COLOR_RED | |
| 375 | else | |
| 376 | text = ent:Nick() | |
| 377 | client.last_id = ent | |
| 378 | end | |
| 379 | ||
| 380 | -- in minimalist targetID, colour nick with health level | |
| 381 | if minimal then | |
| 382 | _, color = util.HealthToString(ent:Health()) | |
| 383 | end | |
| 384 | ||
| 385 | if client:IsTraitor() and GAMEMODE.round_state == ROUND_ACTIVE then | |
| 386 | target_traitor = ent:IsTraitor() | |
| 387 | end | |
| 388 | ||
| 389 | target_detective = ent:IsDetective() | |
| 390 | ||
| 391 | elseif cls == "prop_ragdoll" then | |
| 392 | -- only show this if the ragdoll has a nick, else it could be a mattress | |
| 393 | if CORPSE.GetPlayerNick(ent, false) == false then return end | |
| 394 | ||
| 395 | target_corpse = true | |
| 396 | ||
| 397 | if CORPSE.GetFound(ent, false) or not DetectiveMode() then | |
| 398 | text = CORPSE.GetPlayerNick(ent, "A Terrorist") | |
| 399 | else | |
| 400 | text = L.target_unid | |
| 401 | color = COLOR_YELLOW | |
| 402 | end | |
| 403 | elseif not hint then | |
| 404 | -- Not something to ID and not something to hint about | |
| 405 | return | |
| 406 | end | |
| 407 | ||
| 408 | local x_orig = ScrW() / 2.0 | |
| 409 | local x = x_orig | |
| 410 | local y = ScrH() / 2.0 | |
| 411 | ||
| 412 | local w, h = 0,0 -- text width/height, reused several times | |
| 413 | ||
| 414 | if target_traitor or target_detective then | |
| 415 | surface.SetTexture(ring_tex) | |
| 416 | ||
| 417 | if target_traitor then | |
| 418 | surface.SetDrawColor(255, 0, 0, 200) | |
| 419 | else | |
| 420 | surface.SetDrawColor(0, 0, 255, 220) | |
| 421 | end | |
| 422 | surface.DrawTexturedRect(x-32, y-32, 64, 64) | |
| 423 | end | |
| 424 | ||
| 425 | y = y + 30 | |
| 426 | local font = "FC_HUD_20" | |
| 427 | surface.SetFont( font ) | |
| 428 | ||
| 429 | -- Draw main title, ie. nickname | |
| 430 | if text then | |
| 431 | w1, h1 = surface.GetTextSize( string.upper(text) ) | |
| 432 | w2, h2 = surface.GetTextSize( string.upper(text) ) | |
| 433 | ||
| 434 | x = x - w1 / 2 | |
| 435 | ||
| 436 | local width = w1 + 32 | |
| 437 | ||
| 438 | surface.SetDrawColor( 0, 0, 0, 200 ) | |
| 439 | surface.SetMaterial( FC_HUD.White ) | |
| 440 | ||
| 441 | local tab = CreateBorderedCircle((ScrW()-width)/2 + 14, ScrH()/2 + 30 + 14, 10, 10, 100, 0, 20) | |
| 442 | DrawCorrectFuckingPoly(tab) | |
| 443 | ||
| 444 | if ent:IsPlayer() then | |
| 445 | if LocalPlayer():IsTraitor() and ent:IsTraitor() then | |
| 446 | surface.SetDrawColor( role_string["traitor"] ) | |
| 447 | elseif ent:IsDetective() then | |
| 448 | surface.SetDrawColor( role_string["detective"] ) | |
| 449 | else | |
| 450 | surface.SetDrawColor( role_string["innocent"] ) | |
| 451 | end | |
| 452 | else | |
| 453 | surface.SetDrawColor( role_string["round"] ) | |
| 454 | end | |
| 455 | ||
| 456 | local tab = CreateBorderedCircle((ScrW()-width)/2 + 14, ScrH()/2 + 30 + 14, 8, 8, 100, 0, 20) | |
| 457 | DrawCorrectFuckingPoly(tab) | |
| 458 | ||
| 459 | ||
| 460 | draw.RoundedBox(2, (ScrW()-width)/2 + 26, ScrH()/2 + 34, w1 + 4, h1, Color(0,0,0,200)) | |
| 461 | draw.SimpleText( string.upper(text), "FC_HUD_20", (ScrW()-width)/2 + 28, ScrH()/2 + 44, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ) | |
| 462 | ||
| 463 | -- for ragdolls searched by detectives, add icon | |
| 464 | /*if ent.search_result and client:IsDetective() then | |
| 465 | -- if I am detective and I know a search result for this corpse, then I | |
| 466 | -- have searched it or another detective has | |
| 467 | surface.SetMaterial(magnifier_mat) | |
| 468 | surface.SetDrawColor(200, 200, 255, 255) | |
| 469 | surface.DrawTexturedRect(x + w + 5, y, 16, 16) | |
| 470 | end*/ | |
| 471 | ||
| 472 | y = y + h + 4 | |
| 473 | end | |
| 474 | ||
| 475 | -- Minimalist target ID only draws a health-coloured nickname, no hints, no | |
| 476 | -- karma, no tag | |
| 477 | if minimal then return end | |
| 478 | ||
| 479 | ||
| 480 | -- Draw subtitle: health or type | |
| 481 | local clr = rag_color | |
| 482 | if ent:IsPlayer() then | |
| 483 | text, clr = util.HealthToString(ent:Health()) | |
| 484 | ||
| 485 | -- HealthToString returns a string id, need to look it up | |
| 486 | text = L[text] | |
| 487 | elseif hint then | |
| 488 | text = GetRaw(hint.name) or hint.name | |
| 489 | else | |
| 490 | return | |
| 491 | end | |
| 492 | font = "TargetIDSmall2" | |
| 493 | ||
| 494 | surface.SetFont( font ) | |
| 495 | w, h = surface.GetTextSize( text ) | |
| 496 | x = x_orig - w / 2 | |
| 497 | ||
| 498 | //draw.SimpleText( text, font, x+1, y+1, COLOR_BLACK ) | |
| 499 | //draw.SimpleText( text, font, x, y, clr ) | |
| 500 | ||
| 501 | font = "TargetIDSmall" | |
| 502 | surface.SetFont( font ) | |
| 503 | ||
| 504 | local h_karma, h_hint, h_karma_color, h_hint_color = "", "", Color(255,255,255,200), Color(255,255,255,200) | |
| 505 | ||
| 506 | -- Draw second subtitle: karma | |
| 507 | if ent:IsPlayer() and KARMA.IsEnabled() then | |
| 508 | text, clr = util.KarmaToString(ent:GetBaseKarma()) | |
| 509 | ||
| 510 | text = L[text] | |
| 511 | ||
| 512 | w, h = surface.GetTextSize( text ) | |
| 513 | y = y + h + 5 | |
| 514 | x = x_orig - w / 2 | |
| 515 | ||
| 516 | h_karma = text | |
| 517 | h_karma_color = clr | |
| 518 | end | |
| 519 | ||
| 520 | -- Draw key hint | |
| 521 | if hint and hint.hint then | |
| 522 | if not hint.fmt then | |
| 523 | text = GetRaw(hint.hint) or hint.hint | |
| 524 | else | |
| 525 | text = hint.fmt(ent, hint.hint) | |
| 526 | end | |
| 527 | ||
| 528 | w, h = surface.GetTextSize(text) | |
| 529 | x = x_orig - w / 2 | |
| 530 | y = y + h + 5 | |
| 531 | h_hint = text | |
| 532 | elseif ent:IsPlayer() and ent.sb_tag then | |
| 533 | h_hint = LANG.GetTranslation(ent.sb_tag.txt) or "" | |
| 534 | h_hint_color = ent.sb_tag.color | |
| 535 | end | |
| 536 | ||
| 537 | surface.SetFont( "FC_HUD_20" ) | |
| 538 | ||
| 539 | w1, h1 = surface.GetTextSize( string.upper(h_karma) ) | |
| 540 | w2, h2 = surface.GetTextSize( string.upper(h_hint) ) | |
| 541 | ||
| 542 | local addw, addh = 0, 0 | |
| 543 | ||
| 544 | if ent:IsPlayer() and ent:Alive() then | |
| 545 | addw = 48 | |
| 546 | addh = 24 | |
| 547 | ||
| 548 | if FC_HUD.ShowOnlyHP then w1, w2 = -4, -4 end | |
| 549 | end | |
| 550 | ||
| 551 | local width = math.max(w1, w2) + 4 + addw | |
| 552 | ||
| 553 | draw.RoundedBox(2, (ScrW()-width)/2, ScrH()/2 + 58, width, 24 + addh, Color(0,0,0,200)) | |
| 554 | ||
| 555 | if ent:IsPlayer() and ent:Alive() then | |
| 556 | ||
| 557 | local y1,y2 = ScrH()/2 + 70, ScrH()/2 + 94 | |
| 558 | ||
| 559 | if h_karma == "" then y2 = ScrH()/2 + 82 end | |
| 560 | if h_hint == "" then y1 = ScrH()/2 + 82 end | |
| 561 | ||
| 562 | if !FC_HUD.ShowOnlyHP then | |
| 563 | ||
| 564 | draw.SimpleText( string.upper(h_karma), "FC_HUD_20", (ScrW()-width)/2 + 48, y1, h_karma_color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ) | |
| 565 | draw.SimpleText( string.upper(h_hint), "FC_HUD_20", (ScrW()-width)/2 + 48, y2, h_hint_color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ) | |
| 566 | ||
| 567 | end | |
| 568 | ||
| 569 | surface.SetDrawColor( 255, 0, 0, 200 ) | |
| 570 | surface.SetMaterial( FC_HUD.White ) | |
| 571 | ||
| 572 | local parts = NiceUV((ScrW()-width)/2 + 24, ScrH()/2 + 82, 32, 32, math.Clamp(ent:Health(), 0, 100) / 100 * 360, true ) | |
| 573 | ||
| 574 | surface.SetMaterial( FC_HUD.SmallHP ) | |
| 575 | if FC_HUD.TeamBasedHP and (target_traitor or target_detective) then | |
| 576 | if target_traitor then | |
| 577 | surface.SetDrawColor( role_string["traitor"] ) | |
| 578 | else | |
| 579 | surface.SetDrawColor( role_string["detective"] ) | |
| 580 | end | |
| 581 | else | |
| 582 | surface.SetDrawColor( role_string["innocent"] ) | |
| 583 | end | |
| 584 | surface.SetDrawColor(160, 205, 95, 200) | |
| 585 | surface.DrawPoly(parts) | |
| 586 | ||
| 587 | if ent:Armor() > 0 then | |
| 588 | ||
| 589 | local parts = NiceUV((ScrW()-width)/2 + 24, ScrH()/2 + 82, 32, 32, math.Clamp(ent:Armor(), 0, 100) / 100 * 360, true ) | |
| 590 | ||
| 591 | surface.SetMaterial( FC_HUD.SmallAR ) | |
| 592 | surface.SetDrawColor(255,255,255,200) | |
| 593 | surface.DrawPoly(parts) | |
| 594 | ||
| 595 | end | |
| 596 | ||
| 597 | else | |
| 598 | draw.SimpleText( string.upper(h_hint), "FC_HUD_20", ScrW()/2, ScrH()/2 + 70, h_hint_color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | |
| 599 | end | |
| 600 | ||
| 601 | text = nil | |
| 602 | ||
| 603 | ||
| 604 | end | |
| 605 | ||
| 606 | end | |
| 607 | ||
| 608 | local delay = 0.075 | |
| 609 | local showtime = 3 | |
| 610 | ||
| 611 | local margin = 10 | |
| 612 | local width = 350 | |
| 613 | local height = 22 | |
| 614 | ||
| 615 | local barcorner = surface.GetTextureID( "gui/corner8" ) | |
| 616 | ||
| 617 | local col_active = {
| |
| 618 | tip = {
| |
| 619 | [ROLE_INNOCENT] = role_string["innocent"], | |
| 620 | [ROLE_TRAITOR] = role_string["traitor"], | |
| 621 | [ROLE_DETECTIVE] = role_string["detective"] | |
| 622 | }, | |
| 623 | ||
| 624 | bg = Color(0, 0, 0, 250), | |
| 625 | ||
| 626 | text_empty = Color(200, 20, 20, 255), | |
| 627 | text_empty_2 = Color(200, 200, 20, 255), | |
| 628 | text = Color(255, 255, 255, 255), | |
| 629 | ||
| 630 | shadow = 255 | |
| 631 | }; | |
| 632 | ||
| 633 | local col_dark = {
| |
| 634 | tip = {
| |
| 635 | [ROLE_INNOCENT] = role_string_2["innocent"], | |
| 636 | [ROLE_TRAITOR] = role_string_2["traitor"], | |
| 637 | [ROLE_DETECTIVE] = role_string_2["detective"] | |
| 638 | }, | |
| 639 | ||
| 640 | bg = Color(0, 0, 0, 200), | |
| 641 | ||
| 642 | text_empty = Color(200, 20, 20, 100), | |
| 643 | text_empty_2 = Color(200, 200, 20, 100), | |
| 644 | text = Color(255, 255, 255, 100), | |
| 645 | ||
| 646 | shadow = 100 | |
| 647 | }; | |
| 648 | ||
| 649 | -- Draw a bar in the style of the the weapon pickup ones | |
| 650 | local round = math.Round | |
| 651 | function WSWITCH:DrawBarBg(x, y, w, h, col) | |
| 652 | draw.RoundedBoxEx( 2, x + 20, y - 15, w - 20, 30, col.bg, false, true, false, true ) | |
| 653 | draw.RoundedBoxEx( 2, x, y - 15, 20, 30, Color(255,255,255,200), true, false, true, false ) | |
| 654 | end | |
| 655 | ||
| 656 | local TryTranslation = LANG.TryTranslation | |
| 657 | function WSWITCH:DrawWeapon(x, y, c, wep) | |
| 658 | if not IsValid(wep) then return false end | |
| 659 | ||
| 660 | local name = TryTranslation(wep:GetPrintName() or wep.PrintName or "...") | |
| 661 | local cl1, am1 = wep:Clip1(), wep:Ammo1() | |
| 662 | local ammo = false | |
| 663 | ||
| 664 | -- Clip1 will be -1 if a melee weapon | |
| 665 | -- Ammo1 will be false if weapon has no owner (was just dropped) | |
| 666 | if cl1 != -1 and am1 != false then | |
| 667 | ammo = Format("%i + %02i", cl1, am1)
| |
| 668 | end | |
| 669 | ||
| 670 | -- Slot | |
| 671 | 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}
| |
| 672 | ||
| 673 | draw.SimpleText( wep.Slot + 1, "FC_HUD_30", x+10, y, Color(0,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) | |
| 674 | ||
| 675 | -- Name | |
| 676 | spec.text = string.upper(name) | |
| 677 | spec.pos[1] = x + 10 + height | |
| 678 | draw.Text(spec) | |
| 679 | ||
| 680 | local clip, max, inv, invmax = wep:Clip1() or 0, wep.Primary.ClipSize or 0, wep:Ammo1() or 0, wep.ClipMax or 0 | |
| 681 | ||
| 682 | if clip != -1 then | |
| 683 | local col1, col2 = c.text, c.text | |
| 684 | ||
| 685 | if clip == 0 then | |
| 686 | col1 = c.text_empty | |
| 687 | elseif clip/max <= 0.25 then | |
| 688 | col1 = c.text_empty_2 | |
| 689 | end | |
| 690 | ||
| 691 | if inv == 0 then | |
| 692 | col2 = c.text_empty | |
| 693 | elseif inv/invmax <= 0.25 then | |
| 694 | col2 = c.text_empty_2 | |
| 695 | end | |
| 696 | ||
| 697 | if clip < 10 then | |
| 698 | clip = "0"..clip | |
| 699 | end | |
| 700 | ||
| 701 | if inv < 10 then | |
| 702 | inv = "0"..inv | |
| 703 | end | |
| 704 | ||
| 705 | local w, h = draw.SimpleText(inv, "FC_HUD_30", ScrW() - margin*3, y, col2, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER) | |
| 706 | local w2, h2 = draw.SimpleText("+", "FC_HUD_30", ScrW() - margin*3 - w - 4, y, c.text, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
| |
| 707 | draw.SimpleText(clip, "FC_HUD_30", ScrW() - margin*3 - w - w2 - 8, y, col1, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER) | |
| 708 | ||
| 709 | end | |
| 710 | ||
| 711 | return true | |
| 712 | end | |
| 713 | ||
| 714 | function WSWITCH:Draw(client) | |
| 715 | if not self.Show then return end | |
| 716 | ||
| 717 | local weps = self.WeaponCache | |
| 718 | ||
| 719 | local x = ScrW() - width - margin*2 | |
| 720 | local y = ScrH() - (#weps * (height + margin)) | |
| 721 | ||
| 722 | local col = col_dark | |
| 723 | for k, wep in pairs(weps) do | |
| 724 | if self.Selected == k then | |
| 725 | col = col_active | |
| 726 | else | |
| 727 | col = col_dark | |
| 728 | end | |
| 729 | ||
| 730 | self:DrawBarBg(x, y, width, height, col) | |
| 731 | if not self:DrawWeapon(x, y, col, wep) then | |
| 732 | ||
| 733 | self:UpdateWeaponCache() | |
| 734 | return | |
| 735 | end | |
| 736 | ||
| 737 | y = y + height + margin | |
| 738 | end | |
| 739 | end | |
| 740 | ||
| 741 | function GAMEMODE:HUDDrawPickupHistory() | |
| 742 | if (GAMEMODE.PickupHistory == nil) then return end | |
| 743 | ||
| 744 | local x, y = ScrW() - GAMEMODE.PickupHistoryWide - 20, GAMEMODE.PickupHistoryTop | |
| 745 | local tall = 0 | |
| 746 | local wide = 0 | |
| 747 | ||
| 748 | for k, v in pairs( GAMEMODE.PickupHistory ) do | |
| 749 | ||
| 750 | if v.time < CurTime() then | |
| 751 | ||
| 752 | if (v.y == nil) then v.y = y end | |
| 753 | ||
| 754 | v.x = x | |
| 755 | v.y = (v.y*5 + y) / 6 | |
| 756 | ||
| 757 | local delta = (v.time + v.holdtime) - CurTime() | |
| 758 | delta = delta / v.holdtime | |
| 759 | delta = math.Clamp( delta, 0, 1 ) | |
| 760 | ||
| 761 | local nam = v.name | |
| 762 | ||
| 763 | if v.amount then | |
| 764 | nam = v.name.." ["..v.amount.."]" | |
| 765 | end | |
| 766 | ||
| 767 | nam = string.upper(nam) | |
| 768 | ||
| 769 | surface.SetFont("FC_HUD_20")
| |
| 770 | local fw, fh = surface.GetTextSize(v.name) | |
| 771 | local fw2 = 0 | |
| 772 | ||
| 773 | if v.amount then | |
| 774 | fw2 = surface.GetTextSize(" ["..v.amount.."]")
| |
| 775 | fw = fw + fw2 | |
| 776 | end | |
| 777 | ||
| 778 | local clampw = 0 | |
| 779 | local al = 0 | |
| 780 | ||
| 781 | if delta >= 0.85 then | |
| 782 | clampw = 0 | |
| 783 | elseif delta < 0.85 and delta > 0.8 then | |
| 784 | clampw = fw * ( 1 - ((delta - 0.8)*20) ) | |
| 785 | elseif delta > 0.2 then | |
| 786 | clampw = fw * 1 | |
| 787 | elseif delta <= 0.2 and delta > 0.15 then | |
| 788 | clampw = fw * ((delta - 0.15)*20) | |
| 789 | elseif delta <= 0.1 then | |
| 790 | clampw = 0 | |
| 791 | end | |
| 792 | ||
| 793 | if delta > 0.9 then | |
| 794 | al = 1 - ((delta - 0.9) * 10) | |
| 795 | elseif delta < 0.1 then | |
| 796 | al = (delta) * 10 | |
| 797 | else | |
| 798 | al = 1 | |
| 799 | end | |
| 800 | ||
| 801 | local boxw = math.max( clampw, 0 ) | |
| 802 | ||
| 803 | draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y - 18, boxw + 20, 24, Color(0,0,0,200 * al) ) | |
| 804 | ||
| 805 | draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y - 18, 6, 2, Color(255,255,255,200 * al) ) | |
| 806 | draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y - 16, 2, 4, Color(255,255,255,200 * al) ) | |
| 807 | ||
| 808 | draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y + 4, 6, 2, Color(255,255,255,200 * al) ) | |
| 809 | draw.RoundedBox( 0, ScrW() - 40 - boxw, v.y, 2, 4, Color(255,255,255,200 * al) ) | |
| 810 | ||
| 811 | draw.RoundedBox( 0, ScrW() - 26, v.y - 18, 6, 2, Color(255,255,255,200 * al) ) | |
| 812 | draw.RoundedBox( 0, ScrW() - 22, v.y - 16, 2, 4, Color(255,255,255,200 * al) ) | |
| 813 | ||
| 814 | draw.RoundedBox( 0, ScrW() - 26, v.y + 4, 6, 2, Color(255,255,255,200 * al) ) | |
| 815 | draw.RoundedBox( 0, ScrW() - 22, v.y, 2, 4, Color(255,255,255,200 * al) ) | |
| 816 | ||
| 817 | render.SetScissorRect( ScrW() - 40 - boxw + 10, v.y - 18, ScrW() - 30, v.y + 6, true ) | |
| 818 | 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 ) | |
| 819 | if v.amount then | |
| 820 | 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 ) | |
| 821 | end | |
| 822 | render.SetScissorRect( ScrW() - 40 - boxw, v.y - 18, boxw, 24, false ) | |
| 823 | ||
| 824 | y = y + (v.height + 16) | |
| 825 | tall = tall + v.height + 18 | |
| 826 | wide = math.Max( wide, v.width + v.height + 24 ) | |
| 827 | ||
| 828 | if delta == 0 then GAMEMODE.PickupHistory[k] = nil end | |
| 829 | end | |
| 830 | end | |
| 831 | ||
| 832 | GAMEMODE.PickupHistoryTop = (GAMEMODE.PickupHistoryTop * 5 + ( ScrH() * 0.75 - tall ) / 2 ) / 6 | |
| 833 | GAMEMODE.PickupHistoryWide = (GAMEMODE.PickupHistoryWide * 5 + wide) / 6 | |
| 834 | end | |
| 835 | ||
| 836 | GAMEMODE.HUDPaint = function() | |
| 837 | local client = LocalPlayer() | |
| 838 | ||
| 839 | GAMEMODE:HUDDrawTargetID() | |
| 840 | ||
| 841 | MSTACK:Draw(client) | |
| 842 | ||
| 843 | if (not client:Alive()) or client:Team() == TEAM_SPEC then | |
| 844 | return | |
| 845 | end | |
| 846 | ||
| 847 | ||
| 848 | RADAR:Draw(client) | |
| 849 | TBHUD:Draw(client) | |
| 850 | WSWITCH:Draw(client) | |
| 851 | ||
| 852 | VOICE.Draw(client) | |
| 853 | DISGUISE.Draw(client) | |
| 854 | ||
| 855 | GAMEMODE:HUDDrawPickupHistory() | |
| 856 | end | |
| 857 | ||
| 858 | hook.Add("HUDPaint", "FC_HUD", function()
| |
| 859 | ||
| 860 | local y = ScrH() | |
| 861 | local L = LANG.GetUnsafeLanguageTable() | |
| 862 | ||
| 863 | ||
| 864 | local is_haste = HasteMode() and GetRoundState() == ROUND_ACTIVE | |
| 865 | local is_traitor = LocalPlayer():IsTraitor() or !LocalPlayer():Alive() | |
| 866 | ||
| 867 | local endtime = GetGlobalFloat("ttt_round_end", 0) - CurTime()
| |
| 868 | ||
| 869 | local overtime = false | |
| 870 | local text | |
| 871 | local color = Color(255,255,255,200) | |
| 872 | ||
| 873 | -- Time displays differently depending on whether haste mode is on, | |
| 874 | -- whether the player is traitor or not, and whether it is overtime. | |
| 875 | if is_haste then | |
| 876 | local hastetime = GetGlobalFloat("ttt_haste_end", 0) - CurTime()
| |
| 877 | if hastetime < 0 then | |
| 878 | if (not is_traitor) or (math.ceil(CurTime()) % 7 <= 2) then | |
| 879 | -- innocent or blinking "overtime" | |
| 880 | text = L.overtime | |
| 881 | overtime = true | |
| 882 | else | |
| 883 | -- traitor and not blinking "overtime" right now, so standard endtime display | |
| 884 | text = string.ToMinutesSeconds(math.max(0, endtime)) | |
| 885 | color = Color(255,0,0,200) | |
| 886 | end | |
| 887 | else | |
| 888 | -- still in starting period | |
| 889 | local t = hastetime | |
| 890 | if is_traitor and math.ceil(CurTime()) % 6 < 2 then | |
| 891 | t = endtime | |
| 892 | color = Color(255,0,0,200) | |
| 893 | end | |
| 894 | text = string.ToMinutesSeconds(math.max(0, t)) | |
| 895 | end | |
| 896 | else | |
| 897 | -- bog standard time when haste mode is off (or round not active) | |
| 898 | text = string.ToMinutesSeconds(math.max(0, endtime)) | |
| 899 | end | |
| 900 | ||
| 901 | ||
| 902 | if LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR and GetRoundState() != ROUND_WAIT then | |
| 903 | ||
| 904 | draw.RoundedBox(2, 20, y - 114, 94, 94, Color(0,0,0,200)) | |
| 905 | ||
| 906 | if FC_HUD.LastHP == nil then FC_HUD.LastHP = LocalPlayer():Health() end | |
| 907 | ||
| 908 | if LocalPlayer():Health() != FC_HUD.LastHP then | |
| 909 | ||
| 910 | local tab = {}
| |
| 911 | tab.time = CurTime() + 0.5 | |
| 912 | tab.last = FC_HUD.LastHP | |
| 913 | tab.new = LocalPlayer():Health() | |
| 914 | ||
| 915 | table.insert(FC_HUD.HPFallout, tab) | |
| 916 | ||
| 917 | print("NEW", FC_HUD.LastHP, LocalPlayer():Health())
| |
| 918 | end | |
| 919 | ||
| 920 | for k, v in pairs(FC_HUD.HPFallout) do | |
| 921 | ||
| 922 | if CurTime() >= v.time then | |
| 923 | FC_HUD.HPFallout[k] = nil | |
| 924 | continue | |
| 925 | end | |
| 926 | ||
| 927 | local parts = NiceUV(67, y - 67, 64, 64, math.Clamp(v.last, 0, 100) / 100 * 360, true ) | |
| 928 | ||
| 929 | local alpha = (v.time - CurTime()) * 510 | |
| 930 | ||
| 931 | surface.SetMaterial( FC_HUD.BigHP ) | |
| 932 | surface.SetDrawColor( 205, 0, 0, alpha ) | |
| 933 | surface.DrawPoly(parts) | |
| 934 | ||
| 935 | end | |
| 936 | ||
| 937 | FC_HUD.LastHP = LocalPlayer():Health() | |
| 938 | ||
| 939 | surface.SetDrawColor( 255, 0, 0, 200 ) | |
| 940 | surface.SetMaterial( FC_HUD.White ) | |
| 941 | ||
| 942 | local parts = NiceUV(67, y - 67, 64, 64, math.Clamp(LocalPlayer():Health(), 0, 100) / 100 * 360, true ) | |
| 943 | ||
| 944 | surface.SetMaterial( FC_HUD.BigHP ) | |
| 945 | ||
| 946 | if FC_HUD.TeamBasedHP then | |
| 947 | surface.SetDrawColor( role_string[string.lower(LocalPlayer():GetRoleString())] or role_string["innocent"]) | |
| 948 | else | |
| 949 | if LocalPlayer():Health() >= 25 then | |
| 950 | surface.SetDrawColor(role_string["innocent"]) | |
| 951 | else | |
| 952 | surface.SetDrawColor(role_string["traitor"]) | |
| 953 | end | |
| 954 | end | |
| 955 | ||
| 956 | surface.DrawPoly(parts) | |
| 957 | ||
| 958 | if LocalPlayer():HasEquipment(EQUIP_ARMOR) then | |
| 959 | ||
| 960 | local parts = NiceUV(67, y - 67, 64, 64, 360, true ) | |
| 961 | ||
| 962 | surface.SetMaterial( FC_HUD.BigAR ) | |
| 963 | surface.SetDrawColor(255, 255, 255, 200) | |
| 964 | surface.DrawPoly(parts) | |
| 965 | ||
| 966 | end | |
| 967 | ||
| 968 | draw.SimpleText(LocalPlayer():Health(), "FC_HUD_40", 67, y - 67, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) | |
| 969 | ||
| 970 | draw.RoundedBoxEx(2, 118, y - 114, 20, 30, Color(255,255,255,200), true, false, true, false) | |
| 971 | draw.RoundedBoxEx(2, 138, y - 114, 120, 30, Color(0,0,0,200), false, true, false, true) | |
| 972 | ||
| 973 | surface.SetMaterial( FC_HUD.White ) | |
| 974 | local tab = CreateBorderedCircle(128, y - 99, 8, 8, 85, 0, 10) | |
| 975 | surface.SetDrawColor( 0, 0, 0, 200 ) | |
| 976 | surface.SetMaterial( FC_HUD.White ) | |
| 977 | DrawCorrectFuckingPoly(tab) | |
| 978 | ||
| 979 | draw.SimpleText(text, "FC_HUD_30", 198, y - 99, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) | |
| 980 | ||
| 981 | local y2 = 0 | |
| 982 | ||
| 983 | //if LocalPlayer():IsActiveTraitor() or LocalPlayer():IsActiveDetective() then | |
| 984 | draw.RoundedBoxEx(2, 138, y - 82 + y2, 120, 30, Color(0,0,0,200), false, true, false, true) | |
| 985 | draw.RoundedBoxEx(2, 118, y - 82 + y2, 20, 30, Color(255,255,255,200), true, false, true, false) | |
| 986 | draw.SimpleText("$", "FC_HUD_20", 128, y - 67 + y2, Color(0,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
| |
| 987 | ||
| 988 | local cred = LocalPlayer():GetCredits() | |
| 989 | ||
| 990 | draw.SimpleText(cred.." CREDITS", "FC_HUD_30", 198, y - 67 + y2, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) | |
| 991 | y2 = 32 | |
| 992 | //end | |
| 993 | local clip, max, inv, invmax = GetAmmo() | |
| 994 | ||
| 995 | if clip != -1 then | |
| 996 | draw.RoundedBoxEx(2, 138, y - 82 + y2, 120, 30, Color(0,0,0,200), false, true, false, true) | |
| 997 | ||
| 998 | local col1, col2 = Color(255,255,255,200), Color(255,255,255,200) | |
| 999 | ||
| 1000 | if clip == 0 then | |
| 1001 | col1 = Color(200,20,20,200) | |
| 1002 | elseif clip/max <= 0.25 then | |
| 1003 | col1 = Color(200,200,20,200) | |
| 1004 | end | |
| 1005 | ||
| 1006 | if inv == 0 then | |
| 1007 | col2 = Color(200,20,20,200) | |
| 1008 | elseif inv/invmax <= 0.25 then | |
| 1009 | col2 = Color(200,200,20,200) | |
| 1010 | end | |
| 1011 | ||
| 1012 | if clip < 10 then | |
| 1013 | clip = "0"..clip | |
| 1014 | end | |
| 1015 | ||
| 1016 | if inv < 10 then | |
| 1017 | inv = "0"..inv | |
| 1018 | end | |
| 1019 | ||
| 1020 | draw.SimpleText("+", "FC_HUD_30", 198, y - 67 + y2, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
| |
| 1021 | draw.SimpleText(clip, "FC_HUD_30", 198 - 8, y - 67 + y2, col1, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER) | |
| 1022 | draw.SimpleText(inv, "FC_HUD_30", 198 + 10, y - 67 + y2, col2, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) | |
| 1023 | ||
| 1024 | draw.RoundedBoxEx(2, 118, y - 82 + y2, 20, 30, Color(255,255,255,200), true, false, true, false) | |
| 1025 | ||
| 1026 | surface.SetDrawColor( 0, 0, 0, 200 ) | |
| 1027 | surface.SetMaterial( FC_HUD.White ) | |
| 1028 | local tab = CreateBorderedCircle(128, y - 67 + y2, 8, 8, 100, 0, 10) | |
| 1029 | surface.SetMaterial( FC_HUD.White ) | |
| 1030 | DrawCorrectFuckingPoly(tab) | |
| 1031 | ||
| 1032 | draw.RoundedBox(0, 126, y - 75 + y2, 4, 16, Color(255,255,255,200)) | |
| 1033 | draw.RoundedBox(0, 120, y - 69 + y2, 16, 4, Color(255,255,255,200)) | |
| 1034 | end | |
| 1035 | ||
| 1036 | y = y - 130 | |
| 1037 | ||
| 1038 | else | |
| 1039 | ||
| 1040 | surface.SetFont("FC_HUD_20")
| |
| 1041 | ||
| 1042 | local text = "" | |
| 1043 | local punch = false | |
| 1044 | local w, h = surface.GetTextSize( text ) | |
| 1045 | w = w + 16 | |
| 1046 | ||
| 1047 | local tgt = LocalPlayer():GetObserverTarget() | |
| 1048 | ||
| 1049 | if IsValid(tgt) and tgt:IsPlayer() then | |
| 1050 | ||
| 1051 | text = string.upper(tgt:Nick()) | |
| 1052 | w, h = surface.GetTextSize( text ) | |
| 1053 | w = w + 16 | |
| 1054 | elseif IsValid(tgt) and tgt:GetNWEntity("spec_owner", nil) == LocalPlayer() then
| |
| 1055 | punch = true | |
| 1056 | text = string.upper((LANG.GetUnsafeLanguageTable().punch_title or "PUNCH-O-METER")) | |
| 1057 | w, h = surface.GetTextSize( text ) | |
| 1058 | w = w + 16 | |
| 1059 | else | |
| 1060 | text = string.upper(string.Interp(LANG.GetUnsafeLanguageTable().spec_help, { usekey = Key("+use", "USE") }))
| |
| 1061 | w, h = surface.GetTextSize( text ) | |
| 1062 | w = w + 16 | |
| 1063 | end | |
| 1064 | ||
| 1065 | draw.RoundedBox(0, ScrW()/2 - w/2, 20, w, 30, Color(0,0,0,200)) | |
| 1066 | ||
| 1067 | draw.RoundedBox(0, ScrW()/2 - w/2 + 2, 20, 6, 2, Color(255,255,255,200)) | |
| 1068 | draw.RoundedBox(0, ScrW()/2 - w/2, 20, 2, 8, Color(255,255,255,200)) | |
| 1069 | ||
| 1070 | draw.RoundedBox(0, ScrW()/2 - w/2 + 2, 48, 6, 2, Color(255,255,255,200)) | |
| 1071 | draw.RoundedBox(0, ScrW()/2 - w/2, 42, 2, 8, Color(255,255,255,200)) | |
| 1072 | ||
| 1073 | draw.RoundedBox(0, ScrW()/2 + w/2 - 8, 20, 6, 2, Color(255,255,255,200)) | |
| 1074 | draw.RoundedBox(0, ScrW()/2 + w/2 - 2, 20, 2, 8, Color(255,255,255,200)) | |
| 1075 | ||
| 1076 | draw.RoundedBox(0, ScrW()/2 + w/2 - 8, 48, 6, 2, Color(255,255,255,200)) | |
| 1077 | draw.RoundedBox(0, ScrW()/2 + w/2 - 2, 42, 2, 8, Color(255,255,255,200)) | |
| 1078 | ||
| 1079 | if punch then | |
| 1080 | punches = LocalPlayer():GetNWFloat("specpunches", 0)
| |
| 1081 | ||
| 1082 | local w2 = (w-4) * punches | |
| 1083 | ||
| 1084 | render.SetScissorRect( ScrW()/2 - w/2, 20, ScrW()/2 - w/2 + w2, 50, true ) | |
| 1085 | draw.RoundedBox( 0, ScrW()/2 - w/2 + 4, 24, w - 8, 22, Color(255,255,255,200) ) | |
| 1086 | draw.SimpleText( text, "FC_HUD_20", ScrW()/2, 35, Color(0,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | |
| 1087 | render.SetScissorRect( ScrW()/2 - w/2, 20, 0, 50, false ) | |
| 1088 | ||
| 1089 | render.SetScissorRect( ScrW()/2 - w/2 + w2, 20, ScrW()/2 + w/2 - 4, 50, true ) | |
| 1090 | draw.SimpleText( text, "FC_HUD_20", ScrW()/2, 35, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | |
| 1091 | render.SetScissorRect( ScrW()/2 - w/2, 20, 0, 50, false ) | |
| 1092 | ||
| 1093 | else | |
| 1094 | draw.SimpleText( text, "FC_HUD_20", ScrW()/2, 35, Color(255,255,255,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | |
| 1095 | end | |
| 1096 | ||
| 1097 | y = y - 30 | |
| 1098 | ||
| 1099 | end | |
| 1100 | ||
| 1101 | local t = "" | |
| 1102 | local col = role_string["round"] | |
| 1103 | ||
| 1104 | if GetRoundState() == ROUND_WAIT or LocalPlayer():Alive() == false or LocalPlayer():Team() == TEAM_SPECTATOR then | |
| 1105 | ||
| 1106 | else | |
| 1107 | text = "" | |
| 1108 | end | |
| 1109 | ||
| 1110 | if GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR then | |
| 1111 | t = L[ LocalPlayer():GetRoleStringRaw() ] | |
| 1112 | col = role_string[ LocalPlayer():GetRoleStringRaw() ] | |
| 1113 | text = "" | |
| 1114 | else | |
| 1115 | t = L[ roundstate_string[GetRoundState()] ] | |
| 1116 | end | |
| 1117 | ||
| 1118 | surface.SetDrawColor( 0, 0, 0, 200 ) | |
| 1119 | ||
| 1120 | local mul = 0 | |
| 1121 | local font = "FC_HUD_20" | |
| 1122 | ||
| 1123 | if FC_HUD.LargerStatus then | |
| 1124 | mul = 4 | |
| 1125 | font = "FC_HUD_30" | |
| 1126 | end | |
| 1127 | ||
| 1128 | surface.SetMaterial( FC_HUD.White ) | |
| 1129 | local tab = CreateBorderedCircle(30, y - mul, 10 + mul, 10 + mul, 100, 0, 20) | |
| 1130 | surface.SetMaterial( FC_HUD.White ) | |
| 1131 | DrawCorrectFuckingPoly(tab) | |
| 1132 | ||
| 1133 | surface.SetDrawColor( col ) | |
| 1134 | ||
| 1135 | surface.SetMaterial( FC_HUD.White ) | |
| 1136 | local tab = CreateBorderedCircle(30, y - mul, 8 + mul, 8 + mul, 100, 0, 20) | |
| 1137 | surface.SetMaterial( FC_HUD.White ) | |
| 1138 | DrawCorrectFuckingPoly(tab) | |
| 1139 | ||
| 1140 | surface.SetFont(font) | |
| 1141 | local w, h = surface.GetTextSize(string.upper(t)) | |
| 1142 | local w2, h2 = surface.GetTextSize(string.upper(text)) | |
| 1143 | local w3 = 0 | |
| 1144 | ||
| 1145 | if text != "" then | |
| 1146 | w3 = surface.GetTextSize(" - ")
| |
| 1147 | end | |
| 1148 | ||
| 1149 | local BoxCol = Color(0,0,0,200) | |
| 1150 | ||
| 1151 | if FC_HUD.ColoredRoleBack and GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR then | |
| 1152 | if LocalPlayer():IsActiveTraitor() then | |
| 1153 | BoxCol = Color(150, 0, 0, 200) | |
| 1154 | elseif LocalPlayer():IsActiveDetective() then | |
| 1155 | BoxCol = Color(0, 0, 150, 200) | |
| 1156 | else | |
| 1157 | BoxCol = Color(0, 150, 0, 200) | |
| 1158 | end | |
| 1159 | end | |
| 1160 | ||
| 1161 | local TextColor = Color(255,255,255,200) | |
| 1162 | ||
| 1163 | if FC_HUD.ColoredRoleText and GetRoundState() == ROUND_ACTIVE and LocalPlayer():Alive() and LocalPlayer():Team() != TEAM_SPECTATOR then | |
| 1164 | if LocalPlayer():IsActiveTraitor() then | |
| 1165 | TextColor = role_string["traitor"] | |
| 1166 | elseif LocalPlayer():IsActiveDetective() then | |
| 1167 | TextColor = role_string["detective"] | |
| 1168 | else | |
| 1169 | TextColor = role_string["innocent"] | |
| 1170 | end | |
| 1171 | end | |
| 1172 | ||
| 1173 | draw.RoundedBox(2, 50 - 2, y-10 - mul * 2, w + 8 + w2 + w3, 20 + mul * 2, BoxCol) | |
| 1174 | local xz, yz = draw.SimpleText(string.upper(t), font, 52, y - mul, TextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) | |
| 1175 | if text != "" then | |
| 1176 | xz = draw.SimpleText(" - ", font, 52 + xz, y - mul, TextColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) + xz
| |
| 1177 | end | |
| 1178 | draw.SimpleText(string.upper(text), font, 52 + xz, y - mul, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) | |
| 1179 | end) | |
| 1180 | end) | |
| 1181 | end |