aboutsummaryrefslogtreecommitdiff
path: root/gamemode/client
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-07-10 17:04:29 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-07-10 17:04:29 -0400
commit1de5f9ac6f038bfed2230cc1272b253794b2f41a (patch)
tree15bc9d515f1f48c036522afb7cc71f60243849a9 /gamemode/client
downloadartery-1de5f9ac6f038bfed2230cc1272b253794b2f41a.tar.gz
artery-1de5f9ac6f038bfed2230cc1272b253794b2f41a.tar.bz2
artery-1de5f9ac6f038bfed2230cc1272b253794b2f41a.zip
Initial commit
Diffstat (limited to 'gamemode/client')
-rw-r--r--gamemode/client/cl_inventory.lua199
-rw-r--r--gamemode/client/cl_pac.lua2
-rw-r--r--gamemode/client/cl_systems.lua4
-rw-r--r--gamemode/client/vgui/vgui_DMultiModelPanel.lua161
4 files changed, 366 insertions, 0 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
new file mode 100644
index 0000000..6db72dd
--- /dev/null
+++ b/gamemode/client/cl_inventory.lua
@@ -0,0 +1,199 @@
+--[[
+ Displays the inventory, for more information see /gamemode/shared/inventory.lua
+]]
+print("Hello from cl_inventory.lua")
+local invfuncs = include("../shared/inventory_common.lua")
+local plyisininventory = false
+
+function ShowInventory(ply,cmd,args)
+ if plyisininventory then return end
+ 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 sheet = vgui.Create( "DPropertySheet", invpanel )
+ sheet:Dock( FILL )
+
+ local invsheet = vgui.Create( "DPanel", sheet )
+ invsheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end
+ sheet:AddSheet( "Inventory", invsheet, "icon16/cross.png" )
+
+ local skillsheet = vgui.Create( "DPanel", sheet )
+ skillsheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end
+ sheet:AddSheet( "Skills", skillsheet, "icon16/tick.png" )
+
+ --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}
+ }
+ print("Displaying inventory:")
+ PrintTable(LocalPlayer().Inventory.Equiped)
+ 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
+ PrintTable(item)
+ print("In",k)
+ 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)
+ print("Writing string",k)
+ net.WriteString(k)
+ net.SendToServer()
+ end
+ end, {} )
+ else
+ print("eqslot",k,"was not false, it was")
+ PrintTable(v)
+ local eqslot = vgui.Create("DPanel",invsheet)
+ eqslot:SetSize(slotsize,slotsize)
+ eqslot:SetPos(displaypos[k][1],displaypos[k][2])
+ --eqslot:SetImage( "overviews/de_inferno", "vgui/avatar_default" )
+ --eqslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(100,0,0)) end
+ eqslot:Droppable("Inventory")
+ eqslot.Item = v
+ eqslot.wasequiped = k
+ end
+ end
+
+ local backpacksheet = vgui.Create( "DPropertySheet", invsheet )
+ backpacksheet:SetPos(0,slotsize * 6)
+ backpacksheet:SetSize((width / 4) - 25, height - (slotsize * 6) - 50)
+
+ 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" )
+
+ invfuncs.DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer())
+
+ --[[
+ local backgrid = vgui.Create( "DGrid", tbacksheet )
+ backgrid:SetPos( 10, 30 )
+ backgrid:SetCols( v[2][1] )
+ backgrid:SetColWide( v[2][2] )
+ backgrid:Dock(FILL)
+
+ for i=1,#(v[1]) do
+ for j=1,#(v[1][i]) do
+ if type(v[1][j][i]) == "table" then
+ print("Loading icon")
+ local item = v[1][j][i]
+ print("Item is:")
+ PrintTable(item)
+ local itemwidth = 0
+ for _,l in pairs(item.Shape) do
+ itemwidth = math.Max(itemwidth,#l)
+ end
+ local itemheight = #item.Shape
+ local invicon = vgui.Create( "DButton", tbacksheet )
+ invicon:SetSize(slotsize*itemwidth,slotsize*itemheight)
+ invicon:SetPos(slotsize*(i-1),slotsize*(j-1))
+ --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end
+ invicon.Item = item
+ invicon.invpos = {j,i}
+ invicon.backpack = k
+ invicon:Droppable("Inventory")
+ elseif not v[1][j][i] then
+ local emptyslot = vgui.Create("DPanel", tbacksheet)
+ 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
+ print("receiver",receiver)
+ print("menuIndex",menuIndex)
+ print("tableOfDroppedPanels",tableOfDroppedPanels)
+ PrintTable(tableOfDroppedPanels)
+ local item = tableOfDroppedPanels[1].Item
+ print("Checking if item:")
+ PrintTable(item)
+ print("Can fit in pack:",j,i)
+ if invfuncs.CanFitInBackpack(v,j,i,item) then
+ local fromtbl = tableOfDroppedPanels[1].invpos
+ local wasequiped = tableOfDroppedPanels[1].wasequiped
+ if wasequiped then
+ print("wasequiped",wasequiped)
+ net.Start("unequipitem")
+ net.WriteString(wasequiped)
+ net.WriteUInt(k,16)
+ net.WriteUInt(i,16)
+ net.WriteUInt(j,16)
+ net.SendToServer()
+ else
+ net.Start("moveitem")
+ net.WriteUInt(k,16) -- 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
+
+end
+
+hook.Add("OnSpawnMenuOpen","ArteryOpenInventory",ShowInventory)
+hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function()
+ if LocalPlayer().invpanel == nil then return end
+ LocalPlayer().invpanel:Remove()
+ plyisininventory = false
+end)
+
+concommand.Add("showinventory",ShowInventory)
+local viewdistance = 100
+local rotatespeed = 65
+hook.Add("CalcView","ArteryInventoryView",function(ply,pos,ang,fov,nearz,farz)
+ local view = {}
+ view.origin = pos
+ if plyisininventory then
+ local xoff = viewdistance * math.sin(math.rad(CurTime() * rotatespeed))
+ local yoff = viewdistance * math.cos(math.rad(CurTime() * rotatespeed))
+ view.origin = view.origin + ( Vector(xoff,yoff,10) )
+ ang.pitch = 20
+ ang.yaw = (-CurTime() * rotatespeed) - 90
+ end
+ view.angles = ang
+ view.fov = fov
+ view.drawviewer = plyisininventory
+
+ return view
+end)
diff --git a/gamemode/client/cl_pac.lua b/gamemode/client/cl_pac.lua
new file mode 100644
index 0000000..6a7abed
--- /dev/null
+++ b/gamemode/client/cl_pac.lua
@@ -0,0 +1,2 @@
+
+local pmeta = FindMetaTable("Player")
diff --git a/gamemode/client/cl_systems.lua b/gamemode/client/cl_systems.lua
new file mode 100644
index 0000000..0165239
--- /dev/null
+++ b/gamemode/client/cl_systems.lua
@@ -0,0 +1,4 @@
+--[[
+ Something to display all the systems delt with serverside
+]]
+local systems = {}
diff --git a/gamemode/client/vgui/vgui_DMultiModelPanel.lua b/gamemode/client/vgui/vgui_DMultiModelPanel.lua
new file mode 100644
index 0000000..37d0883
--- /dev/null
+++ b/gamemode/client/vgui/vgui_DMultiModelPanel.lua
@@ -0,0 +1,161 @@
+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" )