Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Source/Settings.as
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ enum GearboxTachometerStyle
Bar,
Dots,
Blocks,
Lights,
}

[Setting category="Gearbox" name="Tachometer style" if="Setting_Gearbox_ShowTachometer"]
Expand Down Expand Up @@ -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="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);

[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"]
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);
Expand Down
96 changes: 77 additions & 19 deletions Source/Things/Gearbox.as
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ 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
default: return Setting_Gearbox_Gear0Color;
}
}

void RenderNumbers(const vec2 &in pos, const vec2 &in size, uint gear, float rpm)
{
nvg::BeginPath();
Expand All @@ -70,23 +91,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);
Expand All @@ -109,7 +114,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;
Expand Down Expand Up @@ -208,6 +213,59 @@ class DashboardGearbox : DashboardThing
}
break;
}

case GearboxTachometerStyle::Lights: {
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 = gearCount;
color = Setting_Gearbox_Lights_Color_Reverse;
}

if (Setting_Gearbox_UseGearColors) {
color = GearColor(gear);
}

if (Setting_Gearbox_Lights_ShowLowHighRPM) {
if (rpm <= Setting_Gearbox_Downshift && gear >= 2) {
color = Setting_Gearbox_LowRPMColor;
} else if (rpm >= Setting_Gearbox_Upshift && gear <= gearCount - 1) {
color = Setting_Gearbox_HighRPMColor;
}
}

float lightPadding = 8.0f;
float spaceForPadding = lightPadding * float(gearCount + 1);
float lightSize = (size.x - spaceForPadding) / float(gearCount);

for (uint i = 0; i < gearCount; i++) {
nvg::BeginPath();
nvg::RoundedRect(
pos.x + (i + 1) * lightPadding + i * lightSize,
pos.y + lightPadding,
lightSize,
size.y - 2 * lightPadding,
Setting_Gearbox_BorderRadius
);
if (i < lights) {
nvg::FillColor(color);
} else {
nvg::FillColor(Setting_Gearbox_Lights_Color_Background);
}
nvg::Fill();
}

break;
}
}

// Border
Expand Down Expand Up @@ -237,7 +295,7 @@ class DashboardGearbox : DashboardThing
}

if (Setting_Gearbox_ShowTachometer) {
RenderTachometer(offset, size, rpm);
RenderTachometer(offset, size, rpm, gear);
}
}
}