Quantum is a Garry's Mod RPG framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
quantum/gamemode/engine/derma/menus/menu_character.lua

120 lines
4.0 KiB

-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local menu = {}
local net = Quantum.Client.Menu.GetAPI( "net" )
local page = Quantum.Client.Menu.GetAPI( "page" )
local resScale = Quantum.Client.ResolutionScale
local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
local pages = {
charSelect = function( parent )
local args = {
CloseButtonText = "Quit",
CloseButtonFont = "q_text2",
}
local p, c = page.New( parent, args )
local clist = vgui.Create( "DPanel", p )
clist:SetSize( 380 * resScale, sh - padding*15 )
clist.w, clist.h = clist:GetSize()
clist:SetPos( (sw - clist.w) - padding*2, padding*5 )
clist.x, clist.y = clist:GetPos()
clist.Paint = function( self, 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
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 )
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
5 years ago
f:SetDraggable( false )
f:MakePopup()
local charSel = pages.charSelect( f ) -- test
end
end
return menu