mirror of
https://github.com/willox/gmod-keypad.git
synced 2025-03-04 03:13:31 -05:00
good night for 4eal
This commit is contained in:
parent
8dd0cd5f72
commit
fb2a285fee
@ -1,5 +1,7 @@
|
||||
include "sh_init.lua"
|
||||
|
||||
local debug = CreateConVar("keypad_debug", "0")
|
||||
|
||||
local mat = CreateMaterial("keypad_aaaaaaaaaaaaaaaaaaaaabaaaaaaaaaasaae", "VertexLitGeneric", {
|
||||
["$basetexture"] = "white",
|
||||
["$color"] = "{ 42 42 42 }",
|
||||
@ -21,6 +23,7 @@ function ENT:Draw()
|
||||
|
||||
pos:Add(self:GetForward() * 0.01) -- Pop out of front to stop culling
|
||||
pos:Add(self:GetRight() * -0.03) -- Left margin
|
||||
pos:Add(self:GetUp() * -0.03) -- Top margin
|
||||
|
||||
local ang = self:GetAngles()
|
||||
ang:RotateAroundAxis(ang:Right(), -90)
|
||||
@ -28,14 +31,29 @@ function ENT:Draw()
|
||||
|
||||
local w, h = 130, 230 -- :(
|
||||
|
||||
--print(util.IntersectRayWithPlane(EyePos(), LocalPlayer():GetAimVector(), pos, ang:Forward()))
|
||||
local ply = LocalPlayer()
|
||||
|
||||
if not IsValid(ply) then
|
||||
return
|
||||
end
|
||||
|
||||
local intersect = util.IntersectRayWithPlane(ply:EyePos(), ply:GetAimVector(), pos, (ply:EyePos() - pos):GetNormal())
|
||||
print(intersect)
|
||||
|
||||
cam.Start3D2D(pos, ang, 0.05)
|
||||
self:Paint(w, h)
|
||||
self:Paint(w, h, intersect.x, intersect.y)
|
||||
cam.End3D2D()
|
||||
|
||||
if debug:GetBool() then
|
||||
render.SetBlend(0.05)
|
||||
cam.IgnoreZ(true)
|
||||
self:DrawModel()
|
||||
cam.IgnoreZ(false)
|
||||
render.SetBlend(1)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Paint(w, h, mousex, mousey)
|
||||
surface.SetDrawColor(Color(255, 0, 0, 20))
|
||||
surface.DrawRect(4, 4, w - 8, h - 8)
|
||||
function ENT:Paint(w, h, x, y)
|
||||
surface.SetDrawColor(Color(255, 255, 255, 10))
|
||||
surface.DrawRect(0, 0, w, h * 0.2)
|
||||
end
|
Loading…
Reference in New Issue
Block a user