zombiesurvival-evolved/gamemodes/zombiesurvival/gamemode/cl_util.lua

65 lines
1.6 KiB
Lua
Raw Normal View History

2014-10-02 08:49:54 +08:00
concommand.Add("printdxinfo", function()
print("DX Level: "..tostring(render.GetDXLevel()))
print("Supports HDR: "..tostring(render.SupportsHDR()))
print("Supports Pixel Shaders 1.4: "..tostring(render.SupportsPixelShaders_1_4()))
print("Supports Pixel Shaders 2.0: "..tostring(render.SupportsPixelShaders_2_0()))
print("Supports Vertex Shaders 2.0: "..tostring(render.SupportsVertexShaders_2_0()))
end)
local function GetViewModelPosition(self, pos, ang)
return pos + ang:Forward() * -256, ang
end
function DontDrawViewModel()
if SWEP then
SWEP.GetViewModelPosition = GetViewModelPosition
end
end
-- Scales the screen based around 1080p but doesn't make things TOO tiny on low resolutions.
function BetterScreenScale()
return math.Clamp(ScrH() / 1080, 0.6, 1)
end
function render.GetLightRGB(pos)
local vec = render.GetLightColor(pos)
return vec.r, vec.g, vec.b
end
function EasyLabel(parent, text, font, textcolor)
local dpanel = vgui.Create("DLabel", parent)
if font then
dpanel:SetFont(font or "DefaultFont")
end
dpanel:SetText(text)
dpanel:SizeToContents()
if textcolor then
dpanel:SetTextColor(textcolor)
end
dpanel:SetKeyboardInputEnabled(false)
dpanel:SetMouseInputEnabled(false)
return dpanel
end
function EasyButton(parent, text, xpadding, ypadding)
local dpanel = vgui.Create("DButton", parent)
if textcolor then
dpanel:SetFGColor(textcolor or color_white)
end
if text then
dpanel:SetText(text)
end
dpanel:SizeToContents()
if xpadding then
dpanel:SetWide(dpanel:GetWide() + xpadding * 2)
end
if ypadding then
dpanel:SetTall(dpanel:GetTall() + ypadding * 2)
end
return dpanel
end