From a255824202a0750f2543fed65debb63df0e4455b Mon Sep 17 00:00:00 2001 From: AlmTech Date: Mon, 30 Sep 2019 18:56:50 +0200 Subject: [PATCH] Added a 'page' library & added loading debug --- gamemode/engine/derma/lib/cl_menu_pages.lua | 38 +++++++++++++++++++ .../engine/derma/menus/menu_character.lua | 4 ++ gamemode/init.lua | 36 ++++++++++++++---- 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 gamemode/engine/derma/lib/cl_menu_pages.lua diff --git a/gamemode/engine/derma/lib/cl_menu_pages.lua b/gamemode/engine/derma/lib/cl_menu_pages.lua new file mode 100644 index 0000000..c2e9e6a --- /dev/null +++ b/gamemode/engine/derma/lib/cl_menu_pages.lua @@ -0,0 +1,38 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + +local page = {} +local scale = Quantum.Client.ResolutionScale + +function page.New( args ) + + args.w, args.h = args.w, args.h || ScrW(), ScrH() + args.x, args.y = args.x, args.y || 0, 0 + + local p = vgui.Create( "DPanel", args.parent ) + p.w, p.h = args.w, args.h + p.x, p.y = args.x, args.y + + p:SetSize( p.w, p.h ) + p:SetPos( p.x, p.y ) + p.Paint = args.Paint || function( self, w, h ) + -- Draw nothing, unless this function is overwritten + end + p.OnClose = args.OnClose || function() end + + local close = vgui.Create( "DButton", p ) + close:SetSize( 50 * scale, 20 * scale ) + close.DoClick = function() p:Close() end + close.Paint = args.CloseButtonPaint || function( self, w, h ) + surface.SetDrawColor( 255, 60, 60, 255 ) + surface.DrawRect( 0, 0, w, h ) + end + + return p +end + +return page \ No newline at end of file diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index c9d8f1b..6d6f036 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -11,6 +11,10 @@ local net = Quantum.Client.Menu.GetAPI( "net" ) local resScale = Quantum.Client.ResolutionScale +local panels = { + [1] = function( parent, args ) end +} + function menu.open( dt ) local sw, sh = ScrW(), ScrH() local padding = 10 * resScale diff --git a/gamemode/init.lua b/gamemode/init.lua index b344213..36eafaf 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -18,59 +18,79 @@ if SERVER then local function loadCoreFiles() local fol = GM.FolderName .. "/gamemode/engine/core/" - + MsgC( "\n" ) + Quantum.Debug( "Loading core files..." ) -- Shared files local shFiles = file.Find( fol .. "/sh_*.lua", "LUA" ) for _, file in pairs( shFiles ) do AddCSLuaFile( fol .. file ) - include( fol .. file ) + include( fol .. file ) + Quantum.Debug( "(CORE) Loaded: " .. fol .. file ) end -- CLient files local clFiles = file.Find( fol .. "/client/cl_*.lua", "LUA" ) for _, file in pairs( clFiles ) do AddCSLuaFile( fol .. "client/" .. file ) + Quantum.Debug( "(CORE) Loaded: " .. fol .. "client/" .. file ) end -- Server files local cFiles = file.Find( fol .. "/server/sv_*.lua", "LUA" ) for _, file in pairs( cFiles ) do include( fol .. "server/" .. file ) + Quantum.Debug( "(CORE) Loaded: " .. fol .. "server/" .. file ) end end local function loadLibFiles() local fol = GM.FolderName .. "/gamemode/engine/lib/" - + MsgC( "\n" ) + Quantum.Debug( "Loading libraries..." ) -- Shared files local shFiles = file.Find( fol .. "/sh_*.lua", "LUA" ) for _, file in pairs( shFiles ) do AddCSLuaFile( fol .. file ) - include( fol .. file ) + include( fol .. file ) + Quantum.Debug( "Added library: " .. fol .. file ) end -- CLient files local clFiles = file.Find( fol .. "/client/cl_*.lua", "LUA" ) for _, file in pairs( clFiles ) do AddCSLuaFile( fol .. "client/" .. file ) + Quantum.Debug( "Added library: " .. fol .. "client/" .. file ) end -- Server files local cFiles = file.Find( fol .. "/server/sv_*.lua", "LUA" ) for _, file in pairs( cFiles ) do include( fol .. "server/" .. file ) + Quantum.Debug( "Added library: " .. fol .. "server/" .. file ) end end local function addAllDermaMenus() local fol = GM.FolderName .. "/gamemode/engine/derma/" + MsgC( "\n" ) + Quantum.Debug( "Loading menus...") + AddCSLuaFile( fol .. "cl_menu.lua" ) - AddCSLuaFile( fol .. "lib/cl_network.lua" ) - local libfol = GM.FolderName .. "/gamemode/engine/derma/menus/" - local menuFiles = file.Find( libfol .. "menu_*.lua", "LUA" ) - for _, file in pairs( menuFiles ) do + -- add all the menu libs + local libfol = fol .. "lib/" + local libFiles = file.Find( libfol .. "cl_*.lua", "LUA" ) + for _, file in pairs( libFiles ) do AddCSLuaFile( libfol .. file ) + Quantum.Debug( "Added library: " .. libfol .. file ) + end + + -- add the menu's + local menufol = GM.FolderName .. "/gamemode/engine/derma/menus/" + local menuFiles = file.Find( menufol .. "menu_*.lua", "LUA" ) + for _, file in pairs( menuFiles ) do + AddCSLuaFile( menufol .. file ) + Quantum.Debug( "Added menu: " .. menufol .. file ) end end