diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-05-20 13:15:45 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-05-20 13:15:45 -0400 |
| commit | 0ae33ad32868af226fba6d887320aa87aa19d3a4 (patch) | |
| tree | f2cdbfeb5ba5fa8364126a4753cba3b2b6d06a8f /gamemode/inventorysystem | |
| parent | c6698dad925e75ffd2ca2f2e30a595d4ce48d240 (diff) | |
| download | artery-0ae33ad32868af226fba6d887320aa87aa19d3a4.tar.gz artery-0ae33ad32868af226fba6d887320aa87aa19d3a4.tar.bz2 artery-0ae33ad32868af226fba6d887320aa87aa19d3a4.zip | |
Fixed models drawing in inventory
Diffstat (limited to 'gamemode/inventorysystem')
| -rw-r--r-- | gamemode/inventorysystem/equipment/cl_equipment.lua | 10 | ||||
| -rw-r--r-- | gamemode/inventorysystem/shapedinventory/cl_shaped.lua | 59 |
2 files changed, 17 insertions, 52 deletions
diff --git a/gamemode/inventorysystem/equipment/cl_equipment.lua b/gamemode/inventorysystem/equipment/cl_equipment.lua index 82560be..74152dc 100644 --- a/gamemode/inventorysystem/equipment/cl_equipment.lua +++ b/gamemode/inventorysystem/equipment/cl_equipment.lua @@ -124,12 +124,12 @@ inv.DrawOnDPanel = function(self,panel) end print("Found something equiped in ", k) if self.equiped[k].OnEqpPaint then - pn.Paint = self.equiped[k].OnEqpPaint + pn.PaintOver = self.equiped[k].OnEqpPaint end else --We don't have something equiped! if v.img and v.img.material then local c = col.ui.border - pn.Paint = function(tp,w,h) + pn.PaintOver = function(tp,w,h) surface.SetDrawColor(c.r,c.g,c.b) surface.DrawOutlinedRect(0, 0, w, h) surface.SetDrawColor(255,255,255) @@ -155,9 +155,9 @@ inv.DrawOnDPanel = function(self,panel) end end if item.OnEqpPaint then - self[position[1]].Paint = item.OnEqpPaint + self[position[1]].PaintOver = item.OnEqpPaint else - self[position[1]].Paint = function(panel) + self[position[1]].PaintOver = function(panel) draw.DrawText( item.Name, "DermaDefault", 10, 10, Color( 0, 0, 0, 0 )) end end @@ -170,7 +170,7 @@ inv.DrawOnDPanel = function(self,panel) local pn = self[position[1]] pn.DoClick = function() end local c = col.ui.border - pn.Paint = function(self,w,h) + pn.PaintOver = function(self,w,h) surface.SetDrawColor(c.r,c.g,c.b) surface.DrawOutlinedRect(0, 0, w, h) surface.SetDrawColor(255,255,255) 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"}) |
