From acc5b071a6ff36f07c22fae8507d019b778b4c3f Mon Sep 17 00:00:00 2001 From: AlmTech Date: Mon, 30 Sep 2019 19:34:27 +0200 Subject: [PATCH] Character menu stuff & page api stuff --- gamemode/engine/derma/cl_menu.lua | 3 +- gamemode/engine/derma/lib/cl_menu_pages.lua | 6 +++- .../engine/derma/menus/menu_character.lua | 35 +++++++++++++------ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/gamemode/engine/derma/cl_menu.lua b/gamemode/engine/derma/cl_menu.lua index 61cd6e7..afaeed5 100644 --- a/gamemode/engine/derma/cl_menu.lua +++ b/gamemode/engine/derma/cl_menu.lua @@ -7,7 +7,8 @@ Quantum.Client.Menu = {} local libs = { - ["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua" + ["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua", + ["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_page.lua" } Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end diff --git a/gamemode/engine/derma/lib/cl_menu_pages.lua b/gamemode/engine/derma/lib/cl_menu_pages.lua index c2e9e6a..bf261f8 100644 --- a/gamemode/engine/derma/lib/cl_menu_pages.lua +++ b/gamemode/engine/derma/lib/cl_menu_pages.lua @@ -13,6 +13,9 @@ function page.New( args ) args.w, args.h = args.w, args.h || ScrW(), ScrH() args.x, args.y = args.x, args.y || 0, 0 + args.closeW, args.closeH = args.closeW, args.closeH || 50 * scale, 20 * scale + args.closeX, args.closeY = args.closeX, args.closeY || args.closeW, args.closeH + local p = vgui.Create( "DPanel", args.parent ) p.w, p.h = args.w, args.h p.x, p.y = args.x, args.y @@ -25,7 +28,8 @@ function page.New( args ) p.OnClose = args.OnClose || function() end local close = vgui.Create( "DButton", p ) - close:SetSize( 50 * scale, 20 * scale ) + close:SetSize( args.closeW, args.closeH ) + close:SetPos( args.closeX, args.closeY ) close.DoClick = function() p:Close() end close.Paint = args.CloseButtonPaint || function( self, w, h ) surface.SetDrawColor( 255, 60, 60, 255 ) diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index 6d6f036..f3ffd51 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -8,11 +8,32 @@ local menu = {} local net = Quantum.Client.Menu.GetAPI( "net" ) +local page = Quantum.Client.Menu.GetAPI( "page" ) local resScale = Quantum.Client.ResolutionScale -local panels = { - [1] = function( parent, args ) end +local pages = { + charSelect = function() + local args = { + CloseButtonPaint = function( self, w, h ) + surface.SetDrawColor( 100, 100, 100, 255 ) + surface.DrawRect( 0, 0, w, h ) + end, + OnClose = function() print("close test") end + } + local p = page.New( args ) + + local clist = vgui.Create( "DPanel", p ) + clist:SetSize( 200 * resScale, sh - padding*10 ) + clist.w, clist.h = clist:GetSize() + clist:SetPos( (sw - clist.w) - padding*2, sh/2 - clist.h/2 ) + clist.Paint = function( self, w, h ) + surface.SetDrawColor( 0, 0, 0, 200 ) + surface.DrawRect( 0, 0, w, h ) + end + + return p + end } function menu.open( dt ) @@ -28,15 +49,9 @@ function menu.open( dt ) end f:MakePopup() + pages.charSelect() -- test - local clist = vgui.Create( "DPanel", f ) - clist:SetSize( 200 * resScale, sh - padding*10 ) - clist.w, clist.h = clist:GetSize() - clist:SetPos( (sw - clist.w) - padding*2, sh/2 - clist.h/2 ) - clist.Paint = function( self, w, h ) - surface.SetDrawColor( 0, 0, 0, 200 ) - surface.DrawRect( 0, 0, w, h ) - end + -- local txt = vgui.Create( "DTextEntry", f ) -- txt:SetText( "Enter name here" )