FP can have different FOV for VM, debug spawner has preferred order

This commit is contained in:
Fesiug 2024-09-21 23:44:54 -04:00
parent a7825e495a
commit 32d7bee0ec
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
3 changed files with 65 additions and 11 deletions

View File

@ -9,6 +9,7 @@ local cam_u = CreateConVar( "b-cam_u", 12 )
local cam_fov = CreateConVar( "b-cam_fov", 75 )
local cam_fp = CreateConVar( "b-cam_fp", 0 )
local cam_fp_fov = CreateConVar( "b-cam_fp_fov", 75 )
local lastfp
local m = 3
@ -35,6 +36,43 @@ function CamSpot( ang, pos )
return tr.HitPos
end
function Convert( fovDegrees, ratio )
local halfAngleRadians = fovDegrees * ( 0.5 * math.pi / 180 )
local t = math.tan( halfAngleRadians )
t = t * ratio
local retDegrees = ( 180 / math.pi ) * math.atan( t )
return retDegrees * 2
end
function QConvert( fovDegrees )
return Convert( fovDegrees, (3/4)/(ScrH()/ScrW()) )
end
function GM:PreDrawViewModels()
local fp = cam_fp:GetBool()
if fp then
cam.Start3D( nil, nil, QConvert( cam_fp_fov:GetFloat() ) )
cam.IgnoreZ( true )
local p = LocalPlayer()
p.IWantDraw = true
p:DrawModel()
local w = p:HandlerCheck()
if w:GetActiveR():IsValid() then
w:GetActiveR():DrawModel()
end
p.IWantDraw = false
cam.IgnoreZ( false )
cam.End3D()
end
end
function GM:PrePlayerDraw( ply, flags )
local fp = cam_fp:GetBool()
if fp and ply == LocalPlayer() and !ply.IWantDraw then
return true
end
end
function GM:CalcView( ply, pos, ang, fov )
local view = {
origin = CamSpot(TPSOverride), -- pos includes the smoothstair offset which looks stupid here

View File

@ -60,6 +60,7 @@ local function painterly( self, w, h )
return true
end
local preferredcategoryorder = { "pistol", "smg", "assaultrifle", "machinegun", "shotgun", "utility" }
local function OpenDebugMenu()
if IsValid(DebugMenu) then DebugMenu:Remove() end
@ -253,6 +254,19 @@ local function OpenDebugMenu()
local categories = {}
-- preferred order
for index, category in SortedPairs( preferredcategoryorder ) do
if category == "base" then continue end
if !categories[category] then
local cate = opt:Add("DCollapsibleCategory")
cate:Dock(TOP)
cate:SetLabel(category)
local plist = vgui.Create("DPanelList")
cate:SetContents(plist)
categories[category] = plist
end
end
for iname, idata in SortedPairs( ITEMS ) do
if idata.Category == "base" then continue end
if !categories[idata.Category] then
@ -338,7 +352,7 @@ local function recursebones( ent, O_id, level )
local gap = ""
for i=1, level do gap = gap .. " " end
for index, id in ipairs( ent:GetChildBones( O_id ) ) do
chat.AddText( gap, c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) )
MsgC( gap, c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) .. "\n" )
recursebones( ent, id, level+1 )
end
end
@ -349,7 +363,7 @@ function printallbones( ent )
for id=0, ent:GetBoneCount()-1 do
if ent:GetBoneName(id) == "__INVALIDBONE__" then continue end
if ent:GetBoneParent(id) != -1 then continue end
chat.AddText( gap, c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) )
MsgC( c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) .. "\n" )
recursebones( ent, id, 1 )
end
end

View File

@ -7,18 +7,19 @@ local function qpaint( self, 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 )
draw.SimpleText( self.text, "HUD_36", w/2, 4, 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" },
{ type = TYPE_NUMBER, cvar = "b-cam_fov", min = 30, max = 120, name = "Camera FOV" },
{ type = TYPE_BOOL, cvar = "b-cam_fp", name = "First-person Mode" },
{ type = TYPE_NUMBER, cvar = "b-cam_fp_fov", min = 30, max = 120, name = "FP weapon FOV" },
}
},
{
@ -111,9 +112,10 @@ 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:SetSize( 300, 300 )
PauseMenu:SetPos( ScrW()/2 - 300 - 5, ScrH()/2 - 300/2 )
PauseMenu:MakePopup()
PauseMenu:SetKeyboardInputEnabled( true )
local p = LocalPlayer()
local myteam = p:Team()
@ -145,7 +147,7 @@ local function StartPauseMenu()
button:Dock(TOP)
button:DockMargin( 0, 0, 0, 10 )
button:SetText( "" )
button:SetTall( 32 )
button:SetTall( 40 )
button.text = data.name
button.Paint = qpaint
button.DoClick = data.DoClick