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")