From e4bda2189b9b0b5837dc4c0103231dade8ebc8a1 Mon Sep 17 00:00:00 2001 From: AlmTech Date: Sun, 15 Sep 2019 20:13:49 +0200 Subject: [PATCH] Added more menu file loading system stuff --- gamemode/cl_init.lua | 2 +- gamemode/engine/core/sh_player_binds.lua | 4 ++-- gamemode/engine/derma/cl_menu.lua | 3 +-- .../{lib/cl_character.lua => menus/menu_character.lua} | 0 gamemode/engine/lib/server/sv_networking.lua | 4 ++++ gamemode/init.lua | 10 +++++----- 6 files changed, 13 insertions(+), 10 deletions(-) rename gamemode/engine/derma/{lib/cl_character.lua => menus/menu_character.lua} (100%) diff --git a/gamemode/cl_init.lua b/gamemode/cl_init.lua index 37ea302..cfd9e79 100644 --- a/gamemode/cl_init.lua +++ b/gamemode/cl_init.lua @@ -41,7 +41,7 @@ if CLIENT then local function loadAllDermaMenus() local fol = GM.FolderName .. "/gamemode/engine/derma/" - include( fol .. "/cl_menu.lua" ) + include( fol .. "cl_menu.lua" ) end function Quantum.Client.Load() diff --git a/gamemode/engine/core/sh_player_binds.lua b/gamemode/engine/core/sh_player_binds.lua index 2135f0d..5a969a3 100644 --- a/gamemode/engine/core/sh_player_binds.lua +++ b/gamemode/engine/core/sh_player_binds.lua @@ -13,7 +13,7 @@ if SERVER then Quantum.Debug( tostring( pl ) .. " pressed IN_USE" ) end, ["openCharMenu"] = function( pl ) - + Quantum.Net.OpenMenu( pl, "character", {} ) end } @@ -21,6 +21,6 @@ if SERVER then if( keyfuncs[key] ) then keyfuncs[key]( ply ) end end function GM:ShowHelp( ply ) - + keyfuncs["openCharMenu"]( ply ) end end \ No newline at end of file diff --git a/gamemode/engine/derma/cl_menu.lua b/gamemode/engine/derma/cl_menu.lua index 48c757a..1f5e2b8 100644 --- a/gamemode/engine/derma/cl_menu.lua +++ b/gamemode/engine/derma/cl_menu.lua @@ -6,8 +6,7 @@ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ net.Receive( "quantum_menu_net", function( len, pl ) - local menu = net.ReadString() local dt = net.ReadTable() - local menu = include( "lib/cl_" .. menu .. ".lua" ) + local menu = include( "menus/menu_" .. dt.id .. ".lua" ) menu.open( dt ) end) \ No newline at end of file diff --git a/gamemode/engine/derma/lib/cl_character.lua b/gamemode/engine/derma/menus/menu_character.lua similarity index 100% rename from gamemode/engine/derma/lib/cl_character.lua rename to gamemode/engine/derma/menus/menu_character.lua diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 468458c..c6882e0 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -49,6 +49,10 @@ local function SendDatatableToClient( client, dt, type ) net.Send( client ) end +function Quantum.Net.OpenMenu( pl, type, dt ) + SendDatatableToClient( pl, dt, type ) +end + local funcs = { ["createChar"] = true } diff --git a/gamemode/init.lua b/gamemode/init.lua index f2264e3..343b80c 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -63,13 +63,13 @@ if SERVER then end local function addAllDermaMenus() - - AddCSLuaFile( fol .. "/cl_menu.lua" ) - local fol = GM.FolderName .. "/gamemode/engine/derma/" - local menuFiles = file.Find( fol .. "/lib/menu_*.lua", "LUA" ) + AddCSLuaFile( fol .. "cl_menu.lua" ) + + local libfol = GM.FolderName .. "/gamemode/engine/derma/menus/" + local menuFiles = file.Find( libfol .. "menu_*.lua", "LUA" ) for _, file in pairs( menuFiles ) do - AddCSLuaFile( fol .. "/" .. file ) + AddCSLuaFile( libfol .. file ) end end