print("Custom Inventory Loaded") local invxsize = 800 local invysize = 500 local bPanelWidth = invxsize * 0.25 local bPanelHeight = invysize * 0.8 local dPanelWidth = 540 local dPanelHeight = 400 local curDisplay = nil 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, }, } surface.CreateFont( "gmNameFont", { font = "Century", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name size = 21, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "ButtonText", { font = "Century", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name size = 25, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.CreateFont( "StructureText", { font = "Century", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name size = 14, weight = 800, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) local function createTooltipTextFor(tbl) local string = "" for k,v in pairs(tbl) do string = string .. (k .. " x" .. v .. "\n") end return string end local function createPanel() local frame = vgui.Create( "InventoryFrame" ) return frame end local function createMenuFor(menu, tbl) print("Createing actions for:") PrintTable(tbl) for k,v in pairs(tbl) do if(isfunction(v)) then --This is a dead-end, add the menu local thisoption = menu:AddOption(k,v) else --Otherwise it should be a table, recursively call to create local submenu = menu:AddSubMenu(k) createMenuFor(submenu,v) end end end // Frame local PANEL = {} function PANEL:Init() self:SetSize( invxsize, invysize ) self:SetTitle( "Inventory" ) self:MakePopup() self:Center() self:SetKeyboardInputEnabled(true) self:ShowCloseButton(false) self.OnKeyCodePressed = function(self,key) if(key == KEY_Q)then 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 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 ) titlePanel.Paint = function() draw.RoundedBox( 0, 0, 0, titlePanel:GetWide(), titlePanel:GetTall(), Color( 153, 0, 0) ) surface.SetFont( "gmNameFont" ) surface.SetTextColor( 0,0,0 ) 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 ) btn:SetPos( 0, (k-1)*btn:GetTall() + ((k-1)*1) + (titlePanelWidth+10) ) btn.Paint = function() draw.RoundedBox( 0, 0, 0, btn:GetWide(), btn:GetTall(), Color( 0, 0, 102 ) ) surface.SetFont( "ButtonText" ) surface.SetTextColor( 255,255,255 ) surface.SetTextPos( (btn:GetWide()/2) - ( surface.GetTextSize(v['txt'])/2 ), (btn:GetTall()/2) - (select( 2, surface.GetTextSize( v['txt'] ) )/2) ) 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() draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 250 ) ) end vgui.Register( "InventoryFrame", PANEL, "DFrame" ) // Inventory local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) local col = 0 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!") continue elseif(GMS.Resources[k].Icon == nil) then img:SetImage("vgui/avatar_default") print("Resource:" .. k .. " does not have an .Icon field! This might be a bug!") continue else 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 else row=0 col=col+1 slot:SetPos(row*dPanelWidth/5, (col-1)*100 + 25) row=row+1 end i=i+1 end end function PANEL:Paint() resAmount = 0 for k,v in pairs(Resources) do resAmount = resAmount+v end 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" ) // Structures local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) dpnl:SetVerticalScrollbarEnabled(true) local col = 0 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) modelPanel:SetSize( slot:GetWide(), slot:GetTall() ) modelPanel:SetModel( v.BuildSiteModel ) modelPanel:SetCamPos( Vector( 50,50,50 ) ) modelPanel:SetLookAt( Vector( 0, 0, 20 ) ) 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 else row=0 col=col+1 slot:SetPos(row*dPanelWidth/5, (col-1)*100) row=row+1 end i=i+1 end end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Structures", PANEL, "DPanel" ) // Combinations local PANEL = {} function PANEL:Init() local dpnl = vgui.Create( "DScrollPanel", self ) dpnl:SetSize( dPanelWidth, dPanelHeight ) dpnl:SetPos( 0, 0 ) local col = 0 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)) slot.DoClick = function() --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 else row=0 col=col+1 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 end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Combinations", PANEL, "DPanel" ) // Equipment local PANEL = {} function PANEL:Init() end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Equipment", PANEL, "DPanel" ) // Props 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()) local labelnum = 0 for k,v in pairs(GMS_SpawnLists) do local DCollapsible = vgui.Create( "DCollapsibleCategory" ) DCollapsible:SetLabel(k) DCollapsible:SetSize(dpnl:GetWide(),200) DCollapsible:SetPadding(5) --DCollapsible:SetPos(0,labelnum) DCollapsible:SetExpanded( 0 ) layout:Add(DCollapsible) labelnum = labelnum + 20 local propgrid = vgui.Create("DTileLayout", DCollapsible) propgrid:SetBaseSize( 64 ) -- Tile size propgrid:Dock( FILL ) propgrid:MakeDroppable( "unique_name" ) -- Allows us to rearrange children DCollapsible:SetContents(propgrid) for i,j in pairs(v) do local itm = vgui.Create("DModelPanel", propgrid) itm:SetCamPos( Vector( 50,50,50 ) ) itm:SetLookAt( Vector( 0, 0, 20 ) ) itm:SetModel(j) itm:SetSize( 64, 64 ) itm.DoClick = function() RunConsoleCommand( "gm_spawn", j, 0 ) end propgrid:Add(itm) end --layout:Add(combipanel) end end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Props", PANEL, "DPanel" ) // Tools local PANEL = {} function PANEL:Init() 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 ) function self.Tools:Paint() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 75, 75, 75 ) ) end 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 function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Tools", PANEL, "DPanel" ) // Admin local PANEL = {} function PANEL:Init() end function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end vgui.Register( "Admin", PANEL, "DPanel" ) local invpanel = nil function GM:OnSpawnMenuOpen() if(invpanel == nil) then invpanel = createPanel() return end if(! invpanel:IsValid()) then invpanel = createPanel() return end end function GM:ReloadSpawnMenu() if(invpanel == nil) then return end if(!invpanel:IsValid()) then return end if(invpanel != nil) then invpanel:Close() invpanel = createPanel() return end end function GM:OnSpawnMenuClose() end function GM:SpawnMenuEnabled() return false end