diff --git a/src/option_window.rs b/src/option_window.rs index 3933b16..6ad4f78 100644 --- a/src/option_window.rs +++ b/src/option_window.rs @@ -19,6 +19,7 @@ pub struct OptionWindow { category: OptionsCategory, card_options: Vec<(&'static Type, Box)>, select_idx: Option, + allow_changing_cards: bool, } #[derive(PartialEq, Eq)] @@ -41,13 +42,16 @@ impl OptionWindow { category: OptionsCategory::General, card_options, select_idx, + allow_changing_cards: !state.power(), } } fn sync_settings(&self, state: &mut EmuState) { state.update_options(self.options); - let cards = self.card_options.iter().map(|(typ, settings_ui)| (*typ, typ.new_card(ron::from_str(&settings_ui.serialize_settings()).unwrap()).unwrap())).collect(); - state.set_cards(cards); + if self.allow_changing_cards { + let cards = self.card_options.iter().map(|(typ, settings_ui)| (*typ, typ.new_card(ron::from_str(&settings_ui.serialize_settings()).unwrap()).unwrap())).collect(); + state.set_cards(cards); + } } } @@ -69,6 +73,7 @@ impl Window for OptionWindow { } OptionsCategory::Cards => { TopBottomPanel::top("card_opts").show_inside(ui, |ui| { + ui.set_enabled(self.allow_changing_cards); SidePanel::left("card_opts_left") .show_separator_line(false) .show_inside(ui, |ui| { diff --git a/src/state.rs b/src/state.rs index 97fe804..857caf1 100644 --- a/src/state.rs +++ b/src/state.rs @@ -229,6 +229,10 @@ impl EmuState { self.cards.iter().map(|(typ, card)| (typ.name().to_string(), card.get_settings())).collect() } + pub fn power(&self) -> bool { + self.fp_state.power() + } + fn read_mem(&mut self, address: u16) -> u8 { self.cards.iter_mut().find_map(|(_, card)| card.read_mem(address)).unwrap_or(0xFF) }