Simplify setting new options on user confirmation

This commit is contained in:
pjht 2024-01-30 13:04:14 -06:00
parent 3862080cb1
commit 30c82a64ac
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -308,7 +308,6 @@ impl eframe::App for AltairEmulator {
if self.running { if self.running {
self.run_cpu_cycle(); self.run_cpu_cycle();
} }
let old_fan_enabled = self.options.fan_enabled;
if let Some(option_window) = self.option_window.as_mut() { if let Some(option_window) = self.option_window.as_mut() {
if option_window.draw(ctx, &mut self.options) { if option_window.draw(ctx, &mut self.options) {
self.option_window = None; self.option_window = None;
@ -320,14 +319,13 @@ impl eframe::App for AltairEmulator {
.send(AudioMessage::SetVolume(self.options.volume)) .send(AudioMessage::SetVolume(self.options.volume))
.unwrap(); .unwrap();
} }
} if self.options.fan_enabled && self.fp_state.power() {
if (old_fan_enabled != self.options.fan_enabled) && self.fp_state.power() {
if self.options.fan_enabled {
self.audio_tx.send(AudioMessage::FanOn).unwrap(); self.audio_tx.send(AudioMessage::FanOn).unwrap();
} else { } else {
self.audio_tx.send(AudioMessage::FanOff).unwrap(); self.audio_tx.send(AudioMessage::FanOff).unwrap();
} }
} }
if self.running { if self.running {
ctx.request_repaint(); ctx.request_repaint();
} }