Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Fix for #31 (#36)
Browse files Browse the repository at this point in the history
Allow the user to disable APG's color overriding.
  • Loading branch information
AvarianKnight authored Mar 2, 2020
1 parent 43b810c commit 70da0df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions lua/apg/cl_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ local function APGBuildGhostPanel()
menu:switch( 170, 20, "Always frozen", "alwaysFrozen" )
menu:switch( 170, 20, "Fading Doors", "fadingDoorGhosting" )
menu:switch( 170, 20, "Ignore Vehicles", "vehAntiGhost" )
menu:switch( 170, 20, "Enable Color", "ghostColorToggle")
local offsets = menu:panelDone()

local Mixer = vgui.Create( "CtrlColor", panel )
Expand Down
32 changes: 18 additions & 14 deletions lua/apg/modules/ghosting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ end
APG._SetColor = APG._SetColor or ENT.SetColor

function ENT:SetColor( color, ... )
if not APG.cfg["ghostColorToggle"].value then return end
local color = color
local r, g, b, a

Expand Down Expand Up @@ -138,24 +139,25 @@ function APG.entGhost( ent, noCollide, enforce )
end

ent.APG_Ghosted = true
if APG.cfg["ghostColorToggle"].value then
timer.Simple(0, function()
if not IsValid( ent ) then return end

timer.Simple(0, function()
if not IsValid( ent ) then return end
if not ent.APG_oldColor then
ent.APG_oldColor = ent:GetColor()

if not ent.APG_oldColor then
ent.APG_oldColor = ent:GetColor()
if not enforce then
if ent.OldColor then ent.APG_oldColor = ent.OldColor end -- For FPP
if ent.__DPPColor then ent.APG_oldColor = ent.__DPPColor end -- For DPP

if not enforce then
if ent.OldColor then ent.APG_oldColor = ent.OldColor end -- For FPP
if ent.__DPPColor then ent.APG_oldColor = ent.__DPPColor end -- For DPP

ent.OldColor = nil
ent.__DPPColor = nil
ent.OldColor = nil
ent.__DPPColor = nil
end
end
end

ent:SetColor( APG.cfg[ "ghostColor" ].value )
end)
ent:SetColor( APG.cfg[ "ghostColor" ].value )
end)
end

ent.APG_oldRenderMode = ent:GetRenderMode()
ent:SetRenderMode( RENDERMODE_TRANSALPHA )
Expand Down Expand Up @@ -192,7 +194,9 @@ function APG.entUnGhost( ent, ply, failmsg )
ent:DrawShadow( true )

ent:SetRenderMode( ent.APG_oldRenderMode or RENDERMODE_NORMAL )
ent:SetColor( ent.APG_oldColor or Color( 255, 255, 255, 255) )
if APG.cfg["ghostColorToggle"].value then
ent:SetColor( ent.APG_oldColor or Color( 255, 255, 255, 255) )
end
ent.APG_oldColor = false

local newCollisionGroup = COLLISION_GROUP_INTERACTIVE
Expand Down
5 changes: 5 additions & 0 deletions lua/apg/sh_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ defaultSettings.cfg = {
desc = "Color set on ghosted props"
},

ghostColorToggle = {
value = true,
desc = "Toggle ghosting color."
},

badEnts = {
value = {
["prop_physics"] = true,
Expand Down

0 comments on commit 70da0df

Please sign in to comment.