Settings panel, HUD enable stuff

This commit is contained in:
Fesiug 2023-12-04 18:20:18 -05:00
parent a9834f5be8
commit 2aa8694014
5 changed files with 97 additions and 26 deletions

View File

@ -42,6 +42,11 @@ CONVARS_CL = {}
CONVARS_CL["hud_scale"] = { 2, 1, 4, false, true, "HUD integer scaling" } CONVARS_CL["hud_scale"] = { 2, 1, 4, false, true, "HUD integer scaling" }
CONVARS_CL["hud_tempactive"] = { "benny", nil, nil, false, true, "HUD color scheme temporary" } CONVARS_CL["hud_tempactive"] = { "benny", nil, nil, false, true, "HUD color scheme temporary" }
CONVARS_CL["hud_enable_health"] = { 1, nil, nil, false, true, "Draw Health panel" }
CONVARS_CL["hud_enable_hotbar"] = { 1, nil, nil, false, true, "Draw Hotbar panel" }
CONVARS_CL["hud_enable_active"] = { 1, nil, nil, false, true, "Draw Active Weapons panel" }
CONVARS_CL["hud_enable_hints"] = { 1, nil, nil, false, true, "Draw Hints panel" }
CONVARS_CL["wep_toggleaim"] = { 1, 0, 1, true, true, "Hold or toggle to aim weapon." } CONVARS_CL["wep_toggleaim"] = { 1, 0, 1, true, true, "Hold or toggle to aim weapon." }
CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." } CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." }

View File

@ -1,2 +1,63 @@
-- Settings panel -- Settings panel
-- 0 = checkbox, 1 = slider, 2 = string
local conf = {
[1] = {
{ "benny_hud_enable_health", "Health", 0 },
{ "benny_hud_enable_active", "Active Weapon", 0 },
{ "benny_hud_enable_hints", "Hints", 0 },
{ "benny_hud_enable_hotbar", "Hotbar", 0 },
{ "benny_hud_scale", "Scale", 1, 1, 4, 0 },
},
}
function OpenSettingsMenu()
local Base = vgui.Create("DFrame")
Base:SetTitle("Settings")
Base:SetSize( 800, 600 )
Base:Center()
Base:MakePopup()
do -- Sect 1
local Sect = Base:Add("DCollapsibleCategory")
Sect:Dock(TOP)
Sect:SetLabel("Preferences")
local Scroll = Base:Add("DPanel")
Scroll:DockPadding( 10, 5, 10, 5 )
Scroll.Paint = function() end
Sect:SetContents( Scroll )
for i, v in ipairs( conf[1] ) do
if v[3] == 0 then
local Butt = Scroll:Add("DCheckBoxLabel")
Butt:Dock(TOP)
Butt:DockMargin( 0, 2, 0, 2 )
Butt:SetText( v[2] )
Butt:SetConVar( v[1] )
elseif v[3] == 1 then
local Butt = Scroll:Add("DNumSlider")
Butt:Dock(TOP)
Butt:DockMargin( 0, 2, 0, 2 )
Butt:SetText( v[2] )
Butt:SetConVar( v[1] )
Butt:SetMin( v[4] )
Butt:SetMax( v[5] )
Butt:SetDecimals( v[6] )
end
end
end
do -- Sect 2
local Sect = Base:Add("DCollapsibleCategory")
Sect:Dock(TOP)
Sect:SetLabel("Controls")
end
do -- Sect 3
local Sect = Base:Add("DCollapsibleCategory")
Sect:Dock(TOP)
Sect:SetLabel("HUD")
end
end

View File

@ -1,2 +1,6 @@
-- Singleplayer score panel -- Singleplayer score panel
function OpenScorePanel()
end

View File

@ -272,7 +272,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local active = GetConVar("benny_hud_tempactive"):GetString() local active = GetConVar("benny_hud_tempactive"):GetString()
local scheme = schemes[active] local scheme = schemes[active]
do -- Health if ConVarCL_Bool("hud_enable_health") then -- Health
local b_w, b_h = ss(142), ss(32) local b_w, b_h = ss(142), ss(32)
local b_bh = ss(14) local b_bh = ss(14)
local b_bh2 = ss(8) local b_bh2 = ss(8)
@ -337,7 +337,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end end
end end
if true then -- Hints if ConVarCL_Bool("hud_enable_hints") then -- Hints
local b_w, b_h = ss(130), ss(0) local b_w, b_h = ss(130), ss(0)
local b_x, b_y = sw - Wb - b_w, Hb + ss(200)--sh/2 - b_h/2 local b_x, b_y = sw - Wb - b_w, Hb + ss(200)--sh/2 - b_h/2
@ -410,7 +410,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end end
end end
if wep then -- Weapon
if wep and ConVarCL_Bool("hud_enable_active") then -- Weapon
local inv = p:INV_Get() local inv = p:INV_Get()
local wep1 = wep:BTable( false ) local wep1 = wep:BTable( false )
local wep1c = wep:BClass( false ) local wep1c = wep:BClass( false )
@ -705,7 +706,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end end
end end
if wep then -- Newinv
if wep and ConVarCL_Bool("hud_enable_hotbar") then -- Newinv
local weighted = p:INV_Weight() local weighted = p:INV_Weight()
local inv = p:INV_Get() local inv = p:INV_Get()
local iflip = table.Flip( p:INV_Get()) local iflip = table.Flip( p:INV_Get())

View File

@ -168,26 +168,25 @@ hook.Add( "PlayerDeathSound", "Benny_PlayerDeathSound", function( ply )
return true -- we don't want the default sound! return true -- we don't want the default sound!
end ) end )
function GM:ShowHelp( ply ) if CLIENT then
if SERVER then hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Dev", function( ply, button )
ply:SendLua( [[OpenSMenu()]] ) local wep = ply:BennyCheck()
end
end
function GM:ShowTeam( ply ) if button == KEY_F1 then
if SERVER then OpenSettingsMenu()
ply:SendLua( [[OpenDeadeye()]] ) elseif button == KEY_F2 then
end OpenScorePanel()
end elseif button == KEY_F3 then
OpenSMenu()
function GM:ShowSpare1( ply ) elseif button == KEY_F4 then
if SERVER then OpenDeadeye()
ply:ConCommand( "benny_gui_settings" ) elseif button == KEY_F5 then
end elseif button == KEY_F6 then
end elseif button == KEY_F7 then
elseif button == KEY_F8 then
function GM:ShowSpare2( ply ) elseif button == KEY_F9 then
if SERVER then elseif button == KEY_F11 then
ply:ConCommand( "benny_gui_spscore" ) elseif button == KEY_F12 then
end end
end)
end end