From 0f4de003bb34572eded3d1f748d99bdbb2e00a8f Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sat, 6 Jun 2026 02:11:51 +0200 Subject: [PATCH 1/3] Cache color --- lua/effects/glide_explosion.lua | 3 ++- lua/entities/glide_projectile.lua | 3 ++- lua/entities/glide_rotor.lua | 3 ++- lua/entities/glide_wheel/init.lua | 6 ++++-- lua/entities/gtav_insurgent.lua | 3 ++- lua/glide/client/vgui/stream_editor.lua | 2 +- lua/glide/client/vgui/stream_editor_tab.lua | 3 ++- lua/glide/server/ragdoll.lua | 16 ++++++++++------ lua/glide/server/sockets.lua | 5 +++-- lua/weapons/glide_repair.lua | 2 +- 10 files changed, 29 insertions(+), 17 deletions(-) diff --git a/lua/effects/glide_explosion.lua b/lua/effects/glide_explosion.lua index 01c879cf..d222266f 100644 --- a/lua/effects/glide_explosion.lua +++ b/lua/effects/glide_explosion.lua @@ -26,9 +26,10 @@ end local GLOW_MAT = Material( "sprites/light_glow02_add" ) +local color_render = Color( 255, 200, 150, 255 ) function EFFECT:Render() render.SetMaterial( GLOW_MAT ) - render.DrawSprite( self.origin, self.size, self.size, Color( 255, 200, 150, 255 ) ) + render.DrawSprite( self.origin, self.size, self.size, color_render ) end local FLAME_MATERIAL = "glide/effects/flamelet" diff --git a/lua/entities/glide_projectile.lua b/lua/entities/glide_projectile.lua index 64ebeede..7c78f57a 100644 --- a/lua/entities/glide_projectile.lua +++ b/lua/entities/glide_projectile.lua @@ -152,6 +152,7 @@ local traceData = { mins = Vector() } +local color_red = Color( 255, 0, 0 ) function ENT:Think() local t = CurTime() @@ -193,7 +194,7 @@ function ENT:Think() traceData.filter[2] = self:GetOwner() if GetDevMode() then - debugoverlay.Line( traceData.start, traceData.endpos, 0.75, Color( 255, 0, 0 ), true ) + debugoverlay.Line( traceData.start, traceData.endpos, 0.75, color_red, true ) end -- Trace result is stored on `ray` diff --git a/lua/entities/glide_rotor.lua b/lua/entities/glide_rotor.lua index 8b555cf7..aa142a8c 100644 --- a/lua/entities/glide_rotor.lua +++ b/lua/entities/glide_rotor.lua @@ -160,6 +160,7 @@ end local GetDevMode = Glide.GetDevMode --- Check if the rotor blades are hitting things. +local color_red = Color( 255, 0, 0 ) function ENT:CheckRotorClearance( dt, parent ) -- The trace will use a spinning angle separate from the model self.traceAngle = ( self.traceAngle + dt * 1600 ) % 360 @@ -176,7 +177,7 @@ function ENT:CheckRotorClearance( dt, parent ) data.endpos = origin + dir * self.radius if GetDevMode() then - debugoverlay.Line( data.start, data.endpos, 0.05, Color( 255, 0, 0 ), true ) + debugoverlay.Line( data.start, data.endpos, 0.05, color_red, true ) end local tr = TraceHull( data ) diff --git a/lua/entities/glide_wheel/init.lua b/lua/entities/glide_wheel/init.lua index e39ffd6a..40568b16 100644 --- a/lua/entities/glide_wheel/init.lua +++ b/lua/entities/glide_wheel/init.lua @@ -359,6 +359,8 @@ local EntSetLocalPos = FindMetaTable( "Entity" ).SetLocalPos local tractionCycle = Vector() local contactPos = Vector() +local color_gray = Color( 100, 100, 100 ) +local color_green = Color( 0, 200, 0 ) function ENT:DoPhysics( vehicle, phys, traceFilter, outLin, outAng, dt, vehSurfaceGrip, vehSurfaceResistance, vehPos, vehVel, vehAngVel ) local state, params = self.state, self.params @@ -400,8 +402,8 @@ function ENT:DoPhysics( vehicle, phys, traceFilter, outLin, outAng, dt, vehSurfa state.lastSurfaceId = surfaceId if state.isDebugging then - debugoverlay.Cross( pos, 10, 0.05, Color( 100, 100, 100 ), true ) - debugoverlay.Box( contactPos, traceData.mins, traceData.maxs, 0.05, Color( 0, 200, 0 ) ) + debugoverlay.Cross( pos, 10, 0.05, color_gray, true ) + debugoverlay.Box( contactPos, traceData.mins, traceData.maxs, 0.05, color_green ) end if not ray.Hit then diff --git a/lua/entities/gtav_insurgent.lua b/lua/entities/gtav_insurgent.lua index e8eb4f26..cc41410c 100644 --- a/lua/entities/gtav_insurgent.lua +++ b/lua/entities/gtav_insurgent.lua @@ -75,12 +75,13 @@ if CLIENT then stream:LoadPreset( "insurgent" ) end + local color_green = Color( 0, 255, 0 ) function ENT:OnLocalPlayerEnter( seatIndex ) self:DisableCrosshair() -- Enable the crosshair when a player enters the turret seat if seatIndex == TURRET_SEAT_INDEX then - self:EnableCrosshair( { iconType = "dot", color = Color( 0, 255, 0 ) } ) + self:EnableCrosshair( { iconType = "dot", color = color_green } ) else -- Let the base class handle it BaseClass.OnLocalPlayerEnter( self, seatIndex ) diff --git a/lua/glide/client/vgui/stream_editor.lua b/lua/glide/client/vgui/stream_editor.lua index 5157bdcc..42cbbf7b 100644 --- a/lua/glide/client/vgui/stream_editor.lua +++ b/lua/glide/client/vgui/stream_editor.lua @@ -628,7 +628,7 @@ function PANEL:ShowExportFrame( code, titleText, helpText ) local labelHelp = vgui.Create( "DLabel", frame ) labelHelp:SetFont( "Trebuchet18" ) labelHelp:SetText( helpText ) - labelHelp:SetTextColor( Color( 255, 255, 255 ) ) + labelHelp:SetTextColor( color_white ) labelHelp:Dock( TOP ) labelHelp:SetContentAlignment( 5 ) diff --git a/lua/glide/client/vgui/stream_editor_tab.lua b/lua/glide/client/vgui/stream_editor_tab.lua index b81d02d7..06c10e55 100644 --- a/lua/glide/client/vgui/stream_editor_tab.lua +++ b/lua/glide/client/vgui/stream_editor_tab.lua @@ -480,6 +480,7 @@ end local IsKeyDown = input.IsKeyDown +local color_red = Color( 255, 0, 0 ) function PANEL:Think() if not self.isEngineOn then return end @@ -520,7 +521,7 @@ function PANEL:Think() if self.isRedlining ~= isRedlining then self.isRedlining = isRedlining - self.rpmLabel:SetColor( isRedlining and Color( 255, 0, 0 ) or color_white ) + self.rpmLabel:SetColor( isRedlining and color_red or color_white ) end local rpmFraction = ( rpm - self.minRPM ) / ( self.maxRPM - self.minRPM ) diff --git a/lua/glide/server/ragdoll.lua b/lua/glide/server/ragdoll.lua index ac5588dd..341e63b6 100644 --- a/lua/glide/server/ragdoll.lua +++ b/lua/glide/server/ragdoll.lua @@ -248,6 +248,10 @@ do local ray = {} --- Check if a vehicle exit position/ragdoll respawn point is unobstructed. + local color_red = Color( 255, 0, 0 ) + local color_orange = Color( 255, 100, 0 ) + local color_green = Color( 0, 255, 0 ) + local color_opacity20 = Color( 255, 255, 255, 20 ) function Glide.ValidateExitPos( origin, pos, traceData ) traceData = traceData or {} @@ -263,8 +267,8 @@ do if ray.Hit then if GetDevMode() then - debugoverlay.Line( origin, traceData.endpos, 8, Color( 255, 0, 0 ), true ) - debugoverlay.EntityTextAtPosition( traceData.endpos, 0, "", 8, Color( 255, 0, 0 ) ) + debugoverlay.Line( origin, traceData.endpos, 8, color_red, true ) + debugoverlay.EntityTextAtPosition( traceData.endpos, 0, "", 8, color_red ) end return true, pos @@ -278,16 +282,16 @@ do if ray.StartSolid then if GetDevMode() then - debugoverlay.Line( origin, traceData.endpos, 8, Color( 255, 100, 0 ), true ) - debugoverlay.EntityTextAtPosition( traceData.endpos, 0, "", 8, Color( 255, 100, 0 ) ) + debugoverlay.Line( origin, traceData.endpos, 8, color_orange, true ) + debugoverlay.EntityTextAtPosition( traceData.endpos, 0, "", 8, color_orange ) end return true, pos end if GetDevMode() then - debugoverlay.Line( origin, pos, 8, Color( 0, 255, 0 ), true ) - debugoverlay.Box( pos, traceData.mins, traceData.maxs, 8, Color( 255, 255, 255, 20 ) ) + debugoverlay.Line( origin, pos, 8, color_green, true ) + debugoverlay.Box( pos, traceData.mins, traceData.maxs, 8, color_opacity20 ) end return false, pos diff --git a/lua/glide/server/sockets.lua b/lua/glide/server/sockets.lua index 0ff39a99..258411b1 100644 --- a/lua/glide/server/sockets.lua +++ b/lua/glide/server/sockets.lua @@ -80,6 +80,7 @@ local Remove = table.remove local FindClosestSocket = Glide.FindClosestSocket local GetDevMode = Glide.GetDevMode +local color_orange = Color( 255, 145, 0 ) timer.Create( "Glide.UpdateSockets", 0.1, 0, function() local vehicleCount = #vehiclesWithSockets if vehicleCount == 0 then return end @@ -138,12 +139,12 @@ timer.Create( "Glide.UpdateSockets", 0.1, 0, function() if not GetDevMode() then return end for _, v in ipairs( receptacles ) do - debugoverlay.Cross( v.pos, 8, 0.1, Color( 255, 145, 0 ), true ) + debugoverlay.Cross( v.pos, 8, 0.1, color_orange, true ) debugoverlay.Text( v.pos, v.id .. " | isReceptacle: true", 0.1, false ) end for _, v in ipairs( plugs ) do - debugoverlay.Cross( v.pos, 8, 0.1, Color( 255, 145, 0 ), true ) + debugoverlay.Cross( v.pos, 8, 0.1, color_orange, true ) debugoverlay.Text( v.pos, v.id .. " | isReceptacle: false", 0.1, false ) end end ) diff --git a/lua/weapons/glide_repair.lua b/lua/weapons/glide_repair.lua index 94937faa..1826656e 100644 --- a/lua/weapons/glide_repair.lua +++ b/lua/weapons/glide_repair.lua @@ -135,7 +135,7 @@ function SWEP:DrawHUD() local x, y = ScrW() * 0.5, ScrH() * 0.5 - Glide.DrawWeaponCrosshair( x, y, "glide/aim_dot.png", 0.05, Color( 255, 255, 255, 255 ) ) + Glide.DrawWeaponCrosshair( x, y, "glide/aim_dot.png", 0.05, color_white ) local w = math.floor( ScrH() * 0.4 ) local h = math.floor( ScrH() * 0.03 ) From aff5109bb13bca9a79a49962b348015418e39f1b Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sat, 6 Jun 2026 02:13:46 +0200 Subject: [PATCH 2/3] Cache color EnableCrosshair --- lua/entities/base_glide/cl_hud.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/entities/base_glide/cl_hud.lua b/lua/entities/base_glide/cl_hud.lua index 8a3468d5..d4e42e08 100644 --- a/lua/entities/base_glide/cl_hud.lua +++ b/lua/entities/base_glide/cl_hud.lua @@ -10,6 +10,7 @@ do ["square"] = "glide/aim_square.png" } + local color_green = Color( 100, 255, 100 ) function ENT:EnableCrosshair( params ) params = params or {} @@ -18,7 +19,7 @@ do icon = CROSSHAIR_ICONS[params.iconType or "dot"], size = params.size or 0.05, - color = params.color or Color( 100, 255, 100 ) + color = params.color or color_green } end From e54c912658c309360696b3fdec23d3981e4947c1 Mon Sep 17 00:00:00 2001 From: Vitroze Date: Sat, 6 Jun 2026 02:43:28 +0200 Subject: [PATCH 3/3] Cache color --- lua/entities/base_glide_plane/cl_init.lua | 3 ++- lua/glide/client/vgui/sound_browser.lua | 3 ++- lua/glide/client/vgui/stream_editor_layer.lua | 3 ++- lua/weapons/glide_homing_launcher.lua | 2 +- lua/weapons/gmod_tool/stools/glide_misc_sounds.lua | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lua/entities/base_glide_plane/cl_init.lua b/lua/entities/base_glide_plane/cl_init.lua index 9410fd96..6a0f962e 100644 --- a/lua/entities/base_glide_plane/cl_init.lua +++ b/lua/entities/base_glide_plane/cl_init.lua @@ -176,6 +176,7 @@ local size, x, y local power = 0 --- Override this base class function. +local COLOR_STALL = Color( 255, 100, 100, 200 ) function ENT:DrawVehicleHUD( screenW, screenH ) local playerListWidth = BaseClass.DrawVehicleHUD( self, screenW, screenH ) @@ -231,7 +232,7 @@ function ENT:DrawVehicleHUD( screenW, screenH ) x = x + ( size * 0.5 ) - ( w * 0.5 ) y = y - h - size * 0.1 - surface.SetDrawColor( 255, 100, 100, 200 ) + surface.SetDrawColor( COLOR_STALL ) surface.DrawRect( x, y, w, h ) SimpleText( text, "GlideHUD", x + w * 0.5, y + h * 0.5, colors.icon, 1, 1 ) diff --git a/lua/glide/client/vgui/sound_browser.lua b/lua/glide/client/vgui/sound_browser.lua index cbd505e1..b7a44d1a 100644 --- a/lua/glide/client/vgui/sound_browser.lua +++ b/lua/glide/client/vgui/sound_browser.lua @@ -97,6 +97,7 @@ local L = StyledTheme.GetUpperLanguagePhrase local PANEL = {} +local BLACK_COLOR = Color( 0, 0, 0, 255 ) function PANEL:Init() local frameW, frameH = ScaleSize( 1000 ), ScaleSize( 700 ) @@ -137,7 +138,7 @@ function PANEL:Init() panelFooter:DockPadding( ScaleSize( 4 ), ScaleSize( 4 ), ScaleSize( 4 ), ScaleSize( 4 ) ) panelFooter.Paint = function( _, w, h ) - surface.SetDrawColor( 0, 0, 0, 255 ) + surface.SetDrawColor( BLACK_COLOR ) surface.DrawRect( 0, 0, w, h ) end diff --git a/lua/glide/client/vgui/stream_editor_layer.lua b/lua/glide/client/vgui/stream_editor_layer.lua index 19a8b594..9d23e830 100644 --- a/lua/glide/client/vgui/stream_editor_layer.lua +++ b/lua/glide/client/vgui/stream_editor_layer.lua @@ -372,6 +372,7 @@ end local COLOR_HEADER = Color( 60, 60, 60 ) local COLOR_LIST_HEADER = Color( 40, 40, 40, 255 ) +local COLOR_LAYER = Color( 13, 122, 13, 255 ) local SimpleText = draw.SimpleText function PANEL:Paint( w, h ) @@ -382,7 +383,7 @@ function PANEL:Paint( w, h ) DrawRect( 0, 0, w, headerHeight, COLOR_HEADER ) if self.layerData then - surface.SetDrawColor( 13, 122, 13 ) + surface.SetDrawColor( COLOR_LAYER ) surface.DrawRect( 1, 1, ( w - 2 ) * self.layerData.volume, headerHeight - 2 ) SimpleText( self.id, "StyledTheme_Small", padding, headerHeight * 0.5, colors.buttonText, 0, 1 ) diff --git a/lua/weapons/glide_homing_launcher.lua b/lua/weapons/glide_homing_launcher.lua index 32a34a25..ee373317 100644 --- a/lua/weapons/glide_homing_launcher.lua +++ b/lua/weapons/glide_homing_launcher.lua @@ -334,7 +334,7 @@ if CLIENT then if user:KeyDown( IN_ATTACK2 ) then surface.SetMaterial( AREA_MAT ) - surface.SetDrawColor( 255, 255, 255, 255 ) + surface.SetDrawColor( color_white ) surface.DrawTexturedRectRotated( ScrW() * 0.5, ScrH() * 0.5, size, size, 0 ) end diff --git a/lua/weapons/gmod_tool/stools/glide_misc_sounds.lua b/lua/weapons/gmod_tool/stools/glide_misc_sounds.lua index 30a4285e..19032f97 100644 --- a/lua/weapons/gmod_tool/stools/glide_misc_sounds.lua +++ b/lua/weapons/gmod_tool/stools/glide_misc_sounds.lua @@ -123,13 +123,15 @@ function TOOL:Reload( trace ) end local TEXT_COLOR = Color( 255, 255, 255, 255 ) +local COLOR_BACKGROUND = Color( 30, 30, 30, 255 ) +local COLOR_HEADER = Color( 70, 70, 70, 255 ) local HEADER_HEIGHT = 28 local function CategoryPaint( s, w, h ) - surface.SetDrawColor( 30, 30, 30, 255 ) + surface.SetDrawColor( COLOR_BACKGROUND ) surface.DrawRect( 0, 0, w, h ) - surface.SetDrawColor( 70, 70, 70, 255 ) + surface.SetDrawColor( COLOR_HEADER ) surface.DrawRect( 0, 0, w, HEADER_HEIGHT ) draw.SimpleText( s._name, "Trebuchet18", 4, HEADER_HEIGHT * 0.5, TEXT_COLOR, 0, 1 )