Залив

This commit is contained in:
Refosel
2026-03-30 10:39:52 +03:00
commit 2b57c019cb
2010 changed files with 185745 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
AddCSLuaFile()
require("mw_utils")
require("mw_math")
function SWEP:CalcView(ply, pos, ang, fov)
--do vm first
local vm = self:GetViewModel()
if (IsValid(vm) && GetConVar("mgbase_debug_vmrender"):GetInt() >= 1) then
local vpos, vang = Vector(pos), Angle(ang)
if (GetConVar("mgbase_debug_freeview"):GetInt() <= 0) then
vm:CalcViewModelView(vpos, vang)
vm:SetRenderOrigin(vpos)
vm:SetRenderAngles(vang)
end
vm:CalcView(pos, ang)
vm:SetNoDraw(false)
end
ang.p = math.Clamp(ang.p, -89, 89)
local rpm = math.Clamp(self.Primary.RPM / 10, 55, 90)
local rate = 60 / (rpm * 10)
rate = 20 - (rate * 100)
self.Camera.Shake = mw_math.SafeLerp(rate * FrameTime(), self.Camera.Shake, 0)
local pitch = (math.cos(CurTime() * rpm) * (self.Camera.Shake * 0.5)) * mw_math.SafeLerp(self:GetAimDelta(), 1, 0.4)
local recoilAndShakeAngles = Angle(pitch, 0, math.sin(CurTime() * rpm))
recoilAndShakeAngles:Mul(self.Camera.Shake * (Lerp(self:GetAimDelta(), 1, self.Recoil.AdsShakeMultiplier || 1)))
ang:Add(recoilAndShakeAngles)
local vpAngles = self:GetOwner():GetViewPunchAngles()
vpAngles:Mul(mw_math.SafeLerp(self:GetAimDelta(), 0.5, 0.01))
ang:Sub(vpAngles)
--breathing
self.Camera.LerpBreathing = self.Camera.LerpBreathing || Angle()
mw_math.SafeLerpAngle(10 * FrameTime(), self.Camera.LerpBreathing, self:GetBreathingSwayAngle())
if (GetConVar("mgbase_debug_disablebreathing"):GetInt() <= 0) then
ang:Add(self.Camera.LerpBreathing)
end
--end breathing
mw_math.VectorAddAndMul(pos, ang:Forward(), -self.Camera.Shake)
if (self.Cone.DecreaseEveryShot != nil && self.Cone.MinDecreaseEveryShot != nil) then
local mul = self:GetConeDecreaseEveryShotMultiplier()
local delta = 1 - mul
self.Camera.SprayEffect = mw_math.SafeLerp(10 * FrameTime(), self.Camera.SprayEffect, delta * 10)
end
self.Camera.Fov = mw_math.SafeLerp(20 * FrameTime(), self.Camera.Fov, self:GetAimDelta())
self.Camera.FovAimDelta = mw_math.SafeLerp(20 * FrameTime(), self.Camera.FovAimDelta || 0, self:GetAimModeDelta())
local diff = 0
if (self:HasFlag("Reloading")) then
diff = (1 - self.Zoom.FovMultiplier) * 0.05
end
self.Camera.LerpReloadFov = mw_math.SafeLerp(10 * FrameTime(), self.Camera.LerpReloadFov, diff)
local fovDeltaComp = 90 / fov
local zoom = Lerp(self.Camera.FovAimDelta, self.Zoom.FovMultiplier, 0.9)
local fovMultiplier = mw_math.SafeLerp(self.Camera.Fov * self.Camera.Fov * self.Camera.Fov, 1, (zoom + self.Camera.LerpReloadFov))
fov = (fov * fovMultiplier) + (self.Camera.Shake * 1.5)
fov = fov * Lerp(self.Camera.Fov, 1, fovDeltaComp)
fov = fov - Lerp(self.Camera.Fov, self.Camera.SprayEffect, 0)
--customization
local bCustomizing = self:HasFlag("Customizing")
self.Camera.LerpCustomization = mw_math.SafeLerp(5 * FrameTime(), self.Camera.LerpCustomization, mw_math.btn(bCustomizing))
local lerp = self.Camera.LerpCustomization
local forward = ang:Forward()
forward:Mul(lerp * -3)
pos:Add(forward)
return pos, ang, fov
end
function SWEP:PostDrawViewModel(viewmodel, player, weapon) end --ignore me

View File

