diff options
| author | Scott <scotth0828@gmail.com> | 2016-05-30 17:52:20 -0400 |
|---|---|---|
| committer | Scott <scotth0828@gmail.com> | 2016-05-30 17:52:20 -0400 |
| commit | dee21960c708a18785320d8dcabc7322a1f90da7 (patch) | |
| tree | 1e8bc2c5f7b5090023653333b0c33c70f3a5ee7d /gamemode/structuresystem/common.lua | |
| parent | 99ecd9db0c2aca2a37e24ef38374b7d535d43049 (diff) | |
| download | gmstranded-dee21960c708a18785320d8dcabc7322a1f90da7.tar.gz gmstranded-dee21960c708a18785320d8dcabc7322a1f90da7.tar.bz2 gmstranded-dee21960c708a18785320d8dcabc7322a1f90da7.zip | |
v1 of structure menu
Diffstat (limited to 'gamemode/structuresystem/common.lua')
| -rw-r--r-- | gamemode/structuresystem/common.lua | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/gamemode/structuresystem/common.lua b/gamemode/structuresystem/common.lua index 1c174d0..2eb2233 100644 --- a/gamemode/structuresystem/common.lua +++ b/gamemode/structuresystem/common.lua @@ -1,22 +1,28 @@ local buts = 92 +local recipeWidth = buts*4 +local recipeHeight = buts*1.5 local function makeCraftingWindow(name) - local pw = ScrW() / 1.3 - local ph = ScrH() / 1.4 + local pw = 750 + local ph = 500 local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( pw, ph ) DermaPanel:SetTitle( name ) DermaPanel:SetDraggable( true ) DermaPanel:Center() - DermaPanel.Grid = vgui.Create("DGrid",DermaPanel) - DermaPanel.Grid:SetPos(10,30) - DermaPanel.Grid:SetColWide(buts) - DermaPanel.Grid:SetCols(pw / buts) - DermaPanel.Grid:SetRowHeight(buts) - DermaPanel.info = vgui.Create("DPanel",DermaPanel) + DermaPanel.scroll = vgui.Create( "DScrollPanel", DermaPanel ) + DermaPanel.scroll:Dock(FILL) + DermaPanel.scroll:SetPos( 0, 25 ) + DermaPanel.scroll:SetPadding() + DermaPanel.Grid = vgui.Create("DGrid",DermaPanel.scroll) + DermaPanel.Grid:SetPos(0,0) + DermaPanel.Grid:SetColWide(recipeWidth-10) + DermaPanel.Grid:SetCols(pw / recipeWidth) + DermaPanel.Grid:SetRowHeight(recipeHeight-10) + /*DermaPanel.info = vgui.Create("DPanel",DermaPanel) DermaPanel.info:SetPos(10,(buts * 2) + 30) DermaPanel.info:SetSize(pw - 20, buts * 0.75) DermaPanel.info:Dock(BOTTOM) @@ -34,6 +40,7 @@ local function makeCraftingWindow(name) DermaPanel.makebutton:SetPos(10,(buts * 2) + (buts * 0.75) + 30) DermaPanel.makebutton:SetSize(ScrW() / 1.3 - 20, (buts / 4)) DermaPanel.makebutton:SetText("Craft") + DermaPanel.makebutton:SetEnabled(false) DermaPanel.makebutton.DoClick = function() net.Start("makerecipe") net.WriteString(DermaPanel.structname) @@ -42,6 +49,7 @@ local function makeCraftingWindow(name) net.WriteUInt(DermaPanel.recipeMult, GMS.NETINT_BITCOUNT) net.SendToServer() end + */ return DermaPanel end @@ -89,13 +97,17 @@ function genericMakeCrafting(tbl) local DermaPanel = makeCraftingWindow(tbl.Name) for k,v in pairs(tbl.Recipes) do - local testbut = vgui.Create("DImageButton") - testbut:SetText(v.Name) - testbut:SetImage(v.Image) - testbut:SetSize(buts,buts) - testbut.Paint = function(self,w,h) - draw.RoundedBox( 8, 5, 5, w-10, h-10, Color( 0, 0, 0 ) ) - local fillcolor = Color(0,0,200) + local recipeButton = vgui.Create("DButton") + local text = v.Description .. "\nRequires:" + for i,j in pairs(v.Req) do + text = text .. "\n" .. i .. "x" .. j + end + recipeButton.text = text + recipeButton:SetText("") + recipeButton:SetSize(recipeWidth,recipeHeight) + recipeButton.Paint = function(self,w,h) + //draw.RoundedBox( 8, 5, 5, w-10, h-10, Color( 0, 0, 0 ) ) + local fillcolor = Color(255,255,255) if v.haslevelsfor then if v.hasmatsfor then fillcolor = Color(200,200,200) @@ -105,9 +117,13 @@ function genericMakeCrafting(tbl) else fillcolor = Color(200,200,0) end - draw.RoundedBox(8,10,10,w-20,h-20,fillcolor) + draw.RoundedBox(0,10,10,w-20,h-20,Color(255,255,255)) + draw.RoundedBox(0,15,15,110,h-30,fillcolor) + draw.RoundedBox(8,20,20,100,h-40,Color(255,255,255)) + draw.SimpleText( v.Description, "Default", 150, 20, Color(0,0,0) ) + end - testbut.DoClick = function(button) + recipeButton.DoClick = function(button) DermaPanel.structname = tbl.Name DermaPanel.recipeNum = v.genericNum DermaPanel.recipeMult = v.mult @@ -119,7 +135,13 @@ function genericMakeCrafting(tbl) DermaPanel.reqtext:SetText(text) DermaPanel.makebutton:SetEnabled(v.haslevelsfor and v.hasmatsfor) end - DermaPanel.Grid:AddItem(testbut) + + local img = vgui.Create("DImage", recipeButton) + img:SetPos(24, 20) + img:SetSize(buts, buts) + img:SetImage(v.Image) + + DermaPanel.Grid:AddItem(recipeButton) DermaPanel:MakePopup() end /* |
