diff options
Diffstat (limited to 'gamemode/inventorysystem/equipment/cl_equipment.lua')
| -rw-r--r-- | gamemode/inventorysystem/equipment/cl_equipment.lua | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/gamemode/inventorysystem/equipment/cl_equipment.lua b/gamemode/inventorysystem/equipment/cl_equipment.lua index 5ffcccc..7abd27a 100644 --- a/gamemode/inventorysystem/equipment/cl_equipment.lua +++ b/gamemode/inventorysystem/equipment/cl_equipment.lua @@ -1,6 +1,7 @@ local col = nrequire("colortheme.lua") local svg = nrequire("cl_svg.lua") +local com = nrequire("cl_common.lua") local inv = {} local width, height = (ScrW() / 4) - 25, ScrH() @@ -98,20 +99,37 @@ local eqp = { } inv.DrawOnDPanel = function(self,panel) + print("Drawing equipment on panel") local prox = {} for k,v in pairs(eqp) do - local pn = vgui.Create("DImage",panel) + local pn = vgui.Create("DButton",panel) pn:SetSize(iconsize,iconsize) pn:SetPos(v.x,v.y) - if self.equiped[k] then - if self.equiped[k].OnPaint then - pn.Paint = self.equiped[k].OnPaint + pn.info = {} + pn.info.owner = LocalPlayer() + pn.info.id = self.id + pn.info.pos = {k} + pn.info.inv = self + pn:Droppable("item") + pn:Receiver("item",com.generatereceiver(),{"one","two","three"}) + if self.equiped[k] then --We have something equiped! + if self.equiped[k].GetOptions then + pn.DoClick = function() + local dm = DermaMenu() + com.CreateMenuFor(dm,self.equiped[k].GetOptions()) + dm:Open() + end + end + print("Found something equiped in ", k) + if self.equiped[k].OnEqpPaint then + pn.Paint = self.equiped[k].OnEqpPaint else pn.Paint = function(tp,w,h) draw.RoundedBox( 8, 0, 0, w, h, Color( 255, 0, 0 ) ) end end - else + else --We don't have something equiped! + print("Nothing was equiped in ", k) if v.img and v.img.material then local c = col.ui.border pn.Paint = function(tp,w,h) @@ -129,12 +147,42 @@ inv.DrawOnDPanel = function(self,panel) end prox[k] = pn end - prox.Put = function(position,item) - print("Put was called!") + prox.Put = function(self,position,item) + print("Put was called!",position,item) + PrintTable(position) + PrintTable(item) + assert(self[position[1]] ~= nil, "Tried to put an item into an unknown slot!") + if item.GetOptions then + self[position[1]].DoClick = function() + local dm = DermaMenu() + com.CreateMenuFor(dm,item.GetOptions()) + dm:Open() + end + end + if item.OnEqpPaint then + self[position[1]].Paint = item.OnEqpPaint + else + self[position[1]].Paint = function(tp,w,h) + draw.RoundedBox( 8, 0, 0, w, h, Color( 255, 0, 0 ) ) + end + end + self[position[1]]:Droppable("item") end - prox.Remove = function(position) - print("Remove was called!") + prox.Remove = function(self,position) + local pn = self[position[1]] + pn.DoClick = function() end + local c = col.ui.border + pn.Paint = function(self,w,h) + surface.SetDrawColor(c.r,c.g,c.b) + surface.DrawOutlinedRect(0, 0, w, h) + surface.SetDrawColor(255,255,255) + surface.SetMaterial( eqp[position[1]].img.material ) + surface.DrawTexturedRect( 0, 0, w, h ) + end + print("Remove was called!",position) + pn:Droppable("none") end + return prox end return inv |
