--[[
	Hack vs Hack: Redux
]]--

require( "datastream" ) -- :(

include( "shared.lua" )

local draw 				= draw
local surface 			= surface
local GetConVarNumber 	= GetConVarNumber
local math 				= math
local Color 			= Color
local table 			= table
local util 				= util

local AllowedElements = {
							"CHudChat",
							"CHudCrosshair",
							"CHudGMod",
							"CHudVoiceStatus",
							"CHudVoiceSelfStatus"
}

function GM:HUDShouldDraw( element )
	return table.HasValue( AllowedElements, element ) or ( element == "CHudWeaponSelection" )
end

surface.CreateFont( "HUDNumber", 36, 700, true, false, "hud_main_hvh" )
surface.CreateFont( "csd", 56, 500, true, false, "hud_icons_hvh_s" )
surface.CreateFont( "csd", 256, 500, true, false, "hud_icons_hvh_b" )

function GetAmmo( ply )
	if ply:GetActiveWeapon() == nil then
		return 0
	end
	
	if ply:Health() <= 0 then return 0 end
	
	if !ValidEntity( ply:GetActiveWeapon() ) then return 0 end
	
	return ply:GetActiveWeapon():Clip1()
end

function GM:HUDPaint()
	local SELF = LocalPlayer()
	local killstreak_count = SELF:GetNetworkedInt( "hvh_killstreak" )
	local ammo = GetAmmo( SELF )
	
	-- Killstreaks --
	draw.SimpleTextOutlined( "Current killstreak: " .. killstreak_count, "hud_main_hvh", 20, ( ScrH() / 2 ) + 35, color_white, 0, 0, 3, Color( 255, 135, 30 ) )
	
	-- Health --
	draw.SimpleTextOutlined( "F", "hud_icons_hvh_s", 11, ( ScrH() - 52 ), color_white, 0, 0, 3, Color( 255, 135, 30 ) )
	draw.RoundedBox( 6, 60, ( ScrH() - 60 ), 276, 45, Color( 255, 135, 30 ) )
	draw.RoundedBox( 6, 64, ( ScrH() - 56 ), 268, 37, color_white )
	surface.SetDrawColor( Color( 255, 135, 30 ) )
	surface.DrawRect( 70, ( ScrH() - 50 ), 256, 25 )
	surface.SetDrawColor( color_white )
	surface.DrawRect( 70, ( ScrH() - 50 ), 256 * ( SELF:Health() / 100 ), 25 )
	
	--draw.SimpleTextOutlined( SELF:Health(), "Trebuchet19", 256 * ( SELF:Health() / 100 ) + 65, ( ScrH() - 47 ), color_white, 3, 0, 3, Color( 255, 135, 30 ) )
	
	-- Ammo --
	--draw.RoundedBox( 24, ScrW() - 100, ScrH() - 50, 150, 100, color_white )
	draw.SimpleTextOutlined( "N", "hud_icons_hvh_s", ScrW() - 40, ( ScrH() - 49 ), color_white, 3, 0, 3, Color( 255, 135, 30 ) )
	draw.SimpleTextOutlined( ammo, "hud_main_hvh", ScrW() - 60, ( ScrH() - 49 ), color_white, 2, 0, 3, Color( 255, 135, 30 ) )
end