mirror of
https://github.com/IAmTomShaw/f1-race-replay.git
synced 2026-05-09 16:35:49 +02:00
[PR #47] Feature: Add Last Lap Time and Interval Gaps to Race Replay Leaderboard #99
Labels
No labels
bug
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/f1-race-replay#99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/47
Author: @KingSajxxd
Created: 12/15/2025
Status: 🔄 Open
Base:
main← Head:main📝 Commits (1)
4aba004feat: Add lap times and interval gaps to race leaderboard📊 Changes
3 files changed (+140 additions, -27 deletions)
View changed files
📝
src/f1_data.py(+79 -13)📝
src/interfaces/race_replay.py(+11 -3)📝
src/ui_components.py(+50 -11)📄 Description
Description
This PR enhances the Race Replay UI by adding two critical data points to the leaderboard: Last Lap Time and Interval (time gap to the car ahead). This brings the replay experience closer to a real F1 broadcast.
Previously, the leaderboard only showed positions and tire compounds. Now, it calculates real-time gaps in seconds (interpolated from telemetry data) and displays the most recent lap time for every driver.
Changes Overview
1. Data Processing (
src/f1_data.py)Added Last Lap Logic:
_process_single_driverto capture theLapTimeof the previous lap and forward-fill it into the current lap's telemetry frames.Added Interval Calculation:
get_race_telemetryto calculate the time gap (in seconds) between cars.np.interpto find the exact timestamp when the "car ahead" was at the "current car's" current distance, then calculates the difference (current_time - time_ahead_was_here).Frame Payload:
last_lap_time_strandinterval_strfor every driver.2. UI Components (
src/ui_components.py)Widened Leaderboard:
LeaderboardComponentwidth from 240px to 400px to accommodate the new columns.New Headers:
Rendering:
draw()method to render the newlast_lap_time(center-aligned) andinterval(right-aligned) text strings.3. Race Replay Interface (
src/interfaces/race_replay.py)Window Layout:
right_ui_marginfrom 260 to 420 to fit the wider leaderboard without overlapping the track.Data Passing:
on_drawto extract the new fields (last_lap_time_str,interval_str) from the frame data and pass them as a 6-item tuple to theLeaderboardComponent.How to Test
Run the replay with the
--refresh-dataflag to regenerate the cache with the new metrics:Observe the leaderboard on the right side; it should now display lap times and intervals.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.