From ec84e01c49db09daf4c2adfbd9fc2324d400361b Mon Sep 17 00:00:00 2001 From: Melody Madeline Lyons Date: Wed, 3 Jul 2024 09:24:23 -0700 Subject: [PATCH] Remove Window::name It was just technical debt, back from when Window deduplication was by Window::name instead of Window::id --- crates/core/src/window.rs | 5 -- crates/ui/src/lib.rs | 8 --- crates/ui/src/windows/about.rs | 4 -- crates/ui/src/windows/actors.rs | 16 ++--- crates/ui/src/windows/appearance.rs | 70 +++++++++---------- crates/ui/src/windows/armor.rs | 16 ++--- crates/ui/src/windows/classes.rs | 16 ++--- crates/ui/src/windows/common_event_edit.rs | 16 ++--- crates/ui/src/windows/config_window.rs | 52 +++++++------- crates/ui/src/windows/console.rs | 6 +- crates/ui/src/windows/enemies.rs | 16 ++--- crates/ui/src/windows/event_edit.rs | 6 +- crates/ui/src/windows/global_config_window.rs | 6 +- crates/ui/src/windows/items.rs | 16 ++--- crates/ui/src/windows/misc.rs | 18 +---- crates/ui/src/windows/new_project.rs | 6 +- crates/ui/src/windows/reporter.rs | 6 +- crates/ui/src/windows/script_edit.rs | 16 ++--- crates/ui/src/windows/skills.rs | 16 ++--- crates/ui/src/windows/states.rs | 16 ++--- crates/ui/src/windows/weapons.rs | 16 ++--- 21 files changed, 137 insertions(+), 210 deletions(-) diff --git a/crates/core/src/window.rs b/crates/core/src/window.rs index 324d0960..7c3157c8 100644 --- a/crates/core/src/window.rs +++ b/crates/core/src/window.rs @@ -154,11 +154,6 @@ pub trait Window { update_state: &mut crate::UpdateState<'_>, ); - /// Optionally used as the title of the window. - fn name(&self) -> String { - "Untitled Window".to_string() - } - /// Required to prevent duplication. fn id(&self) -> egui::Id; diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 7f5cdcf2..f92a976d 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -125,14 +125,6 @@ macro_rules! window_enum { } } - fn name(&self) -> String { - match self { - $( - Self::$variant(v) => v.name(), - )* - } - } - fn id(&self) -> egui::Id { match self { $( diff --git a/crates/ui/src/windows/about.rs b/crates/ui/src/windows/about.rs index 921ac72d..3e043d84 100644 --- a/crates/ui/src/windows/about.rs +++ b/crates/ui/src/windows/about.rs @@ -42,10 +42,6 @@ impl Default for Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - "About".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("About Luminol") } diff --git a/crates/ui/src/windows/actors.rs b/crates/ui/src/windows/actors.rs index 6301dff2..8e30e6be 100644 --- a/crates/ui/src/windows/actors.rs +++ b/crates/ui/src/windows/actors.rs @@ -222,14 +222,6 @@ fn draw_exp(ui: &mut egui::Ui, actor: &luminol_data::rpg::Actor, total: &mut boo } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_actor_name { - format!("Editing actor {:?}", name) - } else { - "Actor Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("actor_editor") } @@ -257,7 +249,13 @@ impl luminol_core::Window for Window { self.selected_actor_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_actor_name { + format!("Editing actor {:?}", name) + } else { + "Actor Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/appearance.rs b/crates/ui/src/windows/appearance.rs index 4743bba5..59d65d8c 100644 --- a/crates/ui/src/windows/appearance.rs +++ b/crates/ui/src/windows/appearance.rs @@ -35,35 +35,33 @@ impl luminol_core::Window for Window { egui::Id::new("luminol_appearance_window") } - fn name(&self) -> String { - "Luminol Appearance".to_string() - } - fn show( &mut self, ctx: &egui::Context, open: &mut bool, update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()).open(open).show(ctx, |ui| { - // Or these together so if one OR the other is true the window shows. - self.egui_settings_open = - ui.button("Egui Settings").clicked() || self.egui_settings_open; + egui::Window::new("Luminol Appearance") + .open(open) + .show(ctx, |ui| { + // Or these together so if one OR the other is true the window shows. + self.egui_settings_open = + ui.button("Egui Settings").clicked() || self.egui_settings_open; - ui.menu_button("Code Theme", |ui| { - for t in luminol_config::SyntectTheme::iter() { - ui.radio_value( - &mut update_state.global_config.theme.syntect_theme, - t, - t.to_string(), - ); - } + ui.menu_button("Code Theme", |ui| { + for t in luminol_config::SyntectTheme::iter() { + ui.radio_value( + &mut update_state.global_config.theme.syntect_theme, + t, + t.to_string(), + ); + } - ui.label("Code sample"); - ui.label(luminol_components::syntax_highlighting::highlight( - ui.ctx(), - update_state.global_config.theme, - r#" + ui.label("Code sample"); + ui.label(luminol_components::syntax_highlighting::highlight( + ui.ctx(), + update_state.global_config.theme, + r#" class Foo < Array end def bar(baz) @@ -71,21 +69,21 @@ impl luminol_core::Window for Window { print 1, 2.0 puts [0x3, :4, '5'] "#, - "rb", - )); - }); + "rb", + )); + }); - if ui - .button("Clear Loaded Textures") - .on_hover_text( - "You may need to reopen maps/windows for any changes to take effect.", - ) - .clicked() - { - update_state.graphics.texture_loader.clear(); - update_state.graphics.atlas_loader.clear(); - update_state.bytes_loader.forget_all(); - } - }); + if ui + .button("Clear Loaded Textures") + .on_hover_text( + "You may need to reopen maps/windows for any changes to take effect.", + ) + .clicked() + { + update_state.graphics.texture_loader.clear(); + update_state.graphics.atlas_loader.clear(); + update_state.bytes_loader.forget_all(); + } + }); } } diff --git a/crates/ui/src/windows/armor.rs b/crates/ui/src/windows/armor.rs index d4febb8f..cf73a50b 100644 --- a/crates/ui/src/windows/armor.rs +++ b/crates/ui/src/windows/armor.rs @@ -39,14 +39,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_armor_name { - format!("Editing armor {:?}", name) - } else { - "Armor Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("armor_editor") } @@ -70,7 +62,13 @@ impl luminol_core::Window for Window { self.selected_armor_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_armor_name { + format!("Editing armor {:?}", name) + } else { + "Armor Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/classes.rs b/crates/ui/src/windows/classes.rs index 05360761..1124869b 100644 --- a/crates/ui/src/windows/classes.rs +++ b/crates/ui/src/windows/classes.rs @@ -99,14 +99,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_class_name { - format!("Editing class {:?}", name) - } else { - "Class Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("class_editor") } @@ -133,7 +125,13 @@ impl luminol_core::Window for Window { self.selected_class_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_class_name { + format!("Editing class {:?}", name) + } else { + "Class Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/common_event_edit.rs b/crates/ui/src/windows/common_event_edit.rs index 538e1eea..1e828e6e 100644 --- a/crates/ui/src/windows/common_event_edit.rs +++ b/crates/ui/src/windows/common_event_edit.rs @@ -41,14 +41,6 @@ impl Default for Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - self.tabs - .focused_name() - .map_or("Common Events".to_string(), |name| { - format!("Editing Common Event {name}") - }) - } - fn id(&self) -> egui::Id { egui::Id::new("Common Events") } @@ -59,7 +51,13 @@ impl luminol_core::Window for Window { open: &mut bool, update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + let name = self + .tabs + .focused_name() + .map_or("Common Events".to_string(), |name| { + format!("Editing Common Event {name}") + }); + egui::Window::new(name) .default_width(500.) .id(egui::Id::new("common_events_edit")) .open(open) diff --git a/crates/ui/src/windows/config_window.rs b/crates/ui/src/windows/config_window.rs index 0839d76a..caac5401 100644 --- a/crates/ui/src/windows/config_window.rs +++ b/crates/ui/src/windows/config_window.rs @@ -30,10 +30,6 @@ pub struct Window {} impl Window {} impl luminol_core::Window for Window { - fn name(&self) -> String { - "Local Luminol Config".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("Local Luminol Config") } @@ -44,31 +40,33 @@ impl luminol_core::Window for Window { open: &mut bool, update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()).open(open).show(ctx, |ui| { - let config = update_state - .project_config - .as_mut() - .expect("project not open"); + egui::Window::new("Local Luminol Config") + .open(open) + .show(ctx, |ui| { + let config = update_state + .project_config + .as_mut() + .expect("project not open"); - ui.label("Project name"); - ui.text_edit_singleline(&mut config.project.project_name); - ui.label("Scripts path"); - ui.text_edit_singleline(&mut config.project.scripts_path); - ui.checkbox( - &mut config.project.use_ron, - "Use RON (Rusty Object Notation)", - ); - egui::ComboBox::from_label("RGSS Version") - .selected_text(config.project.rgss_ver.to_string()) - .show_ui(ui, |ui| { - for ver in luminol_config::RGSSVer::iter() { - ui.selectable_value(&mut config.project.rgss_ver, ver, ver.to_string()); - } - }); + ui.label("Project name"); + ui.text_edit_singleline(&mut config.project.project_name); + ui.label("Scripts path"); + ui.text_edit_singleline(&mut config.project.scripts_path); + ui.checkbox( + &mut config.project.use_ron, + "Use RON (Rusty Object Notation)", + ); + egui::ComboBox::from_label("RGSS Version") + .selected_text(config.project.rgss_ver.to_string()) + .show_ui(ui, |ui| { + for ver in luminol_config::RGSSVer::iter() { + ui.selectable_value(&mut config.project.rgss_ver, ver, ver.to_string()); + } + }); - ui.label("Playtest Executable"); - ui.text_edit_singleline(&mut config.project.playtest_exe); - }); + ui.label("Playtest Executable"); + ui.text_edit_singleline(&mut config.project.playtest_exe); + }); } fn requires_filesystem(&self) -> bool { diff --git a/crates/ui/src/windows/console.rs b/crates/ui/src/windows/console.rs index 0f34bd63..5e9ee7c4 100644 --- a/crates/ui/src/windows/console.rs +++ b/crates/ui/src/windows/console.rs @@ -39,10 +39,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - self.term.title.clone() - } - fn id(&self) -> egui::Id { self.term.id } @@ -57,7 +53,7 @@ impl luminol_core::Window for Window { open: &mut bool, update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + egui::Window::new(&self.term.title) .id(self.term.id) .open(open) .show(ctx, |ui| { diff --git a/crates/ui/src/windows/enemies.rs b/crates/ui/src/windows/enemies.rs index 070ea7a7..93c90952 100644 --- a/crates/ui/src/windows/enemies.rs +++ b/crates/ui/src/windows/enemies.rs @@ -247,14 +247,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_enemy_name { - format!("Editing enemy {:?}", name) - } else { - "Enemy Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("enemy_editor") } @@ -283,7 +275,13 @@ impl luminol_core::Window for Window { self.selected_enemy_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_enemy_name { + format!("Editing enemy {:?}", name) + } else { + "Enemy Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/event_edit.rs b/crates/ui/src/windows/event_edit.rs index 9cfcb3db..519266e7 100644 --- a/crates/ui/src/windows/event_edit.rs +++ b/crates/ui/src/windows/event_edit.rs @@ -72,10 +72,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - format!("Event 'TODO' ID {}", self.event_id) - } - fn id(&self) -> egui::Id { egui::Id::new("luminol_event_edit") .with(self.map_id) @@ -100,7 +96,7 @@ impl luminol_core::Window for Window { let mut modified = false; let mut graphic_modified = false; - egui::Window::new(self.name()) + egui::Window::new(format!("Event '{}' ID {}", event.name, self.event_id)) .open(open) .id(self.id()) .show(ctx, |ui| { diff --git a/crates/ui/src/windows/global_config_window.rs b/crates/ui/src/windows/global_config_window.rs index 10912dff..db9c9f04 100644 --- a/crates/ui/src/windows/global_config_window.rs +++ b/crates/ui/src/windows/global_config_window.rs @@ -26,10 +26,6 @@ pub struct Window {} impl luminol_core::Window for Window { - fn name(&self) -> String { - "Luminol Preferences".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("luminol_preferences_window") } @@ -40,7 +36,7 @@ impl luminol_core::Window for Window { open: &mut bool, _update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + egui::Window::new("Luminol Preferences") .open(open) .show(ctx, |_ui| {}); } diff --git a/crates/ui/src/windows/items.rs b/crates/ui/src/windows/items.rs index c5fac9fe..d04b2f62 100644 --- a/crates/ui/src/windows/items.rs +++ b/crates/ui/src/windows/items.rs @@ -61,14 +61,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_item_name { - format!("Editing item {:?}", name) - } else { - "Item Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("item_editor") } @@ -94,7 +86,13 @@ impl luminol_core::Window for Window { self.selected_item_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_item_name { + format!("Editing item {:?}", name) + } else { + "Item Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/misc.rs b/crates/ui/src/windows/misc.rs index 6f31057b..52a09c11 100644 --- a/crates/ui/src/windows/misc.rs +++ b/crates/ui/src/windows/misc.rs @@ -27,10 +27,6 @@ pub struct EguiInspection {} impl luminol_core::Window for EguiInspection { - fn name(&self) -> String { - "Egui Inspection".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("Egui Inspection") } @@ -41,7 +37,7 @@ impl luminol_core::Window for EguiInspection { open: &mut bool, _update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + egui::Window::new("Egui Inspection") .open(open) .show(ctx, |ui| ctx.inspection_ui(ui)); } @@ -52,10 +48,6 @@ impl luminol_core::Window for EguiInspection { pub struct EguiMemory {} impl luminol_core::Window for EguiMemory { - fn name(&self) -> String { - "Egui Memory".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("Egui Memory") } @@ -66,7 +58,7 @@ impl luminol_core::Window for EguiMemory { open: &mut bool, _update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + egui::Window::new("Egui Memory") .open(open) .show(ctx, |ui| ctx.memory_ui(ui)); } @@ -76,10 +68,6 @@ impl luminol_core::Window for EguiMemory { pub struct FilesystemDebug {} impl luminol_core::Window for FilesystemDebug { - fn name(&self) -> String { - "Filesystem Debug".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("Filesystem Debug Window") } @@ -90,7 +78,7 @@ impl luminol_core::Window for FilesystemDebug { open: &mut bool, update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + egui::Window::new("Filesystem Debug") .open(open) .show(ctx, |ui| update_state.filesystem.debug_ui(ui)); } diff --git a/crates/ui/src/windows/new_project.rs b/crates/ui/src/windows/new_project.rs index 53516fdd..9bb59bb7 100644 --- a/crates/ui/src/windows/new_project.rs +++ b/crates/ui/src/windows/new_project.rs @@ -65,10 +65,6 @@ impl Default for Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - "New Project".to_string() - } - fn id(&self) -> egui::Id { egui::Id::new("New Project") } @@ -80,7 +76,7 @@ impl luminol_core::Window for Window { update_state: &mut luminol_core::UpdateState<'_>, ) { let mut win_open = true; - egui::Window::new(self.name()) + egui::Window::new("New Project") .open(&mut win_open) .show(ctx, |ui| { ui.add_enabled_ui( diff --git a/crates/ui/src/windows/reporter.rs b/crates/ui/src/windows/reporter.rs index bd6194d6..0ed38386 100644 --- a/crates/ui/src/windows/reporter.rs +++ b/crates/ui/src/windows/reporter.rs @@ -63,10 +63,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - "Crash Reporter".into() - } - fn id(&self) -> egui::Id { egui::Id::new("reporter") } @@ -94,7 +90,7 @@ impl luminol_core::Window for Window { let mut should_close = false; - egui::Window::new(self.name()) + egui::Window::new("Crash Reporter") .id(egui::Id::new("reporter")) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/script_edit.rs b/crates/ui/src/windows/script_edit.rs index 0d830e7c..0067ad77 100644 --- a/crates/ui/src/windows/script_edit.rs +++ b/crates/ui/src/windows/script_edit.rs @@ -36,14 +36,6 @@ impl Default for Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - self.tabs - .focused_name() - .map_or("Scripts".to_string(), |name| { - format!("Editing Script {name}") - }) - } - fn id(&self) -> egui::Id { egui::Id::new("Script Edit") } @@ -54,7 +46,13 @@ impl luminol_core::Window for Window { open: &mut bool, update_state: &mut luminol_core::UpdateState<'_>, ) { - egui::Window::new(self.name()) + let name = self + .tabs + .focused_name() + .map_or("Scripts".to_string(), |name| { + format!("Editing Script {name}") + }); + egui::Window::new(name) .open(open) .id(egui::Id::new("script_editor_window")) .show(ctx, |ui| { diff --git a/crates/ui/src/windows/skills.rs b/crates/ui/src/windows/skills.rs index d4c22727..5c410cc9 100644 --- a/crates/ui/src/windows/skills.rs +++ b/crates/ui/src/windows/skills.rs @@ -39,14 +39,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_skill_name { - format!("Editing skill {:?}", name) - } else { - "Skill Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("skill_editor") } @@ -72,7 +64,13 @@ impl luminol_core::Window for Window { self.selected_skill_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_skill_name { + format!("Editing skill {:?}", name) + } else { + "Skill Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/states.rs b/crates/ui/src/windows/states.rs index 6794f0c8..6fb79435 100644 --- a/crates/ui/src/windows/states.rs +++ b/crates/ui/src/windows/states.rs @@ -39,14 +39,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_state_name { - format!("Editing state {:?}", name) - } else { - "State Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("state_editor") } @@ -70,7 +62,13 @@ impl luminol_core::Window for Window { self.selected_state_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_state_name { + format!("Editing state {:?}", name) + } else { + "State Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open) diff --git a/crates/ui/src/windows/weapons.rs b/crates/ui/src/windows/weapons.rs index 81ba357a..1e439507 100644 --- a/crates/ui/src/windows/weapons.rs +++ b/crates/ui/src/windows/weapons.rs @@ -39,14 +39,6 @@ impl Window { } impl luminol_core::Window for Window { - fn name(&self) -> String { - if let Some(name) = &self.selected_weapon_name { - format!("Editing weapon {:?}", name) - } else { - "Weapon Editor".into() - } - } - fn id(&self) -> egui::Id { egui::Id::new("weapon_editor") } @@ -71,7 +63,13 @@ impl luminol_core::Window for Window { self.selected_weapon_name = None; - let response = egui::Window::new(self.name()) + let name = if let Some(name) = &self.selected_weapon_name { + format!("Editing weapon {:?}", name) + } else { + "Weapon Editor".into() + }; + + let response = egui::Window::new(name) .id(self.id()) .default_width(500.) .open(open)