From 2aa8694014de31f17f5dbc3bf153931edf0caec1 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Mon, 4 Dec 2023 18:20:18 -0500 Subject: [PATCH] Settings panel, HUD enable stuff --- .../gamemode/modules/commons/sh_convars.lua | 5 ++ .../gamemode/modules/gui/cl_settings.lua | 63 ++++++++++++++++++- .../benny/gamemode/modules/gui/cl_spscore.lua | 6 +- .../benny/gamemode/modules/player/cl_hud.lua | 10 +-- .../gamemode/modules/player/sh_basic.lua | 39 ++++++------ 5 files changed, 97 insertions(+), 26 deletions(-) diff --git a/gamemodes/benny/gamemode/modules/commons/sh_convars.lua b/gamemodes/benny/gamemode/modules/commons/sh_convars.lua index 7e99728..e422b86 100644 --- a/gamemodes/benny/gamemode/modules/commons/sh_convars.lua +++ b/gamemodes/benny/gamemode/modules/commons/sh_convars.lua @@ -42,6 +42,11 @@ CONVARS_CL = {} 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_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_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." } diff --git a/gamemodes/benny/gamemode/modules/gui/cl_settings.lua b/gamemodes/benny/gamemode/modules/gui/cl_settings.lua index 842910b..8a93779 100644 --- a/gamemodes/benny/gamemode/modules/gui/cl_settings.lua +++ b/gamemodes/benny/gamemode/modules/gui/cl_settings.lua @@ -1,2 +1,63 @@ --- Settings panel \ No newline at end of file +-- 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 \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/gui/cl_spscore.lua b/gamemodes/benny/gamemode/modules/gui/cl_spscore.lua index 33c600f..220dab2 100644 --- a/gamemodes/benny/gamemode/modules/gui/cl_spscore.lua +++ b/gamemodes/benny/gamemode/modules/gui/cl_spscore.lua @@ -1,2 +1,6 @@ --- Singleplayer score panel \ No newline at end of file +-- Singleplayer score panel + +function OpenScorePanel() + +end \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index e5b4634..a4c6eb2 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -272,7 +272,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() local active = GetConVar("benny_hud_tempactive"):GetString() 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_bh = ss(14) local b_bh2 = ss(8) @@ -337,7 +337,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() 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_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 - if wep then -- Weapon + + if wep and ConVarCL_Bool("hud_enable_active") then -- Weapon local inv = p:INV_Get() local wep1 = wep:BTable( false ) local wep1c = wep:BClass( false ) @@ -705,7 +706,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() end end - if wep then -- Newinv + + if wep and ConVarCL_Bool("hud_enable_hotbar") then -- Newinv local weighted = p:INV_Weight() local inv = p:INV_Get() local iflip = table.Flip( p:INV_Get()) diff --git a/gamemodes/benny/gamemode/modules/player/sh_basic.lua b/gamemodes/benny/gamemode/modules/player/sh_basic.lua index a57f107..d8feca4 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_basic.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_basic.lua @@ -168,26 +168,25 @@ hook.Add( "PlayerDeathSound", "Benny_PlayerDeathSound", function( ply ) return true -- we don't want the default sound! end ) -function GM:ShowHelp( ply ) - if SERVER then - ply:SendLua( [[OpenSMenu()]] ) - end -end +if CLIENT then +hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Dev", function( ply, button ) + local wep = ply:BennyCheck() -function GM:ShowTeam( ply ) - if SERVER then - ply:SendLua( [[OpenDeadeye()]] ) - end -end - -function GM:ShowSpare1( ply ) - if SERVER then - ply:ConCommand( "benny_gui_settings" ) - end -end - -function GM:ShowSpare2( ply ) - if SERVER then - ply:ConCommand( "benny_gui_spscore" ) + if button == KEY_F1 then + OpenSettingsMenu() + elseif button == KEY_F2 then + OpenScorePanel() + elseif button == KEY_F3 then + OpenSMenu() + elseif button == KEY_F4 then + OpenDeadeye() + elseif button == KEY_F5 then + elseif button == KEY_F6 then + elseif button == KEY_F7 then + elseif button == KEY_F8 then + elseif button == KEY_F9 then + elseif button == KEY_F11 then + elseif button == KEY_F12 then end +end) end \ No newline at end of file