Persist watch rom setting

This commit is contained in:
Simon Gellis 2026-08-15 00:59:35 -04:00
parent 762f43fd42
commit a6c12a986c
No known key found for this signature in database
GPG Key ID: DA576912FED9577B
2 changed files with 6 additions and 3 deletions

View File

@ -143,6 +143,8 @@ pub struct SimConfig {
#[serde(default)] #[serde(default)]
pub low_battery: bool, pub low_battery: bool,
#[serde(default)] #[serde(default)]
pub watch_rom: bool,
#[serde(default)]
pub position: Option<Pos2>, pub position: Option<Pos2>,
} }
@ -157,6 +159,7 @@ impl SimConfig {
dimensions: DisplayMode::Anaglyph.proportions() + Vec2::new(0.0, 22.0), dimensions: DisplayMode::Anaglyph.proportions() + Vec2::new(0.0, 22.0),
audio_enabled: true, audio_enabled: true,
low_battery: false, low_battery: false,
watch_rom: false,
position: None, position: None,
} }
} }

View File

@ -73,6 +73,7 @@ impl GameWindow {
) -> Self { ) -> Self {
let config = SimConfig::load(&persistence, sim_id); let config = SimConfig::load(&persistence, sim_id);
let _ = proxy.send_event(UserEvent::LowBattery(sim_id, config.low_battery)); let _ = proxy.send_event(UserEvent::LowBattery(sim_id, config.low_battery));
client.send_command(EmulatorCommand::WatchRom(sim_id, config.watch_rom));
let toasts = Toasts::new() let toasts = Toasts::new()
.with_anchor(Anchor::BottomLeft) .with_anchor(Anchor::BottomLeft)
.with_margin((10.0, 10.0).into()) .with_margin((10.0, 10.0).into())
@ -333,6 +334,7 @@ impl GameWindow {
} }
let watch_rom = self.client.is_rom_watched(self.sim_id); let watch_rom = self.client.is_rom_watched(self.sim_id);
if ui.selectable_button(watch_rom, "Watch ROM").clicked() { if ui.selectable_button(watch_rom, "Watch ROM").clicked() {
self.update_config(|c| c.watch_rom = !watch_rom);
self.client self.client
.send_command(EmulatorCommand::WatchRom(self.sim_id, !watch_rom)); .send_command(EmulatorCommand::WatchRom(self.sim_id, !watch_rom));
} }
@ -393,9 +395,7 @@ impl GameWindow {
ui.separator(); ui.separator();
let low_battery = self.config.low_battery; let low_battery = self.config.low_battery;
if ui.selectable_button(low_battery, "Low Battery").clicked() { if ui.selectable_button(low_battery, "Low Battery").clicked() {
self.update_config(|c| { self.update_config(|c| c.low_battery = !low_battery);
c.low_battery = !low_battery;
});
let _ = self let _ = self
.proxy .proxy
.send_event(UserEvent::LowBattery(self.sim_id, !low_battery)); .send_event(UserEvent::LowBattery(self.sim_id, !low_battery));