From 8003c42a84ee97a7f02eb0b8543815acd721285e Mon Sep 17 00:00:00 2001 From: AlmTech Date: Thu, 3 Oct 2019 15:24:15 +0200 Subject: [PATCH] Even more character menu stuff --- gamemode/engine/derma/lib/cl_menu_pages.lua | 8 +- gamemode/engine/derma/lib/cl_menu_theme.lua | 16 ++++ .../engine/derma/menus/menu_character.lua | 89 ++++++++++--------- 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/gamemode/engine/derma/lib/cl_menu_pages.lua b/gamemode/engine/derma/lib/cl_menu_pages.lua index 058a0eb..9826f76 100644 --- a/gamemode/engine/derma/lib/cl_menu_pages.lua +++ b/gamemode/engine/derma/lib/cl_menu_pages.lua @@ -10,6 +10,8 @@ local scale = Quantum.Client.ResolutionScale local padding = 10 * scale local padding_s = 4 * scale +local theme = Quantum.Client.Menu.GetAPI( "theme" ) + function page.New( parent, args ) -- check the vars @@ -48,11 +50,7 @@ function page.New( parent, args ) end close.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end close.Paint = args.CloseButtonPaint || function( self, w, h ) - surface.SetDrawColor( 50, 50, 50, 255 ) - surface.DrawRect( 0, 0, w, h ) - - surface.SetDrawColor( 235, 64, 52, 255 ) - surface.DrawRect( padding_s/2, padding_s/2, w - padding_s/2, h - padding_s/2 ) + theme.sharpbutton( self ) end return p, close end diff --git a/gamemode/engine/derma/lib/cl_menu_theme.lua b/gamemode/engine/derma/lib/cl_menu_theme.lua index 81b563c..98e24fd 100644 --- a/gamemode/engine/derma/lib/cl_menu_theme.lua +++ b/gamemode/engine/derma/lib/cl_menu_theme.lua @@ -58,4 +58,20 @@ function theme.button( b, color ) draw.RoundedBox( 4, padding_s/2, padding_s/2, w - padding_s, h - padding_s, clr ) -- inner end +function theme.sharpbutton( b ) + local w, h = b:GetSize() + + if( b:IsHovered() ) then + surface.SetDrawColor( 205, 205, 205, 255 ) + else + surface.SetDrawColor( 50, 50, 50, 255 ) + end + + + surface.DrawRect( 0, 0, w, h ) + + surface.SetDrawColor( 235, 64, 52, 255 ) + surface.DrawRect( padding_s/2, padding_s/2, w - padding_s/2, h - padding_s/2 ) +end + return theme \ 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 c46b6be..e2a6de3 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -18,12 +18,51 @@ local padding_s = 4 * resScale local pages = { - charSelect = function( parent ) + charCreate = function( parent ) + local pW, pH = parent:GetSize() local args = { - CloseButtonText = "Quit", - CloseButtonFont = "q_text2" + CloseButtonText = "Return", + CloseButtonFont = "q_text", } local p, c = page.New( parent, args ) + p:SetVisible( true ) + + c:SetSize( 85 * resScale, 25 * resScale ) + local closeW, closeH = c:GetSize() + c:SetPos( padding*4, (pH - closeH) - padding*4 ) + c.DoClick = function() + surface.PlaySound( "UI/buttonclick.wav" ) + parent.page:SetVisible( true ) + p:Remove() + end + + return p, c + end +} + +function menu.open( dt ) + Quantum.Client.IsInMenu = true -- hide the hud + if( !f ) then + local f = vgui.Create( "DFrame" ) + f:SetTitle( "" ) + f:SetSize( sw, sh ) + f.Paint = function( self, w, h ) + surface.SetDrawColor( 0, 0, 0, 120 ) + surface.DrawRect( 0, 0, w, h ) + end + f:SetDraggable( false ) + f:MakePopup() + function f:OnClose() + Quantum.Client.IsInMenu = false -- show the hud when closed + end + + local args = { + CloseButtonText = "Quit", + CloseButtonFont = "q_text" + } + local p, c = page.New( f, args ) + f.page = p + f.page:SetVisible( true ) local clist = vgui.Create( "DScrollPanel", p ) clist:SetSize( 380 * resScale, sh - padding*15 ) @@ -43,7 +82,7 @@ local pages = { c.Paint = function( self ) theme.button( self ) end c.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) - parent:Close() + f:Close() end --- @@ -109,54 +148,22 @@ local pages = { -- create char button local cr = vgui.Create( "DButton", p ) cr:SetText("Create New Character") - cr:SetFont( "q_text2" ) + cr:SetFont( "q_text" ) cr:SetTextColor( Color( 0, 0, 0, 255 ) ) cr:SizeToContents() cr.w, cr.h = cr:GetSize() cr:SetPos( clist.x + ( clist.w/2 - cr.w/2 ), clist.y + ( ( clist.h - cr.h ) - padding*2 ) ) cr.Paint = function( self ) - theme.button( self ) + theme.sharpbutton( self ) end cr.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) + p:SetVisible( false ) + local crPage = pages.charCreate( f ) end + cr.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end - return p - end, - charCreate = function( parent ) - local pW, pH = parent:GetSize() - local args = { - CloseButtonText = "Return", - CloseButtonFont = "q_text", - } - local p, c = page.New( parent, args ) - - c:SetSize( 85 * resScale, 25 * resScale ) - local closeW, closeH = c:GetSize() - c:SetPos( padding*4, (pH - closeH) - padding*4 ) - - return p - end -} - -function menu.open( dt ) - Quantum.Client.IsInMenu = true -- hide the hud - if( !f ) then - local f = vgui.Create( "DFrame" ) - f:SetTitle( "Character Menu" ) - f:SetSize( sw, sh ) - f.Paint = function( self, w, h ) - surface.SetDrawColor( 0, 0, 0, 120 ) - surface.DrawRect( 0, 0, w, h ) - end - f:SetDraggable( false ) - f:MakePopup() - function f:OnClose() - Quantum.Client.IsInMenu = false -- show the hud when closed - end - - local charSel = pages.charSelect( f ) -- test end end