Skip to content

Implement gear light tachometer#90

Open
zphixon wants to merge 8 commits intocodecat:mainfrom
zphixon:gear-lights
Open

Implement gear light tachometer#90
zphixon wants to merge 8 commits intocodecat:mainfrom
zphixon:gear-lights

Conversation

@zphixon
Copy link

@zphixon zphixon commented Nov 13, 2025

Hello! This is intended to emulate the gear lights on the back of the car. I think this is a little easier to parse than the gear number text. In the future it might be worth copying how car status (turbo, cruise control, etc) change the gear lights.

Trackmania_2025-11-13_16-00-33.online-video-cutter.com.webm

@zphixon
Copy link
Author

zphixon commented Nov 15, 2025

It's been brought to my attention that the existing tach types are relied on as a visual indicator for when a gear shift is about to happen. Something like this would include that functionality.

if (rpm <= Setting_Gearbox_Downshift && gear >= 2) {
	color = Setting_Gearbox_LowRPMColor;
} else if (rpm >= Setting_Gearbox_Upshift && gear <= 4) {
	color = Setting_Gearbox_HighRPMColor;
}

If we include this change we might want to use Setting_Gearbox_MidRPMColor instead of a new separate Setting_Gearbox_Lights_Color. We would probably also want a setting to enable/disable this, as RPM doesn't seem like a super accurate way to predict gear shifts. There doesn't seem to be a downshift threshold value that both avoids flickering the downshift color on gearing up into 2, and also shows the downshift color at all when gearing down into 4. I adjusted the thresholds here to 6400/9700:

Trackmania_2025-11-15_12-41-55.webm

@codecat
Copy link
Owner

codecat commented Nov 16, 2025

Thanks for the PR! I can't playback the videos on my Mac for some reason, but I will take a look at this soon.

@zphixon
Copy link
Author

zphixon commented Nov 18, 2025

Yw! I replaced the mp4s with webms, maybe that helps?

@zphixon
Copy link
Author

zphixon commented Feb 3, 2026

Hi, hate to bump but did you ever get a chance to look at this 👉👈

@codecat
Copy link
Owner

codecat commented Feb 3, 2026

Sorry I forgot! I'll try to take a look today.

Copy link
Owner

@codecat codecat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work so far! Looks clean enough, but needs support for Maniaplanet and Turbo.

float spaceForPadding = lightPadding * 6.0;
float lightSize = (size.x - spaceForPadding) / 5.0;

for (uint i = 0; i < 5; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more than 5 gears in Maniaplanet and Turbo cars, so we should support that too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all cars in mp4 have 7, and all cars in turbo have 9? I don't own these games so I can't test it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right, it may indeed be a bit different for the non-Stadium cars :( You may have to look at the current car model the player is driving.

Arguably this may also be something to look at the the non-Stadium cars in Trackmania - I'm not sure about those gearboxes.

Copy link
Author

@zphixon zphixon Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VehicleState is telling me all the tm2020 cars have 5 gears. Zai on the TM discord tells me for tm2

canyon valley lagoon traffic have 7
the rest have 5

but VehicleState::GetVehicleType is only implemented in tm2020. Supposing it can be added for other games it should be a pretty simple fix over here. Still don't know about turbo

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'll take a quick look at this tonight and get back to this. 👍

@zphixon
Copy link
Author

zphixon commented Feb 7, 2026

Went ahead and added the low/high RPM colors behind a setting. Also now uses gear colors if they're enabled (instead of having a second separate checkbox). Reworded the settings to reflect that

Copy link
Owner

@codecat codecat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes! We'll indeed need to look at the other cars on Maniaplanet. Other than that, there's a small style fix.

Comment on lines 1 to 7
#if MP4
const uint MAX_GEAR = 7;
#elif TURBO
const uint MAX_GEAR = 9;
#else
const uint MAX_GEAR = 5;
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant is only used when GearboxTachometerStyle::Lights is used, so to keep the global scope clean you can move this (as a regular variable) into that same switch case.

It could then probably also be named lightCount rather than "max gear", which may be a bit clearer in its purpose/intent?

float spaceForPadding = lightPadding * 6.0;
float lightSize = (size.x - spaceForPadding) / 5.0;

for (uint i = 0; i < 5; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right, it may indeed be a bit different for the non-Stadium cars :( You may have to look at the current car model the player is driving.

Arguably this may also be something to look at the the non-Stadium cars in Trackmania - I'm not sure about those gearboxes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants