Settings, "X overrides Primary Attack" settings...

This commit is contained in:
Fesiug 2023-12-06 01:04:00 -05:00
parent 5ea4634429
commit d52abef64a
3 changed files with 63 additions and 29 deletions

View File

@ -54,7 +54,19 @@ function SWEP:D_SetClip( hand, value )
end
function SWEP:C_DualCheck()
return self:BTable( true )--self:BTable( false ) and self:BTable( true ) and self:BClass( false ).Features == "firearm" and self:BClass( true ).Features == "firearm"
local p = self:GetOwner()
local lt = self:BTable( true )
if lt then
if lt.Features == "firearm" then
return p:GetInfoNum( "benny_wep_ao_firearms", 1 )==1
elseif lt.Features == "grenade" then
return p:GetInfoNum( "benny_wep_ao_grenades", 0 )==1
else
return p:GetInfoNum( "benny_wep_ao_junk", 0 )==1
end
else
return false
end
end
function SWEP:C_AttackDown( hand )

View File

@ -48,6 +48,9 @@ CONVARS_CL["hud_enable_active"] = { 1, nil, nil, false, true, "Draw Active
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_ao_firearms"] = { 1, 0, 1, true, true, "Whether offhand firearms overrides primary attack." }
CONVARS_CL["wep_ao_grenades"] = { 0, 0, 1, true, true, "Whether offhand grenades overrides primary attack." }
CONVARS_CL["wep_ao_junk"] = { 0, 0, 1, true, true, "Whether offhand junk overrides primary attack." }
CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." }

View File

@ -4,14 +4,53 @@
-- 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 },
{ 0, "benny_hud_enable_health", "Health", },
{ 0, "benny_hud_enable_active", "Active Weapon", },
{ 0, "benny_hud_enable_hints", "Hints", },
{ 0, "benny_hud_enable_hotbar", "Hotbar", },
{ 1, "benny_hud_scale", "Scale", 1, 4, 0 },
},
[2] = {
{ 0, "benny_wep_ao_firearms", "Firearms Override Primary Attack" },
{ 2, "Pressing Left Mouse will shoot an offhand firearm." },
{ 0, "benny_wep_ao_grenades", "Grenades Override Primary Attack" },
{ 2, "Pressing Left Mouse will throw an offhand grenade." },
{ 0, "benny_wep_ao_junk", "Junk Override Primary Attack" },
{ 2, "Pressing Left Mouse will throw offhand junk." },
},
}
local function genpan( Base, Sect, Num )
local Scroll = Base:Add("DPanel")
Scroll:DockPadding( 10, 5, 10, 5 )
Scroll.Paint = function() end
Sect:SetContents( Scroll )
for i, v in ipairs( conf[Num] ) do
if v[1] == 0 then
local Butt = Scroll:Add("DCheckBoxLabel")
Butt:Dock(TOP)
Butt:DockMargin( 0, 2, 0, 2 )
Butt:SetText( v[3] )
Butt:SetConVar( v[2] )
elseif v[1] == 1 then
local Butt = Scroll:Add("DNumSlider")
Butt:Dock(TOP)
Butt:DockMargin( 0, 2, 0, 2 )
Butt:SetText( v[3] )
Butt:SetConVar( v[2] )
Butt:SetMin( v[4] )
Butt:SetMax( v[5] )
Butt:SetDecimals( v[6] )
elseif v[1] == 2 then
local Butt = Scroll:Add("DLabel")
Butt:Dock(TOP)
Butt:DockMargin( 40, -5, 0, 0 )
Butt:SetText( v[2] )
end
end
end
function OpenSettingsMenu()
local Base = vgui.Create("DFrame")
Base:SetTitle("Settings")
@ -24,35 +63,15 @@ function OpenSettingsMenu()
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
genpan( Base, Sect, 1 )
end
do -- Sect 2
local Sect = Base:Add("DCollapsibleCategory")
Sect:Dock(TOP)
Sect:SetLabel("Controls")
genpan( Base, Sect, 2 )
end
do -- Sect 3