app: draw the whole timeline under the review scrubber

Every event in the recording gets a tick: kills and deaths coloured by
whether they were the player's, objectives and LP changes in the accent,
game start and end muted. Highlights sit on the track as bands.

The summoner carries a #TAG that the live client data's KillerName does
not, so involvement never matched and every game showed 0 highlights.
Names are compared without the tag now.
This commit is contained in:
vhaudiquet committed 2026-11-15 23:34:23 +01:00
1 parent e7a36c3129
commit 17c73925bf
2 files changed
+132 -57

No files matched your search

+100 -52
View File
@@ -207,7 +207,7 @@ pub fn view(app: &App, p: Paint) -> El {
.gap(space::S3)
.child(header)
.child(video_stage(app, p))
.child(scrubber(app, p))
.child(scrubber(app, p, game))
.child(
row()
.key("review-body")
@@ -317,7 +317,7 @@ fn playing(app: &App) -> bool {
app.review.player.as_ref().is_some_and(Player::is_playing)
}
fn scrubber(app: &App, p: Paint) -> El {
fn scrubber(app: &App, p: Paint, game: &Timeline) -> El {
let width = if app.review.scrubber_width > 0.0 {
app.review.scrubber_width
} else {
@@ -326,6 +326,7 @@ fn scrubber(app: &App, p: Paint) -> El {
let duration = app.review.duration.max(0.001);
let progress = (app.review.time / duration).clamp(0.0, 1.0) as f32;
let knob = 14.0;
let player = game.summoner();
let mut bar = el()
.key("scrubber")
@@ -333,7 +334,7 @@ fn scrubber(app: &App, p: Paint) -> El {
.label("Playback position")
.range_value(app.review.time, 0.0, duration)
.w_full()
.h(26.0)
.h(34.0)
.on_layout(|app: &mut App, [_, _, w, _]| {
app.review.scrubber_width = w;
})
@@ -351,38 +352,77 @@ fn scrubber(app: &App, p: Paint) -> El {
el().key("track")
.w_full()
.h(6.0)
.absolute(0.0, 10.0)
.absolute(0.0, 12.0)
.radius(3.0)
.fill(p.t.control_off)
.a11y_hidden(),
)
.child(
el().key("played")
.w((width * progress).max(2.0))
.h(6.0)
.absolute(0.0, 10.0)
.radius(3.0)
.fill(p.accent)
.a11y_hidden(),
);
// Each highlight as a band on the track, so the clip it exports is visible at a glance.
for (index, clip) in app.review.highlights.iter().enumerate() {
let x = (clip.start / duration).clamp(0.0, 1.0) as f32 * (width - 6.0);
let start = clip.start;
let x = (clip.start / duration).clamp(0.0, 1.0) as f32 * width;
let end = (clip.end / duration).clamp(0.0, 1.0) as f32 * width;
let ink = match clip.kind {
highlight::Kind::Death => p.danger(),
highlight::Kind::Assist => p.muted(),
_ => p.success(),
};
bar = bar.child(
el().key(format!("marker-{index}"))
.role("button")
.label(format!("{} at {}", clip.kind.label(), format::clock(start)))
.w(6.0)
.h(12.0)
.absolute(x, 2.0)
el().key(format!("clip-{index}"))
.w((end - x).max(4.0))
.h(6.0)
.absolute(x, 12.0)
.radius(3.0)
.fill(match clip.kind {
highlight::Kind::Death => p.danger(),
highlight::Kind::Assist => p.muted(),
_ => p.success(),
})
.on_press(move |app: &mut App| app.review.seek(start))
.fill(ink.alpha(0.32))
.a11y_hidden(),
);
}
bar = bar.child(
el().key("played")
.w((width * progress).max(2.0))
.h(6.0)
.absolute(0.0, 12.0)
.radius(3.0)
.fill(p.accent.alpha(0.55))
.a11y_hidden(),
);
// One tick per timeline event, below the track: every kill, objective and change the
// recording has, not only the player's own.
for (index, event) in game.events.iter().enumerate() {
let at = event.time();
if !at.is_finite() || at < 0.0 || at > duration {
continue;
}
let x = (at / duration) as f32 * (width - 2.0);
let involvement = player
.as_deref()
.and_then(|name| highlight::involvement(event, name));
let ink = match event.event_type.as_str() {
"kill" => match involvement {
Some(highlight::Kind::Death) => p.danger(),
Some(_) => p.success(),
None => p.muted().alpha(0.75),
},
"objective" | "lp_change" => p.accent,
"game_start" | "game_end" => p.muted(),
_ => p.muted().alpha(0.5),
};
let label = match involvement {
Some(kind) => kind.label().to_string(),
None if event.description.is_empty() => event.event_type.clone(),
None => event.description.clone(),
};
bar = bar.child(
el().key(format!("event-tick-{index}"))
.role("button")
.label(format!("{label} at {}", format::clock(at)))
.w(2.0)
.h(9.0)
.absolute(x, 21.0)
.fill(ink)
.on_press(move |app: &mut App| app.review.seek(at))
.a11y_hidden(),
);
}
@@ -390,7 +430,7 @@ fn scrubber(app: &App, p: Paint) -> El {
bar.child(
el().key("knob")
.size(knob, knob)
.absolute(progress * (width - knob), 6.0)
.absolute(progress * (width - knob), 8.0)
.radius(knob / 2.0)
.fill(p.t.knob)
.shadow(1.0, 3.0, p.t.knob_shadow)
@@ -403,11 +443,15 @@ fn highlights(app: &App, p: Paint, game: &Timeline) -> El {
let mut list = col().key("highlight-rows").w_full().gap(4.0);
if app.review.highlights.is_empty() {
list = list.child(
text("No kills or deaths in this recording.")
.key("no-highlights")
.font(body(12.0))
.color(p.muted())
.padding(space::S2),
text(if game.events.is_empty() {
"No timeline was saved for this recording."
} else {
"No kills or deaths in this recording."
})
.key("no-highlights")
.font(body(12.0))
.color(p.muted())
.padding(space::S2),
);
}
for (index, clip) in app.review.highlights.iter().enumerate() {
@@ -517,19 +561,21 @@ fn highlights(app: &App, p: Paint, game: &Timeline) -> El {
.color(p.muted()),
)
.child(
col()
.key("highlight-scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(list),
app.highlights_scroll.follow(
col()
.key("highlight-scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(list),
),
)
}
fn events(_app: &App, p: Paint, game: &Timeline) -> El {
fn events(app: &App, p: Paint, game: &Timeline) -> El {
let interesting = |kind: &str| {
matches!(
kind,
@@ -605,14 +651,16 @@ fn events(_app: &App, p: Paint, game: &Timeline) -> El {
.color(p.muted()),
)
.child(
col()
.key("event-scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(list),
app.events_scroll.follow(
col()
.key("event-scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(list),
),
)
}