diff --git a/app/README.md b/app/README.md index 189a88e..acc869c 100644 --- a/app/README.md +++ b/app/README.md @@ -57,7 +57,8 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti 2. Pipe client: done. Requests are typed (`Command`), the worker thread keeps the UI off tokio. The same types are tested against the daemon's serde names. 3. Settings: done. General, recording, audio and daemon tabs; device and encoder lists come from - `getAudioDevices` and `getEncoders`; changes go out through `updateSettings`. + `getAudioDevices` and `getEncoders`; changes go out through `updateSettings`, and each + application volume slider sends `updateAudioSource` as it moves. 4. Match history: done. Cards read `GameHistory.vue`'s fields (result, champion, queue, KDA, CS/m, gold/m, LP change) from the raw API responses in each timeline, with the queue filters. 5. Video: not libmpv. Rune ships a `Player` with a native surface and frame seeking @@ -81,8 +82,6 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti JSON matches the daemon's `IpcCommand` and response types in tests. - Champion and item images are not drawn: the app has no Data Dragon image cache yet, so cards show names and numbers. -- Settings currently apply on Save. Per-source volume editing exists in the model but has no - control yet. ## The vendored crates diff --git a/app/src/app.rs b/app/src/app.rs index b19bb2f..ff30936 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -10,7 +10,7 @@ use crate::history::{self, QueueCategory, Timeline}; use crate::ipc::{self, Daemon}; use crate::os; use crate::screens; -use crate::settings::Settings; +use crate::settings::{AudioSource, AudioSourceType, Settings}; use crate::ui::{self, Paint, body, heading}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -170,7 +170,53 @@ impl App { }; self.games = history::sample(); self.games_loaded = true; - let settings = Settings::default(); + self.devices = AudioDevices { + input_devices: vec![AudioDevice { + id: "mic-1".into(), + name: "Microphone (USB Audio)".into(), + is_default: true, + }], + output_devices: vec![ + AudioDevice { + id: "out-1".into(), + name: "Speakers (Realtek)".into(), + is_default: true, + }, + AudioDevice { + id: "out-2".into(), + name: "Headphones (USB Audio)".into(), + is_default: false, + }, + ], + }; + self.encoders = Encoders { + available: vec![EncoderInfo { + id: "jim_nvenc".into(), + name: "NVIDIA NVENC".into(), + available: true, + is_hardware: true, + }], + current: "jim_nvenc".into(), + }; + let mut settings = Settings::default(); + settings.audio.capture_apps = vec![ + AudioSource { + id: "discord".into(), + name: "Discord".into(), + source_type: AudioSourceType::Application, + device: "Discord.exe".into(), + volume: Some(80), + enabled: true, + }, + AudioSource { + id: "spotify".into(), + name: "Spotify".into(), + source_type: AudioSourceType::Application, + device: "Spotify.exe".into(), + volume: Some(35), + enabled: true, + }, + ]; self.form.apply(&settings); self.settings = Some(settings); } diff --git a/app/src/ipc.rs b/app/src/ipc.rs index 21a181b..c960296 100644 --- a/app/src/ipc.rs +++ b/app/src/ipc.rs @@ -39,10 +39,7 @@ pub enum Command { GetEncoders, GetAudioDevices, AddAudioSource, - RemoveAudioSource { - id: String, - }, - #[allow(dead_code)] + RemoveAudioSource { id: String }, UpdateAudioSource, StartRecording, StopRecording, @@ -376,7 +373,6 @@ impl Daemon { ); } - #[allow(dead_code)] pub fn update_audio_source(&self, source: Value) { self.send( Request::UpdateAudioSource, diff --git a/app/src/screens/settings.rs b/app/src/screens/settings.rs index e2d141b..fbe8a61 100644 --- a/app/src/screens/settings.rs +++ b/app/src/screens/settings.rs @@ -667,19 +667,22 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec, content: .h(36.0), ); } - for source in &a.capture_apps { + for (index, source) in a.capture_apps.iter().enumerate() { let id = source.id.clone(); + let volume = source.volume.unwrap_or(100); sources = sources.child( row() .key(format!("source-{}", source.id)) - .h(40.0) + .h(48.0) .px(space::S3) .center_y() + .gap(space::S3) .justify_between() .radius(radius::MD) .child( col() .key("source-labels") + .grow(1.0) .gap(1.0) .child( text(source.name.clone()) @@ -698,6 +701,33 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec, content: .color(p.muted()), ), ) + .child( + row() + .key("source-volume") + .gap(space::S2) + .center_y() + .child(ui::slider( + p, + format!("volume-{}", source.id), + "Application volume", + volume, + move |app: &mut App, value| { + let payload = { + let Some(source) = + app.form.draft.audio.capture_apps.get_mut(index) + else { + return; + }; + source.volume = Some(value); + serde_json::to_value(&*source).ok() + }; + app.form.dirty = true; + if let Some(payload) = payload { + app.daemon.update_audio_source(payload); + } + }, + )), + ) .child(ui::button( p, &format!("remove-{}", source.id), @@ -709,7 +739,6 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec, content: )), ); } - let source_type = app.form.source_type; content .child(ui::card( diff --git a/app/src/ui.rs b/app/src/ui.rs index 888391c..a6f78a8 100644 --- a/app/src/ui.rs +++ b/app/src/ui.rs @@ -180,11 +180,12 @@ pub fn toggle_row( /// A 0-100 slider with its value spelled out on the right. pub fn slider( p: Paint, - key: &'static str, + key: impl Into, label: &'static str, value: u32, on_change: impl Fn(&mut App, u32) + Send + Sync + 'static, ) -> El { + let key = key.into(); let (w, h, k, bar) = (180.0, 22.0, 18.0, 4.0); let travel = w - k; let v = (value.min(100) as f32 / 100.0).clamp(0.0, 1.0);