aboutsummaryrefslogtreecommitdiff
path: root/gamemode/client
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-01-13 20:33:59 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-01-13 20:33:59 -0500
commitf4ee62bb0725a3ae94477b2818071f506e4dfd9f (patch)
tree5b185d1f93aea4e14a2d93e4addfde4dafda9bed /gamemode/client
parent98e0462e4f6b13ff26af5211409352d45dd9453e (diff)
downloadartery-f4ee62bb0725a3ae94477b2818071f506e4dfd9f.tar.gz
artery-f4ee62bb0725a3ae94477b2818071f506e4dfd9f.tar.bz2
artery-f4ee62bb0725a3ae94477b2818071f506e4dfd9f.zip
Finished up shaped inventory, and more work on shared functions.
Diffstat (limited to 'gamemode/client')
-rw-r--r--gamemode/client/cl_inventory.lua100
-rw-r--r--gamemode/client/qtabs/cl_qinventory.lua52
2 files changed, 88 insertions, 64 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
index 390b923..0e14d50 100644
--- a/gamemode/client/cl_inventory.lua
+++ b/gamemode/client/cl_inventory.lua
@@ -5,9 +5,11 @@
Reserved inventory id's
1 - Equipment
2 - Prayers
+ 3 - Skills
+ 4 - Quests
]]
local qinv = nrequire("cl_qinventory.lua")
-local qpray = nrequire("cl_qprayers.lua")
+--local qpray = nrequire("cl_qprayers.lua")
print("Hello from cl_inventory.lua")
--debug.Trace()
@@ -17,32 +19,15 @@ local prayerequiped = {
}
net.Receive("equiphelpprayer",function()
- print("equiphelp received client side!")
- prayerequiped[4] = "Noob Help"
+ print("equiphelp received client side!")
+ prayerequiped[4] = "Noob Help"
end)
local lastpanel = lastpanel or 1
---A master list of inventory sheets
-local inventorysheets = {}
-
--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
---Requires a table of strings to functions, or strings to tables of strings to functions.
---Be careful not to make this a recursive table.
-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 qframe = nil --The master frame
local qtabs = {} --The tabs
@@ -63,7 +48,7 @@ local function BuildInventory()
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:SetSize(width / 4, height)
qframe:SetTitle("Inventory")
qframe:SetDraggable(true)
qframe:MakePopup()
@@ -76,16 +61,19 @@ local function BuildInventory()
tabsheet:Dock(FILL)
local invsheet = qinv.CreateInventorySheet(tabsheet)
- local invid = #qtabs + 1
- invsheet.id = invid
- qtabs[invid] = invsheet
+ --qpray.CreatePrayerSheet(tabsheet)
+ invsheet.id = #qtabs + 1
+ qtabs[#qtabs + 1] = invsheet
+ --prasheet.id = #qtabs + 1
+ --qtabs[#qtabs + 1] = prasheet
tabsheet:AddSheet("Inventory",invsheet,"icon16/user.png")
+ --tabsheet:AddSheet("Prayers",prasheet,"icon16/user.png")
end
local function ShowInventory()
print("qframe is ", qframe)
- if not qframe then BuildInventory()
+ if not qframe then BuildInventory()
else qframe:Show() end
plyisininventory = true
end
@@ -97,13 +85,13 @@ 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
- --PrintTable(v)
- v.panel:Close()
- LocalPlayer().invdisplays[k] = nil
- end
+ lastpanel = sheet:GetActiveTab():GetPanel().sheetnum
+ for k,v in pairs(LocalPlayer().invdisplays) do
+ if not v.panel:IsValid() then continue end
+ --PrintTable(v)
+ v.panel:Close()
+ LocalPlayer().invdisplays[k] = nil
+ end
end)
concommand.Add("showinventory",ShowInventory)
@@ -112,28 +100,28 @@ local rotatespeed = 65
local bone = nil
local previousheadscale = Vector(1,1,1)
hook.Add("CalcView","ArteryInventoryView",function(ply,pos,ang,fov,nearz,farz)
- if bone == nil then
- bone = LocalPlayer():LookupBone("ValveBiped.Bip01_Head1")
- end
- local view = {}
- --view.origin = LocalPlayer():GetBonePosition(bone) + LocalPlayer():GetUp() * 2
- view.origin = pos
- if plyisininventory then
- local trot = math.rad(CurTime() * rotatespeed)
- local xoff = viewdistance * math.sin(trot)
- local yoff = viewdistance * math.cos(trot)
- view.origin = view.origin + Vector(xoff,yoff,10)
- ang.pitch = 20
- ang.yaw = (-CurTime() * rotatespeed) - 90
- end
- view.angles = ang
- view.fov = fov
- if not plyisininventory then
- LocalPlayer():ManipulateBoneScale(bone,Vector(0,0,0))
- else
- LocalPlayer():ManipulateBoneScale(bone,previousheadscale)
- end
- view.drawviewer = plyisininventory
-
- return view
+ if bone == nil then
+ bone = LocalPlayer():LookupBone("ValveBiped.Bip01_Head1")
+ end
+ local view = {}
+ --view.origin = LocalPlayer():GetBonePosition(bone) + LocalPlayer():GetUp() * 2
+ view.origin = pos
+ if plyisininventory then
+ local trot = math.rad(CurTime() * rotatespeed)
+ local xoff = viewdistance * math.sin(trot)
+ local yoff = viewdistance * math.cos(trot)
+ view.origin = view.origin + Vector(xoff,yoff,10)
+ ang.pitch = 20
+ ang.yaw = (-CurTime() * rotatespeed) - 90
+ end
+ view.angles = ang
+ view.fov = fov
+ if not plyisininventory then
+ LocalPlayer():ManipulateBoneScale(bone,Vector(0,0,0))
+ else
+ LocalPlayer():ManipulateBoneScale(bone,previousheadscale)
+ end
+ view.drawviewer = plyisininventory
+
+ return view
end)
diff --git a/gamemode/client/qtabs/cl_qinventory.lua b/gamemode/client/qtabs/cl_qinventory.lua
index a3f8a16..e60424f 100644
--- a/gamemode/client/qtabs/cl_qinventory.lua
+++ b/gamemode/client/qtabs/cl_qinventory.lua
@@ -1,7 +1,6 @@
--[[
One of the tabs in the inventory
]]
-
local inv = nrequire("inventory/inventory.lua")
local itm = nrequire("item.lua")
@@ -9,13 +8,41 @@ local q = {}
local known_inventories = {}
local inventory_frames = {}
+local invsheet
+local drawsheeton = function(id,inventory)
+ if invsheet == nil then return end
+ local tpanel = vgui.Create( "DPanel", invsheet )
+ --tpanel.Paint = function( self, w, h )
+ -- draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 128, 255 ) )
+ --end
+ if inventory.DrawOnDPanel then
+ print("Has drawondpanel")
+ local prox = inventory:DrawOnDPanel(tpanel)
+ print("Prox returned was",prox)
+ PrintTable(prox)
+ known_inventories[id]:AddObserver(prox)
+ print("Oservers is now")
+ PrintTable(known_inventories[id].observers)
+ end
+ invsheet:AddSheet( inventory.Name, tpanel, "icon16/tab.png" )
+end
net.Receive("art_ObserveInventory",function()
local id = net.ReadUInt(32)
local inv_type = net.ReadString()
print("Got inv type", inv_type,"id",id)
- local inital_data = net.ReadData(net.ReadUInt(32))
- known_inventories[id] = inv.CreateInventoryFromData(inv_type,initaldata)
+ local datalen = net.ReadUInt(32)
+ local inital_data = net.ReadData(datalen)
+ local ownent = net.ReadEntity()
+ local tinv = inv.CreateInventoryFromData(inv_type,inital_data)
+ tinv.owner = ownent
+ tinv.id = id
+ print("Created new inventory:")
+ PrintTable(tinv)
+ known_inventories[id] = tinv
+ drawsheeton(id,tinv)
+ print("known inventories is now:")
+ PrintTable(known_inventories)
end)
net.Receive("art_UpdateInventory",function()
@@ -24,9 +51,15 @@ net.Receive("art_UpdateInventory",function()
local position = net.ReadTable()
if isput then
local item_name = net.ReadString()
+ print("Putting ", item_name, "into inventory ",id, " at position")
+ PrintTable(position)
local item_data = net.ReadData(net.ReadUInt(32))
local item = itm.GetItemFromData(item_name,item_data)
known_inventories[id]:Put(position,item)
+ print("Inventorie's observers:")
+ PrintTable(known_inventories[id].observers)
+ print("Inventory is now")
+ PrintTable(known_inventories[id])
else
known_inventories[id]:Remove(position)
end
@@ -41,17 +74,15 @@ net.Receive("art_CloseInventory",function()
end
end)
-local width,height = (ScrW() / 4) - 10, ScrH()
-local iconsize = width / 5
-
-
q.CreateInventorySheet = function(dpanel_parent)
--assert(known_inventories[watch_id] ~= nil,"Attempted to watch an inventory that dosn't exist!")
--Display the equipment inventories
- local invsheet = vgui.Create( "DPropertySheet", dpanel_parent )
+ invsheet = vgui.Create( "DPropertySheet", dpanel_parent )
invsheet:Dock( FILL )
for k,v in pairs(known_inventories) do
+ drawsheeton(k,v)
+ --[[
local tpanel = vgui.Create( "DPanel", invsheet )
tpanel.Paint = function( self, w, h )
draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 128, 255 ) )
@@ -61,9 +92,14 @@ q.CreateInventorySheet = function(dpanel_parent)
known_inventories[k]:AddObserver(prox)
end
invsheet:AddSheet( v.Name, tpanel, "icon16/tab.png" )
+ ]]
end
return invsheet
end
+concommand.Add("PrintKnownInventories",function(ply,cmd,args)
+ PrintTable(known_inventories)
+end)
+
return q