aboutsummaryrefslogtreecommitdiff
path: root/gamemode/client
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/client')
-rw-r--r--gamemode/client/cl_inventory.lua107
-rw-r--r--gamemode/client/cl_weaponswitch.lua4
-rw-r--r--gamemode/client/hud/cl_svgtest.lua46
-rw-r--r--gamemode/client/qtabs/cl_qinventory.lua69
-rw-r--r--gamemode/client/qtabs/cl_qprayers.lua8
-rw-r--r--gamemode/client/vgui/vgui_DMultiModelPanel.lua161
6 files changed, 181 insertions, 214 deletions
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)
diff --git a/gamemode/client/cl_weaponswitch.lua b/gamemode/client/cl_weaponswitch.lua
index f7edcfc..085a0b3 100644
--- a/gamemode/client/cl_weaponswitch.lua
+++ b/gamemode/client/cl_weaponswitch.lua
@@ -1,4 +1,6 @@
-function GM:PlayerSwitchWeapon( ply, oldWeapon, newWeapon )
+local gm = GM or GAMEMODE
+
+function gm:PlayerSwitchWeapon( ply, oldWeapon, newWeapon )
return false
end
diff --git a/gamemode/client/hud/cl_svgtest.lua b/gamemode/client/hud/cl_svgtest.lua
new file mode 100644
index 0000000..baeb698
--- /dev/null
+++ b/gamemode/client/hud/cl_svgtest.lua
@@ -0,0 +1,46 @@
+do return end
+local svg = nrequire("cl_svg.lua")
+local mats = {}
+local matstrs = {}
+for i = 2,10 do
+ for _,t in pairs({"clubs","diamonds","hearts","spades"}) do
+ matstrs[#matstrs + 1] = string.format( "materials/svg/aussiesim/cards/svg/000000/transparent/card-%d-%s.svg",i,t)
+ end
+end
+
+for k,v in pairs(matstrs) do
+ mats[k] = file.Read(v,"GAME")
+end
+local truemats = {}
+for k,v in pairs(matstrs) do
+ truemats[k] = svg.MaterialFromSVG(v)
+end
+--local parsed = xmlparser:parse(matstr)
+local htmls = {}
+local nx = ScrW()/64
+local ny = ScrH()/64
+for x = 1,nx do
+ for y = 1,ny do
+ local thtml = vgui.Create("DSprite") --svg.SvgOnDpanel("materials/svg/aussiesim/cards/svg/000000/transparent/card-2-clubs.svg")
+ thtml:SetSize(64,64)
+ thtml:SetPos(x * 64,y * 64)
+ htmls[y * nx + x] = thtml
+ end
+end
+
+hook.Add("HUDPaint","paint_svg",function()
+ --local randommat = table.Random(matstrs)
+ --html:RunJavascript( string.format("document.body.innerHTML = 'HTML changed from Lua using JavaScript!';"" )
+ --[[
+ for k,v in pairs(htmls) do
+ v:UpdateImage(randommat)
+ end
+ ]]
+
+ for k,v in pairs(htmls) do
+ local randommat = table.Random(truemats)
+ if randommat.material then
+ v:SetMaterial(randommat.material)
+ end
+ end
+end)
diff --git a/gamemode/client/qtabs/cl_qinventory.lua b/gamemode/client/qtabs/cl_qinventory.lua
new file mode 100644
index 0000000..a3f8a16
--- /dev/null
+++ b/gamemode/client/qtabs/cl_qinventory.lua
@@ -0,0 +1,69 @@
+--[[
+ One of the tabs in the inventory
+]]
+
+local inv = nrequire("inventory/inventory.lua")
+local itm = nrequire("item.lua")
+
+local q = {}
+
+local known_inventories = {}
+local inventory_frames = {}
+
+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)
+end)
+
+net.Receive("art_UpdateInventory",function()
+ local id = net.ReadUInt(32)
+ local isput = net.ReadBool()
+ local position = net.ReadTable()
+ if isput then
+ local item_name = net.ReadString()
+ local item_data = net.ReadData(net.ReadUInt(32))
+ local item = itm.GetItemFromData(item_name,item_data)
+ known_inventories[id]:Put(position,item)
+ else
+ known_inventories[id]:Remove(position)
+ end
+end)
+
+net.Receive("art_CloseInventory",function()
+ local id = net.ReadUInt(32)
+ known_inventories[id] = nil
+ if inventory_frames[id] then
+ inventory_frames[id]:Close()
+ inventory_frames[id] = nil
+ 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:Dock( FILL )
+
+ for k,v in pairs(known_inventories) do
+ 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 v.DrawOnDPanel then
+ local prox = v:DrawOnDPanel(tpanel)
+ known_inventories[k]:AddObserver(prox)
+ end
+ invsheet:AddSheet( v.Name, tpanel, "icon16/tab.png" )
+ end
+
+ return invsheet
+end
+
+return q
diff --git a/gamemode/client/qtabs/cl_qprayers.lua b/gamemode/client/qtabs/cl_qprayers.lua
new file mode 100644
index 0000000..9f1b9ab
--- /dev/null
+++ b/gamemode/client/qtabs/cl_qprayers.lua
@@ -0,0 +1,8 @@
+
+local p = {}
+
+function p.CreatePrayerSheet(dpanel_parent)
+
+end
+
+return p
diff --git a/gamemode/client/vgui/vgui_DMultiModelPanel.lua b/gamemode/client/vgui/vgui_DMultiModelPanel.lua
deleted file mode 100644
index 37d0883..0000000
--- a/gamemode/client/vgui/vgui_DMultiModelPanel.lua
+++ /dev/null
@@ -1,161 +0,0 @@
-local PANEL = {}
-
-AccessorFunc( PANEL, "m_fAnimSpeed", "AnimSpeed" )
-AccessorFunc( PANEL, "vCamPos", "CamPos" )
-AccessorFunc( PANEL, "fFOV", "FOV" )
-AccessorFunc( PANEL, "vLookatPos", "LookAt" )
-AccessorFunc( PANEL, "aLookAngle", "LookAng" )
-AccessorFunc( PANEL, "colAmbientLight", "AmbientLight" )
-AccessorFunc( PANEL, "colColor", "Color" )
-AccessorFunc( PANEL, "bAnimated", "Animated" )
-
-function PANEL:Init()
-
- self.Entities = {}
- self.LastPaint = 0
- self.DirectionalLight = {}
- self.FarZ = 4096
-
- self:SetCamPos( Vector( 50, 50, 50 ) )
- self:SetLookAt( Vector( 0, 0, 40 ) )
- self:SetFOV( 70 )
-
- self:SetText( "" )
- self:SetAnimSpeed( 0.5 )
- self:SetAnimated( false )
-
- self:SetAmbientLight( Color( 50, 50, 50 ) )
-
- self:SetDirectionalLight( BOX_TOP, Color( 255, 255, 255 ) )
- self:SetDirectionalLight( BOX_FRONT, Color( 255, 255, 255 ) )
-
- self:SetColor( Color( 255, 255, 255, 255 ) )
-
-end
-
-function PANEL:SetDirectionalLight( iDirection, color )
- self.DirectionalLight[ iDirection ] = color
-end
-
-function PANEL:AddModel( strModelName )
-
- -- Note: Not in menu dll
- if ( !ClientsideModel ) then return end
-
- self.Entities[#self.Entities+1] = ClientsideModel(strModelName, RENDER_GROUP_OPAQUE_ENTITY)
- if ( !IsValid( self.Entities[#self.Entities] ) ) then return end
-
- self.Entities[#self.Entities]:SetNoDraw( true )
- self.Entities[#self.Entities]:SetIK( false )
-
-end
-
-function PANEL:DrawModel()
-
- local curparent = self
- local rightx = self:GetWide()
- local leftx = 0
- local topy = 0
- local bottomy = self:GetTall()
- local previous = curparent
- while( curparent:GetParent() != nil ) do
- curparent = curparent:GetParent()
- local x, y = previous:GetPos()
- topy = math.Max( y, topy + y )
- leftx = math.Max( x, leftx + x )
- bottomy = math.Min( y + previous:GetTall(), bottomy + y )
- rightx = math.Min( x + previous:GetWide(), rightx + x )
- previous = curparent
- end
- render.SetScissorRect( leftx, topy, rightx, bottomy, true )
-
- for k,v in pairs(self.Entities) do
- local ret = self:PreDrawModel( v )
- if ( ret != false ) then
- v:DrawModel()
- self:PostDrawModel( v )
- end
- end
-
- render.SetScissorRect( 0, 0, 0, 0, false )
-
-end
-
-function PANEL:PreDrawModel( ent )
- return true
-end
-
-function PANEL:PostDrawModel( ent )
-
-end
-
-function PANEL:Paint( w, h )
- for k,v in pairs(self.Entities) do
- if ( !IsValid( v ) ) then continue end
-
- local x, y = self:LocalToScreen( 0, 0 )
-
- self:LayoutEntity( v )
-
- local ang = self.aLookAngle
- if ( !ang ) then
- ang = ( self.vLookatPos - self.vCamPos ):Angle()
- end
-
- cam.Start3D( self.vCamPos, ang, self.fFOV, x, y, w, h, 5, self.FarZ )
-
- render.SuppressEngineLighting( true )
- render.SetLightingOrigin( v:GetPos() )
- render.ResetModelLighting( self.colAmbientLight.r / 255, self.colAmbientLight.g / 255, self.colAmbientLight.b / 255 )
- render.SetColorModulation( self.colColor.r / 255, self.colColor.g / 255, self.colColor.b / 255 )
- render.SetBlend( ( self:GetAlpha() / 255 ) * ( self.colColor.a / 255 ) )
-
- for i = 0, 6 do
- local col = self.DirectionalLight[ i ]
- if ( col ) then
- render.SetModelLighting( i, col.r / 255, col.g / 255, col.b / 255 )
- end
- end
-
- self:DrawModel()
-
- render.SuppressEngineLighting( false )
- cam.End3D()
-
- self.LastPaint = RealTime()
- end
-end
-
---[[
-function PANEL:StartScene( name )
-
- if ( IsValid( self.Scene ) ) then
- self.Scene:Remove()
- end
-
- self.Scene = ClientsideScene( name, self.Entity )
-
-end
-]]
-
-function PANEL:LayoutEntity( Entity )
-
- --
- -- This function is to be overriden
- --
-
- if ( self.bAnimated ) then
- self:RunAnimation()
- end
- Entity:SetAngles( Angle( 0, RealTime() * 10 % 360, 0 ) )
-
-end
-
-function PANEL:OnRemove()
- for k,v in pairs(self.Entities) do
- v:Remove()
- self.Entities[k] = nil
- end
-end
-
-derma.DefineControl( "DModelPanel", "A panel containing a model", PANEL, "DModelPanel" )