diff options
Diffstat (limited to 'gamemode/client')
| -rw-r--r-- | gamemode/client/cl_inventory.lua | 166 |
1 files changed, 96 insertions, 70 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua index a032a13..651017d 100644 --- a/gamemode/client/cl_inventory.lua +++ b/gamemode/client/cl_inventory.lua @@ -13,46 +13,46 @@ local buttons = { { - + txt = "Inventory", admin = false, - + }, { - + txt = "Structures", admin = false, - + }, { - + txt = "Combinations", admin = false, - + }, { - + txt = "Equipment", admin = false, - + }, { - + txt = "Props", admin = false, - + }, { - + txt = "Tools", admin = false, - + }, { - + txt = "Admin", admin = true, - + }, @@ -118,9 +118,9 @@ local function createTooltipTextFor(tbl) end local function createPanel() - + local frame = vgui.Create( "InventoryFrame" ) - + return frame end @@ -142,7 +142,7 @@ end local PANEL = {} function PANEL:Init() - + self:SetSize( invxsize, invysize ) self:SetTitle( "Inventory" ) self:MakePopup() @@ -154,31 +154,31 @@ function PANEL:Init() self:Close() end end - + local buttonPanel = vgui.Create("DPanel", self) buttonPanel:SetSize( bPanelWidth, bPanelHeight ) buttonPanel:SetPos( 10, self:GetTall() * 0.1 ) buttonPanel.Paint = function() draw.RoundedBox(12,0,0,buttonPanel:GetWide(),buttonPanel:GetTall(),Color(0, 0, 0, 255)) end - + local displayPanel = vgui.Create("DPanel", self) displayPanel:SetSize( dPanelWidth, dPanelHeight ) displayPanel:SetPos( buttonPanel:GetWide() + 30, self:GetTall() * 0.1 ) if (curDisplay != nil) then dis = vgui.Create(curDisplay,displayPanel) dis:SetSize(dPanelWidth,dPanelHeight) - else + else dis = vgui.Create(buttons[1]['txt'], displayPanel) dis:SetSize(dPanelWidth,dPanelHeight) end displayPanel.Paint = function() - + draw.RoundedBox( 0, 0, 0, displayPanel:GetWide(), displayPanel:GetTall(), Color( 255, 255, 255 ) ) end - + titlePanelWidth = 50 - + local titlePanel = vgui.Create("DPanel", buttonPanel) titlePanel:SetSize(buttonPanel:GetWide(),titlePanelWidth) titlePanel:SetPos( 0,0 ) @@ -189,11 +189,11 @@ function PANEL:Init() surface.SetTextPos( (titlePanel:GetWide()/2) - ( surface.GetTextSize(gmod.GetGamemode().Name)/2 ), (titlePanel:GetTall()/2) - (select( 2, surface.GetTextSize( gmod.GetGamemode().Name ) )/2) ) surface.DrawText( gmod.GetGamemode().Name ) end - + for k,v in pairs(buttons) do - + if (v['admin'] and !LocalPlayer():IsAdmin()) then break end - + local btn = vgui.Create("DButton", buttonPanel) btn:SetText("") btn:SetSize( buttonPanel:GetWide(), 44 ) @@ -206,18 +206,18 @@ function PANEL:Init() surface.DrawText( v['txt'] ) end btn.DoClick = function() - + displayPanel:Clear() local d = vgui.Create( v['txt'], displayPanel ) d:SetSize( dPanelWidth, dPanelHeight ) curDisplay = v['txt'] - + end - + end - - + + end function PANEL:Paint() @@ -231,7 +231,7 @@ vgui.Register( "InventoryFrame", PANEL, "DFrame" ) local PANEL = {} function PANEL:Init() - + local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) @@ -241,30 +241,30 @@ function PANEL:Init() local row = 0 i = 0 for k,v in SortedPairs(Resources) do - + if (v == 0) then continue end - + local slot = vgui.Create("DButton", dpnl) slot:SetSize(dPanelWidth/5, 100) slot:SetText("") - + slot.Paint = function() - + draw.RoundedBox( 0, 1, 1, slot:GetWide()-2, slot:GetTall()-2, Color( 250, 250, 250, 250 ) ) draw.RoundedBox( 8, 4, 4, slot:GetWide()-8, slot:GetTall()-8, Color( 0, 0, 0, 250 ) ) - - + + surface.SetFont( "ButtonText" ) surface.SetTextColor( 255,255,255 ) surface.SetTextPos( (slot:GetWide()/2) - ( surface.GetTextSize("x"..v)/2 ), (slot:GetTall()/2) + select( 2, surface.GetTextSize( "x"..v ) ) - 5 ) surface.DrawText( "x"..v ) - + end - + local img = vgui.Create("DImage", slot) img:SetPos(0, 0) img:SetSize(slot:GetWide(), slot:GetTall()) - + if(GMS.Resources[k] == nil) then --This resource is not registered! img:SetImage("vgui/avatar_default") print("Resource:" .. k .. " not registed! This might be a bug!") @@ -277,16 +277,16 @@ function PANEL:Init() img:SetImage(GMS.Resources[k].Icon) slot:SetTooltip(k.."\n"..GMS.Resources[k].Description) end - - + + slot.DoClick = function() local menu = vgui.Create("DMenu") createMenuFor(menu,GMS.Resources[k].Actions) menu:Open() - + end - - + + if (i % 5 != 0 ) then slot:SetPos(row*dPanelWidth/5, (col-1)*100 + 25) row=row+1 @@ -296,11 +296,11 @@ function PANEL:Init() slot:SetPos(row*dPanelWidth/5, (col-1)*100 + 25) row=row+1 end - + i=i+1 - + end - + end @@ -313,9 +313,9 @@ function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) draw.RoundedBox(0,0,0,self:GetWide(),25,Color(0,0,0,250)) - + draw.SimpleText( "Total: " .. resAmount .. "/" .. 25 + ( GetSkill( "Survival" ) * 5 ), "ButtonText", 0, 0, Color(255,255,255) ) - + end vgui.Register( "Inventory", PANEL, "DPanel" ) @@ -336,11 +336,11 @@ function PANEL:Init() local row = 0 i = 0 for k,v in SortedPairs(GMS.Combinations["Structures"]) do - + local slot = vgui.Create("DButton", dpnl) slot:SetSize(dPanelWidth/5, 100) slot:SetText("") - + local modelPanel = vgui.Create( "DModelPanel", slot ) modelPanel:SetFont("StructureText") modelPanel:SetText(v.Name) @@ -351,7 +351,7 @@ function PANEL:Init() modelPanel.DoClick = function() LocalPlayer():ConCommand("gms_MakeCombination Structures " .. k ) end - + if (i % 5 != 0 ) then slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 @@ -387,7 +387,7 @@ function PANEL:Init() local row = 0 i = 0 for k,v in SortedPairs(GMS.Combinations["Combinations"]) do - + local slot = vgui.Create("DButton", dpnl) slot:SetSize(dPanelWidth/5, 100) slot:SetTooltip(createTooltipTextFor(v.Req)) @@ -395,7 +395,7 @@ function PANEL:Init() --print("I want to combine a " .. v.Name) LocalPlayer():ConCommand("gms_MakeCombination Combinations " .. v.Name) end - + if (i % 5 != 0 ) then slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 @@ -405,23 +405,23 @@ function PANEL:Init() slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 end - + slot.Paint = function() draw.RoundedBox( 0, 1, 1, slot:GetWide()-2, slot:GetTall()-2, Color( 250, 250, 250, 250 ) ) draw.RoundedBox( 8, 4, 4, slot:GetWide()-8, slot:GetTall()-8, Color( 0, 0, 0, 250 ) ) - + surface.SetFont( "ButtonText" ) surface.SetTextColor( 255,255,255 ) surface.SetTextPos( (slot:GetWide()/2) - ( surface.GetTextSize(k)/2 ), (slot:GetTall()/2) + (select( 2, surface.GetTextSize( k ) )/2) ) surface.DrawText( v.Name ) end - + local img = vgui.Create("DImage", slot) img:SetPos(0, 0) img:SetSize(slot:GetWide(), slot:GetTall()-20) img:SetImage("gms_icons/gms_weapon.png") - - + + i=i+1 end @@ -454,10 +454,10 @@ local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) - + dpnl:SetSize( 540, 400 ) dpnl:SetPos( 0, 0 ) - + local layout = vgui.Create( "DListLayout", dpnl) layout:SetSize(dpnl:GetWide(), dpnl:GetTall()) @@ -503,17 +503,43 @@ vgui.Register( "Props", PANEL, "DPanel" ) local PANEL = {} function PANEL:Init() - - self.Tools = vgui.Create( "DPanelList", self ) - self.Tools:EnableVerticalScrollbar( true ) + self.ActiveTool = "Weld" + self.Tools = vgui.Create( "DListLayout", self ) + --self.Tools:EnableVerticalScrollbar( true ) self.Tools:SetSize(dPanelWidth/3, dPanelWidth) - self.Tools:SetSpacing( 5 ) - self.Tools:SetPadding( 5 ) + --self.Tools:SetSpacing( 5 ) + --self.Tools:SetPadding( 5 ) function self.Tools:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end - - PrintTable(spawnmenu.GetTools()) + + self.ControlPanel = vgui.Create("DForm",self) + self.ControlPanel:SetSize((dPanelWidth/3)*2,dPanelWidth) + self.ControlPanel:SetPos(dPanelWidth/3,0) + local g = controlpanel.Get("Weld") + print(g) + self.ControlPanel:AddItem(g) + + for k,v in pairs(spawnmenu.GetTools()[1]["Items"]) do + for i,j in pairs(v) do + if(istable(j)) then + local isprohibitied = false + for k,l in pairs(GMS.ProhibitedStools) do + if(j.ItemName == l) then + isprohibitied = true + end + end + if(!isprohibitied) then + local button = vgui.Create("DButton",self.Tools) + button:SetText(j.Text) + --self.Tools:Add + print("adding " .. j.Text) + end + end + end + end + + --PrintTable(spawnmenu.GetTools()[1]["Items"][1]) end |
