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()))
|
||||
}
|
||||
Reference in new issue
Block a user