aboutsummaryrefslogtreecommitdiff
path: root/gamemode/ents/art_chest/cl_art_chest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/ents/art_chest/cl_art_chest.lua')
-rw-r--r--gamemode/ents/art_chest/cl_art_chest.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/gamemode/ents/art_chest/cl_art_chest.lua b/gamemode/ents/art_chest/cl_art_chest.lua
new file mode 100644
index 0000000..6800810
--- /dev/null
+++ b/gamemode/ents/art_chest/cl_art_chest.lua
@@ -0,0 +1,64 @@
+local ENT = nrequire("sh_art_chest.lua")
+--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
+local invfuncs = nrequire("inventory/inventory.lua")
+
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+function ENT:Initialize()
+end
+
+function ENT:OnRemove()
+end
+
+function ENT:Think()
+end
+
+function ENT:Draw()
+
+ self:DrawModel()
+end
+
+local oldpanel = nil
+local namecache = {}
+
+net.Receive("openchestinv",function(len,ply)
+ if oldpanel ~= nil then oldpanel:Remove() end
+ local what = net.ReadEntity()
+ local chest = invfuncs.DeSerializeBackpack()
+ ShowInventory()
+ local dat = {}
+ dat.redraw = function()
+ net.Start("requestchestinv")
+ net.WriteEntity(what)
+ net.SendToServer()
+ end
+ dat.panel = vgui.Create( "DFrame" )
+ oldpanel = dat.panel
+ dat.panel.OnClose = function()
+ net.Start("closechestinv")
+ net.WriteEntity(what)
+ net.SendToServer()
+ end
+ table.insert(LocalPlayer().invdisplays,dat)
+ local width = ScrW()
+ local height = ScrH()
+ local invpanel = dat.panel
+ invpanel:SetPos( width - (width / 4), 0 )
+ invpanel:SetSize( width / 4, height )
+ if namecache[what] == nil then
+ net.Start("requestchestname")
+ net.WriteEntity(what)
+ net.SendToServer()
+ invpanel:SetTitle( "Chest" )
+ else
+ invpanel:SetTitle(namecache[what])
+ end
+ invpanel:SetDraggable( true )
+ invpanel:MakePopup()
+ local innerpanel = vgui.Create("DPanel",dat.panel)
+ innerpanel:Dock(FILL)
+ innerpanel.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end
+ invfuncs.DrawBackpackOnDPanel(innerpanel, chest, 1, what)
+end)
+
+scripted_ents.Register(ENT, "art_chest")