diff options
Diffstat (limited to 'gamemode/inventorysystem/shapedinventory/cl_shaped.lua')
| -rw-r--r-- | gamemode/inventorysystem/shapedinventory/cl_shaped.lua | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/gamemode/inventorysystem/shapedinventory/cl_shaped.lua b/gamemode/inventorysystem/shapedinventory/cl_shaped.lua index 83c2217..051f0bc 100644 --- a/gamemode/inventorysystem/shapedinventory/cl_shaped.lua +++ b/gamemode/inventorysystem/shapedinventory/cl_shaped.lua @@ -8,12 +8,15 @@ local width = ScrW() --local height = ScrH() local iconsize = ((width / 4) - 20) / 5 + local function default_paint(self,w,h) --Draw a box surface.SetDrawColor(col.ui.border) - surface.DrawOutlinedRect( 0, 0, w, h ) + surface.DrawOutlinedRect( 0, 0, w, h ) + --xpcall(self.DrawModel,function() end,self) end + --[[ local function calcposition(dimx,dimy,x,y) return (y * dimx) + x @@ -64,10 +67,11 @@ local function drawitemat(self,x,y,item) end end if item.DoOnPanel then + print("Calling cl_shaped's DoOnPanel") item:DoOnPanel(tp) end if item.Paint then - tp.Paint = item.Paint + tp.PaintOver = item.Paint end end @@ -77,58 +81,18 @@ local function undrawitemat(self,x,y) local dpn = self.gridpanels[x][y] dpn:Droppable("") dpn:SetText("") + if dpn:GetModel() then + dpn.Entity:Remove() + end for k,v in pairs(dpn:GetChildren()) do v:Remove() end runonshape(self,item.Shape,x,y,function(panel) panel:SetVisible(true) panel:SetSize(iconsize,iconsize) - panel.Paint = default_paint + panel.PaintOver = default_paint panel.DoClick = function() end end) end ---[[ -local function generatereceiver(tinv,x,y) - return function(self,panels,dropped,index,cx,cy) - if dropped then - local froment,toent = panels[1].info.owner,self.info.owner - local fromid,toid = panels[1].info.id,self.info.id - local frompos,topos = panels[1].info.pos,self.info.pos - local frominv,toinv = panels[1].info.inv,self.info.inv - print("Something was dropped on:",x,y) - PrintTable(panels) - print("froment:",froment) - print("toent:",toent) - print("fromid",fromid) - print("toid",toid) - print("frompos:",frompos) - PrintTable(panels[1].info.pos) - print("topos:",topos) - PrintTable(self.info.pos) - print("frominv",frominv) - print("toinv",toinv) - local item = frominv:Get(frompos) - print("item was", item) - --Fake remove the item, in case the position we want to move it to overlaps with where it is now. - frominv:Remove(frompos) - local cf = toinv:CanFitIn(topos,item) - frominv:Put(frompos,item) - print("canfit was:",cf) - if cf == true then - --Send the request - net.Start("art_RequestInvMove") - net.WriteEntity(froment) - net.WriteEntity(toent) - net.WriteUInt(fromid,32) - net.WriteUInt(toid,32) - net.WriteTable(frompos) - net.WriteTable(topos) - net.SendToServer() - end - end - end -end -]] - inv.DrawOnDPanel = function(self,panel) local DScrollPanel = vgui.Create( "DScrollPanel",panel) DScrollPanel:SetPos( 0, 0 ) @@ -147,8 +111,9 @@ inv.DrawOnDPanel = function(self,panel) for x = 1, self.dimx do for y = 1, self.dimy do local dp = vgui.Create("DModelPanel") + function dp:LayoutEntity( Entity ) return end -- disables default rotation dp:SetSize(iconsize,iconsize) - dp.Paint = default_paint + dp.PaintOver = default_paint dp:SetText("") --dp:Droppable("item") dp:Receiver("item",com.generatereceiver(),{"one","two","three"}) |
