1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
--[[
One of the tabs in the inventory
]]
local inv = nrequire("inventory/inventory.lua")
local itm = nrequire("item.lua")
local q = {}
local known_inventories = {}
local inventory_frames = {}
net.Receive("art_ObserveInventory",function()
local id = net.ReadUInt(32)
local inv_type = net.ReadString()
print("Got inv type", inv_type,"id",id)
local inital_data = net.ReadData(net.ReadUInt(32))
known_inventories[id] = inv.CreateInventoryFromData(inv_type,initaldata)
end)
net.Receive("art_UpdateInventory",function()
local id = net.ReadUInt(32)
local isput = net.ReadBool()
local position = net.ReadTable()
if isput then
local item_name = net.ReadString()
local item_data = net.ReadData(net.ReadUInt(32))
local item = itm.GetItemFromData(item_name,item_data)
known_inventories[id]:Put(position,item)
else
known_inventories[id]:Remove(position)
end
end)
net.Receive("art_CloseInventory",function()
local id = net.ReadUInt(32)
known_inventories[id] = nil
if inventory_frames[id] then
inventory_frames[id]:Close()
inventory_frames[id] = nil
end
end)
local width,height = (ScrW() / 4) - 10, ScrH()
local iconsize = width / 5
q.CreateInventorySheet = function(dpanel_parent)
--assert(known_inventories[watch_id] ~= nil,"Attempted to watch an inventory that dosn't exist!")
--Display the equipment inventories
local invsheet = vgui.Create( "DPropertySheet", dpanel_parent )
invsheet:Dock( FILL )
for k,v in pairs(known_inventories) do
local tpanel = vgui.Create( "DPanel", invsheet )
tpanel.Paint = function( self, w, h )
draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 128, 255 ) )
end
if v.DrawOnDPanel then
local prox = v:DrawOnDPanel(tpanel)
known_inventories[k]:AddObserver(prox)
end
invsheet:AddSheet( v.Name, tpanel, "icon16/tab.png" )
end
return invsheet
end
return q
|