app: add native rune client for record-daemon
Replaces the Vue/Tauri front end with a rune app that speaks the daemon's existing IPC protocol: settings (general, recording, audio), match history and game review with a scrubber, event markers and ffmpeg highlight export. Includes tray icon, launch at login, single instance, toasts, a headless snapshot path for checking screens, and a cargo-packager NSIS config. Rune is pinned to 4ddf696b0f and its three patched crates are vendored under app/vendor, since a dependency's [patch.crates-io] does not apply to the app. The daemon's OBS bootstrap never reached its IPC server on this machine, so the live check is a `--probe` command; the wire format is covered by tests.
This commit is contained in:
1 parent
d712c4ea85
commit
0377141e4f
349 files changed
+142819
No files matched your search
@@ -0,0 +1,306 @@
|
||||
//! Match history: the timelines on disk, newest first, filtered by queue.
|
||||
//!
|
||||
//! The card reads like `GameHistory.vue`: result banner, champion, queue, KDA, per-minute
|
||||
//! stats, items are not shown because the app has no Data Dragon image cache yet.
|
||||
|
||||
use rune::tok::{radius, space, type_};
|
||||
use rune::{Color, El, col, el, row, text};
|
||||
|
||||
use crate::app::App;
|
||||
use crate::format;
|
||||
use crate::history::{Outcome, QueueCategory, Timeline};
|
||||
use crate::screens::review;
|
||||
use crate::ui::{self, Paint, body, heading};
|
||||
|
||||
const FILTERS: [Option<QueueCategory>; 6] = [
|
||||
None,
|
||||
Some(QueueCategory::RankedSolo),
|
||||
Some(QueueCategory::RankedFlex),
|
||||
Some(QueueCategory::Normals),
|
||||
Some(QueueCategory::Aram),
|
||||
Some(QueueCategory::Custom),
|
||||
];
|
||||
|
||||
fn filter_label(filter: Option<QueueCategory>) -> &'static str {
|
||||
filter.map_or("All", QueueCategory::label)
|
||||
}
|
||||
|
||||
fn outcome_color(p: Paint, outcome: Outcome) -> Color {
|
||||
match outcome {
|
||||
Outcome::Victory => p.success(),
|
||||
Outcome::Defeat => p.danger(),
|
||||
Outcome::Terminated => p.muted(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn view(app: &App, p: Paint) -> El {
|
||||
let filtered: Vec<(usize, &Timeline)> = app
|
||||
.games
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, g)| app.filter.is_none_or(|f| g.category() == f))
|
||||
.collect();
|
||||
|
||||
let mut list = col().key("games").w_full().gap(space::S2);
|
||||
if !app.games_loaded {
|
||||
list = list.child(
|
||||
text("Loading match history…")
|
||||
.key("loading")
|
||||
.font(body(13.0))
|
||||
.color(p.muted())
|
||||
.padding(space::S6),
|
||||
);
|
||||
} else if app.games.is_empty() {
|
||||
list = list.child(empty(
|
||||
p,
|
||||
"No games recorded",
|
||||
"Start playing: the daemon records each game and it shows up here.",
|
||||
));
|
||||
} else if filtered.is_empty() {
|
||||
list = list.child(empty(
|
||||
p,
|
||||
"No games match this filter",
|
||||
"Pick another queue above.",
|
||||
));
|
||||
} else {
|
||||
for (index, game) in filtered {
|
||||
list = list.child(game_card(p, game, index));
|
||||
}
|
||||
}
|
||||
|
||||
let mut filters = row().key("filters").gap(4.0).center_y();
|
||||
for filter in FILTERS {
|
||||
let selected = app.filter == filter;
|
||||
filters = filters.child(ui::tab(
|
||||
p,
|
||||
filter_label(filter),
|
||||
filter_label(filter),
|
||||
selected,
|
||||
move |app: &mut App| app.filter = filter,
|
||||
));
|
||||
}
|
||||
|
||||
col()
|
||||
.key("history")
|
||||
.w_full()
|
||||
.h_full()
|
||||
.padding(space::S6)
|
||||
.gap(space::S3)
|
||||
.child(
|
||||
row()
|
||||
.key("history-header")
|
||||
.w_full()
|
||||
.justify_between()
|
||||
.center_y()
|
||||
.child(
|
||||
col()
|
||||
.key("history-title")
|
||||
.gap(2.0)
|
||||
.child(
|
||||
text("Match history")
|
||||
.key("title")
|
||||
.font(heading(20.0))
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(
|
||||
text(format!("{} recordings", app.games.len()))
|
||||
.key("count")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(filters),
|
||||
)
|
||||
.child(
|
||||
col()
|
||||
.key("list-scroller")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.scroll(rune::ScrollSpec {
|
||||
stick_bottom: false,
|
||||
})
|
||||
.child(list),
|
||||
)
|
||||
}
|
||||
|
||||
fn empty(p: Paint, title: &str, detail: &str) -> El {
|
||||
col()
|
||||
.key("empty")
|
||||
.w_full()
|
||||
.py(64.0)
|
||||
.gap(6.0)
|
||||
.center()
|
||||
.child(
|
||||
text(title)
|
||||
.key("empty-title")
|
||||
.font(heading(15.0))
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(
|
||||
text(detail)
|
||||
.key("empty-detail")
|
||||
.font(body(12.0))
|
||||
.color(p.muted()),
|
||||
)
|
||||
}
|
||||
|
||||
fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
|
||||
let outcome = game.outcome();
|
||||
let ink = outcome_color(p, outcome);
|
||||
let champion = game.champion().unwrap_or_else(|| "Unknown champion".into());
|
||||
let duration = game.duration_secs.max(0) as f64;
|
||||
let lp = game.lp_change();
|
||||
let stats = game.stats();
|
||||
|
||||
let mut banner = row()
|
||||
.key("banner")
|
||||
.w_full()
|
||||
.h(26.0)
|
||||
.px(space::S3)
|
||||
.center_y()
|
||||
.justify_between()
|
||||
.fill(ink.alpha(0.16))
|
||||
.child(
|
||||
row()
|
||||
.key("banner-left")
|
||||
.gap(8.0)
|
||||
.center_y()
|
||||
.child(
|
||||
text(outcome.label())
|
||||
.key("outcome")
|
||||
.font(type_::LABEL)
|
||||
.color(ink),
|
||||
)
|
||||
.child(
|
||||
text(game.summoner().unwrap_or_default())
|
||||
.key("summoner")
|
||||
.font(body(11.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
);
|
||||
if let Some(lp) = &lp {
|
||||
let lp_ink = if lp.delta >= 0 {
|
||||
p.success()
|
||||
} else {
|
||||
p.danger()
|
||||
};
|
||||
banner = banner.child(
|
||||
text(format!(
|
||||
"{} LP · {}",
|
||||
format::lp_delta(lp.delta),
|
||||
format::rank(&lp.tier, &lp.division)
|
||||
))
|
||||
.key("lp")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(lp_ink),
|
||||
);
|
||||
}
|
||||
|
||||
let kda = match &stats {
|
||||
Some(s) => format!("{}/{}/{}", s.kills, s.deaths, s.assists),
|
||||
None => "0/0/0".into(),
|
||||
};
|
||||
let ratio = stats.as_ref().map_or("0.0".into(), |s| {
|
||||
format::kda_ratio(s.kills, s.deaths, s.assists)
|
||||
});
|
||||
let mut stats_row = row().key("stats").gap(18.0).center_y();
|
||||
if let Some(s) = &stats {
|
||||
stats_row = stats_row
|
||||
.child(stat(p, &format::cs_per_min(s), "CS/m"))
|
||||
.child(stat(p, &format::gold_per_min(s), "Gold/m"))
|
||||
.child(stat(p, &s.vision_score.to_string(), "Vision"));
|
||||
}
|
||||
|
||||
el().key(format!("game-{index}"))
|
||||
.role("button")
|
||||
.label(format!("{champion}, {}", outcome.label()))
|
||||
.focusable(true)
|
||||
.w_full()
|
||||
.radius(radius::LG)
|
||||
.fill(p.t.card)
|
||||
.border(p.hair, p.t.card_border)
|
||||
.shadow(1.0, 2.0, p.t.shadow)
|
||||
.shadow(8.0, 24.0, p.t.shadow_soft)
|
||||
.hover(p.t.hover)
|
||||
.press(p.t.press)
|
||||
.on_press(move |app: &mut App| review::open(app, index))
|
||||
.child(
|
||||
col().key("card").w_full().child(banner).child(
|
||||
row()
|
||||
.key("content")
|
||||
.w_full()
|
||||
.px(space::S3)
|
||||
.py(space::S3)
|
||||
.gap(space::S3)
|
||||
.center_y()
|
||||
.justify_between()
|
||||
.child(
|
||||
col()
|
||||
.key("identity")
|
||||
.gap(2.0)
|
||||
.child(
|
||||
text(champion)
|
||||
.key("champion")
|
||||
.font(heading(16.0))
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(
|
||||
text(format!(
|
||||
"{} · {}",
|
||||
game.queue_label(),
|
||||
format::duration(duration)
|
||||
))
|
||||
.key("queue")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(
|
||||
text(format::relative_time(game.start_time))
|
||||
.key("when")
|
||||
.font(body(11.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
col()
|
||||
.key("kda")
|
||||
.gap(1.0)
|
||||
.items_end()
|
||||
.child(
|
||||
text(kda)
|
||||
.key("kda-values")
|
||||
.font(heading(15.0))
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(
|
||||
text(format!("{ratio} KDA"))
|
||||
.key("kda-ratio")
|
||||
.font(body(11.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(stats_row)
|
||||
.child(
|
||||
text("Review →")
|
||||
.key("open")
|
||||
.font(type_::LABEL)
|
||||
.color(p.accent),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn stat(p: Paint, value: &str, label: &str) -> El {
|
||||
col()
|
||||
.key(format!("stat-{label}"))
|
||||
.gap(0.0)
|
||||
.items_end()
|
||||
.child(
|
||||
text(value)
|
||||
.key("value")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(text(label).key("label").font(body(10.5)).color(p.muted()))
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
//! The three screens: settings, match history and the game review.
|
||||
|
||||
pub mod history;
|
||||
pub mod review;
|
||||
pub mod settings;
|
||||
@@ -0,0 +1,617 @@
|
||||
//! Game review: the recorded clip, a scrubber with event markers, highlights and export.
|
||||
|
||||
use std::sync::mpsc::{Receiver, channel};
|
||||
|
||||
use rune::tok::{radius, space, type_};
|
||||
use rune::{El, Player, SurfaceFit, Tx, col, el, row, text};
|
||||
|
||||
use crate::app::{App, Screen};
|
||||
use crate::format;
|
||||
use crate::highlight::{self, Highlight};
|
||||
use crate::history::{Outcome, Timeline};
|
||||
use crate::ui::{self, Paint, body, heading};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Review {
|
||||
pub game: Option<String>,
|
||||
pub player: Option<Player>,
|
||||
pub time: f64,
|
||||
pub duration: f64,
|
||||
pub scrubber_width: f32,
|
||||
pub highlights: Vec<Highlight>,
|
||||
pub export: Option<Receiver<Result<String, String>>>,
|
||||
pub export_note: Option<String>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl Review {
|
||||
fn playback(&mut self) {
|
||||
if let Some(player) = &self.player {
|
||||
if player.is_playing() {
|
||||
player.pause();
|
||||
} else {
|
||||
player.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn seek(&mut self, seconds: f64) {
|
||||
let at = seconds.clamp(0.0, self.duration.max(0.0));
|
||||
if let Some(player) = &self.player {
|
||||
player.seek(at);
|
||||
self.time = at;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Open a game in the review screen and load its clip.
|
||||
pub fn open(app: &mut App, index: usize) {
|
||||
leave(app);
|
||||
app.screen = Screen::Review;
|
||||
|
||||
let Some(game) = app.games.get(index) else {
|
||||
return;
|
||||
};
|
||||
// Keep the recording id, not the row number: a new recording can re-sort the list.
|
||||
app.review.game = Some(game.recording_id.clone());
|
||||
let path = game.video_path();
|
||||
let highlights = highlight::compute(
|
||||
game,
|
||||
game.summoner().as_deref(),
|
||||
highlight::Options::default(),
|
||||
);
|
||||
let duration = game.duration_secs.max(0) as f64;
|
||||
app.review.highlights = highlights;
|
||||
app.review.duration = duration;
|
||||
|
||||
let Some(path) = path else {
|
||||
app.review.error = Some(format!(
|
||||
"No video file found for this recording ({}).",
|
||||
game.video_file.as_deref().unwrap_or("unnamed")
|
||||
));
|
||||
return;
|
||||
};
|
||||
let player = Player::file(&path);
|
||||
player.set_looping(false);
|
||||
if let Some(waker) = &app.waker {
|
||||
player.set_waker(waker.clone());
|
||||
}
|
||||
app.review.player = Some(player);
|
||||
}
|
||||
|
||||
/// Leave the review screen and stop playback.
|
||||
pub fn leave(app: &mut App) {
|
||||
app.review.player = None;
|
||||
app.review.game = None;
|
||||
app.review.highlights.clear();
|
||||
app.review.time = 0.0;
|
||||
app.review.duration = 0.0;
|
||||
app.review.error = None;
|
||||
app.review.export_note = None;
|
||||
app.review.export = None;
|
||||
}
|
||||
|
||||
/// Called from `poll` while the review screen is up.
|
||||
pub fn tick(app: &mut App, tx: &mut Tx) -> bool {
|
||||
let mut changed = false;
|
||||
if let Some(player) = &app.review.player {
|
||||
let time = player.time();
|
||||
if (time - app.review.time).abs() > 0.001 {
|
||||
app.review.time = time;
|
||||
changed = true;
|
||||
}
|
||||
if let Some(duration) = player.duration() {
|
||||
if duration > 0.0 && (duration - app.review.duration).abs() > 0.05 {
|
||||
app.review.duration = duration;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if app.review.error.is_none() {
|
||||
if let rune::PlayerState::Failed(message) = player.state() {
|
||||
app.review.error = Some(message);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if player.is_playing() {
|
||||
tx.wake_after(std::time::Duration::from_millis(33));
|
||||
}
|
||||
}
|
||||
if let Some(rx) = &app.review.export {
|
||||
match rx.try_recv() {
|
||||
Ok(Ok(path)) => {
|
||||
app.review.export_note = Some(format!("Clip saved to {path}"));
|
||||
app.review.export = None;
|
||||
changed = true;
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
app.review.export_note = Some(format!("Export failed: {e}"));
|
||||
app.review.export = None;
|
||||
changed = true;
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
}
|
||||
changed
|
||||
}
|
||||
|
||||
pub fn view(app: &App, p: Paint) -> El {
|
||||
let Some(game) = app.reviewed() else {
|
||||
return col()
|
||||
.key("review")
|
||||
.padding(space::S6)
|
||||
.child(text("No game selected.").font(body(13.0)).color(p.muted()));
|
||||
};
|
||||
let outcome = game.outcome();
|
||||
let ink = match outcome {
|
||||
Outcome::Victory => p.success(),
|
||||
Outcome::Defeat => p.danger(),
|
||||
Outcome::Terminated => p.muted(),
|
||||
};
|
||||
|
||||
let header = row()
|
||||
.key("review-header")
|
||||
.w_full()
|
||||
.center_y()
|
||||
.justify_between()
|
||||
.child(
|
||||
row()
|
||||
.key("review-title")
|
||||
.gap(10.0)
|
||||
.center_y()
|
||||
.child(ui::button(
|
||||
p,
|
||||
"back",
|
||||
"← Match history",
|
||||
false,
|
||||
|app: &mut App| {
|
||||
leave(app);
|
||||
app.screen = Screen::History;
|
||||
},
|
||||
))
|
||||
.child(
|
||||
text(game.champion().unwrap_or_else(|| "Unknown champion".into()))
|
||||
.key("champion")
|
||||
.font(heading(20.0))
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(
|
||||
text(outcome.label())
|
||||
.key("outcome")
|
||||
.font(type_::LABEL)
|
||||
.color(ink),
|
||||
)
|
||||
.child(
|
||||
text(format!(
|
||||
"{} · {}",
|
||||
game.queue_label(),
|
||||
format::duration(app.review.duration)
|
||||
))
|
||||
.key("meta")
|
||||
.font(body(12.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
text(format::game_start(game.start_time))
|
||||
.key("started")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
);
|
||||
|
||||
col()
|
||||
.key("review")
|
||||
.w_full()
|
||||
.h_full()
|
||||
.padding(space::S6)
|
||||
.gap(space::S3)
|
||||
.child(header)
|
||||
.child(video_stage(app, p))
|
||||
.child(scrubber(app, p))
|
||||
.child(
|
||||
row()
|
||||
.key("review-body")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S3)
|
||||
.child(highlights(app, p, game))
|
||||
.child(events(app, p, game)),
|
||||
)
|
||||
}
|
||||
|
||||
fn video_stage(app: &App, p: Paint) -> El {
|
||||
let mut stage = el()
|
||||
.key("stage")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.radius(radius::LG)
|
||||
.fill(rune::Color::BLACK)
|
||||
.clip_soft(radius::LG);
|
||||
|
||||
if let Some(player) = &app.review.player {
|
||||
stage = stage.child(
|
||||
el().key("video")
|
||||
.w_full()
|
||||
.h_full()
|
||||
.video(player, SurfaceFit::Fit),
|
||||
);
|
||||
} else {
|
||||
stage = stage.child(
|
||||
col()
|
||||
.key("stage-empty")
|
||||
.w_full()
|
||||
.h_full()
|
||||
.center()
|
||||
.gap(6.0)
|
||||
.child(
|
||||
text(
|
||||
app.review
|
||||
.error
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Loading the clip…".into()),
|
||||
)
|
||||
.key("stage-message")
|
||||
.font(body(13.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
col()
|
||||
.key("stage-column")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S2)
|
||||
.child(stage)
|
||||
.child(
|
||||
row()
|
||||
.key("transport")
|
||||
.w_full()
|
||||
.center_y()
|
||||
.gap(space::S3)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"play-pause",
|
||||
if playing(app) { "Pause" } else { "Play" },
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.review.playback();
|
||||
},
|
||||
))
|
||||
.child(ui::button(p, "rewind", "-10 s", false, |app: &mut App| {
|
||||
let at = app.review.time - 10.0;
|
||||
app.review.seek(at);
|
||||
}))
|
||||
.child(ui::button(p, "advance", "+10 s", false, |app: &mut App| {
|
||||
let at = app.review.time + 10.0;
|
||||
app.review.seek(at);
|
||||
}))
|
||||
.child(
|
||||
text(format!(
|
||||
"{} / {}",
|
||||
format::clock(app.review.time),
|
||||
format::clock(app.review.duration)
|
||||
))
|
||||
.key("time")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(el().grow(1.0))
|
||||
.child(
|
||||
text(
|
||||
app.review.export_note.clone().unwrap_or_else(|| {
|
||||
format!("{} highlights", app.review.highlights.len())
|
||||
}),
|
||||
)
|
||||
.key("export-note")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn playing(app: &App) -> bool {
|
||||
app.review.player.as_ref().is_some_and(Player::is_playing)
|
||||
}
|
||||
|
||||
fn scrubber(app: &App, p: Paint) -> El {
|
||||
let width = if app.review.scrubber_width > 0.0 {
|
||||
app.review.scrubber_width
|
||||
} else {
|
||||
800.0
|
||||
};
|
||||
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 mut bar = el()
|
||||
.key("scrubber")
|
||||
.role("slider")
|
||||
.label("Playback position")
|
||||
.range_value(app.review.time, 0.0, duration)
|
||||
.w_full()
|
||||
.h(26.0)
|
||||
.on_layout(|app: &mut App, [_, _, w, _]| {
|
||||
app.review.scrubber_width = w;
|
||||
})
|
||||
.on_step(|app: &mut App, steps, _| {
|
||||
let at = app.review.time + steps as f64 * 5.0;
|
||||
app.review.seek(at);
|
||||
})
|
||||
.on_drag(move |app: &mut App, d: &mut rune::Drag, tx| {
|
||||
let w = app.review.scrubber_width.max(1.0);
|
||||
let at = (d.x / w).clamp(0.0, 1.0) as f64 * app.review.duration;
|
||||
app.review.seek(at);
|
||||
tx.instant();
|
||||
})
|
||||
.child(
|
||||
el().key("track")
|
||||
.w_full()
|
||||
.h(6.0)
|
||||
.absolute(0.0, 10.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(),
|
||||
);
|
||||
|
||||
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;
|
||||
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)
|
||||
.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))
|
||||
.a11y_hidden(),
|
||||
);
|
||||
}
|
||||
|
||||
bar.child(
|
||||
el().key("knob")
|
||||
.size(knob, knob)
|
||||
.absolute(progress * (width - knob), 6.0)
|
||||
.radius(knob / 2.0)
|
||||
.fill(p.t.knob)
|
||||
.shadow(1.0, 3.0, p.t.knob_shadow)
|
||||
.shadow(0.0, 0.5, p.t.edge)
|
||||
.a11y_hidden(),
|
||||
)
|
||||
}
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
for (index, clip) in app.review.highlights.iter().enumerate() {
|
||||
let start = clip.start;
|
||||
let end = clip.end;
|
||||
let video = game.video_path().map(|path| path.display().to_string());
|
||||
let name = format!("{}-highlight-{}", game.recording_id, index);
|
||||
let kind_ink = match clip.kind {
|
||||
highlight::Kind::Death => p.danger(),
|
||||
highlight::Kind::Assist => p.muted(),
|
||||
highlight::Kind::MultiKill | highlight::Kind::TradeKill => p.accent,
|
||||
highlight::Kind::Kill => p.success(),
|
||||
};
|
||||
let mut actions = row().key("actions").gap(6.0).center_y().child(ui::button(
|
||||
p,
|
||||
&format!("play-{index}"),
|
||||
"Play",
|
||||
false,
|
||||
move |app: &mut App| {
|
||||
app.review.seek(start);
|
||||
if let Some(player) = &app.review.player {
|
||||
player.play();
|
||||
}
|
||||
},
|
||||
));
|
||||
if video.is_some() {
|
||||
actions = actions.child(ui::button(
|
||||
p,
|
||||
&format!("export-{index}"),
|
||||
"Export",
|
||||
false,
|
||||
move |app: &mut App| {
|
||||
let (tx, rx) = channel();
|
||||
let Some(video) = video.clone() else { return };
|
||||
let name = name.clone();
|
||||
std::thread::spawn(move || {
|
||||
let result =
|
||||
crate::export::export_clip(&video, start, end, &name, true, "high");
|
||||
let _ = tx.send(result);
|
||||
});
|
||||
app.review.export = Some(rx);
|
||||
app.review.export_note = Some("Exporting clip…".into());
|
||||
},
|
||||
));
|
||||
}
|
||||
list = list.child(
|
||||
row()
|
||||
.key(format!("highlight-{index}"))
|
||||
.w_full()
|
||||
.h(44.0)
|
||||
.px(space::S3)
|
||||
.center_y()
|
||||
.justify_between()
|
||||
.radius(radius::MD)
|
||||
.hover(p.t.hover)
|
||||
.on_press({
|
||||
let start = clip.start;
|
||||
move |app: &mut App| app.review.seek(start)
|
||||
})
|
||||
.child(
|
||||
col()
|
||||
.key("labels")
|
||||
.gap(1.0)
|
||||
.child(
|
||||
row()
|
||||
.key("title-row")
|
||||
.gap(6.0)
|
||||
.center_y()
|
||||
.child(ui::dot(kind_ink))
|
||||
.child(
|
||||
text(clip.title.clone())
|
||||
.key("title")
|
||||
.font(type_::LABEL)
|
||||
.color(p.t.text),
|
||||
)
|
||||
.child(
|
||||
text(format!(
|
||||
"{} to {}",
|
||||
format::clock(start),
|
||||
format::clock(end)
|
||||
))
|
||||
.key("range")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
text(clip.subtitle.clone())
|
||||
.key("subtitle")
|
||||
.font(body(11.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(actions),
|
||||
);
|
||||
}
|
||||
|
||||
col()
|
||||
.key("highlights-panel")
|
||||
.w(360.0)
|
||||
.h_full()
|
||||
.gap(space::S2)
|
||||
.child(
|
||||
text("Highlights")
|
||||
.key("header")
|
||||
.font(type_::SECTION)
|
||||
.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),
|
||||
)
|
||||
}
|
||||
|
||||
fn events(_app: &App, p: Paint, game: &Timeline) -> El {
|
||||
let interesting = |kind: &str| {
|
||||
matches!(
|
||||
kind,
|
||||
"kill" | "death" | "objective" | "game_start" | "game_end" | "lp_change"
|
||||
)
|
||||
};
|
||||
let mut list = col().key("event-rows").w_full().gap(1.0);
|
||||
let mut shown = 0;
|
||||
for event in game.events.iter().filter(|e| interesting(&e.event_type)) {
|
||||
let at = event.time();
|
||||
let label = match event.event_type.as_str() {
|
||||
"kill" => "Kill",
|
||||
"death" => "Death",
|
||||
"objective" => "Objective",
|
||||
"game_start" => "Game start",
|
||||
"game_end" => "Game end",
|
||||
"lp_change" => "LP change",
|
||||
other => other,
|
||||
};
|
||||
let detail = if event.description.is_empty() {
|
||||
label.to_string()
|
||||
} else {
|
||||
event.description.clone()
|
||||
};
|
||||
list = list.child(
|
||||
row()
|
||||
.key(format!("event-{shown}"))
|
||||
.w_full()
|
||||
.h(30.0)
|
||||
.px(space::S2)
|
||||
.center_y()
|
||||
.gap(space::S2)
|
||||
.radius(radius::SM)
|
||||
.hover(p.t.hover)
|
||||
.on_press(move |app: &mut App| app.review.seek(at))
|
||||
.child(
|
||||
text(format::clock(at))
|
||||
.key("time")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(
|
||||
text(detail)
|
||||
.key("detail")
|
||||
.font(body(11.5))
|
||||
.color(p.t.text)
|
||||
.grow(1.0)
|
||||
.shrink()
|
||||
.truncate(),
|
||||
),
|
||||
);
|
||||
shown += 1;
|
||||
}
|
||||
if shown == 0 {
|
||||
list = list.child(
|
||||
text("No timeline events.")
|
||||
.key("no-events")
|
||||
.font(body(12.0))
|
||||
.color(p.muted()),
|
||||
);
|
||||
}
|
||||
|
||||
col()
|
||||
.key("events-panel")
|
||||
.grow(1.0)
|
||||
.min_w(240.0)
|
||||
.h_full()
|
||||
.gap(space::S2)
|
||||
.child(
|
||||
text("Timeline")
|
||||
.key("header")
|
||||
.font(type_::SECTION)
|
||||
.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),
|
||||
)
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user