summaryrefslogtreecommitdiff
path: root/gamemode/client/cl_inventory.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/client/cl_inventory.lua')
-rw-r--r--gamemode/client/cl_inventory.lua149
1 files changed, 139 insertions, 10 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
index 8f8969a..057410f 100644
--- a/gamemode/client/cl_inventory.lua
+++ b/gamemode/client/cl_inventory.lua
@@ -1,3 +1,5 @@
+local invpanel = nil
+
local invxsize = 800
local invysize = 500
@@ -46,7 +48,7 @@ local buttons = {
txt = "Admin",
admin = true,
},
-
+
}
surface.CreateFont( "gmNameFont", {
@@ -178,7 +180,7 @@ 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
-
+
kk = 1
for k,v in pairs(buttons) do
@@ -327,6 +329,17 @@ function PANEL:Init()
i = 0
for k,v in SortedPairs(GMS.Combinations["Structures"]) do
+ local cancraft = true
+ for i,j in pairs(v.Req) do
+ if Resources[i] == nil then
+ cancraft = false
+ break
+ elseif(Resources[i] < j) then
+ cancraft = false
+ break
+ end
+ end
+
local slot = vgui.Create("DButton", dpnl)
slot:SetSize(dPanelWidth/5, 100)
slot:SetText("")
@@ -341,6 +354,14 @@ function PANEL:Init()
modelPanel.DoClick = function()
LocalPlayer():ConCommand("gms_MakeCombination Structures " .. k )
end
+ if(!cancraft) then
+ print("I don't have the resources to build a ")
+ PrintTable(v)
+ modelPanel:SetColor(Color(255,0,0))
+ else
+ print("I have the resource to build a ")
+ PrintTable(v)
+ end
if (i % 5 != 0 ) then
slot:SetPos(row*dPanelWidth/5, (col-1)*100)
@@ -443,7 +464,115 @@ vgui.Register( "Combinations", PANEL, "DPanel" )
local PANEL = {}
function PANEL:Init()
+ ASlot = {
+
+ "NONE", "Helmet", "NONE",
+ "WEAPON", "Chestplate", "SHIELD",
+ "NONE", "Platelegs", "NONE",
+ "NONE", "Boots", "NONE"
+
+ }
+ self.slotWidth = 64
+ self.slotHeight = 64
+ local armorPnl = vgui.Create("DPanel",self)
+ armorPnl:SetPos(2,2)
+ armorPnl:SetSize(dPanelWidth/2-4,dPanelHeight-4)
+ armorPnl:SetBackgroundColor(Color(49,49,49))
+ local infoPnl = vgui.Create("DPanel",self)
+ infoPnl:SetPos(dPanelWidth/2+2,2)
+ infoPnl:SetSize(dPanelWidth/2-4,dPanelHeight-4)
+ infoPnl.Item = "NAME - "
+ infoPnl.Type = "TYPE - "
+ infoPnl.Description = "DESCRIPTION - \n"
+ infoPnl.Text = infoPnl.Item.."\n\n"..infoPnl.Type.."\n\n"..infoPnl.Description.."\n\n"
+ local grid = self:ArmorGrid()
+ grid:SetParent( armorPnl )
+
+
+ for i=1,12 do
+
+ local slot = vgui.Create("DButton",self)
+ slot:SetSize(self.slotWidth,self.slotHeight)
+
+ slot.Type = ASlot[i]
+
+ slot:SetText("")
+
+ local img = vgui.Create("DImage", slot)
+ img:SetPos(0, 0)
+ img:SetSize(slot:GetWide(), slot:GetTall())
+
+ slot.Paint = function()
+ if slot.Type == "NONE" then return end
+ draw.RoundedBox(0,0,0,slot:GetWide(),slot:GetTall(),Color(95,95,95))
+
+ end
+
+ slot.Think = function()
+ if GMS.Equipped == nil then return end
+
+ for k,v in pairs(GMS.Equipped) do
+ if slot.Type == nil then return end
+ if slot.Type == v['Type'] then
+
+ slot.Item = v['Item']
+ if GMS.Resources[v['Item']] == nil or GMS.Resources[v['Item']].Icon == nil then slot.Icon = "test.png" else slot.Icon = GMS.Resources[v['Item']].Icon end
+ slot.Description = v['Description']
+ img:SetImage(slot.Icon)
+
+ end
+ end
+
+ end
+
+ slot.DoClick = function()
+ if slot.Type == "NONE" or slot.Item == nil then return end
+
+ local menu = DermaMenu()
+
+ menu:AddOption( "Examine", function()
+ if not invpanel:IsValid() then return end
+ infoPnl.Item = "NAME - "..slot.Item
+ infoPnl.Type = "TYPE - "..slot.Type
+ infoPnl.Description = "DESCRIPTION - \n\n"..slot.Description
+ infoPnl.Text = infoPnl.Item.."\n\n"..infoPnl.Type.."\n\n"..infoPnl.Description
+
+ end)
+ menu:AddOption( "Unequip", function()
+ if not invpanel:IsValid() then return end
+ net.Start('giveRes')
+ net.WriteEntity(LocalPlayer())
+ net.WriteString(slot.Item)
+ net.WriteInt(1,32)
+ net.SendToServer()
+ for k,v in pairs(GMS.Equipped) do
+ if v['Type'] == slot.Type then table.remove(GMS.Equipped,k) end
+ end
+ end)
+
+ menu:Open()
+
+ end
+
+ grid:AddItem(slot)
+ end
+
+ infoPnl.Paint = function()
+ draw.RoundedBox(0,0,0,infoPnl:GetWide(),infoPnl:GetTall(),Color(99,99,99))
+ draw.DrawText( infoPnl.Text, "TargetID", 10, 10, Color(255,255,255) )
+ end
+
+end
+function PANEL:ArmorGrid()
+
+ self.Grid = vgui.Create("DGrid")
+ self.Grid:SetPos(self.slotWidth/2-4,20)
+ self.Grid:SetColWide(self.slotWidth+10)
+ self.Grid:SetCols(3)
+ self.Grid:SetRowHeight(self.slotHeight+10)
+ return self.Grid
+
end
function PANEL:Paint()
@@ -509,10 +638,10 @@ local PANEL = {}
function PANEL:Init()
self.ActiveTool = "Weld"
-
+
self.pnl = vgui.Create("DPanel", self)
self.pnl:SetSize(dPanelWidth/3, dPanelHeight)
-
+
self.Tools = vgui.Create( "DListLayout", self.pnl )
self.Tools:SetPos(8,8)
self.Tools:SetSize(self.pnl:GetWide()-16, self:GetTall()-16)
@@ -713,9 +842,9 @@ function PANEL:EnableControlPanel( button )
LocalPlayer():ConCommand( button.Command )
end
]]
-
-
-
+
+
+
end
function PANEL:Paint()
@@ -1192,7 +1321,7 @@ vgui.Register( "Admin", PANEL, "DPanel" )
local PANEL = {}
function PANEL:Init()
-
+
local dpnl = vgui.Create( "DScrollPanel", self )
dpnl:SetSize( dPanelWidth, dPanelHeight )
dpnl:SetPos( 0, 0 )
@@ -1245,9 +1374,9 @@ end
vgui.Register( "Tribes", PANEL, "DPanel" )
//Bind it to open on q
-local invpanel = nil
-function GM:OnSpawnMenuOpen()
+function GM:OnSpawnMenuOpen()
+ if(not LocalPlayer():Alive()) then return end
if(invpanel == nil) then
invpanel = createPanel()
return