Fixed loading bugs

master
AlmTech 5 years ago
parent 925e603610
commit 396e0baa32
  1. 2
      gamemode/engine/derma/cl_menu.lua
  2. 45
      gamemode/engine/derma/menus/menu_character.lua
  3. 3
      gamemode/engine/lib/server/sv_character.lua

@ -7,7 +7,7 @@
Quantum.Client.Menu = {} Quantum.Client.Menu = {}
local libs = { local libs = {
["net"] = GAMEMODE.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua" ["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua"
} }
Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end

@ -9,29 +9,46 @@ local menu = {}
local net = Quantum.Client.Menu.GetAPI( "net" ) local net = Quantum.Client.Menu.GetAPI( "net" )
local resScale = Quantum.Client.ResolutionScale
function menu.open( dt ) function menu.open( dt )
local sw, sh = ScrW(), ScrH() local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
if( !f ) then if( !f ) then
local f = vgui.Create( "DFrame" ) local f = vgui.Create( "DFrame" )
f:SetTitle( "Character Menu" ) f:SetTitle( "Character Menu" )
f:SetSize( sw, sh ) f:SetSize( sw, sh )
f.Paint = function( self, w, h )
surface.SetDrawColor( 0, 0, 0, 190 )
surface.DrawRect( 0, 0, w, h )
end
f:MakePopup() f:MakePopup()
local txt = vgui.Create( "DTextEntry", f )
txt:SetText( "Enter name here" ) local clist = vgui.Create( "DPanel", f )
txt:SetSize( 250, 25 ) clist:SetSize( 250 * resScale, 800 * resScale )
local txtW, txtH = txt:GetSize() clist.w, clist.h = clist:GetSize()
txt:SetPos( sw/2 - txtW/2, sh/2 - txtH/2 ) clist:SetPos( (sw - clist.w) - padding*2, sh/2 - clist.h/2 )
local txtX, txtY = txt:GetPos() clist.Paint = function( self, w, h )
surface.SetDrawColor( 0, 0, 0, 200 )
local b = vgui.Create( "DButton", f ) surface.DrawRect( 0, 0, w, h )
b:SetText( "Create Char" )
b:SizeToContents()
local bW, bH = b:GetSize()
b:SetPos( sw/2 - bW/2, txtY - bH )
b.DoClick = function()
net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } )
end end
-- local txt = vgui.Create( "DTextEntry", f )
-- txt:SetText( "Enter name here" )
-- txt:SetSize( 250, 25 )
-- local txtW, txtH = txt:GetSize()
-- txt:SetPos( sw/2 - txtW/2, sh/2 - txtH/2 )
-- local txtX, txtY = txt:GetPos()
-- local b = vgui.Create( "DButton", f )
-- b:SetText( "Create Char" )
-- b:SizeToContents()
-- local bW, bH = b:GetSize()
-- b:SetPos( sw/2 - bW/2, txtY - bH )
-- b.DoClick = function()
-- net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } )
-- end
end end
end end

@ -35,9 +35,10 @@ function Quantum.Server.Char.Load( pl, index, tbl )
local id = pl:SteamID() .. ":" .. index local id = pl:SteamID() .. ":" .. index
if( Quantum.Server.Char.Players[ id ] ~= nil ) then if( Quantum.Server.Char.Players[ id ] ~= nil ) then
Quantum.Server.Char.Players[ id ] = CreateCharTable( tbl ) -- create the character Quantum.Server.Char.Players[ id ] = CreateCharTable( tbl ) -- create the character
Quantum.Server.Inventory.Create( Quantum.Server.Char.Players[ id ] ) -- give the character a inventory Quantum.Server.Char.Players[ id ].inventory = tbl.inventory || Quantum.Server.Inventory.Create( Quantum.Server.Char.Players[ id ] ) -- give the character an inventory
Quantum.Debug( "Created character (" .. id .. ")" ) Quantum.Debug( "Created character (" .. id .. ")" )
return Quantum.Server.Char.Players[ id ]
else else
Quantum.Error( "Tried to duplicate character! Index already used. (" .. id .. ")" ) Quantum.Error( "Tried to duplicate character! Index already used. (" .. id .. ")" )
end end

Loading…
Cancel
Save