Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #128 #129

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions lua/autorun/photon/cl_photon_hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ Photon.AddCustomHUDIcon = function(name, data)

PhotonHUD.Icons[name] = data
PhotonHUD:BuildCode()
PhotonHUD:Init()

if IsValid(PhotonHUD.Panel) then
PhotonHUD:Init()
end
end

function PhotonHUD:BuildCode()
Expand Down Expand Up @@ -302,7 +305,6 @@ function PhotonHUD:Init()
if IsValid(self.Panel) then self.Panel:Remove() end

self.Panel = vgui.Create( "DHTML" )
if not self.Panel then timer.Simple(3, function() self:Init() end) return end
self.Panel:SetPaintedManually(true)
self.Panel:SetSize(512, 512)
self.Panel:SetMouseInputEnabled(false)
Expand Down Expand Up @@ -566,28 +568,32 @@ local function PhotonHtml()
PhotonHUD:AutoUpdate()

if not PhotonHUD.ShouldDraw then return end
if drawTexture != false then
local opacity = 255 * HUD_OPACITY:GetFloat()
setDrawColor(255, 255, 255, opacity)
setMaterial(drawTexture)
if not drawTexture then return end

local wOffset = CV_WIDTH:GetInt()
if wOffset < 0 then wOffset = 0 end
local opacity = 255 * HUD_OPACITY:GetFloat()
setDrawColor(255, 255, 255, opacity)
setMaterial(drawTexture)

local hOffset = CV_HEIGHT:GetInt()
if hOffset < 0 then hOffset = 0 end
local wOffset = CV_WIDTH:GetInt()
if wOffset < 0 then wOffset = 0 end

drawTexturedRect(scrW - 512 - wOffset, scrH - 512 - hOffset, 512, 512)
end
end
hook.Add( "HUDPaint", "Photon.NewHUDPaint", function()
PhotonHtml()
end)
local hOffset = CV_HEIGHT:GetInt()
if hOffset < 0 then hOffset = 0 end

if PhotonHUD then PhotonHUD:Init() end
drawTexturedRect(scrW - 512 - wOffset, scrH - 512 - hOffset, 512, 512)
end

hook.Add("HUDPaint", "Photon.NewHUDPaint", PhotonHtml)

if vgui.GetControlTable("DHTML") then
PhotonHUD:Init()
else
hook.Add("InitPostEntity", "PhotonHUD:Init", function()
PhotonHUD:Init()
end)
end

Photon.HUD = PhotonHUD

local radarBase = Material( "photon/ui/radar_base.png" )

Expand Down