Skip to content

Commit

Permalink
feat standings: print current leader lap
Browse files Browse the repository at this point in the history
  • Loading branch information
xikxp1 committed Oct 30, 2024
1 parent e481904 commit b7f5d5f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iracehud"
version = "0.1.6"
version = "0.1.7"
description = "iRacing HUD overlay built in Tauri"
authors = ["Ivan Kachalkin<xikxp1@gmail.com>"]
edition = "2021"
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub struct StandingsDriver {
best_lap: LapTime,
last_lap: LapTime,
is_player: bool,
is_leader: bool,
is_in_pits: bool,
}

Expand Down Expand Up @@ -446,6 +447,7 @@ impl StandingsDriver {
best_lap: LapTime::new_from_sd(driver.best_lap_time),
last_lap: LapTime::new_from_sd(driver.last_lap_time),
is_player: driver.is_player,
is_leader: driver.is_leader,
is_in_pits: driver.is_in_pits,
}
}
Expand Down
23 changes: 22 additions & 1 deletion src/components/Standings.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import type {
CurrentTime,
Laps,
Position,
Standings,
StrengthOfField,
Expand All @@ -14,6 +15,7 @@
let stength_of_field = 0;
let current_time = "––:––";
let driver_count = 0;
let leader_lap = 0;
let standings: Standings = [];
Expand All @@ -25,6 +27,7 @@
let current_time_channel = new Channel<CurrentTime>();
let stength_of_field_channel = new Channel<StrengthOfField>();
let positions_total_channel = new Channel<Position>();
let race_laps_channel = new Channel<Laps>();
onMount(() => {
interval = setInterval(() => {
Expand All @@ -47,6 +50,10 @@
driver_count = message;
};
race_laps_channel.onmessage = (message) => {
leader_lap = message;
};
invoke("register_event_emitter", {
event: "standings",
onEvent: standings_channel,
Expand All @@ -66,6 +73,11 @@
event: "positions_total",
onEvent: positions_total_channel,
});
invoke("register_event_emitter", {
event: "race_laps",
onEvent: race_laps_channel,
});
});
onDestroy(() => {
Expand All @@ -74,6 +86,7 @@
current_time_channel.onmessage = () => {};
stength_of_field_channel.onmessage = () => {};
positions_total_channel.onmessage = () => {};
race_laps_channel.onmessage = () => {};
invoke("unregister_event_emitter", {
event: "standings",
Expand All @@ -90,6 +103,10 @@
invoke("unregister_event_emitter", {
event: "positions_total",
});
invoke("unregister_event_emitter", {
event: "race_laps",
});
});
</script>

Expand Down Expand Up @@ -149,7 +166,11 @@
{/if}
</td>
<td class="text text-sm text-right pr-1 w-[40px]">
{st?.leader_gap ?? ""}
{#if st?.is_leader && leader_lap > 0}
on L{leader_lap}
{:else}
{st?.leader_gap ?? ""}
{/if}
</td>
</tr>
{/each}
Expand Down
26 changes: 13 additions & 13 deletions src/lib/types/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// This file has been generated by Specta. DO NOT EDIT.

export type RelativeDriver = { car_id: number; position: number; user_name: string; car_number: string; irating: IRating; license: string; player_relative_gap: RelativeGap; is_player: boolean; is_in_pits: boolean; is_off_track: boolean; is_off_world: boolean }

export type LapTime = string

export type Incidents = number
Expand All @@ -10,9 +12,15 @@ export type Telemetry = { ts: number; throttle: number; brake: number; abs_activ

export type TrackMapDriver = { car_id: number; position: number; is_leader: boolean; is_player: boolean; lap_dist_pct: number; is_in_pits: boolean; is_off_track: boolean; is_off_world: boolean; x: number; y: number }

export type LapTimes = LapTimeData[]

export type SessionTime = string

export type RelativeDriver = { car_id: number; position: number; user_name: string; car_number: string; irating: IRating; license: string; player_relative_gap: RelativeGap; is_player: boolean; is_in_pits: boolean; is_off_track: boolean; is_off_world: boolean }
export type Standings = StandingsDriver[]

export type Relative = RelativeDriver[]

export type LapTimeData = { lap: number; lap_time: LapTime }

export type RelativeGap = string

Expand All @@ -24,39 +32,31 @@ export type IRating = string

export type LapsTotal = number

export type LapTimes = LapTimeData[]

export type LapTimeData = { lap: number; lap_time: LapTime }

export type SessionTimeTotal = string

export type Proximity = { is_left: boolean; is_right: boolean }

export type CurrentTime = string

export type StrengthOfField = number

export type Laps = number

export type RPM = number

export type Relative = RelativeDriver[]
export type TrackID = number

export type SessionState = string

export type Standings = StandingsDriver[]

export type Position = number

export type DeltaTime = string

export type TrackID = number

export type TrackMap = TrackMapDriver[]

export type Gear = string

export type StrengthOfField = number

export type Gap = string

export type StandingsDriver = { car_id: number; position: number; user_name: string; car_number: string; irating: IRating; license: string; leader_gap: Gap; best_lap: LapTime; last_lap: LapTime; is_player: boolean; is_in_pits: boolean }
export type StandingsDriver = { car_id: number; position: number; user_name: string; car_number: string; irating: IRating; license: string; leader_gap: Gap; best_lap: LapTime; last_lap: LapTime; is_player: boolean; is_leader: boolean; is_in_pits: boolean }

0 comments on commit b7f5d5f

Please sign in to comment.