From df2c86865e4f476252dd07067a27f528d6c8a23f Mon Sep 17 00:00:00 2001 From: AlmTech Date: Tue, 1 Oct 2019 19:00:39 +0200 Subject: [PATCH] Further progress on the character menu --- gamemode/engine/core/client/cl_fonts.lua | 19 ++++++ gamemode/engine/derma/lib/cl_menu_pages.lua | 5 +- .../engine/derma/menus/menu_character.lua | 66 ++++++++++++++++--- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/gamemode/engine/core/client/cl_fonts.lua b/gamemode/engine/core/client/cl_fonts.lua index 07d33f7..69fa57b 100644 --- a/gamemode/engine/core/client/cl_fonts.lua +++ b/gamemode/engine/core/client/cl_fonts.lua @@ -16,4 +16,23 @@ surface.CreateFont( "q_text", { font = "Arial", size = 22 * Quantum.Client.ResolutionScale, antialias = true +}) + +surface.CreateFont( "q_text2", { + font = "Arial", + size = 26 * Quantum.Client.ResolutionScale, + antialias = true +}) + +surface.CreateFont( "q_charNameText", { + font = "Arial", + outline = true, + size = 28 * Quantum.Client.ResolutionScale, + antialias = true +}) + +surface.CreateFont( "q_header", { + font = "Constantia Bold Italic", + size = 50 * Quantum.Client.ResolutionScale, + antialias = true }) \ No newline at end of file diff --git a/gamemode/engine/derma/lib/cl_menu_pages.lua b/gamemode/engine/derma/lib/cl_menu_pages.lua index 356ccb3..1de59b4 100644 --- a/gamemode/engine/derma/lib/cl_menu_pages.lua +++ b/gamemode/engine/derma/lib/cl_menu_pages.lua @@ -37,7 +37,10 @@ function page.New( parent, args ) close:SetText( args.CloseButtonText || "Close" ) close:SetTextColor( args.CloseButtonTextColor || Color( 0, 0, 0, 255 ) ) close:SetFont( args.CloseButtonFont || "q_text" ) - close:SetSize( args.closeW, args.closeH ) + --close:SetSize( args.closeW, args.closeH ) + close:SizeToContents() + local closeW, closeH = close:GetSize() + close:SetSize( closeW + padding*2, closeH ) close:SetPos( args.closeX, args.closeY ) close.DoClick = function() p:Remove() end close.Paint = args.CloseButtonPaint || function( self, w, h ) diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index 33db1b0..9f78350 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -18,18 +18,68 @@ local padding = 10 * resScale local pages = { charSelect = function( parent ) local args = { - CloseButtonText = "Back", - CloseButtonFont = "q_text", + CloseButtonText = "Quit", + CloseButtonFont = "q_text2", } local p, c = page.New( parent, args ) local clist = vgui.Create( "DPanel", p ) - clist:SetSize( 200 * resScale, sh - padding*10 ) + clist:SetSize( 380 * resScale, sh - padding*15 ) clist.w, clist.h = clist:GetSize() - clist:SetPos( (sw - clist.w) - padding*2, sh/2 - clist.h/2 ) + clist:SetPos( (sw - clist.w) - padding*2, padding*5 ) + clist.x, clist.y = clist:GetPos() clist.Paint = function( self, w, h ) - surface.SetDrawColor( 0, 0, 0, 200 ) - surface.DrawRect( 0, 0, w, h ) + draw.RoundedBox( 6, 0, 0, w, h, Color( 0, 0, 0, 200 ) ) + end + + --- Close/quit button stuff --- + local cW, cH = c:GetSize() + c:SetPos( clist.x, clist.y + clist.h + cH ) + c.DoClick = function() parent:Close() end + --- + + local header = vgui.Create( "DLabel", p ) + header:SetText( "Characters" ) + header:SetFont( "q_header" ) + header:SizeToContents() + local headerW, headerH = header:GetSize() + header:SetPos( (clist.x + headerW/2) - padding, (clist.y - headerH) + padding/2 ) + header:SetTextColor( Color( 255, 255, 255, 255 ) ) + header.Paint = function( self, w, h ) end + + local chars = { + {name="Vernull", lvl=81}, + {name="Devoe", lvl=22}, + {name="Leeroy", lvl=2}, + } + local cpanels = {} + for k, v in pairs( chars ) do + cpanels[k] = vgui.Create( "DButton", clist ) + cpanels[k]:SetText( "" ) + cpanels[k]:SetSize( clist.w - padding, 100 * resScale ) + cpanels[k].w, cpanels[k].h = cpanels[k]:GetSize() + cpanels[k]:SetPos( padding/2, (padding/2)*k + (cpanels[k].h * (k-1)) ) + cpanels[k].Paint = function( self, w, h ) + surface.SetDrawColor( 0, 0, 0, 0 ) + surface.DrawRect( 0, 0, w, h ) + end + + local txt = vgui.Create( "DLabel", cpanels[k] ) + txt:SetText( v.name || "NAME" ) + txt:SetFont( "q_charNameText" ) + txt:SetTextColor( Color( 200, 200, 200, 220 ) ) + txt:SizeToContents() + local txtW, txtH = txt:GetSize() + txt:SetPos( padding, cpanels[k].h/2 - txtH/2 ) + local txtX, txtY = txt:GetPos() + + local lvl = vgui.Create( "DLabel", cpanels[k] ) + lvl:SetText( "Level " .. v.lvl .. " Human" ) + lvl:SetFont( "q_text2" ) + lvl:SetTextColor( Color( 180, 180, 180, 225 ) ) + lvl:SizeToContents() + local lvlW, lvlH = lvl:GetSize() + lvl:SetPos( txtX, txtY + lvlH ) end return p @@ -57,13 +107,13 @@ function menu.open( dt ) f:SetTitle( "Character Menu" ) f:SetSize( sw, sh ) f.Paint = function( self, w, h ) - surface.SetDrawColor( 0, 0, 0, 190 ) + surface.SetDrawColor( 0, 0, 0, 120 ) surface.DrawRect( 0, 0, w, h ) end f:SetDraggable( false ) f:MakePopup() - local char = pages.charCreate( f ) -- test + local charSel = pages.charSelect( f ) -- test end end