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:
vhaudiquet committed 2026-11-15 21:53:44 +01:00
1 parent d712c4ea85
commit 0377141e4f
349 files changed
+142819

No files matched your search

+132
View File
@@ -0,0 +1,132 @@
//! Windows integration that the Tauri app got from plugins: launch at login, one instance,
//! toast notifications and the tray icon.
/// The app's reverse-DNS id, used for single-instance and notifications.
pub const APP_ID: &str = "v.leaguerecorder";
pub const APP_NAME: &str = "League Recorder";
#[cfg(windows)]
const RUN_KEY: &str = r"Software\Microsoft\Windows\CurrentVersion\Run";
#[cfg(windows)]
const RUN_VALUE: &str = "LeagueRecorder";
/// Launch at login writes the executable into the user's `Run` key.
#[cfg(windows)]
pub fn autostart_enabled() -> bool {
use winreg::RegKey;
use winreg::enums::HKEY_CURRENT_USER;
let Ok(key) = RegKey::predef(HKEY_CURRENT_USER).open_subkey(RUN_KEY) else {
return false;
};
key.get_value::<String, _>(RUN_VALUE).is_ok()
}
#[cfg(not(windows))]
pub fn autostart_enabled() -> bool {
false
}
#[cfg(windows)]
pub fn set_autostart(on: bool) -> Result<(), String> {
use winreg::RegKey;
use winreg::enums::HKEY_CURRENT_USER;
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let (key, _) = hkcu
.create_subkey(RUN_KEY)
.map_err(|e| format!("cannot open the Run key: {e}"))?;
if on {
let exe =
std::env::current_exe().map_err(|e| format!("cannot find the executable: {e}"))?;
let value = format!("\"{}\" --hidden", exe.display());
key.set_value(RUN_VALUE, &value)
.map_err(|e| format!("cannot write the Run key: {e}"))
} else {
match key.delete_value(RUN_VALUE) {
Ok(()) => Ok(()),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(()),
Err(e) => Err(format!("cannot remove the Run value: {e}")),
}
}
}
#[cfg(not(windows))]
pub fn set_autostart(_on: bool) -> Result<(), String> {
Err("launch at login is implemented for Windows only".into())
}
/// Register the app so Windows can show its toasts, and group its windows on the taskbar.
pub fn register_notifications() {
let identity = rune_notify::Identity::new(APP_ID, APP_NAME);
if let Err(e) = rune_notify::register(&identity) {
eprintln!("notifications unavailable: {e}");
}
}
/// Post a toast, unless a window already has the user's attention.
pub fn notify(id: &str, title: &str, body: &str) {
if rune_notify::app_focused() {
return;
}
let notification = rune_notify::Notification::new(id, title).body(body);
rune_notify::post(&notification);
}
/// A 32 px tray icon: an accent disc with a white play mark.
pub fn tray_icon() -> rune::TrayIcon {
const SIZE: u32 = 32;
let mut pixels = vec![0u8; (SIZE * SIZE * 4) as usize];
let accent = [0x5b, 0x7c, 0xfa];
let half = SIZE as f32 / 2.0;
let radius = half - 1.0;
// Play triangle: apex right of centre, base left of centre.
let (ax, ay) = (half + 4.5, half);
let (bx, by) = (half - 4.0, half - 6.0);
let (cx, cy) = (half - 4.0, half + 6.0);
let edge = |px: f32, py: f32, x1: f32, y1: f32, x2: f32, y2: f32| {
(x2 - x1) * (py - y1) - (y2 - y1) * (px - x1)
};
for y in 0..SIZE {
for x in 0..SIZE {
let px = x as f32 + 0.5;
let py = y as f32 + 0.5;
let dx = px - half;
let dy = py - half;
// Three pixels of antialiasing at the disc edge.
let coverage = (radius - (dx * dx + dy * dy).sqrt()).clamp(0.0, 1.0);
if coverage <= 0.0 {
continue;
}
let e1 = edge(px, py, ax, ay, bx, by);
let e2 = edge(px, py, bx, by, cx, cy);
let e3 = edge(px, py, cx, cy, ax, ay);
let inside =
(e1 >= 0.0 && e2 >= 0.0 && e3 >= 0.0) || (e1 <= 0.0 && e2 <= 0.0 && e3 <= 0.0);
let ink = if inside { [255, 255, 255] } else { accent };
let i = ((y * SIZE + x) * 4) as usize;
pixels[i] = ink[0];
pixels[i + 1] = ink[1];
pixels[i + 2] = ink[2];
pixels[i + 3] = (coverage * 255.0) as u8;
}
}
rune::TrayIcon::rgba(SIZE, SIZE, pixels)
}
/// The tray menu. `recording` flips the record item's label.
pub fn tray_menu(recording: bool) -> Vec<rune::TrayItem> {
vec![
rune::TrayItem::action("show", "Open League Recorder"),
rune::TrayItem::action("hide", "Hide window"),
rune::TrayItem::Separator,
rune::TrayItem::action(
"record",
if recording {
"Stop recording"
} else {
"Start recording"
},
),
rune::TrayItem::Separator,
rune::TrayItem::action("quit", "Quit"),
]
}