Skip to content

Commit

Permalink
Remove ResetData
Browse files Browse the repository at this point in the history
Was annoying and probably not needed
  • Loading branch information
melody-rs committed Jul 2, 2024
1 parent bbc9cb4 commit 7395dc9
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 28 deletions.
9 changes: 2 additions & 7 deletions crates/core/src/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
/// A basic trait describing a modal that edits some value.
pub trait Modal: Sized {
/// The output type for this modal.
type Data<'m>
where
Self: 'm;
type ResetData<'m>
where
Self: 'm;
type Data<'m>;

/// Return a widget that displays a button for this modal.
fn button<'m>(
Expand All @@ -39,5 +34,5 @@ pub trait Modal: Sized {
update_state: &'m mut crate::UpdateState<'_>,
) -> impl egui::Widget + 'm; // woah rpitit (so cool)

fn reset(&mut self, update_state: &mut crate::UpdateState<'_>, data: Self::ResetData<'_>);
fn reset(&mut self, update_state: &mut crate::UpdateState<'_>, data: Self::Data<'_>);
}
9 changes: 2 additions & 7 deletions crates/modals/src/database_modal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ where

impl<M> luminol_core::Modal for Modal<M>
where
M: DatabaseModalHandler + 'static,
M: DatabaseModalHandler,
{
type Data<'m> = &'m mut usize;
type ResetData<'m> = &'m usize;

fn button<'m>(
&'m mut self,
Expand Down Expand Up @@ -114,11 +113,7 @@ where
}
}

fn reset(
&mut self,
_update_state: &mut luminol_core::UpdateState<'_>,
_data: Self::ResetData<'_>,
) {
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;
}
Expand Down
3 changes: 1 addition & 2 deletions crates/modals/src/event_graphic_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ impl Modal {

impl luminol_core::Modal for Modal {
type Data<'m> = &'m mut luminol_data::rpg::Graphic;
type ResetData<'m> = &'m luminol_data::rpg::Graphic;

fn button<'m>(
&'m mut self,
Expand Down Expand Up @@ -222,7 +221,7 @@ impl luminol_core::Modal for Modal {
}
}

fn reset(&mut self, update_state: &mut UpdateState<'_>, data: Self::ResetData<'_>) {
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;
}
Expand Down
7 changes: 1 addition & 6 deletions crates/modals/src/graphic_picker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl Modal {

impl luminol_core::Modal for Modal {
type Data<'m> = &'m mut Option<camino::Utf8PathBuf>;
type ResetData<'m> = &'m Option<camino::Utf8PathBuf>;

fn button<'m>(
&'m mut self,
Expand Down Expand Up @@ -195,11 +194,7 @@ impl luminol_core::Modal for Modal {
}
}

fn reset(
&mut self,
update_state: &mut luminol_core::UpdateState<'_>,
data: Self::ResetData<'_>,
) {
fn reset(&mut self, update_state: &mut luminol_core::UpdateState<'_>, data: Self::Data<'_>) {
self.update_graphic(update_state, data); // we need to update the button sprite to prevent desyncs
self.state = State::Closed;
}
Expand Down
3 changes: 1 addition & 2 deletions crates/modals/src/sound_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl Modal {

impl luminol_core::Modal for Modal {
type Data<'m> = &'m mut luminol_data::rpg::AudioFile;
type ResetData<'m> = &'m luminol_data::rpg::AudioFile;

fn button<'m>(
&'m mut self,
Expand Down Expand Up @@ -78,7 +77,7 @@ impl luminol_core::Modal for Modal {
}
}

fn reset(&mut self, _: &mut luminol_core::UpdateState<'_>, _data: Self::ResetData<'_>) {
fn reset(&mut self, _: &mut luminol_core::UpdateState<'_>, _data: Self::Data<'_>) {
// we don't need to do much here
self.state = State::Closed;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/windows/event_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl luminol_core::Window for Window {
let page = &mut self.event.pages[self.selected_page];
if self.selected_page != previous_page {
// reset the modal if we've changed pages
self.graphic_modal.reset(update_state, &&mut page.graphic);
self.graphic_modal.reset(update_state, &mut page.graphic);
}

egui::SidePanel::left(id_source.with("side_panel")).show_inside(ui, |ui| {
Expand Down
5 changes: 2 additions & 3 deletions crates/ui/src/windows/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ impl luminol_core::Window for Window {
.changed();
if self.previous_item != Some(item.id) {
// avoid desyncs by resetting the modal if the item has changed
self.graphic_picker
.reset(update_state, &&mut item.icon_name);
self.graphic_picker.reset(update_state, &mut item.icon_name);
}

modified |= ui
Expand Down Expand Up @@ -216,7 +215,7 @@ impl luminol_core::Window for Window {
.changed();
if self.previous_item != Some(item.id) {
// reset the modal if the item has changed (this is practically a no-op)
self.menu_se_picker.reset(update_state, &item.menu_se);
self.menu_se_picker.reset(update_state, &mut item.menu_se);
}

modified |= columns[1]
Expand Down

0 comments on commit 7395dc9

Please sign in to comment.