From 98e0462e4f6b13ff26af5211409352d45dd9453e Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 8 Jan 2017 22:28:08 -0500 Subject: Add a ton of icons, more work on refactoring --- gamemode/client/cl_inventory.lua | 107 ++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 52 deletions(-) (limited to 'gamemode/client/cl_inventory.lua') diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua index 84cb347..390b923 100644 --- a/gamemode/client/cl_inventory.lua +++ b/gamemode/client/cl_inventory.lua @@ -1,6 +1,14 @@ --[[ Displays the inventory, for more information see /gamemode/shared/inventory.lua ]] +--[[ + Reserved inventory id's + 1 - Equipment + 2 - Prayers +]] +local qinv = nrequire("cl_qinventory.lua") +local qpray = nrequire("cl_qprayers.lua") + print("Hello from cl_inventory.lua") --debug.Trace() @@ -15,14 +23,10 @@ end) local lastpanel = lastpanel or 1 +--A master list of inventory sheets local inventorysheets = {} ---[[ -ART.RegisterInventorySheet = function(func) - inventorysheets[#inventorysheets + 1] = func -end -]] - +--Wether the player is in the inventory or not local plyisininventory = false --Displays a dropdown of options under the players mouse, if the option is clicked, does the function @@ -39,60 +43,60 @@ local function createMenuFor(menu, tbl) end end ---[[ -function ART.RefreshDisplays() - local discopy = LocalPlayer().invdisplays - LocalPlayer().invdisplays = {} - for k,ptbl in pairs(discopy) do - if not ptbl.panel:IsValid() then continue end - if ptbl.panel.Close ~= nil then - ptbl.panel:Close() - else - print(ptbl.panel) - error("panel has no close method") - ptbl.panel:Remove() - end - ptbl.redraw() - end -end -]] +local qframe = nil --The master frame +local qtabs = {} --The tabs -local sheet -function ShowInventory(ply,cmd,args) - if plyisininventory then return end - LocalPlayer().invdisplays = LocalPlayer().invdisplays or {} - plyisininventory = true - local width = ScrW() - local height = ScrH() - local dat = {} - dat.panel = vgui.Create( "DFrame" ) - dat.redraw = ShowInventory - table.insert(LocalPlayer().invdisplays,dat) - local invpanel = dat.panel - invpanel:SetPos( 0, 0 ) - invpanel:SetSize( width / 4, height ) - invpanel:SetTitle( "Inventory" ) - invpanel:SetDraggable( true ) - invpanel:MakePopup() - invpanel.OnClose = function(self) - plyisininventory = false - end +local width = ScrW() +local height = ScrH() + +local player_data --The data the player needs to show the q panel +net.Receive("art_load_player_data",function() + print("Got player data") + player_data = net.ReadTable() + print("It was") + PrintTable(player_data) +end) - sheet = vgui.Create( "DPropertySheet", invpanel ) - sheet:Dock( FILL ) +local function BuildInventory() + print("Building inventory") + if qframe then return end + if not player_data then print("no player data!") return end + qframe = vgui.Create("DFrame") + qframe:SetPos(0,0) + qframe:SetSize(width/4, height) + qframe:SetTitle("Inventory") + qframe:SetDraggable(true) + qframe:MakePopup() + qframe.OnClose = function(self) + plyisininventory = false + self:Hide() + return + end + local tabsheet = vgui.Create("DPropertySheet",qframe) + tabsheet:Dock(FILL) + + local invsheet = qinv.CreateInventorySheet(tabsheet) + local invid = #qtabs + 1 + invsheet.id = invid + qtabs[invid] = invsheet + tabsheet:AddSheet("Inventory",invsheet,"icon16/user.png") - for k,v in pairs(inventorysheets) do - local name,tsheet,image = v() - sheet:AddSheet(name,tsheet,image) - tsheet.sheetnum = name - end - sheet:SwitchToName(lastpanel) +end + +local function ShowInventory() + print("qframe is ", qframe) + if not qframe then BuildInventory() + else qframe:Show() end + plyisininventory = true end hook.Add("OnSpawnMenuOpen","ArteryOpenInventory",ShowInventory) hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function() + plyisininventory = false + qframe:Hide() + if (not sheet) or (not sheet:GetActiveTab()) or (not sheet:GetActiveTab():GetPanel()) then return end lastpanel = sheet:GetActiveTab():GetPanel().sheetnum for k,v in pairs(LocalPlayer().invdisplays) do if not v.panel:IsValid() then continue end @@ -100,7 +104,6 @@ hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function() v.panel:Close() LocalPlayer().invdisplays[k] = nil end - plyisininventory = false end) concommand.Add("showinventory",ShowInventory) -- cgit v1.2.3-70-g09d2