Only allow changing cards when system power is off
This commit is contained in:
parent
476c744bfa
commit
e569a2720c
@ -19,6 +19,7 @@ pub struct OptionWindow {
|
||||
category: OptionsCategory,
|
||||
card_options: Vec<(&'static Type, Box<dyn SettingsUi>)>,
|
||||
select_idx: Option<usize>,
|
||||
allow_changing_cards: bool,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
@ -41,14 +42,17 @@ 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Window for OptionWindow {
|
||||
@ -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| {
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user