summaryrefslogtreecommitdiff
path: root/gamemode/client
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-04-29 20:30:52 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-04-29 20:30:52 -0400
commit6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530 (patch)
treea0a9e142b4741ed109a00059e3b98efc86b25b4d /gamemode/client
parent534ce8e8612da3ba6d610a782eeaf10c9135b947 (diff)
downloadgmstranded-6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530.tar.gz
gmstranded-6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530.tar.bz2
gmstranded-6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530.zip
a halfway commit to show scott
Diffstat (limited to 'gamemode/client')
-rw-r--r--gamemode/client/cl_inventory.lua81
-rw-r--r--gamemode/client/cl_syncronize.lua28
2 files changed, 95 insertions, 14 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
index 9e18040..94690ac 100644
--- a/gamemode/client/cl_inventory.lua
+++ b/gamemode/client/cl_inventory.lua
@@ -1,29 +1,82 @@
print("Custom inventory loaded")
+--Some calculations to draw the inventory nicely
+local scrx = ScrW()
+local scry = ScrH()
+--Make the menu 30% of the x to the closest 64 and 100% of the y
+local invxadj = ((scrx*0.4)%64)
+local invxsize = (scrx*0.40)-invxadj-38 --no idea why the 38 works, but it does
+local invysize = scry
+
+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 createPanel()
local frame = vgui.Create( "DFrame" )
- frame:SetSize( 300, 300 )
+ frame:SetSize( invxsize, invysize )
frame:SetTitle( "Inventory" )
frame:MakePopup()
- frame:Center()
+ frame:SetPos(scrx-invxsize,0)
- local layout = vgui.Create( "DTileLayout", frame )
- layout:SetBaseSize( 32 ) -- Tile size
- layout:Dock( FILL )
+ local tabsheet = vgui.Create("DPropertySheet", frame)
+ tabsheet:Dock(FILL)
- //Draw a background so we can see what it's doing
- --layout:SetDrawBackground( true )
- --layout:SetBackgroundColor( Color( 0, 100, 100 ) )
+ local invtab = vgui.Create("DPanel",tabsheet)
+ tabsheet:AddSheet( "Inventory", invtab, "icon16/database.png" )
+ local equiptab = vgui.Create("DPanel",tabsheet)
+ tabsheet:AddSheet( "Equipment", equiptab, "icon16/user.png" )
+ local proptab = vgui.Create("DPanel",tabsheet)
+ tabsheet:AddSheet( "Props", proptab, "icon16/wrench.png" )
+ if(LocalPlayer():IsAdmin()) then
+ local admintab = vgui.Create("DPanel",tabsheet)
+ tabsheet:AddSheet("Admin", admintab, "icon16/bullet_star.png")
+ end
+
+ --Inventory
+ local layout = vgui.Create( "DTileLayout", invtab )
+ layout:SetBaseSize( 64 ) -- Tile size
+ layout:Dock( FILL )
layout:MakeDroppable( "unique_name" ) -- Allows us to rearrange children
+ PrintTable(Resources)
for k, v in SortedPairs( Resources ) do
- layout:Add( Label( v .. k) )
- end
- /*
- for i = 1, 32 do
- layout:Add( Label( " Label " .. i ) )
+ local selection = vgui.Create("DImageButton")
+ if(GMS.Resources[k] == nil) then --This resource is not registered!
+ selection:SetImage("vgui/avatar_default")
+ print("Resource:" .. k .. " not registed! This might be a bug!")
+ continue
+ elseif(GMS.Resources[k].Icon == nil) then
+ selection:SetImage("vgui/avatar_default")
+ print("Resource:" .. k .. " does not have an .Icon field! This might be a bug!")
+ continue
+ else
+ selection:SetImage(GMS.Resources[k].Icon)
+ end
+
+ selection:SetSize(64,64)
+ selection.DoClick = function()
+ if(GMS.Resources[k].UniqueData) then
+ print("We should expand menu to show all uniqueid's")
+ else
+ if(GMS.Resources[k].Actions == nil) then
+ print("gamemode/client/cl_inventory.lua: Looking for actions for " .. k .. " but found nil!")
+ return
+ end
+ local menu = vgui.Create("DMenu")
+ createMenuFor(menu,GMS.Resources[k].Actions)
+ menu:Open()
+ end
+ end
+ layout:Add( selection )
end
- */
end
local invpanel = nil
diff --git a/gamemode/client/cl_syncronize.lua b/gamemode/client/cl_syncronize.lua
new file mode 100644
index 0000000..32d667c
--- /dev/null
+++ b/gamemode/client/cl_syncronize.lua
@@ -0,0 +1,28 @@
+--Makes sure the player knows about things like inventory, skills, experience ect.
+
+net.Receive( "gms_SetResource", function( length, pl)
+ print("Setresources message sent from server")
+ local name = net.ReadString()
+ if(GMS.GetResourceByName(name).UniqueData) then
+ local restable = net.ReadTable()
+ PrintTable(restable)
+ if(Resources[name] == nil) then
+ Resources[name] = {}
+ end
+ table.insert(Resources[name],restable.UniqueDataID,restable)
+ else
+ if(Resources[name] == nil) then
+ Resources[name] = 0
+ end
+ print("Getting with bitcount:" .. GMS.NETINT_BITCOUNT)
+ local num = net.ReadInt(GMS.NETINT_BITCOUNT)
+ print("Resource name: " .. name)
+ print("Resource num: " .. num)
+ Resources[name] = num
+ end
+ print("Finished resource get")
+end)
+
+concommand.Add("gms_cl_printresources",function(ply,cmd,args)
+ PrintTable(Resources)
+end)