aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/shop.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-11-27 22:02:47 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2016-11-27 22:02:47 -0500
commit2c4329e2b6e19182a441f79a5c3010011f8ae767 (patch)
treee4d8cd88690bed4cfacf2d4df39bdeed97b376f8 /gamemode/shared/shop.lua
parent5f2a8015bd5d2a42e79038bb52f20260d8d97ba0 (diff)
downloadartery-2c4329e2b6e19182a441f79a5c3010011f8ae767.tar.gz
artery-2c4329e2b6e19182a441f79a5c3010011f8ae767.tar.bz2
artery-2c4329e2b6e19182a441f79a5c3010011f8ae767.zip
Vairous updates
Diffstat (limited to 'gamemode/shared/shop.lua')
-rw-r--r--gamemode/shared/shop.lua52
1 files changed, 44 insertions, 8 deletions
diff --git a/gamemode/shared/shop.lua b/gamemode/shared/shop.lua
index b188e7c..c330fb3 100644
--- a/gamemode/shared/shop.lua
+++ b/gamemode/shared/shop.lua
@@ -1,3 +1,13 @@
+--[[
+ Displays shop npc's interfaces
+
+ public functions:
+ (sv)ART.OpenShop(shoptbl, ply) :: nil
+ (sv)ART.CreateShop(npctbl) :: nil
+ net messages:
+ art_openshop
+]]
+
local ivf = include("inventory_common.lua")
ART = ART or {}
@@ -34,10 +44,8 @@ end
if SERVER then return end
local w,h = ScrW(),ScrH()
-function DrawShopItemOnDPanel(dp,item)
+local function DrawShopItemOnDPanel(dp,itemtbl,cost)
--An item is a string, and int cost
- local itemtbl = ART.GetItemByName(item[1])
- local cost = item[2]
local shape = itemtbl.Shape
local twidth,theight = 0,#shape
@@ -50,7 +58,7 @@ function DrawShopItemOnDPanel(dp,item)
backgrid:SetPos( 10, 30 )
backgrid:SetCols( twidth )
backgrid:SetColWide( theight )
- backgrid:Dock(FILL)
+ backgrid:Dock(LEFT)
local shopicon = vgui.Create( "DImageButton", dp )
shopicon:SetSize(slotsize * twidth, slotsize * theight)
@@ -65,7 +73,10 @@ function DrawShopItemOnDPanel(dp,item)
if itemtbl.DoOnPanel then
itemtbl.DoOnPanel(shopicon)
end
- --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end
+ shopicon.Paint = function(self, w, h)
+ surface.SetDrawColor( 0, 0, 0, 255 )
+ surface.DrawOutlinedRect( 0, 0, w, h)
+ end
shopicon.DoClick = function()
print("You cliked me!")
end
@@ -92,16 +103,41 @@ function DrawShopItemOnDPanel(dp,item)
print("Found false spot:",k,i)
local emptyslot = vgui.Create("DPanel", dp)
emptyslot:SetSize(slotsize,slotsize)
- emptyslot:SetPos(slotsize * (i - 1), slotsize * (k - 1))
+ emptyslot:SetPos(slotsize * (i - 1) + 2, slotsize * (k - 1) + 2)
end
end
end
end
-function DrawShopOnDPanel(dp,items)
+local slotsize = math.Round(w / 32)
+
+local function DrawShopOnDPanel(dp,items)
--This gets pretty involved, lets try to not make it a clusterfuck.
- DrawShopItemOnDPanel(dp,items[1])
+ dp.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(100,0,0)) end
+ print("dp",dp)
+ local scrollpanel = vgui.Create( "DScrollPanel",dp )
+ print("scollpanel",scrollpanel)
+ scrollpanel.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,0,100)) end
+ scrollpanel:Dock(FILL)
+ for k,v in pairs(items) do
+ local itemtbl = ART.GetItemByName(v[1])
+ local invpanel = vgui.Create( "DPanel", scollpanel)
+ invpanel.Paint = function(self, w, h)
+ draw.RoundedBox(4, 1,1,w-4,h-4,Color(50,50,50))
+ draw.RoundedBox(4, 2,2,w-5,h-5,Color(100,100,100))
+ end
+ print("invpanel",invpanel)
+ DrawShopItemOnDPanel(invpanel,itemtbl,v[2])
+ scrollpanel:AddItem(invpanel)
+ invpanel:Dock(TOP)
+ local x,_ = invpanel:GetSize()
+ print("item is",v)
+ PrintTable(v)
+ invpanel:SetSize(x,slotsize*(#itemtbl.Shape) + 4)
+ invpanel:Dock(TOP)
+
+ end
end