Finished 'page' API for menus

master
AlmTech 5 years ago
parent acc5b071a6
commit c39250e5e4
  1. 2
      gamemode/cl_init.lua
  2. 8
      gamemode/engine/core/client/cl_fonts.lua
  3. 4
      gamemode/engine/core/client/cl_hud.lua
  4. 2
      gamemode/engine/derma/cl_menu.lua
  5. 41
      gamemode/engine/derma/lib/cl_menu_pages.lua
  6. 52
      gamemode/engine/derma/menus/menu_character.lua

@ -8,7 +8,7 @@
if CLIENT then if CLIENT then
include( "shared.lua" ) include( "shared.lua" )
Quantum.Client = {} Quantum.Client = {}
Quantum.Client.ResolutionScale = ScrW() / 1080 Quantum.Client.ResolutionScale = ScrH() / 1080
local function loadCoreFiles() local function loadCoreFiles()
local fol = GM.FolderName .. "/gamemode/engine/core/" local fol = GM.FolderName .. "/gamemode/engine/core/"

@ -7,7 +7,13 @@
surface.CreateFont( "q_HUD", { surface.CreateFont( "q_HUD", {
font = "Arial", font = "Arial",
size = 15 * Quantum.Client.ResolutionScale, size = 38 * Quantum.Client.ResolutionScale,
antialias = true, antialias = true,
outline = true outline = true
})
surface.CreateFont( "q_text", {
font = "Arial",
size = 22 * Quantum.Client.ResolutionScale,
antialias = true
}) })

@ -15,9 +15,9 @@ hook.Add( "HUDShouldDraw", "Quantum_RemoveDefualtHUD", function( hudid )
end) end)
local scale = Quantum.Client.ResolutionScale local scale = Quantum.Client.ResolutionScale
local barW, barH = 250 * scale, 10 * scale local barW, barH = 400 * scale, 25 * scale
local radius = 1 * scale local radius = 1 * scale
local padding = 2 * scale local padding = 5 * scale
local sw, sh = ScrW(), ScrH() local sw, sh = ScrW(), ScrH()
function GM:HUDPaint() function GM:HUDPaint()

@ -8,7 +8,7 @@
Quantum.Client.Menu = {} Quantum.Client.Menu = {}
local libs = { 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" ["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_pages.lua"
} }
Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end

@ -7,16 +7,22 @@
local page = {} local page = {}
local scale = Quantum.Client.ResolutionScale local scale = Quantum.Client.ResolutionScale
local padding = 10 * scale
function page.New( args ) local padding_s = 4 * scale
args.w, args.h = args.w, args.h || ScrW(), ScrH() function page.New( parent, args )
args.x, args.y = args.x, args.y || 0, 0
-- check the vars
args.closeW, args.closeH = args.closeW, args.closeH || 50 * scale, 20 * scale args.w, args.h = parent:GetSize()
args.closeX, args.closeY = args.closeX, args.closeY || args.closeW, args.closeH args.x, args.y = 0, 0
local p = vgui.Create( "DPanel", args.parent ) args.closeW = args.closeW || 90 * scale
args.closeH = args.closeH || 20 * scale
args.closeX = args.closeX || padding
args.closeY = args.closeY || padding
--
local p = vgui.Create( "DPanel", parent )
p.w, p.h = args.w, args.h p.w, p.h = args.w, args.h
p.x, p.y = args.x, args.y p.x, p.y = args.x, args.y
@ -28,15 +34,20 @@ function page.New( args )
p.OnClose = args.OnClose || function() end p.OnClose = args.OnClose || function() end
local close = vgui.Create( "DButton", p ) local close = vgui.Create( "DButton", p )
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:SetPos( args.closeX, args.closeY ) close:SetPos( args.closeX, args.closeY )
close.DoClick = function() p:Close() end close.DoClick = function() p:Remove() end
close.Paint = args.CloseButtonPaint || function( self, w, h ) close.Paint = args.CloseButtonPaint || function( self, w, h )
surface.SetDrawColor( 255, 60, 60, 255 ) surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
end
return p surface.SetDrawColor( 235, 64, 52, 255 )
surface.DrawRect( padding_s/2, padding_s/2, w - padding_s/2, h - padding_s/2 )
end
return p, close
end end
return page return page

@ -11,17 +11,17 @@ local net = Quantum.Client.Menu.GetAPI( "net" )
local page = Quantum.Client.Menu.GetAPI( "page" ) local page = Quantum.Client.Menu.GetAPI( "page" )
local resScale = Quantum.Client.ResolutionScale local resScale = Quantum.Client.ResolutionScale
local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
local pages = { local pages = {
charSelect = function() charSelect = function( parent )
local args = { local args = {
CloseButtonPaint = function( self, w, h ) CloseButtonText = "Back",
surface.SetDrawColor( 100, 100, 100, 255 ) CloseButtonFont = "q_text",
surface.DrawRect( 0, 0, w, h )
end,
OnClose = function() print("close test") end
} }
local p = page.New( args ) local p, c = page.New( parent, args )
local clist = vgui.Create( "DPanel", p ) local clist = vgui.Create( "DPanel", p )
clist:SetSize( 200 * resScale, sh - padding*10 ) clist:SetSize( 200 * resScale, sh - padding*10 )
@ -32,13 +32,26 @@ local pages = {
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
end 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 return p
end end
} }
function menu.open( dt ) function menu.open( dt )
local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
if( !f ) then if( !f ) then
local f = vgui.Create( "DFrame" ) local f = vgui.Create( "DFrame" )
f:SetTitle( "Character Menu" ) f:SetTitle( "Character Menu" )
@ -47,27 +60,10 @@ function menu.open( dt )
surface.SetDrawColor( 0, 0, 0, 190 ) surface.SetDrawColor( 0, 0, 0, 190 )
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
end end
f:IsDraggable( false )
f:MakePopup() f:MakePopup()
pages.charSelect() -- test local char = pages.charCreate( f ) -- test
-- local txt = vgui.Create( "DTextEntry", f )
-- txt:SetText( "Enter name here" )
-- txt:SetSize( 250, 25 )
-- local txtW, txtH = txt:GetSize()
-- txt:SetPos( sw/2 - txtW/2, sh/2 - txtH/2 )
-- local txtX, txtY = txt:GetPos()
-- local b = vgui.Create( "DButton", f )
-- b:SetText( "Create Char" )
-- b:SizeToContents()
-- local bW, bH = b:GetSize()
-- b:SetPos( sw/2 - bW/2, txtY - bH )
-- b.DoClick = function()
-- net.RunNetworkedFunc( "createChar", { name = txt:GetValue() } )
-- end
end end
end end

Loading…
Cancel
Save