-- do return end -- local invfuncs -- invfuncs = ART.invfuncs -- --invfuncs = include("../gamemodes/artery/gamemode/shared/inventory_common.lua") -- --invfuncs = include("../shared/inventory_common.lua") -- assert(invfuncs ~= nil, "Dependency failed") -- -- local function createMenuFor(menu, 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 -- -- local function DrawBackpackOnDPanel(dp, backpack, backpacknum, tent) -- local width = ScrW() -- local height = ScrH() -- local slotsize = math.Round(width / 32) -- local backgrid = vgui.Create( "DGrid", dp ) -- backgrid:SetPos( 10, 30 ) -- backgrid:SetCols( backpack[2][1] ) -- backgrid:SetColWide( backpack[2][2] ) -- backgrid:Dock(FILL) -- for i = 1,#(backpack[1]) do -- for j = 1,#(backpack[1][i]) do -- local item = backpack[1][j][i] -- if type(backpack[1][j][i]) == "table" then -- local itemwidth = 0 -- for _,l in pairs(item.Shape) do -- itemwidth = math.Max(itemwidth,#l) -- end -- local itemheight = #item.Shape -- local invicon = vgui.Create( "DImageButton", dp ) -- invicon:SetSize(slotsize * itemwidth, slotsize * itemheight) -- invicon:SetPos(slotsize * (i - 1), slotsize * (j - 1)) -- invicon:SetText(item.Name) -- if item.Tooltip then -- invicon:SetTooltip(item.Tooltip) -- end -- if item.Paint then -- invicon.Paint = item.Paint -- end -- if item.DoOnPanel then -- item.DoOnPanel(invicon) -- end -- --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end -- invicon.DoClick = function() -- if not item.GetOptions then return end -- local menu = vgui.Create("DMenu") -- createMenuFor(menu,item:GetOptions()) -- menu:Open() -- end -- invicon.Item = item -- invicon.invpos = {j,i} -- invicon.ent = tent -- invicon.backpacknum = backpacknum -- invicon:Droppable("Inventory") -- elseif not backpack[1][j][i] then -- local emptyslot = vgui.Create("DPanel", dp) -- emptyslot:SetSize(slotsize,slotsize) -- emptyslot:SetPos(slotsize * (i - 1), slotsize * (j - 1)) -- --emptyslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,0,100)) end -- emptyslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) -- if not isDropped then return end -- local icon = tableOfDroppedPanels[1] -- local item = icon.Item -- local curpos = icon.invpos -- --Set the shape it was at to false -- if not icon.wasequiped and icon.ent == tent then -- assert(curpos ~= nil, "print curpos was nil when not equiped") -- for k = 1,#item.Shape do -- for l = 1,#(item.Shape[k]) do -- if k == 1 and l == 1 then continue end -- backpack[1][curpos[1] + k - 1][curpos[2] + l - 1] = false -- end -- end -- backpack[1][curpos[1]][curpos[2]] = false -- end -- if invfuncs.CanFitInBackpack(backpack,j,i,item) then -- local fromtbl = icon.invpos -- local wasequiped = icon.wasequiped -- local ondropped = icon.ondropped -- if ondropped then -- ondropped(backpacknum,j,i,item) -- elseif wasequiped then -- net.Start("unequipitem") -- net.WriteString(wasequiped) -- net.WriteUInt(backpacknum,16) -- net.WriteUInt(i,16) -- net.WriteUInt(j,16) -- net.SendToServer() -- else -- net.Start("moveitem") -- net.WriteEntity(icon.ent) -- from ent -- net.WriteEntity(tent) -- to ent -- net.WriteUInt(icon.backpacknum,16) -- from backpack number -- net.WriteUInt(backpacknum,16) -- to backpack number -- net.WriteUInt(fromtbl[1],16) -- From position -- net.WriteUInt(fromtbl[2],16) -- net.WriteUInt(j,16) -- To position -- net.WriteUInt(i,16) -- net.SendToServer() -- if item.onEquip ~= nil then -- item:onEquip(LocalPlayer()) -- end -- end -- end -- end, {} ) -- end -- end -- end -- end -- -- local invsheetfunc = function() -- local width = ScrW() -- local height = ScrH() -- -- -- local invsheet = vgui.Create( "DPanel" ) -- -- invsheet.Paint = function( self, w, h ) end -- -- --Display gear -- local slotsize = math.Round(width / 32) -- local displaypos = { -- ["Head"] = {(width / 8) - slotsize, 25}, -- ["Body"] = {(width / 8) - slotsize, slotsize + 26}, -- ["Legs"] = {(width / 8) - slotsize, (slotsize * 2) + 27}, -- ["Boots"] = {(width / 8) - slotsize, (slotsize * 3) + 28}, -- ["Gloves"] = {(width / 8) + (slotsize), (slotsize * 2) + 27}, -- ["Left"] = {(width / 8) - (1.5 * slotsize), (slotsize * 4) + 29}, -- ["Right"] = {(width / 8) - (0.5 * slotsize), (slotsize * 4) + 29} -- } -- for k,v in pairs (LocalPlayer().Inventory.Equiped) do -- if v == false then -- local eqslot = vgui.Create( "DPanel", invsheet ) -- eqslot:SetSize( slotsize, slotsize ) -- eqslot:SetPos(displaypos[k][1],displaypos[k][2]) -- eqslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY ) -- if not isDropped then return end -- print("Attempting to equip") -- local icon = tableOfDroppedPanels[1] -- local item = icon.Item -- if item.Equipable == k then -- net.Start("equipitem") -- net.WriteUInt(icon.backpacknum,16) -- Backpack number -- local fromtbl = icon.invpos -- net.WriteUInt(fromtbl[1],16) -- From position -- net.WriteUInt(fromtbl[2],16) -- net.WriteString(k) -- net.SendToServer() -- end -- end, {} ) -- else -- local eqslot = vgui.Create("DImageButton",invsheet) -- eqslot:SetSize(slotsize,slotsize) -- eqslot:SetPos(displaypos[k][1],displaypos[k][2]) -- if v.PaintEquiped then -- eqslot.Paint = v.PaintEquiped -- end -- if v.DoOnEquipPanel then -- v.DoOnEquipPanel(eqslot) -- end -- eqslot:Droppable("Inventory") -- eqslot.Item = v -- eqslot.wasequiped = k -- end -- end -- local moneylabel = vgui.Create("DLabel",invsheet) -- moneylabel:SetPos(0,0) -- moneylabel:SetSize(width/5,18) -- moneylabel:SetText(string.format("Credits:%7d", ART.Credits or 0)) -- print("Displaying credits:" .. string.format("Credits:%7d", ART.Credits or 0)) -- -- local backpacksheet = vgui.Create( "DPropertySheet", invsheet ) -- backpacksheet:SetPos(0,slotsize * 6) -- backpacksheet:SetSize((width / 4) - 26, height - (slotsize * 6) - 70) -- for k,v in pairs(LocalPlayer().Inventory.Backpacks) do -- local tbacksheet = vgui.Create( "DPanel", backpacksheet ) -- tbacksheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end -- backpacksheet:AddSheet( v[3], tbacksheet, "icon16/cross.png" ) -- -- DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer()) -- end -- -- return "Inventory", invsheet, "icon16/cross.png" -- end -- -- -- ART.RegisterInventorySheet(invsheetfunc)