Skip to content

Commit

Permalink
Add custom imgui funciton for weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
dhkatz committed Oct 29, 2023
1 parent 9a64da6 commit 142e3ec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion imgui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,23 @@ end
function imgui.ScreenToVector(x, y)
local view = render.GetViewSetup()
local w, h = ScrW(), ScrH()
local fov = view.fovviewmodel
local fov = view.fov
if gState.weapon then
fov = view.fovviewmodel
end

return util.AimVector(view.angles, fov, x, y, w, h)
end

function imgui.Weapon3D2D(weapon, pos, ang, scale, ...)
gState.weapon = weapon
local ret = imgui.Start3D2D(pos, ang, scale, ...)
if not ret then
gState.weapon = nil
end
return ret
end

function imgui.Entity3D2D(ent, lpos, lang, scale, ...)
gState.entity = ent
local ret = imgui.Start3D2D(ent:LocalToWorld(lpos), ent:LocalToWorldAngles(lang), scale, ...)
Expand Down Expand Up @@ -370,6 +382,7 @@ function imgui.End3D2D()
end

gState.entity = nil
gState.weapon = nil
end
end

Expand Down

0 comments on commit 142e3ec

Please sign in to comment.