From 7953cfe498eb3b5d9b53be7c989e2d3f5c59dc2f Mon Sep 17 00:00:00 2001 From: Zack H Date: Thu, 13 Nov 2025 15:49:35 -0500 Subject: [PATCH 1/8] Implement gear light tachometer --- Source/Settings.as | 13 +++++++++++ Source/Things/Gearbox.as | 48 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/Source/Settings.as b/Source/Settings.as index 12de1eb..6a13cda 100644 --- a/Source/Settings.as +++ b/Source/Settings.as @@ -199,6 +199,7 @@ enum GearboxTachometerStyle Bar, Dots, Blocks, + Lights, } [Setting category="Gearbox" name="Tachometer style" if="Setting_Gearbox_ShowTachometer"] @@ -264,6 +265,18 @@ vec4 Setting_Gearbox_Gear4Color = vec4(1, 1, 1, 1); [Setting category="Gearbox" name="Gear 5 color" color if="Setting_Gearbox_UseGearColors"] vec4 Setting_Gearbox_Gear5Color = vec4(1, 1, 1, 1); +[Setting category="Gearbox" name="Use gear colors for lights" if="Setting_Gearbox_TachometerStyle Lights"] +bool Setting_Gearbox_Lights_UseGearColors = false; + +[Setting category="Gearbox" name="Gear light color" color if="Setting_Gearbox_TachometerStyle Lights"] +vec4 Setting_Gearbox_Lights_Color = vec4(0.568f, 1, 0.961f, 1); + +[Setting category="Gearbox" name="Gear light reverse color" color if="Setting_Gearbox_TachometerStyle Lights"] +vec4 Setting_Gearbox_Lights_Color_Reverse = vec4(1, 0.216f, 0.216f, 1); + +[Setting category="Gearbox" name="Gear light background color" color if="Setting_Gearbox_TachometerStyle Lights"] +vec4 Setting_Gearbox_Lights_Color_Background = vec4(0.1f, 0.1f, 0.1f, 1); + #if MP4 || TURBO [Setting category="Gearbox" name="Gear 6 color" color if="Setting_Gearbox_UseGearColors"] vec4 Setting_Gearbox_Gear6Color = vec4(1, 1, 1, 1); diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index 8fc92f4..f4736a5 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -109,7 +109,7 @@ class DashboardGearbox : DashboardThing } } - void RenderTachometer(const vec2 &in pos, const vec2 &in size, float rpm) + void RenderTachometer(const vec2 &in pos, const vec2 &in size, float rpm, uint gear) { float rpmWidth = rpm / m_maxRpm * size.x; float downWidth = Setting_Gearbox_Downshift / m_maxRpm * size.x; @@ -208,6 +208,50 @@ class DashboardGearbox : DashboardThing } break; } + + case GearboxTachometerStyle::Lights: { + uint lights = gear; + vec4 color = Setting_Gearbox_Lights_Color; + + if (gear == 0) { + lights = 5; + color = Setting_Gearbox_Lights_Color_Reverse; + } + + if (Setting_Gearbox_Lights_UseGearColors) { + switch (gear) { + case 0: color = Setting_Gearbox_Gear0Color; break; + case 1: color = Setting_Gearbox_Gear1Color; break; + case 2: color = Setting_Gearbox_Gear2Color; break; + case 3: color = Setting_Gearbox_Gear3Color; break; + case 4: color = Setting_Gearbox_Gear4Color; break; + case 5: color = Setting_Gearbox_Gear5Color; break; + } + } + + float lightPadding = 8.0f; + float spaceForPadding = lightPadding * 6.0; + float lightSize = (size.x - spaceForPadding) / 5.0; + + for (uint i = 0; i < 5; i++) { + nvg::BeginPath(); + nvg::RoundedRect( + pos.x + (i + 1) * lightPadding + i * lightSize, + pos.y + lightPadding, + lightSize, + size.y - 2 * lightPadding, + 4 + ); + if (i < lights) { + nvg::FillColor(color); + } else { + nvg::FillColor(Setting_Gearbox_Lights_Color_Background); + } + nvg::Fill(); + } + + break; + } } // Border @@ -237,7 +281,7 @@ class DashboardGearbox : DashboardThing } if (Setting_Gearbox_ShowTachometer) { - RenderTachometer(offset, size, rpm); + RenderTachometer(offset, size, rpm, gear); } } } From 5fe70a287fd919c3140ef7cb450785c6e507f6f8 Mon Sep 17 00:00:00 2001 From: Zack H Date: Thu, 13 Nov 2025 16:24:12 -0500 Subject: [PATCH 2/8] Change wording, only use gear colors if use gear colors enabled --- Source/Settings.as | 4 ++-- Source/Things/Gearbox.as | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Settings.as b/Source/Settings.as index 6a13cda..858e50f 100644 --- a/Source/Settings.as +++ b/Source/Settings.as @@ -271,10 +271,10 @@ bool Setting_Gearbox_Lights_UseGearColors = false; [Setting category="Gearbox" name="Gear light color" color if="Setting_Gearbox_TachometerStyle Lights"] vec4 Setting_Gearbox_Lights_Color = vec4(0.568f, 1, 0.961f, 1); -[Setting category="Gearbox" name="Gear light reverse color" color if="Setting_Gearbox_TachometerStyle Lights"] +[Setting category="Gearbox" name="Gear light color for gear 0 (reverse)" color if="Setting_Gearbox_TachometerStyle Lights"] vec4 Setting_Gearbox_Lights_Color_Reverse = vec4(1, 0.216f, 0.216f, 1); -[Setting category="Gearbox" name="Gear light background color" color if="Setting_Gearbox_TachometerStyle Lights"] +[Setting category="Gearbox" name="Background color for unlit gear lights" color if="Setting_Gearbox_TachometerStyle Lights"] vec4 Setting_Gearbox_Lights_Color_Background = vec4(0.1f, 0.1f, 0.1f, 1); #if MP4 || TURBO diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index f4736a5..a95a5d5 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -218,7 +218,7 @@ class DashboardGearbox : DashboardThing color = Setting_Gearbox_Lights_Color_Reverse; } - if (Setting_Gearbox_Lights_UseGearColors) { + if (Setting_Gearbox_UseGearColors && Setting_Gearbox_Lights_UseGearColors) { switch (gear) { case 0: color = Setting_Gearbox_Gear0Color; break; case 1: color = Setting_Gearbox_Gear1Color; break; From 817ec56277f554f2dde2b53dcb97f0af6fb71ba9 Mon Sep 17 00:00:00 2001 From: Zack H Date: Fri, 6 Feb 2026 18:47:13 -0600 Subject: [PATCH 3/8] Refactor gear colors --- Source/Things/Gearbox.as | 49 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index a95a5d5..b178f52 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -56,6 +56,26 @@ class DashboardGearbox : DashboardThing LoadFont(); } + vec4 GearColor(uint gear) + { + switch (gear) { + case 0: return Setting_Gearbox_Gear0Color; + case 1: return Setting_Gearbox_Gear1Color; + case 2: return Setting_Gearbox_Gear2Color; + case 3: return Setting_Gearbox_Gear3Color; + case 4: return Setting_Gearbox_Gear4Color; + case 5: return Setting_Gearbox_Gear5Color; +#if MP4 || TURBO + case 6: return Setting_Gearbox_Gear6Color; + case 7: return Setting_Gearbox_Gear7Color; +#endif +#if TURBO + case 8: return Setting_Gearbox_Gear8Color; + case 9: return Setting_Gearbox_Gear9Color; +#endif + } + } + void RenderNumbers(const vec2 &in pos, const vec2 &in size, uint gear, float rpm) { nvg::BeginPath(); @@ -70,23 +90,7 @@ class DashboardGearbox : DashboardThing vec4 textColor = Setting_Gearbox_TextColor; if (Setting_Gearbox_UseGearColors) { - - switch (gear) { - case 0: textColor = Setting_Gearbox_Gear0Color; break; - case 1: textColor = Setting_Gearbox_Gear1Color; break; - case 2: textColor = Setting_Gearbox_Gear2Color; break; - case 3: textColor = Setting_Gearbox_Gear3Color; break; - case 4: textColor = Setting_Gearbox_Gear4Color; break; - case 5: textColor = Setting_Gearbox_Gear5Color; break; -#if MP4 || TURBO - case 6: textColor = Setting_Gearbox_Gear6Color; break; - case 7: textColor = Setting_Gearbox_Gear7Color; break; -#endif -#if TURBO - case 8: textColor = Setting_Gearbox_Gear8Color; break; - case 9: textColor = Setting_Gearbox_Gear9Color; break; -#endif - } + textColor = GearColor(gear); } nvg::FontFace(m_font); nvg::FillColor(textColor); @@ -219,14 +223,7 @@ class DashboardGearbox : DashboardThing } if (Setting_Gearbox_UseGearColors && Setting_Gearbox_Lights_UseGearColors) { - switch (gear) { - case 0: color = Setting_Gearbox_Gear0Color; break; - case 1: color = Setting_Gearbox_Gear1Color; break; - case 2: color = Setting_Gearbox_Gear2Color; break; - case 3: color = Setting_Gearbox_Gear3Color; break; - case 4: color = Setting_Gearbox_Gear4Color; break; - case 5: color = Setting_Gearbox_Gear5Color; break; - } + color = GearColor(gear); } float lightPadding = 8.0f; @@ -240,7 +237,7 @@ class DashboardGearbox : DashboardThing pos.y + lightPadding, lightSize, size.y - 2 * lightPadding, - 4 + Setting_Gearbox_BorderRadius ); if (i < lights) { nvg::FillColor(color); From 91dd75ff9dbdef1d4b2cdec28a8986dd50565a84 Mon Sep 17 00:00:00 2001 From: Zack H Date: Fri, 6 Feb 2026 19:01:28 -0600 Subject: [PATCH 4/8] Use per-game max gear Correct padding and light size --- Source/Things/Gearbox.as | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index b178f52..cd1700e 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -1,3 +1,11 @@ +#if MP4 +const uint MAX_GEAR = 7; +#elif TURBO +const uint MAX_GEAR = 9; +#else +const uint MAX_GEAR = 5; +#endif + class DashboardGearbox : DashboardThing { float m_minRpm = 200.0f; // Minimal RPM to avoid flickering at engine idle @@ -73,6 +81,7 @@ class DashboardGearbox : DashboardThing case 8: return Setting_Gearbox_Gear8Color; case 9: return Setting_Gearbox_Gear9Color; #endif + default: return Setting_Gearbox_Gear0Color; } } @@ -218,7 +227,7 @@ class DashboardGearbox : DashboardThing vec4 color = Setting_Gearbox_Lights_Color; if (gear == 0) { - lights = 5; + lights = MAX_GEAR; color = Setting_Gearbox_Lights_Color_Reverse; } @@ -227,10 +236,10 @@ class DashboardGearbox : DashboardThing } float lightPadding = 8.0f; - float spaceForPadding = lightPadding * 6.0; - float lightSize = (size.x - spaceForPadding) / 5.0; + float spaceForPadding = lightPadding * float(MAX_GEAR + 1); + float lightSize = (size.x - spaceForPadding) / float(MAX_GEAR); - for (uint i = 0; i < 5; i++) { + for (uint i = 0; i < MAX_GEAR; i++) { nvg::BeginPath(); nvg::RoundedRect( pos.x + (i + 1) * lightPadding + i * lightSize, From aa0d950ec3af0f986c6111aad3a449bf5aa3458a Mon Sep 17 00:00:00 2001 From: Zack H Date: Fri, 6 Feb 2026 19:11:45 -0600 Subject: [PATCH 5/8] Always use gear colors if enabled --- Source/Settings.as | 7 ++----- Source/Things/Gearbox.as | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/Settings.as b/Source/Settings.as index 858e50f..b69d28e 100644 --- a/Source/Settings.as +++ b/Source/Settings.as @@ -265,13 +265,10 @@ vec4 Setting_Gearbox_Gear4Color = vec4(1, 1, 1, 1); [Setting category="Gearbox" name="Gear 5 color" color if="Setting_Gearbox_UseGearColors"] vec4 Setting_Gearbox_Gear5Color = vec4(1, 1, 1, 1); -[Setting category="Gearbox" name="Use gear colors for lights" if="Setting_Gearbox_TachometerStyle Lights"] -bool Setting_Gearbox_Lights_UseGearColors = false; - -[Setting category="Gearbox" name="Gear light color" color if="Setting_Gearbox_TachometerStyle Lights"] +[Setting category="Gearbox" name="Gear light color (if not using gear colors)" color if="Setting_Gearbox_TachometerStyle Lights"] vec4 Setting_Gearbox_Lights_Color = vec4(0.568f, 1, 0.961f, 1); -[Setting category="Gearbox" name="Gear light color for gear 0 (reverse)" color if="Setting_Gearbox_TachometerStyle Lights"] +[Setting category="Gearbox" name="Gear light color for gear 0 (backwards, if not using gear colors)" color if="Setting_Gearbox_TachometerStyle Lights"] vec4 Setting_Gearbox_Lights_Color_Reverse = vec4(1, 0.216f, 0.216f, 1); [Setting category="Gearbox" name="Background color for unlit gear lights" color if="Setting_Gearbox_TachometerStyle Lights"] diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index cd1700e..4bf8242 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -231,7 +231,7 @@ class DashboardGearbox : DashboardThing color = Setting_Gearbox_Lights_Color_Reverse; } - if (Setting_Gearbox_UseGearColors && Setting_Gearbox_Lights_UseGearColors) { + if (Setting_Gearbox_UseGearColors) { color = GearColor(gear); } From 2c9ef590481ef55e076ba3b4d0d6b0d83dc7d4d8 Mon Sep 17 00:00:00 2001 From: Zack H Date: Fri, 6 Feb 2026 19:01:47 -0600 Subject: [PATCH 6/8] Use low/high RPM color for gears about to shift --- Source/Things/Gearbox.as | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index 4bf8242..340cdb0 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -235,6 +235,12 @@ class DashboardGearbox : DashboardThing color = GearColor(gear); } + if (rpm <= Setting_Gearbox_Downshift && gear >= 2) { + color = Setting_Gearbox_LowRPMColor; + } else if (rpm >= Setting_Gearbox_Upshift && gear <= MAX_GEAR - 1) { + color = Setting_Gearbox_HighRPMColor; + } + float lightPadding = 8.0f; float spaceForPadding = lightPadding * float(MAX_GEAR + 1); float lightSize = (size.x - spaceForPadding) / float(MAX_GEAR); From bad11297f8fdd6a78e29e7669d6b674182fe43ed Mon Sep 17 00:00:00 2001 From: Zack H Date: Fri, 6 Feb 2026 19:13:28 -0600 Subject: [PATCH 7/8] Put low/high RPM behind setting --- Source/Settings.as | 3 +++ Source/Things/Gearbox.as | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Settings.as b/Source/Settings.as index b69d28e..38d1981 100644 --- a/Source/Settings.as +++ b/Source/Settings.as @@ -265,6 +265,9 @@ vec4 Setting_Gearbox_Gear4Color = vec4(1, 1, 1, 1); [Setting category="Gearbox" name="Gear 5 color" color if="Setting_Gearbox_UseGearColors"] vec4 Setting_Gearbox_Gear5Color = vec4(1, 1, 1, 1); +[Setting category="Gearbox" name="Show low/high RPM colors on gear lights" if="Setting_Gearbox_TachometerStyle Lights"] +bool Setting_Gearbox_Lights_ShowLowHighRPM = true; + [Setting category="Gearbox" name="Gear light color (if not using gear colors)" color if="Setting_Gearbox_TachometerStyle Lights"] vec4 Setting_Gearbox_Lights_Color = vec4(0.568f, 1, 0.961f, 1); diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index 340cdb0..7c6bc38 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -235,10 +235,12 @@ class DashboardGearbox : DashboardThing color = GearColor(gear); } - if (rpm <= Setting_Gearbox_Downshift && gear >= 2) { - color = Setting_Gearbox_LowRPMColor; - } else if (rpm >= Setting_Gearbox_Upshift && gear <= MAX_GEAR - 1) { - color = Setting_Gearbox_HighRPMColor; + if (Setting_Gearbox_Lights_ShowLowHighRPM) { + if (rpm <= Setting_Gearbox_Downshift && gear >= 2) { + color = Setting_Gearbox_LowRPMColor; + } else if (rpm >= Setting_Gearbox_Upshift && gear <= MAX_GEAR - 1) { + color = Setting_Gearbox_HighRPMColor; + } } float lightPadding = 8.0f; From dcf352825c46b19b5159f2875c1d466686d1fb02 Mon Sep 17 00:00:00 2001 From: Zack H Date: Tue, 10 Feb 2026 20:10:42 -0600 Subject: [PATCH 8/8] Move global MAX_GEAR constant to local constant --- Source/Things/Gearbox.as | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Things/Gearbox.as b/Source/Things/Gearbox.as index 7c6bc38..19e1354 100644 --- a/Source/Things/Gearbox.as +++ b/Source/Things/Gearbox.as @@ -1,11 +1,3 @@ -#if MP4 -const uint MAX_GEAR = 7; -#elif TURBO -const uint MAX_GEAR = 9; -#else -const uint MAX_GEAR = 5; -#endif - class DashboardGearbox : DashboardThing { float m_minRpm = 200.0f; // Minimal RPM to avoid flickering at engine idle @@ -226,8 +218,16 @@ class DashboardGearbox : DashboardThing uint lights = gear; vec4 color = Setting_Gearbox_Lights_Color; +#if MP4 + const uint gearCount = 7; +#elif TURBO + const uint gearCount = 9; +#else + const uint gearCount = 5; +#endif + if (gear == 0) { - lights = MAX_GEAR; + lights = gearCount; color = Setting_Gearbox_Lights_Color_Reverse; } @@ -238,16 +238,16 @@ class DashboardGearbox : DashboardThing if (Setting_Gearbox_Lights_ShowLowHighRPM) { if (rpm <= Setting_Gearbox_Downshift && gear >= 2) { color = Setting_Gearbox_LowRPMColor; - } else if (rpm >= Setting_Gearbox_Upshift && gear <= MAX_GEAR - 1) { + } else if (rpm >= Setting_Gearbox_Upshift && gear <= gearCount - 1) { color = Setting_Gearbox_HighRPMColor; } } float lightPadding = 8.0f; - float spaceForPadding = lightPadding * float(MAX_GEAR + 1); - float lightSize = (size.x - spaceForPadding) / float(MAX_GEAR); + float spaceForPadding = lightPadding * float(gearCount + 1); + float lightSize = (size.x - spaceForPadding) / float(gearCount); - for (uint i = 0; i < MAX_GEAR; i++) { + for (uint i = 0; i < gearCount; i++) { nvg::BeginPath(); nvg::RoundedRect( pos.x + (i + 1) * lightPadding + i * lightSize,