Even more character menu stuff

master
AlmTech 5 years ago
parent 188dddb558
commit 8003c42a84
  1. 8
      gamemode/engine/derma/lib/cl_menu_pages.lua
  2. 16
      gamemode/engine/derma/lib/cl_menu_theme.lua
  3. 89
      gamemode/engine/derma/menus/menu_character.lua

@ -10,6 +10,8 @@ local scale = Quantum.Client.ResolutionScale
local padding = 10 * scale local padding = 10 * scale
local padding_s = 4 * scale local padding_s = 4 * scale
local theme = Quantum.Client.Menu.GetAPI( "theme" )
function page.New( parent, args ) function page.New( parent, args )
-- check the vars -- check the vars
@ -48,11 +50,7 @@ function page.New( parent, args )
end end
close.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end close.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
close.Paint = args.CloseButtonPaint || function( self, w, h ) close.Paint = args.CloseButtonPaint || function( self, w, h )
surface.SetDrawColor( 50, 50, 50, 255 ) theme.sharpbutton( self )
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 end
return p, close return p, close
end end

@ -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 draw.RoundedBox( 4, padding_s/2, padding_s/2, w - padding_s, h - padding_s, clr ) -- inner
end 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 return theme

@ -18,12 +18,51 @@ local padding_s = 4 * resScale
local pages = { local pages = {
charSelect = function( parent ) charCreate = function( parent )
local pW, pH = parent:GetSize()
local args = { local args = {
CloseButtonText = "Quit", CloseButtonText = "Return",
CloseButtonFont = "q_text2" CloseButtonFont = "q_text",
} }
local p, c = page.New( parent, args ) 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 ) local clist = vgui.Create( "DScrollPanel", p )
clist:SetSize( 380 * resScale, sh - padding*15 ) clist:SetSize( 380 * resScale, sh - padding*15 )
@ -43,7 +82,7 @@ local pages = {
c.Paint = function( self ) theme.button( self ) end c.Paint = function( self ) theme.button( self ) end
c.DoClick = function() c.DoClick = function()
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
parent:Close() f:Close()
end end
--- ---
@ -109,54 +148,22 @@ local pages = {
-- create char button -- create char button
local cr = vgui.Create( "DButton", p ) local cr = vgui.Create( "DButton", p )
cr:SetText("Create New Character") cr:SetText("Create New Character")
cr:SetFont( "q_text2" ) cr:SetFont( "q_text" )
cr:SetTextColor( Color( 0, 0, 0, 255 ) ) cr:SetTextColor( Color( 0, 0, 0, 255 ) )
cr:SizeToContents() cr:SizeToContents()
cr.w, cr.h = cr:GetSize() 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:SetPos( clist.x + ( clist.w/2 - cr.w/2 ), clist.y + ( ( clist.h - cr.h ) - padding*2 ) )
cr.Paint = function( self ) cr.Paint = function( self )
theme.button( self ) theme.sharpbutton( self )
end end
cr.DoClick = function() cr.DoClick = function()
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
p:SetVisible( false )
local crPage = pages.charCreate( f )
end 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 ) cr.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
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
end end

Loading…
Cancel
Save