WIP Pause Menu

This commit is contained in:
Fesiug 2024-09-21 16:53:57 -04:00
parent dc3d3d815e
commit e58125205e
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
3 changed files with 161 additions and 1 deletions

View File

@ -279,7 +279,7 @@ local function OpenDebugMenu()
end end
end end
local function OpenMyTeamMenu() function OpenMyTeamMenu()
if IsValid(DebugMenu) then DebugMenu:Remove() end if IsValid(DebugMenu) then DebugMenu:Remove() end
DebugMenu = vgui.Create("DFrame") DebugMenu = vgui.Create("DFrame")
DebugMenu:SetSize( 200, 300 ) DebugMenu:SetSize( 200, 300 )

View File

@ -0,0 +1,158 @@
local COLOR_MAIN
local COLOR_DARK
local function qpaint( self, w, h )
surface.SetDrawColor( COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
draw.SimpleText( self.text, "HUD_24", w/2, 6, COLOR_MAIN, TEXT_ALIGN_CENTER )
end
local settings = {
{
name = "Camera",
items = {
{ type = TYPE_BOOL, cvar = "b-cam_fp", name = "First-person Mode" },
{ type = TYPE_NUMBER, cvar = "b-cam_f", min = -200, max = 200, name = "Camera Forward" },
{ type = TYPE_NUMBER, cvar = "b-cam_r", min = -30, max = 30, name = "Camera Right" },
{ type = TYPE_NUMBER, cvar = "b-cam_u", min = -30, max = 30, name = "Camera Up" },
{ type = TYPE_NUMBER, cvar = "b-cam_fov", min = 1, max = 140, name = "Camera FOV" },
}
},
{
name = "Gameplay",
items = {
}
},
}
local entries = {
{
name = "RESUME",
DoClick = function( self )
PauseMenu:Remove()
end,
},
{
name = "LOADOUTS",
DoClick = function( self )
PauseMenu:Remove()
end,
},
{
name = "CHANGE TEAM",
DoClick = function( self )
PauseMenu:Remove()
OpenMyTeamMenu()
end,
},
{
name = "SETTINGS",
DoClick = function( self )
if SettingsMenu and SettingsMenu:IsValid() then SettingsMenu:Remove() return end
SettingsMenu = vgui.Create("EditablePanel")
SettingsMenu:SetSize( 300, 500 )
SettingsMenu:NoClipping( true )
function SettingsMenu:Paint( w, h )
surface.SetDrawColor( COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
end
SettingsMenu:DockPadding( 10, 10, 10, 10 )
function SettingsMenu:PerformLayout( w, h )
local x, y, w, h = PauseMenu:GetBounds()
self:SetPos( x + w + 10, y )
end
local SP = SettingsMenu:Add("DScrollPanel")
SP:Dock(FILL)
for index, data in ipairs( settings ) do
local Cat = SettingsMenu:Add("DCollapsibleCategory")
Cat:SetLabel(data.name)
Cat:Dock(TOP)
SP:AddItem(Cat)
for index, data in ipairs( data.items ) do
if !data.cvarpointer then data.cvarpointer = GetConVar(data.cvar) end
if data.type == TYPE_BOOL then
local Changer = vgui.Create("DCheckBoxLabel", Cat)
Changer:Dock( TOP )
Changer:SetConVar( data.cvar )
Changer:SetText( data.name )
elseif data.type == TYPE_NUMBER then
local Changer = vgui.Create("DNumSlider", Cat)
Changer:Dock( TOP )
Changer:SetConVar( data.cvar )
Changer:SetText( data.name )
Changer:SetMin( data.min )
Changer:SetMax( data.max )
Changer:SetDecimals( 0 )
Changer:SetDefaultValue( data.cvarpointer:GetDefault() )
end
end
end
end,
},
{
name = "QUIT",
DoClick = function( self )
PauseMenu:Remove()
end,
},
}
local function StartPauseMenu()
if PauseMenu and PauseMenu:IsValid() then PauseMenu:Remove() return end
PauseMenu = vgui.Create("EditablePanel")
PauseMenu:SetSize( 300, 500 )
PauseMenu:SetPos( 100, ScrH() - 500 - 100 )
PauseMenu:MakePopup()
local p = LocalPlayer()
local myteam = p:Team()
local MP = BennyGame:GetType() == BG_GTYPE_MP
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
CURRCHAR = TEAMS[myteam].factionid
end
COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
function PauseMenu:Paint( w, h )
surface.SetDrawColor( COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
end
PauseMenu:DockPadding( 10, 10, 10, 10 )
function PauseMenu:OnRemove()
if SettingsMenu and SettingsMenu:IsValid() then SettingsMenu:Remove() end
end
for index, data in ipairs( entries ) do
local button = PauseMenu:Add("DButton")
button:Dock(TOP)
button:DockMargin( 0, 0, 0, 10 )
button:SetText( "" )
button:SetTall( 32 )
button.text = data.name
button.Paint = qpaint
button.DoClick = data.DoClick
end
end
function GM:OnPauseMenuShow()
StartPauseMenu()
return false
end

View File

@ -58,6 +58,8 @@ AC("gamestate.lua")
IN("gamestate.lua") IN("gamestate.lua")
AC("teams.lua") AC("teams.lua")
IN("teams.lua") IN("teams.lua")
AC("pausemenu.lua")
IN("pausemenu.lua")
AC("debugmenu.lua") AC("debugmenu.lua")
IN("debugmenu.lua") IN("debugmenu.lua")