Add mute option
This commit is contained in:
parent
8b0d96533d
commit
cfa3c0da05
20
src/main.rs
20
src/main.rs
@ -32,6 +32,8 @@ fn main() -> Result<(), eframe::Error> {
|
||||
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
|
||||
struct Options {
|
||||
#[serde(default = "Options::default_mute")]
|
||||
mute: bool,
|
||||
#[serde(default = "Options::default_fan_enabled")]
|
||||
fan_enabled: bool,
|
||||
#[serde(default = "Options::default_volume")]
|
||||
@ -39,6 +41,9 @@ struct Options {
|
||||
}
|
||||
|
||||
impl Options {
|
||||
fn default_mute() -> bool {
|
||||
false
|
||||
}
|
||||
fn default_fan_enabled() -> bool {
|
||||
true
|
||||
}
|
||||
@ -61,11 +66,15 @@ struct AltairEmulator {
|
||||
impl AltairEmulator {
|
||||
fn new(cc: &eframe::CreationContext<'_>, audio_tx: Sender<AudioMessage>) -> Self {
|
||||
let options = if cc.storage.unwrap().get_string("options").is_none() {
|
||||
Options { fan_enabled: true, volume: 1.0 }
|
||||
Options { mute: false, fan_enabled: true, volume: 1.0 }
|
||||
} else {
|
||||
eframe::get_value(cc.storage.unwrap(), "options").unwrap()
|
||||
};
|
||||
audio_tx.send(AudioMessage::SetVolume(options.volume)).unwrap();
|
||||
if options.mute {
|
||||
audio_tx.send(AudioMessage::SetVolume(0.0)).unwrap();
|
||||
} else {
|
||||
audio_tx.send(AudioMessage::SetVolume(options.volume)).unwrap();
|
||||
}
|
||||
let mut mem = [0; 65536];
|
||||
let cpu = I8080::new();
|
||||
rand::thread_rng().fill_bytes(&mut mem);
|
||||
@ -300,7 +309,11 @@ impl eframe::App for AltairEmulator {
|
||||
if option_window.draw(ctx, &mut self.options) {
|
||||
self.option_window = None;
|
||||
}
|
||||
self.audio_tx.send(AudioMessage::SetVolume(self.options.volume)).unwrap();
|
||||
if self.options.mute {
|
||||
self.audio_tx.send(AudioMessage::SetVolume(0.0)).unwrap();
|
||||
} else {
|
||||
self.audio_tx.send(AudioMessage::SetVolume(self.options.volume)).unwrap();
|
||||
}
|
||||
}
|
||||
if (old_fan_enabled != self.options.fan_enabled) && self.fp_state.power() {
|
||||
if self.options.fan_enabled {
|
||||
@ -344,6 +357,7 @@ impl OptionWindow {
|
||||
});
|
||||
match self.category {
|
||||
OptionsCategory::General => {
|
||||
ui.checkbox(&mut self.options.mute, "Mute");
|
||||
ui.checkbox(&mut self.options.fan_enabled, "Fan enabled");
|
||||
ui.add(Slider::new(&mut self.options.volume, 0.0..=100.0).text("Volume"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user