Add selectable soundtracks via CLI

Introduce a `Soundtrack` enum with Clap `ValueEnum` support and expose
it in the CLI as a `--sound-track` option. Extend `AudioCmd` with a
`ChangeSoundtrack` variant and refactor audio handling to load and cache
soundtracks per‑track using a thread‑safe `RwLock`. Update the
`handle_audio` function signature to accept the selected soundtrack,
adjust re‑exports, and modify `main` to pass the chosen soundtrack to
the audio thread. Also reposition the logging flag in the CLI
definition.
This commit is contained in:
2026-04-09 02:00:24 +02:00
parent 7ec3eec6e3
commit 633494ed46
4 changed files with 127 additions and 34 deletions
+17 -6
View File
@@ -1,5 +1,6 @@
use crate::app::{
states::{GameMode, PerkDecks, ZoomLevel},
threads::Soundtrack,
view::View,
};
use clap::{Error, Parser, error::ErrorKind, value_parser};
@@ -133,13 +134,15 @@ pub struct Cli {
)]
pub skill_points_limit: u16,
/// Enable logging to a file (default: disabled).
/// Which soundtrack to play (default: default)
#[arg(
long,
help = "Enable logging to file (default: disabled)",
default_value_t = false
)]
pub log: bool,
long,
help = "Soundtrack",
value_name = "...",
default_value_t = Soundtrack::Default,
value_enum
)]
pub sound_track: Soundtrack,
/// Mute soundtrack (default: disabled).
#[arg(
@@ -148,6 +151,14 @@ pub struct Cli {
default_value_t = false
)]
pub mute: bool,
/// Enable logging to a file (default: disabled).
#[arg(
long,
help = "Enable logging to file (default: disabled)",
default_value_t = false
)]
pub log: bool,
}
/// Parses the command line arguments and returns a fully populated `Cli`