fix(config): import original INI semantics

Load case-insensitive Language, Speed, and singular Sound values from an adjacent or embedded TDKPIN.INI before portable JSON exists, preserving Win16 defaults and clamps. Separate runtime playback from stored settings so F12 remains a silent, non-persistent toggle exactly like the original.

Test Plan:
- cargo test --all-targets
- cargo clippy --all-targets --all-features -- -D warnings
- rumdl check CHANGELOG.md RECONSTRUCTION.md README.md
- git diff --check
This commit is contained in:
2026-08-23 19:12:31 +02:00
parent fae322bb91
commit 0e7208e03a
5 changed files with 94 additions and 28 deletions
+11 -23
View File
@@ -108,6 +108,7 @@ pub struct App {
assets: Assets,
persistence: Persistence,
saved: SavedData,
sounds_enabled: bool,
render_target: RenderTarget,
screen: Screen,
return_screen: Screen,
@@ -116,8 +117,6 @@ pub struct App {
loading_started: f64,
loading_until: f64,
last_help_click: f64,
message: String,
message_until: f64,
name: String,
pending_score: u32,
attract: AttractAnimation,
@@ -128,6 +127,7 @@ impl App {
let assets = Assets::load().await;
let persistence = Persistence::new();
let saved = persistence.load();
let sounds_enabled = saved.settings.sounds;
let render_target = render_target(640, 460);
render_target.texture.set_filter(FilterMode::Nearest);
let loading_started = get_time();
@@ -135,6 +135,7 @@ impl App {
assets,
persistence,
saved,
sounds_enabled,
render_target,
screen: Screen::Loading,
return_screen: Screen::Attract,
@@ -143,8 +144,6 @@ impl App {
loading_started,
loading_until: loading_started + 1.1,
last_help_click: -1.0,
message: String::new(),
message_until: 0.0,
name: String::new(),
pending_score: 0,
attract: AttractAnimation::default(),
@@ -224,15 +223,7 @@ impl App {
fn handle_global_input(&mut self) {
if is_key_pressed(KeyCode::F12) {
self.saved.settings.sounds = !self.saved.settings.sounds;
if self.saved.settings.sounds {
"SOUND ON"
} else {
"SOUND OFF"
}
.clone_into(&mut self.message);
self.message_until = get_time() + 1.2;
self.save();
self.sounds_enabled = !self.sounds_enabled;
}
if is_key_pressed(KeyCode::F1) && self.screen != Screen::NameEntry {
if self.screen == Screen::Help {
@@ -274,7 +265,7 @@ impl App {
if is_key_pressed(KeyCode::KpAdd) || is_key_pressed(KeyCode::Equal) {
self.game = Some(Game::new(1));
self.screen = Screen::Playing;
self.assets.play(2001, self.saved.settings.sounds);
self.assets.play(2001, self.sounds_enabled);
}
}
@@ -285,7 +276,7 @@ impl App {
.as_mut()
.is_some_and(Game::add_player_before_launch)
{
self.assets.play(2001, self.saved.settings.sounds);
self.assets.play(2001, self.sounds_enabled);
}
let left_flipper = is_key_down(KeyCode::LeftControl)
|| is_key_down(KeyCode::A)
@@ -340,7 +331,7 @@ impl App {
return;
}
if let Some(resource) = event.sound_resource() {
self.assets.play(resource, self.saved.settings.sounds);
self.assets.play(resource, self.sounds_enabled);
}
}
@@ -390,7 +381,8 @@ impl App {
self.saved.settings.speed = u8::try_from(speed.clamp(1, 5)).unwrap_or(3);
}
1 => {
self.saved.settings.sounds = !self.saved.settings.sounds;
self.sounds_enabled = !self.sounds_enabled;
self.saved.settings.sounds = self.sounds_enabled;
}
_ => {
let current = Language::ALL
@@ -405,7 +397,7 @@ impl App {
self.saved.settings.language = Language::ALL[next];
}
}
self.assets.play(2012, self.saved.settings.sounds);
self.assets.play(2012, self.sounds_enabled);
self.save();
}
@@ -484,10 +476,6 @@ impl App {
Screen::HighScores => self.draw_high_scores(),
Screen::NameEntry => self.draw_name_entry(),
}
if get_time() < self.message_until {
draw_panel(232.0, 205.0, 176.0, 48.0);
draw_centered(&self.message, 229.0, 24, BLACK);
}
}
fn draw_attract(&self) {
@@ -1080,7 +1068,7 @@ impl App {
format!("GRAPHICS DETAIL / SPEED: {}", self.saved.settings.speed),
format!(
"SOUND: {}",
if self.saved.settings.sounds {
if self.sounds_enabled {
"ON"
} else {
"OFF"