diff --git a/crates/core/src/modal.rs b/crates/core/src/modal.rs index 902037d4..1ac00308 100644 --- a/crates/core/src/modal.rs +++ b/crates/core/src/modal.rs @@ -34,6 +34,5 @@ pub trait Modal: Sized { update_state: &'m mut crate::UpdateState<'_>, ) -> impl egui::Widget + 'm; // woah rpitit (so cool) - // FIXME is this used anywhere? - fn reset(&mut self); + fn reset(&mut self, update_state: &mut crate::UpdateState<'_>, data: &Self::Data); } diff --git a/crates/modals/src/database_modal/mod.rs b/crates/modals/src/database_modal/mod.rs index dac34b78..915886d0 100644 --- a/crates/modals/src/database_modal/mod.rs +++ b/crates/modals/src/database_modal/mod.rs @@ -113,7 +113,8 @@ where } } - fn reset(&mut self) { + fn reset(&mut self, _update_state: &mut luminol_core::UpdateState<'_>, _data: &Self::Data) { + // not much internal state, so we dont need to do much here self.state = State::Closed; } } diff --git a/crates/modals/src/event_graphic_picker.rs b/crates/modals/src/event_graphic_picker.rs index 18579311..af03bc83 100644 --- a/crates/modals/src/event_graphic_picker.rs +++ b/crates/modals/src/event_graphic_picker.rs @@ -221,13 +221,14 @@ impl luminol_core::Modal for Modal { } } - fn reset(&mut self) { + fn reset(&mut self, update_state: &mut UpdateState<'_>, data: &Self::Data) { + self.update_graphic(update_state, data); // we need to update the button sprite to prevent desyncs self.state = State::Closed; } } impl Modal { - pub fn update_graphic(&mut self, update_state: &UpdateState<'_>, graphic: &rpg::Graphic) { + fn update_graphic(&mut self, update_state: &UpdateState<'_>, graphic: &rpg::Graphic) { let atlas = update_state .graphics .atlas_loader @@ -240,7 +241,7 @@ impl Modal { graphic, &atlas, ) - .unwrap(); + .unwrap(); // FIXME } fn load_tilepicker( diff --git a/crates/modals/src/graphic_picker/mod.rs b/crates/modals/src/graphic_picker/mod.rs index d0708c1d..b5125d9b 100644 --- a/crates/modals/src/graphic_picker/mod.rs +++ b/crates/modals/src/graphic_picker/mod.rs @@ -112,7 +112,7 @@ impl luminol_core::Modal for Modal { |ui: &mut egui::Ui| todo!() } - fn reset(&mut self) { + fn reset(&mut self, update_state: &mut luminol_core::UpdateState<'_>, data: &Self::Data) { todo!() } } diff --git a/crates/modals/src/sound_picker.rs b/crates/modals/src/sound_picker.rs index ffec79ae..b0fbe617 100644 --- a/crates/modals/src/sound_picker.rs +++ b/crates/modals/src/sound_picker.rs @@ -77,7 +77,8 @@ impl luminol_core::Modal for Modal { } } - fn reset(&mut self) { + fn reset(&mut self, update_state: &mut luminol_core::UpdateState<'_>, _data: &Self::Data) { + // we don't need to do much here self.state = State::Closed; } } diff --git a/crates/ui/src/windows/event_edit.rs b/crates/ui/src/windows/event_edit.rs index bc84974d..4be5adde 100644 --- a/crates/ui/src/windows/event_edit.rs +++ b/crates/ui/src/windows/event_edit.rs @@ -130,9 +130,8 @@ impl luminol_core::Window for Window { let page = &mut self.event.pages[self.selected_page]; if self.selected_page != previous_page { - // we need to update the modal to prevent desyncs - self.graphic_modal - .update_graphic(update_state, &page.graphic); + // reset the modal if we've changed pages + self.graphic_modal.reset(update_state, &page.graphic); } egui::SidePanel::left(id_source.with("side_panel")).show_inside(ui, |ui| { diff --git a/crates/ui/src/windows/items.rs b/crates/ui/src/windows/items.rs index c34f18a0..a05c36ab 100644 --- a/crates/ui/src/windows/items.rs +++ b/crates/ui/src/windows/items.rs @@ -196,7 +196,8 @@ impl luminol_core::Window for Window { )) .changed(); if self.previous_item != Some(item.id) { - self.menu_se_picker.reset(); + // reset the modal if the item has changed (this is practically a no-op) + self.menu_se_picker.reset(update_state, &item.menu_se); } modified |= columns[1]