@@ -0,0 +1,467 @@
AddCSLuaFile()
require("mw_math")
require("mw_utils")
if (SERVER) then
return
end
local shotgunXhairTickMaterial = Material("mg/shotgunxhairtick")
local normalXhairTickMaterial = Material("mg/normalxhairtick")
local crosshairDotMaterial = Material("mg/crosshairdot")
local function drawBinding(x, y, bind)
local key = string.upper(input.LookupBinding(bind) || MWBLTL.Get("HUD_Key_NotBound")..bind)
local scale = ScrH() / 1080
local size = 26 * scale
surface.SetFont("mgbase_command")
local w = math.max(surface.GetTextSize(key) + 10 * scale, size)
draw.RoundedBox(4, x - (w * 0.5 - 1), y - (size * 0.5 * scale - 1), w, size * scale, Color(0, 0, 0, 150))
draw.SimpleText(key, "mgbase_command", x, y, Color(255, 255, 255, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
return w * 0.5 + (5 * scale)
end
local function drawBaseBinding(x, y, bind)
local bindValue = GetConVar(bind):GetInt()
local key = string.upper(bindValue != 0 && input.GetKeyName(bindValue) || MWBLTL.Get("HUD_Key_NotBound")..bind)
local scale = ScrH() / 1080
local size = 26 * scale
surface.SetFont("mgbase_command")
local w = math.max(surface.GetTextSize(key) + 10 * scale, size)
draw.RoundedBox(4, x - (w * 0.5 - 1), y - (size * 0.5 * scale - 1), w, size * scale, Color(0, 0, 0, 150))
draw.SimpleText(key, "mgbase_command", x, y, Color(255, 255, 255, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
return w * 0.5 + (5 * scale)
end
function SWEP:DrawHUD()
if (self:GetOwner():InVehicle()) then
return
end
if (GetConVar("mgbase_debug_crosshair"):GetBool()) then
--draw.SimpleText("+", "DermaDefault", ScrW() * 0.5, ScrH() * 0.5, Color(0, 255, 0, 100), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
surface.SetDrawColor(0, 255, 0, 127)
surface.DrawLine(ScrW() * 0.5 - 50, ScrH() * 0.5, ScrW() * 0.5 + 50, ScrH() * 0.5)
surface.DrawLine(ScrW() * 0.5, ScrH() * 0.5 - 50, ScrW() * 0.5, ScrH() * 0.5 + 50)
--[[--3x
draw.SimpleText("3x", "DermaDefault", ScrW() * 0.5 - (90 * 1.44), ScrH() * 0.5 - (90 * 1.44), Color(0, 255, 0, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
surface.DrawCircle(ScrW() * 0.5, ScrH() * 0.5, 180, 0, 255, 0, 127)
--4x
draw.SimpleText("4x", "DermaDefault", ScrW() * 0.5 - (125 * 1.44), ScrH() * 0.5 - (125 * 1.44), Color(0, 255, 0, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
surface.DrawCircle(ScrW() * 0.5, ScrH() * 0.5, 250, 0, 255, 0, 127)
--10x
draw.SimpleText("10x", "DermaDefault", ScrW() * 0.5 - (165 * 1.44), ScrH() * 0.5 - (165 * 1.44), Color(0, 255, 0, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
surface.DrawCircle(ScrW() * 0.5, ScrH() * 0.5, 330, 0, 255, 0, 127)]]
local att = self:GetViewModel():GetAttachment(mw_utils.LookupAttachmentCached(self:GetViewModel(), self.ViewModelOffsets.Aim.AlignAttachment || "align"))
if (att != nil) then
local pos = att.Pos:ToScreen()
surface.SetDrawColor(255, 0, 0, 127)
surface.DrawLine(pos.x - 50, pos.y, pos.x + 50, pos.y)
surface.DrawLine(pos.x, pos.y - 50, pos.x, pos.y + 50)
draw.SimpleText(MWBLTL.Get("HUD_Debug_Text1"), "DermaDefault", ScrW() * 0.5, ScrH() * 0.75, Color(255, 50, 50, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)
draw.SimpleText(MWBLTL.Get("HUD_Debug_Text2"), "DermaDefault", ScrW() * 0.5, ScrH() * 0.75 + 30, Color(255, 50, 50, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)
end
if (self:GetSight() != nil) then
att = self:GetSight().m_Model:GetAttachment(mw_utils.LookupAttachmentCached(self:GetSight().m_Model, self:GetSight().Reticle.Attachment))
pos = att.Pos:ToScreen()
surface.SetDrawColor(0, 150, 255, 255)
surface.DrawLine(pos.x - 25, pos.y, pos.x + 25, pos.y)
surface.DrawLine(pos.x, pos.y - 25, pos.x, pos.y + 25)
if (self:GetSight().ReticleHybrid != nil) then
att = self:GetSight().m_Model:GetAttachment(mw_utils.LookupAttachmentCached(self:GetSight().m_Model, self:GetSight().ReticleHybrid.Attachment))
pos = att.Pos:ToScreen()
surface.SetDrawColor(0, 150, 255, 255)
surface.DrawLine(pos.x - 25, pos.y, pos.x + 25, pos.y)
surface.DrawLine(pos.x, pos.y - 25, pos.x, pos.y + 25)
end
end
att = self:GetViewModel():GetAttachment(mw_utils.LookupAttachmentCached(self:GetViewModel(), self.ViewModelOffsets.Aim.AlignAttachment || "align"))
if (att != nil) then
--pixel difference
local pos = (att.Pos + att.Ang:Forward() * 1000):ToScreen()
local diffX, diffY = (pos.x - (ScrW() * 0.5)), (pos.y - (ScrH() * 0.5))
local centerX, centerY = ScrW() * 0.5, ScrH() * 0.5
surface.SetDrawColor(255, 0, 255, 255)
surface.DrawLine(centerX, centerY, centerX + (diffX * 10), centerY + (diffY * 10))
draw.SimpleText(MWBLTL.Get("HUD_Debug_Text3")..math.Round(diffX, 2)..", "..math.Round(diffY, 2), "DermaDefault", ScrW() * 0.25, ScrH() * 0.25, Color(255, 0, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
draw.SimpleText(MWBLTL.Get("HUD_Debug_Text4"), "DermaDefault", ScrW() * 0.25, ScrH() * 0.25 + 20, Color(255, 0, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
end
else
if (GetConVar("mgbase_hud_xhair"):GetBool() && !self:HasFlag("Customizing")) then
self:Crosshair()
end
end
if (GetConVar("mgbase_hud_firemode"):GetBool() && !self:HasFlag("Customizing")) then
self:DrawFiremode()
end
self:DrawCommands()
end
local lastIndex = 0
local transitionAnimation = 0
function SWEP:DrawFiremode()
if (self:HasFlag("Holstering")) then
return
end
-- current firemode (outline commented out)
local x,y = ScrW() * 0.5, ScrH() * 0.8
local scale = ScrH() / 1080
if (!self:HasFlag("Lowered")) then
local index = self:GetFiremode()
transitionAnimation = math.min(transitionAnimation + 10 * RealFrameTime(), 1)
if (lastIndex != index) then
transitionAnimation = 0
lastIndex = index
end
local name = string.upper(self.Firemodes[index].Name)
draw.SimpleTextOutlined(name, "mgbase_firemode", x, y + (24 * (1 - transitionAnimation) * scale), Color(255, 255, 255, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0, 0, 0, 20))
-- next firemode
if (self.Firemodes[index + 1]) then
index = index + 1
else
index = 1
end
if (#self.Firemodes > 1) then
drawBaseBinding(x, y - 30, "mgbase_binds_firemode")
end
if (self:GetFiremode() != index) then
name = string.upper(self.Firemodes[index].Name)
draw.SimpleText(name, "mgbase_firemode_alt", x, y + (24 * transitionAnimation * scale), Color(127, 127, 127, 150), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
else
drawBaseBinding(x, y - 30, "mgbase_binds_safety")
draw.SimpleTextOutlined("LOWERED", "mgbase_firemode", x, y, Color(255, 255, 255, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0, 0, 0, 20))
end
end
local bipodIcon = Material("bipodicon")
local bipodDelta = 0
function SWEP:DrawBipod()
if (!self:HasFlag("BipodDeployed")) then
bipodDelta = 0
return
end
bipodDelta = math.min(bipodDelta + RealFrameTime() * 5, 1)
surface.SetAlphaMultiplier(bipodDelta)
local mat = self:GetBipod().Icon
surface.SetMaterial(bipodIcon)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(ScrW() * 0.5 - 15, ScrH() * 0.5 + 88 + (bipodDelta * 12), 32, 30)
surface.SetAlphaMultiplier(1)
end
function SWEP:DrawCommands()
local scale = ScrH() / 1080
local x,y = ScrW() * 0.7, ScrH() * 0.5
if (GetConVar("mgbase_hud_sights"):GetBool()) then
surface.SetAlphaMultiplier(self:GetAimDelta())
if ((self:GetSight() != nil && self:GetSight().ReticleHybrid != nil) || self:GetLaser() != nil) then
local w = drawBaseBinding(x, y, "mgbase_binds_switchsights")
draw.SimpleTextOutlined(": SWITCH AIM", "mgbase_commandSecondary", x + w, y, Color(255, 255, 255, 200), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0, 0, 0, 20))
end
x,y = ScrW() * 0.5, ScrH() * 0.7
if (self:GetSight() != nil && self:GetSight().Optic != nil && self:GetAimModeDelta() <= self.m_hybridSwitchThreshold && !self:GetOwner():KeyDown(IN_SPEED) && GetConVar("mgbase_sv_breathing"):GetInt() > 0) then
local w = drawBinding(x, y, "+speed")
draw.SimpleTextOutlined(MWBLTL.Get("HUD_Commands_Text2"), "mgbase_commandSecondary", x, y + (30 * scale), Color(255, 255, 255, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0, 0, 0, 20))
end
surface.SetAlphaMultiplier(1)
end
if (GetConVar("mgbase_hud_flashlight"):GetBool() && self:GetFlashlightAttachment() != nil && !self:HasFlag("Customizing")) then
surface.SetFont("mgbase_commandSecondary")
local tw = surface.GetTextSize(MWBLTL.Get("HUD_Commands_Text3")) * 0.5
x,y = ScrW() * 0.5 - tw - 7, ScrH() * 0.9 - 150
--if (self:CanChangeAimMode()) then
local w = drawBinding(x, y + 100, "impulse 100")
draw.SimpleTextOutlined(MWBLTL.Get("HUD_Commands_Text3"), "mgbase_commandSecondary", x + w, y + 100, Color(255, 255, 255, 200), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0, 0, 0, 20))
--end
end
end
function SWEP:CanDrawCrosshair()
return !self:HasFlag("Reloading")
&& !self:HasFlag("Sprinting")
&& !self:HasFlag("Holstering")
&& !self:HasFlag("Drawing")
&& !self:HasFlag("Lowered")
&& CurTime() >= self:GetNextInspectTime()
--&& CurTime() > self:GetNextMeleeTime()
end
function SWEP:HUDShouldDraw(name)
if (self:HasFlag("Customizing")) then
return false
end
if (self:HasFlag("Aiming") && name == "CHUDQuickInfo") then
return false
end
if (CurTime() < self:GetNextInspectTime() || self:HasFlag("StoppedInspectAnimation")) then
return false
end
return true
end
function SWEP:DrawCrosshairSticks(x, y, cone)
local aimDelta = 1 - self:GetAimDelta()
surface.SetAlphaMultiplier(aimDelta)
local crosshairAlpha = 200
--dot
local c = self:GetCone()
local m = self.Cone.Max
local h = self.Cone.Hip
local dotDelta = (c - h) / (m - h)
if (m - h <= 0) then
dotDelta = 0
end
local color = string.ToColor(GetConVar("mgbase_hud_xhaircolor"):GetString())
surface.SetDrawColor(color.r, color.g, color.b, 200)
local scale = math.ceil(ScreenScale(2)) -- leadup to appropriate scaling for crosshairs
local size = math.max(scale - bit.band(scale, 1), 4)
surface.SetAlphaMultiplier(aimDelta * (1 - dotDelta))
surface.SetMaterial(crosshairDotMaterial)
surface.DrawTexturedRect(x - size * 0.5, y - size * 0.5, size, size)
surface.SetAlphaMultiplier(aimDelta)
if (self:CanDrawCrosshair()) then
local dist = x - cone -- must be done here for accurate cone representation
local drawRect = surface.DrawTexturedRectRotated
local sizeW = size * 5
local sizeH = size * 5
surface.SetMaterial(normalXhairTickMaterial)
if (self.Bullet.NumBullets > 1) then
surface.SetMaterial(shotgunXhairTickMaterial)
end
--right stick
drawRect(x - dist, y, sizeW, sizeH, 90)
--left stick
drawRect(x + dist, y, sizeW, sizeH, 270)
--down stick
drawRect(x, y - dist, sizeH, sizeW, 0)
if (self.Primary.Automatic || self.Bullet.NumBullets > 1) then
--up stick
drawRect(x, y + dist, sizeH, sizeW, 180)
end
end
surface.SetAlphaMultiplier(1)
surface.SetDrawColor(255, 255, 255, 255)
end
function SWEP:Crosshair()
local x, y = ScrW() * 0.5, ScrH() * 0.5
local vec = EyePos() + (self:GetOwner():EyeAngles() + self:GetOwner():GetViewPunchAngles()):Forward()
local cone = math.floor((vec + ( self:GetCone() * 0.1 * (self:GetOwner():EyeAngles() + self:GetOwner():GetViewPunchAngles()):Right() ) ):ToScreen().x)
local pos = vec:ToScreen()
if (Vector(x, 0, y):DistToSqr(Vector(pos.x, 0, pos.y)) > 2.25) then
x,y = math.floor(pos.x), math.floor(pos.y)
end
self:DrawCrosshairSticks(x, y, cone)
self:DrawBipod(x, y)
end
--FONTS
local function CreateFonts()
local scale = ScrH() / 1080
surface.CreateFont("mgbase_firemode", {
font = "BioSansW05-Light",
size = 30 * scale,
weight = 0
})
surface.CreateFont("mgbase_statName", {
font = "BioSansW05-Light",
size = 24,
weight = 0
})
surface.CreateFont("mgbase_stat", {
font = "BioSansW05-Light",
size = 22,
weight = 0
})
surface.CreateFont("mgbase_control", {
font = "BioSansW05-Light",
size = 22,
weight = 0
})
surface.CreateFont("mgbase_statPositive", {
font = "BioSansW05-Light",
size = 22,
weight = 0,
blursize = 2
})
surface.CreateFont("mgbase_firemode_alt", {
font = "BioSansW05-Light",
size = 24 * scale,
weight = 0
})
surface.CreateFont("mgbase_attSlot", {
font = "Conduit ITC",
size = 24 * scale,
weight = 500
})
surface.CreateFont("mgbase_attSlotMenu", {
font = "Conduit ITC",
size = 24,
weight = 500
})
surface.CreateFont("mgbase_attSlotAttachmentInUse", {
font = "BioSansW05-Light",
size = 24,
weight = 0
})
surface.CreateFont("mgbase_attSlotAttachmentInUse_IsCosmetic", {
font = "Conduit ITC",
size = 20,
weight = 500
})
surface.CreateFont("mgbase_attSlotAttachmentInUse:hover", {
font = "BioSansW05-Light",
size = 24,
weight = 0,
blursize = 1
})
surface.CreateFont("mgbase_attSlotMenu:hover", {
font = "Conduit ITC",
size = 24,
weight = 500,
blursize = 2
})
surface.CreateFont("mgbase_utilityButton", {
font = "BioSansW05-Light",
size = 32,
weight = 0
})
surface.CreateFont("mgbase_utilityButton:hover", {
font = "BioSansW05-Light",
size = 32,
weight = 0,
blursize = 1
})
surface.CreateFont("mgbase_attSlotMenu", {
font = "Conduit ITC",
size = 24,
weight = 500
})
surface.CreateFont("mgbase_attName", {
font = "Conduit ITC",
size = 24 * scale,
weight = 500
})
surface.CreateFont("mgbase_attTitle", {
font = "BioSansW05-Light",
size = 60 * scale,
weight = 0
})
surface.CreateFont("mgbase_attTitle_blur", {
font = "BioSansW05-Light",
size = 60 * scale,
weight = 0,
blursize = 3
})
surface.CreateFont("mgbase_attWeaponName", {
font = "Conduit ITC",
size = 36 * scale,
weight = 500
})
surface.CreateFont("mgbase_command", {
font = "BioSansW05-Light",
size = 26 * scale,
weight = 500
})
surface.CreateFont("mgbase_commandSecondary", {
font = "BioSansW05-Light",
size = 22 * scale,
weight = 500
})
surface.CreateFont("mgbase_presetSpawnMethod", {
font = "BioSansW05-Light",
size = 24,
weight = 0
})
surface.CreateFont("mgbase_presetSpawnMethod_child", {
font = "BioSansW05-Light",
size = 20,
weight = 0
})
end
hook.Add("OnScreenSizeChanged", "MW_UpdateFonts", CreateFonts)
CreateFonts()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,573 @@
AddCSLuaFile()
if (SERVER) then
return
end
hook.Add("AddToolMenuCategories", "Mw_CustomCategory", function()
spawnmenu.AddToolCategory("Options", "mw_options", "MW Options")
end)
local comboBox = nil
local function addAnimList(panel)
if (IsValid(LocalPlayer():GetActiveWeapon()) && LocalPlayer():GetActiveWeapon().Animations != nil) then
if (comboBox != nil) then
comboBox:Remove()
end
comboBox = vgui.Create("DComboBox", panel)
for animName, a in pairs(LocalPlayer():GetActiveWeapon().Animations) do
comboBox:AddChoice(animName)
end
comboBox.OnSelect = function(self, index, value)
RunConsoleCommand("mgbase_debug_animdelta", "0")
timer.Simple(0.04, function()
LocalPlayer():GetActiveWeapon():PlayViewModelAnimation(value)
end)
end
panel:AddItem(comboBox)
RunConsoleCommand("mgbase_debug_animdelta", "0")
end
end
local function getRig()
local currentRig = GetConVar("mgbase_rig"):GetString()
if (MW_RIGS[currentRig] != nil) then
return currentRig
end
return "chands"
end
local function getGloves()
local currentGloves = GetConVar("mgbase_gloves"):GetString()
if (MW_GLOVES[currentGloves] != nil) then
return currentGloves
end
return ""
end
local function addGloveSkinControls(panel)
if (IsValid(panel.gloveSkinBox)) then
panel.gloveSkinBox:Remove()
end
if (IsValid(panel.gloveSkinLabel)) then
panel.gloveSkinLabel:Remove()
end
if (MW_GLOVES[getGloves()] == nil) then
return
end
panel.gloveSkinBox, panel.gloveSkinLabel = panel:ComboBox("Gloves Skin", "mgbase_gloves_skin")
--populate the combobox
for i, skin in SortedPairs(MW_GLOVES[getGloves()].Skins) do
panel.gloveSkinBox:AddChoice(skin, i - 1, GetConVar("mgbase_gloves_skin"):GetInt() == i - 1)
end
end
local function addGloveControls(panel)
if (IsValid(panel.gloveModelBox)) then
panel.gloveModelBox:Remove()
end
if (IsValid(panel.gloveModelLabel)) then
panel.gloveModelLabel:Remove()
end
if (IsValid(panel.gloveSkinBox)) then
panel.gloveSkinBox:Remove()
end
if (IsValid(panel.gloveSkinLabel)) then
panel.gloveSkinLabel:Remove()
end
if (getRig() == "chands") then
return
end
--MODEL
panel.gloveModelBox, panel.gloveModelLabel = panel:ComboBox("Gloves", "mgbase_gloves")
local oldSelect = panel.gloveModelBox.OnSelect
panel.gloveModelBox.OnSelect = function(cb, index, value, data)
oldSelect(cb, index, value, data)
RunConsoleCommand("mgbase_gloves_skin", "0")
timer.Simple(0, function()
addGloveSkinControls(panel)
end)
end
--populate the combobox
for cls, glove in SortedPairs(MW_GLOVES) do
panel.gloveModelBox:AddChoice(glove.Name, cls, getGloves() == cls)
end
--SKIN
addGloveSkinControls(panel)
end
local function addRigSkinControls(panel)
if (IsValid(panel.rigSkinBox)) then
panel.rigSkinBox:Remove()
end
if (IsValid(panel.rigSkinLabel)) then
panel.rigSkinLabel:Remove()
end
if (getRig() == "chands") then
return
end
panel.rigSkinBox, panel.rigSkinLabel = panel:ComboBox("Rig Skin", "mgbase_rig_skin")
--populate the combobox
for i, skin in SortedPairs(MW_RIGS[getRig()].Skins) do
panel.rigSkinBox:AddChoice(skin, i - 1, GetConVar("mgbase_rig_skin"):GetInt() == i - 1)
end
end
local function addRigControls(panel)
--RIG MODEL BOX
if (IsValid(panel.rigModelBox)) then
panel.rigModelBox:Remove()
end
if (IsValid(panel.rigModelLabel)) then
panel.rigMrigModelLabelodelBox:Remove()
end
panel.rigModelBox, panel.rigModelLabel = panel:ComboBox("Rig", "mgbase_rig")
panel.rigModelBox:AddChoice("C_Hands", "chands", getRig() == "chands")
--populate the combobox
for cls, rig in SortedPairs(MW_RIGS) do
panel.rigModelBox:AddChoice(rig.Name, cls, getRig() == cls)
end
local oldSelect = panel.rigModelBox.OnSelect
panel.rigModelBox.OnSelect = function(cb, index, value, data)
oldSelect(cb, index, value, data)
RunConsoleCommand("mgbase_rig_skin", "0")
timer.Simple(0, function()
addRigSkinControls(panel)
addGloveControls(panel)
end)
end
----
--RIG SKIN BOX
addRigSkinControls(panel)
--GLOVES
addGloveControls(panel)
end
local function addBinder(panel, text, convar)
local container = vgui.Create("DPanel", panel)
container:SetTall(30)
container:DockPadding(10, 2, 10, 2)
function container:Paint(w, h)
surface.SetDrawColor(250, 250, 250, 255)
self:DrawFilledRect()
end
local label = vgui.Create("DLabel", container)
label:SetText(text)
label:SetTextColor(Color(0, 0, 0, 255))
label:Dock(LEFT)
local binder = vgui.Create("DBinder", container)
binder:Dock(RIGHT)
binder:SetWide(100)
binder:SetValue(GetConVar(convar):GetInt())
function binder:OnChange(iNum)
GetConVar(convar):SetInt(iNum)
end
panel:AddItem(container)
end
hook.Add("PopulateToolMenu", "CustomMenuSettings", function()
spawnmenu.AddToolMenuOption("Options", "mw_options", "mw_vmodel", MWBLTL.Get("SpawnMenu_VM_Title"), "", "", function(panel)
panel:ClearControls()
panel:NumSlider(MWBLTL.Get("SpawnMenu_VM_Text1"), "mgbase_fx_vmfov", 0.5, 2, 2)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_VM_Help1"))
panel:NumSlider(MWBLTL.Get("SpawnMenu_VM_Text2"), "mgbase_fx_vmfov_ads", 0.5, 2, 2)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_VM_Help2"))
panel:ControlHelp(MWBLTL.Get("SpawnMenu_VM_Help3"))
local divider = vgui.Create("DHorizontalDivider")
panel:AddItem(divider)
panel:Help(MWBLTL.Get("SpawnMenu_VM_Help4"))
addRigControls(panel)
end)
spawnmenu.AddToolMenuOption("Options", "mw_options", "mw_fx", MWBLTL.Get("SpawnMenu_Effs_Title"), "", "", function(panel)
panel:ClearControls()
--panel:CheckBox("Barrel Smoke", "mgbase_fx_smoke")
--panel:ControlHelp("Toggle overheat smoke coming from the barrels.")
panel:CheckBox(MWBLTL.Get("SpawnMenu_Effs_Text2"), "mgbase_fx_blur")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Effs_Help2"))
end)
spawnmenu.AddToolMenuOption("Options", "mw_options", "mw_hud", MWBLTL.Get("SpawnMenu_HUD_Title"), "", "", function(panel)
panel:ClearControls()
panel:Help(MWBLTL.Get("SpawnMenu_HUD_Help1"))
local DermaColorCombo = vgui.Create("DColorCombo", panel)
DermaColorCombo:SetColor(string.ToColor(GetConVar("mgbase_hud_xhaircolor"):GetString()))
function DermaColorCombo:OnValueChanged(col)
RunConsoleCommand("mgbase_hud_xhaircolor", string.FromColor(col))
end
panel:AddItem(DermaColorCombo)
panel:CheckBox(MWBLTL.Get("SpawnMenu_HUD_Text1"), "mgbase_hud_xhair")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_HUD_Help2"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_HUD_Text2"), "mgbase_hud_firemode")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_HUD_Help3"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_HUD_Text3"), "mgbase_hud_flashlight")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_HUD_Help4"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_HUD_Text4"), "mgbase_hud_sights")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_HUD_Help5"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_HUD_Text5"), "mgbase_fx_laser_weaponcolor")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_HUD_Help6"))
end)
spawnmenu.AddToolMenuOption("Options", "mw_options", "mw_controls", MWBLTL.Get("SpawnMenu_Cont_Title"), "", "", function(panel)
panel:ClearControls()
panel:CheckBox(MWBLTL.Get("SpawnMenu_Cont_Text1"), "mgbase_toggleaim")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Cont_Help1"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Cont_Text2"), "mgbase_autoreload")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Cont_Help2"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Cont_Text3"), "mgbase_manualrechamber")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Cont_Help3"))
--[[panel:Help("Customize Menu Bind")
local binder = vgui.Create("DBinder", panel)
binder:SetValue(input.GetKeyCode(input.LookupBinding("mgbase_customize")))
function binder:OnChange(num)
RunConsoleCommand("bind mgbase_customize "..input.LookupKeyBinding(num))
end
panel:AddItem(binder)
panel:ControlHelp("Once this is set, the menu won't show up when pressing the context menu key!")]] --doesn't work lol
panel:CheckBox(MWBLTL.Get("SpawnMenu_Cont_Text4"), "mgbase_aimassist")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Cont_Help6"))
local divider = vgui.Create("DPanel", panel)
divider:SetTall(4)
panel:AddItem(divider)
local method = math.Clamp(GetConVar("mgbase_presetspawnmethod"):GetInt(), 0, 3)
local combo, l = panel:ComboBox(MWBLTL.Get("SpawnMenu_Cont_Text5"), "mgbase_presetspawnmethod")
combo:SetWide(200)
combo:AddChoice(MWBLTL.Get("SpawnMenu_Cont_Text6"), 0, method == 0)
combo:AddChoice(MWBLTL.Get("SpawnMenu_Cont_Text7"), 1, method == 1)
combo:AddChoice(MWBLTL.Get("SpawnMenu_Cont_Text8"), 2, method == 2)
combo:AddChoice(MWBLTL.Get("SpawnMenu_Cont_Text9"), 3, method == 3)
--panel:Button(MWBLTL.Get("SpawnMenu_Cont_Text10"), "mgbase_customize")
divider = vgui.Create("DPanel", panel)
divider:SetTall(4)
panel:AddItem(divider)
addBinder(panel, "Melee", "mgbase_binds_melee")
addBinder(panel, "Low Carry", "mgbase_binds_safety")
addBinder(panel, "Switch Sights", "mgbase_binds_switchsights")
addBinder(panel, "Firemode", "mgbase_binds_firemode")
addBinder(panel, "Customize", "mgbase_binds_customize")
addBinder(panel, "Holster", "mgbase_binds_holster")
addBinder(panel, "Inspect", "mgbase_binds_inspect")
panel:ControlHelp("Press again while inspecting to stop animation.")
end)
spawnmenu.AddToolMenuOption("Options", "mw_options", "mw_debug", MWBLTL.Get("SpawnMenu_Debug_Title"), "", "", function(panel)
panel:ClearControls()
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text1"), "mgbase_debug_freeview")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help1"))
--[[panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text2"), "mgbase_debug_freezeanim")
panel:NumSlider(MWBLTL.Get("SpawnMenu_Debug_Help2"), "mgbase_debug_animdelta", 0, 1, 4)
local buttonToReloadAnims = vgui.Create("DButton", panel)
buttonToReloadAnims:SetText(MWBLTL.Get("SpawnMenu_Debug_Text3"))
buttonToReloadAnims.DoClick = function()
addAnimList(panel)
end
panel:AddItem(buttonToReloadAnims)]]
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text4"), "mgbase_debug_crosshair")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help3"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text5"), "mgbase_debug_disablebreathing")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help4"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text6"), "mgbase_debug_reverb")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help5"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text7"), "mgbase_debug_range")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help6"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text8"), "mgbase_debug_projectiles")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help7"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text9"), "mgbase_debug_vmrender")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help8"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text10"), "mgbase_debug_wmrender")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help9"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_Debug_Text11"), "mgbase_debug_mag")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_Debug_Help10"))
end)
spawnmenu.AddToolMenuOption("Options", "mw_options", "mw_svcontrols", MWBLTL.Get("SpawnMenu_SC_Title"), "", "", function(panel)
panel:ClearControls()
if (!LocalPlayer():IsAdmin()) then
panel:ControlHelp("shoo")
return
end
panel:NumSlider(MWBLTL.Get("SpawnMenu_SC_Text1"), "mgbase_sv_pvpdamage", 0, 5, 1)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help1"))
panel:NumSlider(MWBLTL.Get("SpawnMenu_SC_Text2"), "mgbase_sv_pvedamage", 0, 5, 1)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help2"))
panel:NumSlider(MWBLTL.Get("SpawnMenu_SC_Text3"), "mgbase_sv_recoil", 0, 5, 1)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help3"))
panel:NumSlider(MWBLTL.Get("SpawnMenu_SC_Text4"), "mgbase_sv_accuracy", 0.1, 5, 1)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help4"))
panel:NumSlider(MWBLTL.Get("SpawnMenu_SC_Text5"), "mgbase_sv_range", 1, 10, 1)
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help5"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_SC_Text6"), "mgbase_sv_aimassist")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help6"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_SC_Text7"), "mgbase_sv_breathing")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help7"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_SC_Text8"), "mgbase_sv_customization")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help8"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_SC_Text11"), "mgbase_sv_firstdraws")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help11"))
panel:CheckBox(MWBLTL.Get("SpawnMenu_SC_Text12"), "mgbase_sv_sprintreloads")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help12"))
panel:CheckBox("Shoot Reloads", "mgbase_sv_shootreloads")
panel:ControlHelp("Allows firing to interrupt reloads.")
panel:CheckBox(MWBLTL.Get("SpawnMenu_SC_Text9"), "mgbase_sv_full_penetration")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help9"))
panel:TextEntry(MWBLTL.Get("SpawnMenu_SC_Text10"), "mgbase_sv_customization_limit")
panel:ControlHelp(MWBLTL.Get("SpawnMenu_SC_Help10"))
end)
end)
local function createSpawnIcon(w, propPanel)
return spawnmenu.CreateContentIcon(w.ScriptedEntityType or "weapon", propPanel, {
nicename = w.PrintName or w.ClassName,
spawnname = w.ClassName,
material = w.IconOverride or "entities/" .. w.ClassName .. ".png",
admin = w.AdminOnly
})
end
--sub categories
hook.Add("PopulateWeapons", "AddWeaponContentMW19", function(pnlContent, tree, node)
timer.Simple(0, function()
local weaponsList = list.Get("Weapon")
local mgbaseWeapons = {}
--look into every weapon and see if they're from mgbase
for _, weapon in pairs(weaponsList) do
if (weapons.IsBasedOn(weapon.ClassName, "mg_base") || weapon.ClassName == "mw_infil_flare") then
if (mgbaseWeapons[weapon.Category] == nil) then
mgbaseWeapons[weapon.Category] = {}
end
--keep them for later if so
table.insert(mgbaseWeapons[weapon.Category], weapon)
end
end
--loop through all weapon categories
for _, categoryNode in pairs(tree:Root():GetChildNodes()) do
--if the text matches the categories we saved before we replace DoPopulate
if (mgbaseWeapons[categoryNode:GetText()] != nil) then
local manifest = {
["Other"] = {} --default header
}
--order them by subcategory
for _, weapon in pairs(mgbaseWeapons[categoryNode:GetText()]) do
--get weapon from storeds
local actualWeapon = weapons.Get(weapon.ClassName)
if (actualWeapon.SubCategory == nil) then
table.insert(manifest["Other"], weapon)
else
if (manifest[actualWeapon.SubCategory] == nil) then
manifest[actualWeapon.SubCategory] = {}
end
table.insert(manifest[actualWeapon.SubCategory], weapon)
end
end
categoryNode.DoPopulate = function(self)
-- If we've already populated it - forget it.
if (self.PropPanel) then return end
-- Create the container panel
self.PropPanel = vgui.Create("ContentContainer", pnlContent)
self.PropPanel:SetVisible(false)
self.PropPanel:SetTriggerSpawnlistChange(false)
for categoryName, weps in SortedPairs(manifest) do
if (#weps <= 0) then
continue
end
--create header
local label = vgui.Create("ContentHeader", container)
label:SetText(categoryName)
self.PropPanel:Add(label)
--this is copy from gmod
for _, ent in SortedPairsByMemberValue(weps, "PrintName") do
local icon = createSpawnIcon(ent, self.PropPanel)
local oldPaint = icon.Paint
local we = weapons.Get(ent.ClassName)
local bPossibleBlueprint = we.Base != "mg_base"
if (bPossibleBlueprint) then
icon.DoClick = function()
RunConsoleCommand("gm_giveswep", ent.ClassName)
surface.PlaySound(we.BlueprintSound || "mw/user_interface/aar/ui_aar_operator_complete_reveal.wav")
end
end
icon.Paint = function(self, aWide, aTall)
if (bPossibleBlueprint) then
blueprintIconPaint(self, aWide, aTall)
end
oldPaint(self, aWide, aTall)
end
local oldMenuExtra = icon.OpenMenuExtra
icon.OpenMenuExtra = function(icon, menu)
oldMenuExtra(icon, menu)
local weaponsBasedOnMe = {}
--blueprints
for _, w in pairs(weaponsList) do
if (weapons.IsBasedOn(w.ClassName, ent.ClassName)) then
weaponsBasedOnMe[#weaponsBasedOnMe + 1] = w
end
end
if (#weaponsBasedOnMe > 0) then
menu:AddSpacer()
local grid = vgui.Create("DGrid")
grid:SetCols(math.min(#weaponsBasedOnMe, 3))
grid:SetColWide(icon:GetWide())
grid:SetRowHeight(icon:GetTall())
for _, w in pairs(weaponsBasedOnMe) do
local we = weapons.Get(w.ClassName)
local subIcon = createSpawnIcon(w, menu)
local oldPaint = subIcon.Paint
subIcon.Paint = function(self, aWide, aTall)
blueprintIconPaint(self, aWide, aTall)
oldPaint(self, aWide, aTall)
end
subIcon.DoClick = function()
RunConsoleCommand("gm_giveswep", w.ClassName)
surface.PlaySound(we.BlueprintSound || "mw/user_interface/aar/ui_aar_operator_complete_reveal.wav")
end
subIcon.DoRightClick = function() end
grid:AddItem(subIcon)
end
menu:AddPanel(grid)
end
end
end
end
end
end
end
end) --timer simple
end)
local specialMat = Material("gui/ps_hover.png")
local glowMat = Material("particles/fire_glow")
function blueprintIconPaint(self, aWide, aTall)
if (self.nextGlowSpawn == nil || CurTime() > self.nextGlowSpawn) then
if (self.glows == nil) then
self.glows = {}
end
table.insert(self.glows, {delta = 1, speed = math.random(30, 60), size = math.random(12, 24), x = math.random(6, aWide - 6), y = aWide - 16})
self.nextGlowSpawn = CurTime() + math.random(0.3, 0.5)
end
surface.SetMaterial(glowMat)
for i, glow in pairs(self.glows) do
glow.delta = glow.delta - FrameTime()
glow.y = glow.y - (glow.speed * FrameTime())
surface.SetDrawColor(255, 255, 255, math.sin(math.pi * glow.delta) * 255)
surface.DrawTexturedRectRotated(glow.x, glow.y, glow.size, glow.size, CurTime() + glow.size + glow.speed)
if (glow.delta <= 0) then
table.remove(self.glows, i)
end
end
--surface.SetDrawColor(255, 255, 255, 255)
--surface.SetMaterial(specialMat)
--self:DrawTexturedRect()
end

View File

@@ -0,0 +1,53 @@
AddCSLuaFile()
require("mw_math")
require("mw_utils")
function SWEP:RenderOverride(flags)
if (IsValid(self.SpawnEffect)) then
self.SpawnEffect.ParentEntity = nil
--https://github.com/Facepunch/garrysmod-issues/issues/5345
end
if (GetConVar("mgbase_debug_wmrender"):GetInt() <= 0) then
return
end
local bone = mw_utils.LookupBoneCached(self, self.WorldModelOffsets.Bone)
if (bone != nil && bone > 0) then
if (IsValid(self:GetOwner())) then
self:ManipulateBoneAngles(bone, self.WorldModelOffsets.Angles)
self:ManipulateBonePosition(bone, self.WorldModelOffsets.Pos)
else
self:ManipulateBoneAngles(bone, mw_math.ZeroAngle)
self:ManipulateBonePosition(bone, mw_math.ZeroVector)
end
end
--self:InvalidateBoneCache()
self:SetupBones()
self:DrawModel(flags)
for _, att in pairs(self:GetAllAttachmentsInUse()) do
if (IsValid(att.m_TpModel) && #att.m_TpModel:GetChildren() <= 0) then
att.m_TpModel:DrawModel(flags)
if ((!att.RenderOverride && att.Render != nil) || att.WorldModelRender != nil) then
if (att.WorldModelRender != nil) then
att:WorldModelRender(self)
else
att:Render(self, att.m_TpModel)
end
end
end
end
end
function SWEP:DrawWorldModel(flags)
self:DrawModel(flags)
end
function SWEP:DrawWorldModelTranslucent(flags)
self:DrawWorldModel(flags)
end