From fc4939565554ec575c246f3bd8860470d36a96e7 Mon Sep 17 00:00:00 2001 From: N Date: Wed, 21 Aug 2024 21:01:23 +0300 Subject: [PATCH] feat: unify crates `ui`, `components` and `modals` --- Cargo.lock | 108 +--- Cargo.toml | 2 - crates/components/Cargo.toml | 55 -- crates/modals/Cargo.toml | 36 -- crates/ui/Cargo.toml | 17 +- .../src/components}/animation_frame_view.rs | 0 .../src => ui/src/components}/cellpicker.rs | 0 .../src/components}/collapsing_view.rs | 2 +- .../components}/command_view/command_ui.rs | 0 .../src/components}/command_view/macros.rs | 0 .../src/components}/command_view/mod.rs | 0 .../components}/command_view/parameter_ui.rs | 0 .../src/components}/command_view/ui.rs | 0 .../src/components}/database_view.rs | 2 +- .../src/components}/filesystem_view.rs | 2 +- .../src => ui/src/components}/id_vec.rs | 2 +- .../src => ui/src/components}/map_view.rs | 2 +- .../src/lib.rs => ui/src/components/mod.rs} | 0 .../src => ui/src/components}/sound_tab.rs | 2 +- .../src/components}/syntax_highlighting.rs | 0 .../src => ui/src/components}/tilepicker.rs | 0 .../src => ui/src/components}/ui_ext.rs | 0 crates/ui/src/lib.rs | 4 +- .../src/modals}/animations/batch_edit_tool.rs | 54 +- .../animations/change_cell_number_tool.rs | 12 +- .../animations/change_frame_count_tool.rs | 6 +- .../modals}/animations/clear_frames_tool.rs | 8 +- .../modals}/animations/copy_frames_tool.rs | 10 +- .../src => ui/src/modals}/animations/mod.rs | 0 .../src/modals}/animations/tween_tool.rs | 12 +- .../src/modals}/database_modal/mod.rs | 4 +- .../src/modals}/database_modal/switch.rs | 0 .../src/modals}/database_modal/variable.rs | 0 .../src/modals}/graphic_picker/actor.rs | 4 +- .../src/modals}/graphic_picker/animation.rs | 8 +- .../src/modals}/graphic_picker/basic.rs | 4 +- .../src/modals}/graphic_picker/event.rs | 10 +- .../src/modals}/graphic_picker/hue.rs | 4 +- .../src/modals}/graphic_picker/mod.rs | 2 +- .../src/lib.rs => ui/src/modals/mod.rs} | 0 .../src => ui/src/modals}/move_route.rs | 0 .../src => ui/src/modals}/sound_picker.rs | 6 +- crates/ui/src/tabs/map/brush.rs | 9 +- crates/ui/src/tabs/map/mod.rs | 29 +- crates/ui/src/tabs/map/util.rs | 2 +- crates/ui/src/windows/actors.rs | 587 ++++++++---------- .../ui/src/windows/animations/frame_edit.rs | 63 +- crates/ui/src/windows/animations/mod.rs | 44 +- crates/ui/src/windows/animations/timing.rs | 89 ++- crates/ui/src/windows/animations/window.rs | 136 ++-- crates/ui/src/windows/archive_manager.rs | 16 +- crates/ui/src/windows/armor.rs | 49 +- crates/ui/src/windows/classes.rs | 105 ++-- crates/ui/src/windows/common_event_edit.rs | 4 +- crates/ui/src/windows/enemies.rs | 164 +++-- crates/ui/src/windows/event_edit.rs | 19 +- crates/ui/src/windows/items.rs | 112 ++-- crates/ui/src/windows/preferences.rs | 6 +- crates/ui/src/windows/reporter.rs | 2 +- crates/ui/src/windows/script_edit.rs | 2 +- crates/ui/src/windows/script_manager.rs | 20 +- crates/ui/src/windows/skills.rs | 100 ++- crates/ui/src/windows/sound_test.rs | 4 +- crates/ui/src/windows/states.rs | 105 ++-- crates/ui/src/windows/weapons.rs | 70 +-- 65 files changed, 915 insertions(+), 1200 deletions(-) delete mode 100644 crates/components/Cargo.toml delete mode 100644 crates/modals/Cargo.toml rename crates/{components/src => ui/src/components}/animation_frame_view.rs (100%) rename crates/{components/src => ui/src/components}/cellpicker.rs (100%) rename crates/{components/src => ui/src/components}/collapsing_view.rs (99%) rename crates/{components/src => ui/src/components}/command_view/command_ui.rs (100%) rename crates/{components/src => ui/src/components}/command_view/macros.rs (100%) rename crates/{components/src => ui/src/components}/command_view/mod.rs (100%) rename crates/{components/src => ui/src/components}/command_view/parameter_ui.rs (100%) rename crates/{components/src => ui/src/components}/command_view/ui.rs (100%) rename crates/{components/src => ui/src/components}/database_view.rs (99%) rename crates/{components/src => ui/src/components}/filesystem_view.rs (99%) rename crates/{components/src => ui/src/components}/id_vec.rs (99%) rename crates/{components/src => ui/src/components}/map_view.rs (99%) rename crates/{components/src/lib.rs => ui/src/components/mod.rs} (100%) rename crates/{components/src => ui/src/components}/sound_tab.rs (99%) rename crates/{components/src => ui/src/components}/syntax_highlighting.rs (100%) rename crates/{components/src => ui/src/components}/tilepicker.rs (100%) rename crates/{components/src => ui/src/components}/ui_ext.rs (100%) rename crates/{modals/src => ui/src/modals}/animations/batch_edit_tool.rs (90%) rename crates/{modals/src => ui/src/modals}/animations/change_cell_number_tool.rs (93%) rename crates/{modals/src => ui/src/modals}/animations/change_frame_count_tool.rs (96%) rename crates/{modals/src => ui/src/modals}/animations/clear_frames_tool.rs (94%) rename crates/{modals/src => ui/src/modals}/animations/copy_frames_tool.rs (93%) rename crates/{modals/src => ui/src/modals}/animations/mod.rs (100%) rename crates/{modals/src => ui/src/modals}/animations/tween_tool.rs (94%) rename crates/{modals/src => ui/src/modals}/database_modal/mod.rs (98%) rename crates/{modals/src => ui/src/modals}/database_modal/switch.rs (100%) rename crates/{modals/src => ui/src/modals}/database_modal/variable.rs (100%) rename crates/{modals/src => ui/src/modals}/graphic_picker/actor.rs (99%) rename crates/{modals/src => ui/src/modals}/graphic_picker/animation.rs (98%) rename crates/{modals/src => ui/src/modals}/graphic_picker/basic.rs (99%) rename crates/{modals/src => ui/src/modals}/graphic_picker/event.rs (98%) rename crates/{modals/src => ui/src/modals}/graphic_picker/hue.rs (99%) rename crates/{modals/src => ui/src/modals}/graphic_picker/mod.rs (99%) rename crates/{modals/src/lib.rs => ui/src/modals/mod.rs} (100%) rename crates/{modals/src => ui/src/modals}/move_route.rs (100%) rename crates/{modals/src => ui/src/modals}/sound_picker.rs (94%) diff --git a/Cargo.lock b/Cargo.lock index 161d818a..f0823c09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,12 +167,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "aliasable" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" - [[package]] name = "aligned-vec" version = "0.5.0" @@ -3116,36 +3110,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "luminol-components" -version = "0.4.0" -dependencies = [ - "camino", - "color-eyre", - "egui", - "fragile", - "fuzzy-matcher", - "glam", - "image 0.25.2", - "indextree", - "itertools 0.11.0", - "lexical-sort", - "luminol-audio", - "luminol-config", - "luminol-core", - "luminol-data", - "luminol-egui-wgpu", - "luminol-filesystem", - "luminol-graphics", - "murmur3", - "oneshot", - "parking_lot", - "qp-trie", - "strum", - "syntect", - "wgpu", -] - [[package]] name = "luminol-config" version = "0.4.0" @@ -3334,24 +3298,6 @@ dependencies = [ "luminol-proc-macros", ] -[[package]] -name = "luminol-modals" -version = "0.4.0" -dependencies = [ - "camino", - "color-eyre", - "egui", - "fuzzy-matcher", - "glam", - "lexical-sort", - "luminol-components", - "luminol-core", - "luminol-data", - "luminol-egui-wgpu", - "luminol-graphics", - "ouroboros", -] - [[package]] name = "luminol-proc-macros" version = "0.4.0" @@ -3400,20 +3346,25 @@ dependencies = [ "egui-modal", "futures-lite 2.2.0", "futures-util", + "fuzzy-matcher", + "glam", + "image 0.25.2", "indexmap", + "indextree", "itertools 0.11.0", + "lexical-sort", "luminol-audio", - "luminol-components", "luminol-config", "luminol-core", "luminol-data", + "luminol-egui-wgpu", "luminol-filesystem", "luminol-graphics", "luminol-macros", - "luminol-modals", "luminol-term", "murmur3", "once_cell", + "oneshot", "parking_lot", "poll-promise", "qp-trie", @@ -3424,6 +3375,7 @@ dependencies = [ "serde_yml", "strip-ansi-escapes", "strum", + "syntect", "target-triple", "wgpu", "zip", @@ -4194,31 +4146,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "ouroboros" -version = "0.18.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "944fa20996a25aded6b4795c6d63f10014a7a83f8be9828a11860b08c5fc4a67" -dependencies = [ - "aliasable", - "ouroboros_macro", - "static_assertions", -] - -[[package]] -name = "ouroboros_macro" -version = "0.18.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39b0deead1528fd0e5947a8546a9642a9777c25f6e1e26f34c97b204bbb465bd" -dependencies = [ - "heck", - "itertools 0.12.1", - "proc-macro2", - "proc-macro2-diagnostics", - "quote", - "syn 2.0.51", -] - [[package]] name = "overload" version = "0.1.1" @@ -4510,19 +4437,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "proc-macro2-diagnostics" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.51", - "version_check", - "yansi", -] - [[package]] name = "profiling" version = "1.0.15" @@ -7117,12 +7031,6 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "yansi" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" - [[package]] name = "zbus" version = "3.15.1" diff --git a/Cargo.toml b/Cargo.toml index e3b6800e..25140585 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,6 @@ js-sys = "0.3" lexical-sort = "0.3.1" luminol-audio = { version = "0.4.0", path = "crates/audio/" } -luminol-components = { version = "0.4.0", path = "crates/components/" } luminol-config = { version = "0.4.0", path = "crates/config/" } luminol-core = { version = "0.4.0", path = "crates/core/" } luminol-data = { version = "0.4.0", path = "crates/data/" } @@ -148,7 +147,6 @@ luminol-filesystem = { version = "0.4.0", path = "crates/filesystem/" } luminol-graphics = { version = "0.4.0", path = "crates/graphics/" } luminol-macros = { version = "0.4.0", path = "crates/macros/" } luminol-proc-macros = { version = "0.4.0", path = "crates/proc-macros/" } -luminol-modals = { version = "0.4.0", path = "crates/modals/" } luminol-term = { version = "0.4.0", path = "crates/term/" } luminol-ui = { version = "0.4.0", path = "crates/ui/" } luminol-result = { version = "0.4.0", path = "crates/result" } diff --git a/crates/components/Cargo.toml b/crates/components/Cargo.toml deleted file mode 100644 index bf72d3ee..00000000 --- a/crates/components/Cargo.toml +++ /dev/null @@ -1,55 +0,0 @@ -[package] -name = "luminol-components" - -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -rust-version.workspace = true -readme.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lints] -workspace = true - -[dependencies] -luminol-audio.workspace = true -luminol-core.workspace = true -luminol-config.workspace = true -luminol-data.workspace = true -luminol-graphics.workspace = true -luminol-filesystem.workspace = true - -egui.workspace = true -strum.workspace = true - -luminol-egui-wgpu.workspace = true - -wgpu.workspace = true -glam.workspace = true - -syntect = { version = "5.1.0", default-features = false, features = [ - "default-fancy", -] } - -itertools.workspace = true - -color-eyre.workspace = true - -qp-trie.workspace = true -indextree = "4.6.0" -lexical-sort.workspace = true - -fragile.workspace = true -parking_lot.workspace = true -oneshot.workspace = true - -fuzzy-matcher = "0.3.7" -murmur3.workspace = true - -image.workspace = true -camino.workspace = true diff --git a/crates/modals/Cargo.toml b/crates/modals/Cargo.toml deleted file mode 100644 index 7efe7a82..00000000 --- a/crates/modals/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -name = "luminol-modals" - -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -rust-version.workspace = true -readme.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -[lints] -workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -egui.workspace = true - -camino.workspace = true - -luminol-core.workspace = true -luminol-data.workspace = true -luminol-graphics.workspace = true -luminol-components.workspace = true -luminol-egui-wgpu.workspace = true -glam.workspace = true -color-eyre.workspace = true - -fuzzy-matcher = "0.3.7" - -ouroboros = "0.18.4" - -lexical-sort.workspace = true diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 81ceec9c..15bf3941 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -23,9 +23,8 @@ luminol-config.workspace = true luminol-data.workspace = true luminol-graphics.workspace = true luminol-filesystem.workspace = true -luminol-components.workspace = true -luminol-modals.workspace = true luminol-macros.workspace = true +luminol-egui-wgpu.workspace = true egui.workspace = true egui-modal.workspace = true @@ -54,6 +53,8 @@ zip = { version = "0.6.6", default-features = false, features = ["deflate"] } parking_lot.workspace = true once_cell.workspace = true qp-trie.workspace = true +indextree = "4.6.0" +lexical-sort.workspace = true itertools.workspace = true @@ -65,5 +66,17 @@ murmur3.workspace = true indexmap = "2.2.6" alox-48.workspace = true +fuzzy-matcher = "0.3.7" + +glam.workspace = true + +oneshot.workspace = true + +image.workspace = true + +syntect = { version = "5.1.0", default-features = false, features = [ + "default-fancy", +] } + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] luminol-term = { version = "0.4.0", path = "../term/" } diff --git a/crates/components/src/animation_frame_view.rs b/crates/ui/src/components/animation_frame_view.rs similarity index 100% rename from crates/components/src/animation_frame_view.rs rename to crates/ui/src/components/animation_frame_view.rs diff --git a/crates/components/src/cellpicker.rs b/crates/ui/src/components/cellpicker.rs similarity index 100% rename from crates/components/src/cellpicker.rs rename to crates/ui/src/components/cellpicker.rs diff --git a/crates/components/src/collapsing_view.rs b/crates/ui/src/components/collapsing_view.rs similarity index 99% rename from crates/components/src/collapsing_view.rs rename to crates/ui/src/components/collapsing_view.rs index 2de7ad61..297641a6 100644 --- a/crates/components/src/collapsing_view.rs +++ b/crates/ui/src/components/collapsing_view.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::UiExt; +use super::UiExt; /// A component that shows many copies of a layout and only allows one of them to be expanded at a /// time. diff --git a/crates/components/src/command_view/command_ui.rs b/crates/ui/src/components/command_view/command_ui.rs similarity index 100% rename from crates/components/src/command_view/command_ui.rs rename to crates/ui/src/components/command_view/command_ui.rs diff --git a/crates/components/src/command_view/macros.rs b/crates/ui/src/components/command_view/macros.rs similarity index 100% rename from crates/components/src/command_view/macros.rs rename to crates/ui/src/components/command_view/macros.rs diff --git a/crates/components/src/command_view/mod.rs b/crates/ui/src/components/command_view/mod.rs similarity index 100% rename from crates/components/src/command_view/mod.rs rename to crates/ui/src/components/command_view/mod.rs diff --git a/crates/components/src/command_view/parameter_ui.rs b/crates/ui/src/components/command_view/parameter_ui.rs similarity index 100% rename from crates/components/src/command_view/parameter_ui.rs rename to crates/ui/src/components/command_view/parameter_ui.rs diff --git a/crates/components/src/command_view/ui.rs b/crates/ui/src/components/command_view/ui.rs similarity index 100% rename from crates/components/src/command_view/ui.rs rename to crates/ui/src/components/command_view/ui.rs diff --git a/crates/components/src/database_view.rs b/crates/ui/src/components/database_view.rs similarity index 99% rename from crates/components/src/database_view.rs rename to crates/ui/src/components/database_view.rs index 16b564e2..b6f0e7a7 100644 --- a/crates/components/src/database_view.rs +++ b/crates/ui/src/components/database_view.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::UiExt; +use super::UiExt; use itertools::Itertools; pub struct DatabaseViewResponse { diff --git a/crates/components/src/filesystem_view.rs b/crates/ui/src/components/filesystem_view.rs similarity index 99% rename from crates/components/src/filesystem_view.rs rename to crates/ui/src/components/filesystem_view.rs index 6d90f57b..9f647b33 100644 --- a/crates/components/src/filesystem_view.rs +++ b/crates/ui/src/components/filesystem_view.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::UiExt; +use super::UiExt; use itertools::Itertools; pub struct FileSystemView { diff --git a/crates/components/src/id_vec.rs b/crates/ui/src/components/id_vec.rs similarity index 99% rename from crates/components/src/id_vec.rs rename to crates/ui/src/components/id_vec.rs index a9e3b67d..92c98fc7 100644 --- a/crates/components/src/id_vec.rs +++ b/crates/ui/src/components/id_vec.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::UiExt; +use super::UiExt; use itertools::Itertools; #[derive(Default, Clone)] diff --git a/crates/components/src/map_view.rs b/crates/ui/src/components/map_view.rs similarity index 99% rename from crates/components/src/map_view.rs rename to crates/ui/src/components/map_view.rs index 23cecf1a..e35f9228 100644 --- a/crates/components/src/map_view.rs +++ b/crates/ui/src/components/map_view.rs @@ -163,7 +163,7 @@ impl MapView { ui: &mut egui::Ui, update_state: &luminol_core::UpdateState<'_>, map: &luminol_data::rpg::Map, - tilepicker: &crate::Tilepicker, + tilepicker: &super::Tilepicker, dragging_event: bool, drawing_shape: bool, drawing_shape_pos: Option, diff --git a/crates/components/src/lib.rs b/crates/ui/src/components/mod.rs similarity index 100% rename from crates/components/src/lib.rs rename to crates/ui/src/components/mod.rs diff --git a/crates/components/src/sound_tab.rs b/crates/ui/src/components/sound_tab.rs similarity index 99% rename from crates/components/src/sound_tab.rs rename to crates/ui/src/components/sound_tab.rs index 7747083f..2d8e653f 100644 --- a/crates/components/src/sound_tab.rs +++ b/crates/ui/src/components/sound_tab.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::UiExt; +use super::UiExt; pub struct SoundTab { /// The source for this tab. diff --git a/crates/components/src/syntax_highlighting.rs b/crates/ui/src/components/syntax_highlighting.rs similarity index 100% rename from crates/components/src/syntax_highlighting.rs rename to crates/ui/src/components/syntax_highlighting.rs diff --git a/crates/components/src/tilepicker.rs b/crates/ui/src/components/tilepicker.rs similarity index 100% rename from crates/components/src/tilepicker.rs rename to crates/ui/src/components/tilepicker.rs diff --git a/crates/components/src/ui_ext.rs b/crates/ui/src/components/ui_ext.rs similarity index 100% rename from crates/components/src/ui_ext.rs rename to crates/ui/src/components/ui_ext.rs diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index b616d6a4..63a819c5 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -21,11 +21,13 @@ // it with Steamworks API by Valve Corporation, containing parts covered by // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +#![cfg_attr(target_arch = "wasm32", allow(clippy::arc_with_non_send_sync))] pub type UpdateState<'res> = luminol_core::UpdateState<'res>; +pub mod components; +pub mod modals; pub mod tabs; - pub mod windows; macro_rules! tab_enum { diff --git a/crates/modals/src/animations/batch_edit_tool.rs b/crates/ui/src/modals/animations/batch_edit_tool.rs similarity index 90% rename from crates/modals/src/animations/batch_edit_tool.rs rename to crates/ui/src/modals/animations/batch_edit_tool.rs index 2b48598d..9200b129 100644 --- a/crates/modals/src/animations/batch_edit_tool.rs +++ b/crates/ui/src/modals/animations/batch_edit_tool.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{EnumComboBox, Field, FieldWithCheckbox, UiExt}; use luminol_core::prelude::frame::{FRAME_HEIGHT, FRAME_WIDTH}; use luminol_data::BlendMode; @@ -191,7 +191,7 @@ impl Modal { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { self.start_frame += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Starting Frame", egui::DragValue::new(&mut self.start_frame).range(1..=self.frames_len), )); @@ -202,7 +202,7 @@ impl Modal { } self.end_frame += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Ending Frame", egui::DragValue::new(&mut self.end_frame).range(1..=self.frames_len), )); @@ -219,7 +219,7 @@ impl Modal { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { self.set_pattern += 1; - columns[0].add(luminol_components::FieldWithCheckbox::new( + columns[0].add(FieldWithCheckbox::new( "Pattern", &mut self.set_pattern_enabled, egui::DragValue::new(&mut self.set_pattern) @@ -227,14 +227,14 @@ impl Modal { )); self.set_pattern -= 1; - columns[1].add(luminol_components::FieldWithCheckbox::new( + columns[1].add(FieldWithCheckbox::new( "X", &mut self.set_x_enabled, egui::DragValue::new(&mut self.set_x) .range(-(FRAME_WIDTH as i16 / 2)..=FRAME_WIDTH as i16 / 2), )); - columns[2].add(luminol_components::FieldWithCheckbox::new( + columns[2].add(FieldWithCheckbox::new( "Y", &mut self.set_y_enabled, egui::DragValue::new(&mut self.set_y).range( @@ -242,7 +242,7 @@ impl Modal { ), )); - columns[3].add(luminol_components::FieldWithCheckbox::new( + columns[3].add(FieldWithCheckbox::new( "Scale", &mut self.set_scale_enabled, egui::DragValue::new(&mut self.set_scale) @@ -254,7 +254,7 @@ impl Modal { ui.with_padded_stripe(true, |ui| { ui.columns(4, |columns| { - columns[0].add(luminol_components::FieldWithCheckbox::new( + columns[0].add(FieldWithCheckbox::new( "Rotation", &mut self.set_rotation_enabled, egui::DragValue::new(&mut self.set_rotation) @@ -263,14 +263,14 @@ impl Modal { )); let mut flip = self.set_flip == 1; - columns[1].add(luminol_components::FieldWithCheckbox::new( + columns[1].add(FieldWithCheckbox::new( "Flip", &mut self.set_flip_enabled, egui::Checkbox::without_text(&mut flip), )); self.set_flip = if flip { 1 } else { 0 }; - columns[2].add(luminol_components::FieldWithCheckbox::new( + columns[2].add(FieldWithCheckbox::new( "Opacity", &mut self.set_opacity_enabled, egui::DragValue::new(&mut self.set_opacity).range(0..=255), @@ -281,10 +281,10 @@ impl Modal { 2 => BlendMode::Subtract, _ => BlendMode::Normal, }; - columns[3].add(luminol_components::FieldWithCheckbox::new( + columns[3].add(FieldWithCheckbox::new( "Blending", &mut self.set_blending_enabled, - luminol_components::EnumComboBox::new( + EnumComboBox::new( self.id_source.with("set_blending"), &mut blend_mode, ), @@ -324,25 +324,25 @@ impl Modal { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { let limit = num_patterns.saturating_sub(1) as i16; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Pattern", egui::DragValue::new(&mut self.add_pattern) .range(-limit..=limit), )); - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "X", egui::DragValue::new(&mut self.add_x) .range(-(FRAME_WIDTH as i16)..=FRAME_WIDTH as i16), )); - columns[2].add(luminol_components::Field::new( + columns[2].add(Field::new( "Y", egui::DragValue::new(&mut self.add_y) .range(-(FRAME_HEIGHT as i16)..=FRAME_HEIGHT as i16), )); - columns[3].add(luminol_components::Field::new( + columns[3].add(Field::new( "Scale", egui::DragValue::new(&mut self.add_scale).suffix("%"), )); @@ -351,24 +351,24 @@ impl Modal { ui.with_padded_stripe(true, |ui| { ui.columns(4, |columns| { - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Rotation", egui::DragValue::new(&mut self.add_rotation) .range(-360..=360) .suffix("°"), )); - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Flip", egui::Checkbox::without_text(&mut self.add_flip), )); - columns[2].add(luminol_components::Field::new( + columns[2].add(Field::new( "Opacity", egui::DragValue::new(&mut self.add_opacity).range(-255..=255), )); - columns[3].add(luminol_components::Field::new( + columns[3].add(Field::new( "Blending", egui::DragValue::new(&mut self.add_blending).range(-2..=2), )); @@ -393,7 +393,7 @@ impl Modal { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { self.mul_pattern *= 100.; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Pattern", egui::DragValue::new(&mut self.mul_pattern) .range( @@ -405,7 +405,7 @@ impl Modal { self.mul_pattern /= 100.; self.mul_x *= 100.; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "X", egui::DragValue::new(&mut self.mul_x) .range( @@ -417,7 +417,7 @@ impl Modal { self.mul_x /= 100.; self.mul_y *= 100.; - columns[2].add(luminol_components::Field::new( + columns[2].add(Field::new( "Y", egui::DragValue::new(&mut self.mul_y) .range( @@ -429,7 +429,7 @@ impl Modal { self.mul_y /= 100.; self.mul_scale *= 100.; - columns[3].add(luminol_components::Field::new( + columns[3].add(Field::new( "Scale", egui::DragValue::new(&mut self.mul_scale) .range(0.0..=i16::MAX as f64 * 100.0) @@ -442,7 +442,7 @@ impl Modal { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { self.mul_rotation *= 100.; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Rotation", egui::DragValue::new(&mut self.mul_rotation) .range(-360. * 100.0..=360.0 * 100.0) @@ -451,7 +451,7 @@ impl Modal { self.mul_rotation /= 100.; self.mul_opacity *= 100.; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Opacity", egui::DragValue::new(&mut self.mul_opacity) .range(0.0..=255. * 100.0) @@ -521,7 +521,7 @@ impl Modal { } }); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); ui.add_space(spacing); }); }); diff --git a/crates/modals/src/animations/change_cell_number_tool.rs b/crates/ui/src/modals/animations/change_cell_number_tool.rs similarity index 93% rename from crates/modals/src/animations/change_cell_number_tool.rs rename to crates/ui/src/modals/animations/change_cell_number_tool.rs index caec0239..64c1a5a5 100644 --- a/crates/modals/src/animations/change_cell_number_tool.rs +++ b/crates/ui/src/modals/animations/change_cell_number_tool.rs @@ -22,6 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::Field; + pub struct Modal { state: State, id_source: egui::Id, @@ -101,7 +103,7 @@ impl Modal { .show(ctx, |ui| { ui.columns(2, |columns| { self.start_frame += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Starting Frame", egui::DragValue::new(&mut self.start_frame).range(1..=self.frames_len), )); @@ -112,7 +114,7 @@ impl Modal { } self.end_frame += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Ending Frame", egui::DragValue::new(&mut self.end_frame).range(1..=self.frames_len), )); @@ -125,14 +127,14 @@ impl Modal { ui.columns(2, |columns| { self.first_cell += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Cell Index", egui::DragValue::new(&mut self.first_cell).range(1..=i16::MAX as usize + 1), )); self.first_cell -= 1; self.second_cell += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Cell Index", egui::DragValue::new(&mut self.second_cell) .range(1..=i16::MAX as usize + 1), @@ -157,7 +159,7 @@ impl Modal { ) }); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); if !(win_open && keep_open) { diff --git a/crates/modals/src/animations/change_frame_count_tool.rs b/crates/ui/src/modals/animations/change_frame_count_tool.rs similarity index 96% rename from crates/modals/src/animations/change_frame_count_tool.rs rename to crates/ui/src/modals/animations/change_frame_count_tool.rs index aff5f83a..d2e470da 100644 --- a/crates/modals/src/animations/change_frame_count_tool.rs +++ b/crates/ui/src/modals/animations/change_frame_count_tool.rs @@ -22,6 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::Field; + pub struct Modal { state: State, id_source: egui::Id, @@ -87,7 +89,7 @@ impl Modal { .open(&mut win_open) .id(self.id_source.with("change_frame_count_tool")) .show(ctx, |ui| { - ui.add(luminol_components::Field::new( + ui.add(Field::new( "Frame Count", egui::DragValue::new(&mut self.new_frames_len).range(1..=usize::MAX), )); @@ -113,7 +115,7 @@ impl Modal { ui.label(format!("Change the number of frames in this animation from {} to {}", self.frames_len, self.new_frames_len)); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); if !(win_open && keep_open) { diff --git a/crates/modals/src/animations/clear_frames_tool.rs b/crates/ui/src/modals/animations/clear_frames_tool.rs similarity index 94% rename from crates/modals/src/animations/clear_frames_tool.rs rename to crates/ui/src/modals/animations/clear_frames_tool.rs index 5bae8912..9dbdca16 100644 --- a/crates/modals/src/animations/clear_frames_tool.rs +++ b/crates/ui/src/modals/animations/clear_frames_tool.rs @@ -22,6 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::Field; + pub struct Modal { state: State, id_source: egui::Id, @@ -97,7 +99,7 @@ impl Modal { .show(ctx, |ui| { ui.columns(2, |columns| { self.start_frame += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Starting Frame", egui::DragValue::new(&mut self.start_frame).range(1..=self.frames_len), )); @@ -108,7 +110,7 @@ impl Modal { } self.end_frame += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Ending Frame", egui::DragValue::new(&mut self.end_frame).range(1..=self.frames_len), )); @@ -129,7 +131,7 @@ impl Modal { ) }); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); if !(win_open && keep_open) { diff --git a/crates/modals/src/animations/copy_frames_tool.rs b/crates/ui/src/modals/animations/copy_frames_tool.rs similarity index 93% rename from crates/modals/src/animations/copy_frames_tool.rs rename to crates/ui/src/modals/animations/copy_frames_tool.rs index fd3a62d7..c7a9278e 100644 --- a/crates/modals/src/animations/copy_frames_tool.rs +++ b/crates/ui/src/modals/animations/copy_frames_tool.rs @@ -22,6 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::Field; + pub struct Modal { state: State, id_source: egui::Id, @@ -100,20 +102,20 @@ impl Modal { .show(ctx, |ui| { ui.columns(3, |columns| { self.src_frame += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Source Frame", egui::DragValue::new(&mut self.src_frame).range(1..=self.frames_len), )); self.src_frame -= 1; self.dst_frame += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Destination Frame", egui::DragValue::new(&mut self.dst_frame).range(1..=self.frames_len), )); self.dst_frame -= 1; - columns[2].add(luminol_components::Field::new( + columns[2].add(Field::new( "Frame Count", egui::DragValue::new(&mut self.frame_count) .range(1..=self.frames_len - self.src_frame.max(self.dst_frame)), @@ -136,7 +138,7 @@ impl Modal { ) }); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); if !(win_open && keep_open) { diff --git a/crates/modals/src/animations/mod.rs b/crates/ui/src/modals/animations/mod.rs similarity index 100% rename from crates/modals/src/animations/mod.rs rename to crates/ui/src/modals/animations/mod.rs diff --git a/crates/modals/src/animations/tween_tool.rs b/crates/ui/src/modals/animations/tween_tool.rs similarity index 94% rename from crates/modals/src/animations/tween_tool.rs rename to crates/ui/src/modals/animations/tween_tool.rs index 1026a349..8545a711 100644 --- a/crates/modals/src/animations/tween_tool.rs +++ b/crates/ui/src/modals/animations/tween_tool.rs @@ -22,6 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::Field; + pub struct Modal { state: State, id_source: egui::Id, @@ -109,7 +111,7 @@ impl Modal { .show(ctx, |ui| { ui.columns(2, |columns| { self.start_frame += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Starting Frame", egui::DragValue::new(&mut self.start_frame) .range(1..=self.frames_len.saturating_sub(2)), @@ -121,7 +123,7 @@ impl Modal { } self.end_frame += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Ending Frame", egui::DragValue::new(&mut self.end_frame).range(3..=self.frames_len), )); @@ -134,7 +136,7 @@ impl Modal { ui.columns(2, |columns| { self.start_cell += 1; - columns[0].add(luminol_components::Field::new( + columns[0].add(Field::new( "Starting Cell", egui::DragValue::new(&mut self.start_cell).range(1..=i16::MAX as usize + 1), )); @@ -145,7 +147,7 @@ impl Modal { } self.end_cell += 1; - columns[1].add(luminol_components::Field::new( + columns[1].add(Field::new( "Ending Cell", egui::DragValue::new(&mut self.end_cell).range(1..=i16::MAX as usize + 1), )); @@ -191,7 +193,7 @@ impl Modal { ) }); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); if !(win_open && keep_open) { diff --git a/crates/modals/src/database_modal/mod.rs b/crates/ui/src/modals/database_modal/mod.rs similarity index 98% rename from crates/modals/src/database_modal/mod.rs rename to crates/ui/src/modals/database_modal/mod.rs index 3d267204..599ff84c 100644 --- a/crates/modals/src/database_modal/mod.rs +++ b/crates/ui/src/modals/database_modal/mod.rs @@ -24,7 +24,7 @@ use std::marker::PhantomData; -use luminol_components::UiExt; +use crate::components::UiExt; mod variable; pub use variable::Variable; @@ -198,7 +198,7 @@ where } ui.horizontal(|ui| { - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); if let Some(size) = new_size { ui.add(egui::DragValue::new(size).range(1..=usize::MAX)); diff --git a/crates/modals/src/database_modal/switch.rs b/crates/ui/src/modals/database_modal/switch.rs similarity index 100% rename from crates/modals/src/database_modal/switch.rs rename to crates/ui/src/modals/database_modal/switch.rs diff --git a/crates/modals/src/database_modal/variable.rs b/crates/ui/src/modals/database_modal/variable.rs similarity index 100% rename from crates/modals/src/database_modal/variable.rs rename to crates/ui/src/modals/database_modal/variable.rs diff --git a/crates/modals/src/graphic_picker/actor.rs b/crates/ui/src/modals/graphic_picker/actor.rs similarity index 99% rename from crates/modals/src/graphic_picker/actor.rs rename to crates/ui/src/modals/graphic_picker/actor.rs index 1a09628b..928ccc86 100644 --- a/crates/modals/src/graphic_picker/actor.rs +++ b/crates/ui/src/modals/graphic_picker/actor.rs @@ -22,8 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::UiExt; use color_eyre::eyre::WrapErr; -use luminol_components::UiExt; use luminol_core::prelude::*; use super::{ButtonSprite, Entry, PreviewSprite, Selected}; @@ -360,7 +360,7 @@ impl Modal { egui::TopBottomPanel::bottom(self.id_source.with("bottom")).show_inside(ui, |ui| { ui.add_space(ui.style().spacing.item_spacing.y); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); egui::CentralPanel::default().show_inside(ui, |ui| { diff --git a/crates/modals/src/graphic_picker/animation.rs b/crates/ui/src/modals/graphic_picker/animation.rs similarity index 98% rename from crates/modals/src/graphic_picker/animation.rs rename to crates/ui/src/modals/graphic_picker/animation.rs index 97e5c530..24215743 100644 --- a/crates/modals/src/graphic_picker/animation.rs +++ b/crates/ui/src/modals/graphic_picker/animation.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::{Cellpicker, UiExt}; +use crate::components::{Cellpicker, UiExt}; use luminol_core::prelude::*; use super::Entry; @@ -41,7 +41,7 @@ enum State { entries: Vec, filtered_entries: Vec, search_text: String, - cellpicker: luminol_components::Cellpicker, + cellpicker: Cellpicker, }, } @@ -116,7 +116,7 @@ impl Modal { update_state.filesystem, animation_name.as_deref(), ); - let mut cellpicker = luminol_components::Cellpicker::new( + let mut cellpicker = Cellpicker::new( &update_state.graphics, atlas, Some(luminol_graphics::primitives::cells::ANIMATION_COLUMNS), @@ -284,7 +284,7 @@ impl Modal { }); egui::TopBottomPanel::bottom(self.id_source.with("bottom")).show_inside(ui, |ui| { ui.add_space(ui.style().spacing.item_spacing.y); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); egui::CentralPanel::default().show_inside(ui, |ui| { diff --git a/crates/modals/src/graphic_picker/basic.rs b/crates/ui/src/modals/graphic_picker/basic.rs similarity index 99% rename from crates/modals/src/graphic_picker/basic.rs rename to crates/ui/src/modals/graphic_picker/basic.rs index 4c3b9ca0..e60633d8 100644 --- a/crates/modals/src/graphic_picker/basic.rs +++ b/crates/ui/src/modals/graphic_picker/basic.rs @@ -22,8 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::UiExt; use color_eyre::eyre::WrapErr; -use luminol_components::UiExt; use luminol_core::prelude::*; use super::{ButtonSprite, Entry, PreviewSprite, Selected}; @@ -318,7 +318,7 @@ impl Modal { egui::TopBottomPanel::bottom(self.id_source.with("bottom")).show_inside(ui, |ui| { ui.add_space(ui.style().spacing.item_spacing.y); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); egui::CentralPanel::default().show_inside(ui, |ui| { diff --git a/crates/modals/src/graphic_picker/event.rs b/crates/ui/src/modals/graphic_picker/event.rs similarity index 98% rename from crates/modals/src/graphic_picker/event.rs rename to crates/ui/src/modals/graphic_picker/event.rs index 6a058172..fe13f211 100644 --- a/crates/modals/src/graphic_picker/event.rs +++ b/crates/ui/src/modals/graphic_picker/event.rs @@ -22,9 +22,9 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::{EnumComboBox, UiExt}; use color_eyre::eyre::WrapErr; use egui::Widget; -use luminol_components::UiExt; use luminol_core::prelude::*; use super::{ButtonSprite, Entry, PreviewSprite}; @@ -493,17 +493,13 @@ impl Modal { }); ui.horizontal(|ui| { ui.label("Blend Mode"); - luminol_components::EnumComboBox::new( - self.id_source.with("blend_mode"), - blend_mode, - ) - .ui(ui); + EnumComboBox::new(self.id_source.with("blend_mode"), blend_mode).ui(ui); }); ui.add_space(1.0); // pad out the bottom }); egui::TopBottomPanel::bottom(self.id_source.with("bottom")).show_inside(ui, |ui| { ui.add_space(ui.style().spacing.item_spacing.y); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); egui::CentralPanel::default().show_inside(ui, |ui| { diff --git a/crates/modals/src/graphic_picker/hue.rs b/crates/ui/src/modals/graphic_picker/hue.rs similarity index 99% rename from crates/modals/src/graphic_picker/hue.rs rename to crates/ui/src/modals/graphic_picker/hue.rs index fc1c672f..8c7dd5ba 100644 --- a/crates/modals/src/graphic_picker/hue.rs +++ b/crates/ui/src/modals/graphic_picker/hue.rs @@ -22,8 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::UiExt; use color_eyre::eyre::WrapErr; -use luminol_components::UiExt; use luminol_core::prelude::*; use super::{ButtonSprite, Entry, PreviewSprite, Selected}; @@ -343,7 +343,7 @@ impl Modal { egui::TopBottomPanel::bottom(self.id_source.with("bottom")).show_inside(ui, |ui| { ui.add_space(ui.style().spacing.item_spacing.y); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }); egui::CentralPanel::default().show_inside(ui, |ui| { diff --git a/crates/modals/src/graphic_picker/mod.rs b/crates/ui/src/modals/graphic_picker/mod.rs similarity index 99% rename from crates/modals/src/graphic_picker/mod.rs rename to crates/ui/src/modals/graphic_picker/mod.rs index af595789..d1a7f99e 100644 --- a/crates/modals/src/graphic_picker/mod.rs +++ b/crates/ui/src/modals/graphic_picker/mod.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::UiExt; use luminol_core::prelude::*; pub mod actor; diff --git a/crates/modals/src/lib.rs b/crates/ui/src/modals/mod.rs similarity index 100% rename from crates/modals/src/lib.rs rename to crates/ui/src/modals/mod.rs diff --git a/crates/modals/src/move_route.rs b/crates/ui/src/modals/move_route.rs similarity index 100% rename from crates/modals/src/move_route.rs rename to crates/ui/src/modals/move_route.rs diff --git a/crates/modals/src/sound_picker.rs b/crates/ui/src/modals/sound_picker.rs similarity index 94% rename from crates/modals/src/sound_picker.rs rename to crates/ui/src/modals/sound_picker.rs index 82e60c46..52974cb8 100644 --- a/crates/modals/src/sound_picker.rs +++ b/crates/ui/src/modals/sound_picker.rs @@ -31,7 +31,7 @@ pub struct Modal { enum State { Closed, - Open { tab: luminol_components::SoundTab }, + Open { tab: crate::components::SoundTab }, } impl Modal { @@ -62,7 +62,7 @@ impl luminol_core::Modal for Modal { let mut button_response = ui.button(button_text); if button_response.clicked() { - let tab = luminol_components::SoundTab::new( + let tab = crate::components::SoundTab::new( update_state.filesystem, self.source, data.clone(), @@ -110,7 +110,7 @@ impl Modal { ui, |ui| { ui.add_space(1.0); - luminol_components::close_options_ui(ui, &mut keep_open, &mut needs_save); + crate::components::close_options_ui(ui, &mut keep_open, &mut needs_save); }, ); diff --git a/crates/ui/src/tabs/map/brush.rs b/crates/ui/src/tabs/map/brush.rs index 6a9b514a..d7653721 100644 --- a/crates/ui/src/tabs/map/brush.rs +++ b/crates/ui/src/tabs/map/brush.rs @@ -21,7 +21,7 @@ // it with Steamworks API by Valve Corporation, containing parts covered by // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. - +use crate::components::SelectedTile; use itertools::Itertools; impl super::Tab { @@ -34,8 +34,7 @@ impl super::Tab { map: &mut luminol_data::rpg::Map, ) { let map_pos = egui::pos2(map_x as f32, map_y as f32); - let initial_tile = - luminol_components::SelectedTile::from_id(map.data[(map_x, map_y, tile_layer)]); + let initial_tile = SelectedTile::from_id(map.data[(map_x, map_y, tile_layer)]); let left = self.tilepicker.selected_tiles_left; let right = self.tilepicker.selected_tiles_right; let top = self.tilepicker.selected_tiles_top; @@ -129,9 +128,7 @@ impl super::Tab { continue; } - if luminol_components::SelectedTile::from_id(map.data[position]) - == initial_tile - { + if SelectedTile::from_id(map.data[position]) == initial_tile { stack.push(position); } } diff --git a/crates/ui/src/tabs/map/mod.rs b/crates/ui/src/tabs/map/mod.rs index 4a8f885e..aa98aace 100644 --- a/crates/ui/src/tabs/map/mod.rs +++ b/crates/ui/src/tabs/map/mod.rs @@ -23,6 +23,7 @@ // Program grant you additional permission to convey the resulting work. #![allow(unused_imports)] +use crate::components::{MapView, SelectedLayer, Tilepicker}; use egui::Pos2; use std::{cell::RefMut, collections::HashMap, collections::VecDeque}; @@ -52,8 +53,8 @@ pub struct Tab { /// ID of the map that is being edited. pub id: usize, /// The tilemap. - pub view: luminol_components::MapView, - pub tilepicker: luminol_components::Tilepicker, + pub view: MapView, + pub tilepicker: Tilepicker, drawing_shape: bool, event_windows: luminol_core::Windows, @@ -123,8 +124,8 @@ impl Tab { ) -> color_eyre::Result { // *sigh* // borrow checker. - let view = luminol_components::MapView::new(update_state, id)?; - let tilepicker = luminol_components::Tilepicker::new(update_state, id); + let view = MapView::new(update_state, id)?; + let tilepicker = Tilepicker::new(update_state, id); let map = update_state.data.get_or_load_map( id, @@ -242,8 +243,8 @@ impl luminol_core::Tab for Tab { ui.menu_button( // Format the text based on what layer is selected. match self.view.selected_layer { - luminol_components::SelectedLayer::Events => "Events ⏷".to_string(), - luminol_components::SelectedLayer::Tiles(layer) => { + SelectedLayer::Events => "Events ⏷".to_string(), + SelectedLayer::Tiles(layer) => { format!("Layer {} ⏷", layer + 1) } }, @@ -270,7 +271,7 @@ impl luminol_core::Tab for Tab { ui.columns(1, |columns| { columns[0].selectable_value( &mut self.view.selected_layer, - luminol_components::SelectedLayer::Tiles(index), + SelectedLayer::Tiles(index), format!("Layer {}", index + 1), ); }); @@ -282,7 +283,7 @@ impl luminol_core::Tab for Tab { ui.columns(1, |columns| { columns[0].selectable_value( &mut self.view.selected_layer, - luminol_components::SelectedLayer::Events, + SelectedLayer::Events, egui::RichText::new("Events").italics(), ); }); @@ -381,9 +382,7 @@ impl luminol_core::Tab for Tab { let tileset = &tilesets.data[map.tileset_id]; // Save the state of the selected layer into the cache - if let luminol_components::SelectedLayer::Tiles(tile_layer) = - self.view.selected_layer - { + if let SelectedLayer::Tiles(tile_layer) = self.view.selected_layer { self.layer_cache .copy_from_slice(map.data.layer_as_slice(tile_layer)); } @@ -466,9 +465,7 @@ impl luminol_core::Tab for Tab { } } - if let luminol_components::SelectedLayer::Tiles(tile_layer) = - self.view.selected_layer - { + if let SelectedLayer::Tiles(tile_layer) = self.view.selected_layer { // Tile drawing if response.is_pointer_button_down_on() && ui.input(|i| { @@ -663,9 +660,7 @@ impl luminol_core::Tab for Tab { event.extra_data.is_editor_open = false; } - if let luminol_components::SelectedLayer::Tiles(tile_layer) = - self.view.selected_layer - { + if let SelectedLayer::Tiles(tile_layer) = self.view.selected_layer { // Write the buffered tile changes to the tilemap for y in 0..map.data.ysize() { for x in 0..map.data.xsize() { diff --git a/crates/ui/src/tabs/map/util.rs b/crates/ui/src/tabs/map/util.rs index b9fe6f17..17c1fdef 100644 --- a/crates/ui/src/tabs/map/util.rs +++ b/crates/ui/src/tabs/map/util.rs @@ -145,7 +145,7 @@ impl super::Tab { pub(super) fn set_tile( &self, map: &mut luminol_data::rpg::Map, - tile: luminol_components::SelectedTile, + tile: crate::components::SelectedTile, position: (usize, usize, usize), ) { if self.brush_density != 1. { diff --git a/crates/ui/src/windows/actors.rs b/crates/ui/src/windows/actors.rs index 4a2a4692..95abc598 100644 --- a/crates/ui/src/windows/actors.rs +++ b/crates/ui/src/windows/actors.rs @@ -22,12 +22,12 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::{Field, OptionalIdComboBox, UiExt}; use itertools::Itertools; -use luminol_components::UiExt; +use crate::modals::graphic_picker::actor::Modal as GraphicPicker; use luminol_core::Modal; use luminol_data::rpg::armor::Kind; -use luminol_modals::graphic_picker::actor::Modal as GraphicPicker; pub struct Window { selected_actor_name: Option, @@ -38,7 +38,7 @@ pub struct Window { exp_view_is_total: bool, exp_view_is_depersisted: bool, - view: luminol_components::DatabaseView, + view: crate::components::DatabaseView, } impl Window { @@ -61,7 +61,7 @@ impl Window { exp_view_is_depersisted: false, exp_view_is_total: false, - view: luminol_components::DatabaseView::new(), + view: crate::components::DatabaseView::new(), } } } @@ -273,7 +273,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.horizontal(|ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Icon", self.graphic_picker.button( (&mut actor.character_name, &mut actor.character_hue), @@ -290,7 +290,7 @@ impl luminol_core::Window for Window { } modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut actor.name) .desired_width(f32::INFINITY), @@ -301,9 +301,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Class", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (actor.id, "class"), &mut actor.class_id, @@ -330,289 +330,248 @@ impl luminol_core::Window for Window { let class = classes.data.get(actor.class_id); ui.with_padded_stripe(false, |ui| { - ui.add(luminol_components::Field::new( - "Starting Weapon", - |ui: &mut egui::Ui| { - egui::Frame::none() - .show(ui, |ui| { - ui.columns(2, |columns| { - modified |= columns[0] - .add( - luminol_components::OptionalIdComboBox::new( - update_state, - (actor.id, "weapon_id"), - &mut actor.weapon_id, - class - .map_or_else( - Default::default, - |c| { - c.weapon_set.iter().copied() - }, - ) - .filter(|id| { - (0..weapons.data.len()) - .contains(id) - }), - |id| { - weapons.data.get(id).map_or_else( - || "".into(), - |w| { - format!( - "{:0>4}: {}", - id + 1, - w.name - ) - }, + ui.add(Field::new("Starting Weapon", |ui: &mut egui::Ui| { + egui::Frame::none() + .show(ui, |ui| { + ui.columns(2, |columns| { + modified |= columns[0] + .add(OptionalIdComboBox::new( + update_state, + (actor.id, "weapon_id"), + &mut actor.weapon_id, + class + .map_or_else(Default::default, |c| { + c.weapon_set.iter().copied() + }) + .filter(|id| { + (0..weapons.data.len()).contains(id) + }), + |id| { + weapons.data.get(id).map_or_else( + || "".into(), + |w| { + format!( + "{:0>4}: {}", + id + 1, + w.name ) }, - ), - ) - .changed(); - modified |= columns[1] - .checkbox(&mut actor.weapon_fix, "Fixed") - .changed(); - }); - }) - .response - }, - )); + ) + }, + )) + .changed(); + modified |= columns[1] + .checkbox(&mut actor.weapon_fix, "Fixed") + .changed(); + }); + }) + .response + })); }); ui.with_padded_stripe(true, |ui| { - ui.add(luminol_components::Field::new( - "Starting Shield", - |ui: &mut egui::Ui| { - egui::Frame::none() - .show(ui, |ui| { - ui.columns(2, |columns| { - modified |= columns[0] - .add( - luminol_components::OptionalIdComboBox::new( - update_state, - (actor.id, "armor1_id"), - &mut actor.armor1_id, - class - .map_or_else( - Default::default, - |c| c.armor_set.iter().copied(), - ) - .filter(|id| { - (0..armors.data.len()) - .contains(id) - && armors - .data - .get(*id) - .is_some_and(|a| { - matches!( - a.kind, - Kind::Shield - ) - }) - }), - |id| { - armors.data.get(id).map_or_else( - || "".into(), + ui.add(Field::new("Starting Shield", |ui: &mut egui::Ui| { + egui::Frame::none() + .show(ui, |ui| { + ui.columns(2, |columns| { + modified |= columns[0] + .add(OptionalIdComboBox::new( + update_state, + (actor.id, "armor1_id"), + &mut actor.armor1_id, + class + .map_or_else(Default::default, |c| { + c.armor_set.iter().copied() + }) + .filter(|id| { + (0..armors.data.len()).contains(id) + && armors.data.get(*id).is_some_and( |a| { - format!( - "{:0>4}: {}", - id + 1, - a.name, + matches!( + a.kind, + Kind::Shield ) }, ) + }), + |id| { + armors.data.get(id).map_or_else( + || "".into(), + |a| { + format!( + "{:0>4}: {}", + id + 1, + a.name, + ) }, - ), - ) - .changed(); - modified |= columns[1] - .checkbox(&mut actor.armor1_fix, "Fixed") - .changed(); - }); - }) - .response - }, - )); + ) + }, + )) + .changed(); + modified |= columns[1] + .checkbox(&mut actor.armor1_fix, "Fixed") + .changed(); + }); + }) + .response + })); }); ui.with_padded_stripe(false, |ui| { - ui.add(luminol_components::Field::new( - "Starting Helmet", - |ui: &mut egui::Ui| { - egui::Frame::none() - .show(ui, |ui| { - ui.columns(2, |columns| { - modified |= columns[0] - .add( - luminol_components::OptionalIdComboBox::new( - update_state, - (actor.id, "armor2_id"), - &mut actor.armor2_id, - class - .map_or_else( - Default::default, - |c| c.armor_set.iter().copied(), - ) - .filter(|id| { - (0..armors.data.len()) - .contains(id) - && armors - .data - .get(*id) - .is_some_and(|a| { - matches!( - a.kind, - Kind::Helmet - ) - }) - }), - |id| { - armors.data.get(id).map_or_else( - || "".into(), + ui.add(Field::new("Starting Helmet", |ui: &mut egui::Ui| { + egui::Frame::none() + .show(ui, |ui| { + ui.columns(2, |columns| { + modified |= columns[0] + .add(OptionalIdComboBox::new( + update_state, + (actor.id, "armor2_id"), + &mut actor.armor2_id, + class + .map_or_else(Default::default, |c| { + c.armor_set.iter().copied() + }) + .filter(|id| { + (0..armors.data.len()).contains(id) + && armors.data.get(*id).is_some_and( |a| { - format!( - "{:0>4}: {}", - id + 1, - a.name, + matches!( + a.kind, + Kind::Helmet ) }, ) + }), + |id| { + armors.data.get(id).map_or_else( + || "".into(), + |a| { + format!( + "{:0>4}: {}", + id + 1, + a.name, + ) }, - ), - ) - .changed(); - modified |= columns[1] - .checkbox(&mut actor.armor2_fix, "Fixed") - .changed(); - }); - }) - .response - }, - )); + ) + }, + )) + .changed(); + modified |= columns[1] + .checkbox(&mut actor.armor2_fix, "Fixed") + .changed(); + }); + }) + .response + })); }); ui.with_padded_stripe(true, |ui| { - ui.add(luminol_components::Field::new( - "Starting Body Armor", - |ui: &mut egui::Ui| { - egui::Frame::none() - .show(ui, |ui| { - ui.columns(2, |columns| { - modified |= columns[0] - .add( - luminol_components::OptionalIdComboBox::new( - update_state, - (actor.id, "armor3_id"), - &mut actor.armor3_id, - class - .map_or_else( - Default::default, - |c| c.armor_set.iter().copied(), - ) - .filter(|id| { - (0..armors.data.len()) - .contains(id) - && armors - .data - .get(*id) - .is_some_and(|a| { - matches!( - a.kind, - Kind::BodyArmor - ) - }) - }), - |id| { - armors.data.get(id).map_or_else( - || "".into(), + ui.add(Field::new("Starting Body Armor", |ui: &mut egui::Ui| { + egui::Frame::none() + .show(ui, |ui| { + ui.columns(2, |columns| { + modified |= columns[0] + .add(OptionalIdComboBox::new( + update_state, + (actor.id, "armor3_id"), + &mut actor.armor3_id, + class + .map_or_else(Default::default, |c| { + c.armor_set.iter().copied() + }) + .filter(|id| { + (0..armors.data.len()).contains(id) + && armors.data.get(*id).is_some_and( |a| { - format!( - "{:0>4}: {}", - id + 1, - a.name, + matches!( + a.kind, + Kind::BodyArmor ) }, ) + }), + |id| { + armors.data.get(id).map_or_else( + || "".into(), + |a| { + format!( + "{:0>4}: {}", + id + 1, + a.name, + ) }, - ), - ) - .changed(); - modified |= columns[1] - .checkbox(&mut actor.armor3_fix, "Fixed") - .changed(); - }); - }) - .response - }, - )); + ) + }, + )) + .changed(); + modified |= columns[1] + .checkbox(&mut actor.armor3_fix, "Fixed") + .changed(); + }); + }) + .response + })); }); ui.with_padded_stripe(false, |ui| { - ui.add(luminol_components::Field::new( - "Starting Accessory", - |ui: &mut egui::Ui| { - egui::Frame::none() - .show(ui, |ui| { - ui.columns(2, |columns| { - modified |= columns[0] - .add( - luminol_components::OptionalIdComboBox::new( - update_state, - (actor.id, "armor4_id"), - &mut actor.armor4_id, - class - .map_or_else( - Default::default, - |c| c.armor_set.iter().copied(), - ) - .filter(|id| { - (0..armors.data.len()) - .contains(id) - && armors - .data - .get(*id) - .is_some_and(|a| { - matches!( - a.kind, - Kind::Accessory - ) - }) - }), - |id| { - armors.data.get(id).map_or_else( - || "".into(), + ui.add(Field::new("Starting Accessory", |ui: &mut egui::Ui| { + egui::Frame::none() + .show(ui, |ui| { + ui.columns(2, |columns| { + modified |= columns[0] + .add(OptionalIdComboBox::new( + update_state, + (actor.id, "armor4_id"), + &mut actor.armor4_id, + class + .map_or_else(Default::default, |c| { + c.armor_set.iter().copied() + }) + .filter(|id| { + (0..armors.data.len()).contains(id) + && armors.data.get(*id).is_some_and( |a| { - format!( - "{:0>4}: {}", - id + 1, - a.name, + matches!( + a.kind, + Kind::Accessory ) }, ) + }), + |id| { + armors.data.get(id).map_or_else( + || "".into(), + |a| { + format!( + "{:0>4}: {}", + id + 1, + a.name, + ) }, - ), - ) - .changed(); - modified |= columns[1] - .checkbox(&mut actor.armor4_fix, "Fixed") - .changed(); - }); - }) - .response - }, - )); + ) + }, + )) + .changed(); + modified |= columns[1] + .checkbox(&mut actor.armor4_fix, "Fixed") + .changed(); + }); + }) + .response + })); }); ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Initial Level", egui::Slider::new(&mut actor.initial_level, 1..=99), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Final Level", egui::Slider::new( &mut actor.final_level, @@ -654,14 +613,14 @@ impl luminol_core::Window for Window { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "EXP Curve Basis", egui::Slider::new(&mut actor.exp_basis, 10..=50), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "EXP Curve Inflation", egui::Slider::new(&mut actor.exp_inflation, 10..=50), )) @@ -671,91 +630,73 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { - columns[0].add(luminol_components::Field::new( - "Max HP", - |ui: &mut egui::Ui| { - draw_graph( - ui, - actor, - 0, - 1..=9999, - egui::Color32::from_rgb(204, 0, 0), - ) - }, - )); - - columns[1].add(luminol_components::Field::new( - "Max SP", - |ui: &mut egui::Ui| { - draw_graph( - ui, - actor, - 1, - 1..=9999, - egui::Color32::from_rgb(245, 123, 0), - ) - }, - )); + columns[0].add(Field::new("Max HP", |ui: &mut egui::Ui| { + draw_graph( + ui, + actor, + 0, + 1..=9999, + egui::Color32::from_rgb(204, 0, 0), + ) + })); + + columns[1].add(Field::new("Max SP", |ui: &mut egui::Ui| { + draw_graph( + ui, + actor, + 1, + 1..=9999, + egui::Color32::from_rgb(245, 123, 0), + ) + })); }); }); ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { - columns[0].add(luminol_components::Field::new( - "STR", - |ui: &mut egui::Ui| { - draw_graph( - ui, - actor, - 2, - 1..=999, - egui::Color32::from_rgb(237, 213, 0), - ) - }, - )); - - columns[1].add(luminol_components::Field::new( - "DEX", - |ui: &mut egui::Ui| { - draw_graph( - ui, - actor, - 3, - 1..=999, - egui::Color32::from_rgb(116, 210, 22), - ) - }, - )); + columns[0].add(Field::new("STR", |ui: &mut egui::Ui| { + draw_graph( + ui, + actor, + 2, + 1..=999, + egui::Color32::from_rgb(237, 213, 0), + ) + })); + + columns[1].add(Field::new("DEX", |ui: &mut egui::Ui| { + draw_graph( + ui, + actor, + 3, + 1..=999, + egui::Color32::from_rgb(116, 210, 22), + ) + })); }); }); ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { - columns[0].add(luminol_components::Field::new( - "AGI", - |ui: &mut egui::Ui| { - draw_graph( - ui, - actor, - 4, - 1..=999, - egui::Color32::from_rgb(52, 101, 164), - ) - }, - )); - - columns[1].add(luminol_components::Field::new( - "INT", - |ui: &mut egui::Ui| { - draw_graph( - ui, - actor, - 5, - 1..=999, - egui::Color32::from_rgb(117, 80, 123), - ) - }, - )); + columns[0].add(Field::new("AGI", |ui: &mut egui::Ui| { + draw_graph( + ui, + actor, + 4, + 1..=999, + egui::Color32::from_rgb(52, 101, 164), + ) + })); + + columns[1].add(Field::new("INT", |ui: &mut egui::Ui| { + draw_graph( + ui, + actor, + 5, + 1..=999, + egui::Color32::from_rgb(117, 80, 123), + ) + })); }); }); diff --git a/crates/ui/src/windows/animations/frame_edit.rs b/crates/ui/src/windows/animations/frame_edit.rs index fa0bdd07..59888980 100644 --- a/crates/ui/src/windows/animations/frame_edit.rs +++ b/crates/ui/src/windows/animations/frame_edit.rs @@ -22,9 +22,12 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_core::Modal; - use super::HistoryEntry; +use crate::{ + components::{AnimationFrameView, Cellpicker, EnumComboBox, Field}, + modals::{self, animations::batch_edit_tool}, +}; +use luminol_core::Modal; use luminol_data::BlendMode; use luminol_graphics::frame::{FRAME_HEIGHT, FRAME_WIDTH}; @@ -85,7 +88,7 @@ pub fn show_frame_edit( update_state.filesystem, animation.animation_name.as_deref(), ); - let mut frame_view = luminol_components::AnimationFrameView::new(update_state, atlas); + let mut frame_view = AnimationFrameView::new(update_state, atlas); if let Some(battler_name) = &system.battler_name { match update_state.graphics.texture_loader.load_now( update_state.filesystem, @@ -122,8 +125,7 @@ pub fn show_frame_edit( cellpicker } else { let atlas = frame_view.frame.atlas.clone(); - let mut cellpicker = - luminol_components::Cellpicker::new(&update_state.graphics, atlas, None, 0.5); + let mut cellpicker = Cellpicker::new(&update_state.graphics, atlas, None, 0.5); cellpicker.view.display.set_hue( &update_state.graphics.render_state, animation.animation_hue as f32 / 360., @@ -135,11 +137,10 @@ pub fn show_frame_edit( let animation_graphic_picker = if let Some(modal) = &mut state.animation_graphic_picker { modal } else { - state.animation_graphic_picker = - Some(luminol_modals::graphic_picker::animation::Modal::new( - animation, - "animation_graphic_picker".into(), - )); + state.animation_graphic_picker = Some(modals::graphic_picker::animation::Modal::new( + animation, + "animation_graphic_picker".into(), + )); state.animation_graphic_picker.as_mut().unwrap() }; @@ -220,7 +221,7 @@ pub fn show_frame_edit( } ui.horizontal(|ui| { - ui.add(luminol_components::Field::new( + ui.add(Field::new( "Editor Scale", egui::Slider::new(&mut frame_view.scale, 15.0..=300.0) .suffix("%") @@ -238,7 +239,7 @@ pub fn show_frame_edit( let changed = ui .add_enabled( state.animation_state.is_none(), - luminol_components::Field::new( + Field::new( "Frame", egui::DragValue::new(&mut state.frame_index).range(1..=animation.frames.len()), ), @@ -251,22 +252,22 @@ pub fn show_frame_edit( } state.frame_needs_update |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Condition", - luminol_components::EnumComboBox::new("condition", &mut state.condition) + EnumComboBox::new("condition", &mut state.condition) .max_width(18.) .wrap_mode(egui::TextWrapMode::Extend), )) .changed(); - ui.add(luminol_components::Field::new( + ui.add(Field::new( "Onion Skin", egui::Checkbox::without_text(&mut state.enable_onion_skin), )); let old_fps = state.animation_fps; let changed = ui - .add(luminol_components::Field::new( + .add(Field::new( "FPS", egui::DragValue::new(&mut state.animation_fps).range(0.1..=f64::MAX), )) @@ -506,7 +507,7 @@ pub fn show_frame_edit( .history .push(animation.id, i, vec![HistoryEntry::new_cell(data, j)]); match modals.batch_edit.mode { - luminol_modals::animations::batch_edit_tool::Mode::Set => { + batch_edit_tool::Mode::Set => { if modals.batch_edit.set_pattern_enabled { data[(j, 0)] = modals.batch_edit.set_pattern; } @@ -532,7 +533,7 @@ pub fn show_frame_edit( data[(j, 7)] = modals.batch_edit.set_blending; } } - luminol_modals::animations::batch_edit_tool::Mode::Add => { + batch_edit_tool::Mode::Add => { data[(j, 0)] = data[(j, 0)] .saturating_add(modals.batch_edit.add_pattern) .clamp( @@ -567,7 +568,7 @@ pub fn show_frame_edit( data[(j, 7)] = data[(j, 7)].rem_euclid(3); } } - luminol_modals::animations::batch_edit_tool::Mode::Mul => { + batch_edit_tool::Mode::Mul => { data[(j, 0)] = ((data[(j, 0)] + 1) as f64 * modals.batch_edit.mul_pattern) .clamp(1., frame_view.frame.atlas.num_patterns() as f64) .round_ties_even() as i16 @@ -794,7 +795,7 @@ pub fn show_frame_edit( ui.columns(4, |columns| { let mut pattern = frame.cell_data[(i, 0)] + 1; let changed = columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Pattern", egui::DragValue::new(&mut pattern) .range(1..=frame_view.frame.atlas.num_patterns() as i16), @@ -806,7 +807,7 @@ pub fn show_frame_edit( } properties_modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "X", egui::DragValue::new(&mut frame.cell_data[(i, 1)]) .range(-(FRAME_WIDTH as i16 / 2)..=FRAME_WIDTH as i16 / 2), @@ -814,7 +815,7 @@ pub fn show_frame_edit( .changed(); properties_modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "Y", egui::DragValue::new(&mut frame.cell_data[(i, 2)]) .range(-(FRAME_HEIGHT as i16 / 2)..=FRAME_HEIGHT as i16 / 2), @@ -822,7 +823,7 @@ pub fn show_frame_edit( .changed(); properties_modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "Scale", egui::DragValue::new(&mut frame.cell_data[(i, 3)]) .range(1..=i16::MAX) @@ -833,7 +834,7 @@ pub fn show_frame_edit( ui.columns(4, |columns| { properties_modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Rotation", egui::DragValue::new(&mut frame.cell_data[(i, 4)]) .range(0..=360) @@ -843,10 +844,7 @@ pub fn show_frame_edit( let mut flip = frame.cell_data[(i, 5)] == 1; let changed = columns[1] - .add(luminol_components::Field::new( - "Flip", - egui::Checkbox::without_text(&mut flip), - )) + .add(Field::new("Flip", egui::Checkbox::without_text(&mut flip))) .changed(); if changed { frame.cell_data[(i, 5)] = if flip { 1 } else { 0 }; @@ -854,7 +852,7 @@ pub fn show_frame_edit( } properties_modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "Opacity", egui::DragValue::new(&mut frame.cell_data[(i, 6)]).range(0..=255), )) @@ -866,9 +864,9 @@ pub fn show_frame_edit( _ => BlendMode::Normal, }; let changed = columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "Blending", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (animation.id, state.frame_index, i, 7usize), &mut blend_mode, ), @@ -1106,8 +1104,7 @@ pub fn show_frame_edit( frame_view .frame .rebuild_all_cells(&update_state.graphics, animation, state.frame_index); - let mut cellpicker = - luminol_components::Cellpicker::new(&update_state.graphics, atlas, None, 0.5); + let mut cellpicker = Cellpicker::new(&update_state.graphics, atlas, None, 0.5); cellpicker.view.display.set_hue( &update_state.graphics.render_state, animation.animation_hue as f32 / 360., diff --git a/crates/ui/src/windows/animations/mod.rs b/crates/ui/src/windows/animations/mod.rs index c59cf4ec..f2067fb7 100644 --- a/crates/ui/src/windows/animations/mod.rs +++ b/crates/ui/src/windows/animations/mod.rs @@ -22,6 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::CollapsingView; + mod frame_edit; mod timing; mod util; @@ -37,9 +39,9 @@ pub struct Window { frame_edit_state: FrameEditState, timing_edit_state: TimingEditState, - collapsing_view: luminol_components::CollapsingView, + collapsing_view: crate::components::CollapsingView, modals: Modals, - view: luminol_components::DatabaseView, + view: crate::components::DatabaseView, } struct FrameEditState { @@ -47,9 +49,9 @@ struct FrameEditState { frame_index: usize, condition: luminol_data::rpg::animation::Condition, enable_onion_skin: bool, - frame_view: Option, - cellpicker: Option, - animation_graphic_picker: Option, + frame_view: Option, + cellpicker: Option, + animation_graphic_picker: Option, flash_maps: luminol_data::OptionVec, animation_state: Option, saved_frame_index: Option, @@ -76,7 +78,7 @@ struct AnimationState { struct TimingEditState { previous_frame: Option, - se_picker: luminol_modals::sound_picker::Modal, + se_picker: crate::modals::sound_picker::Modal, } #[derive(Debug, Default)] @@ -190,12 +192,12 @@ impl HistoryEntry { } struct Modals { - copy_frames: luminol_modals::animations::copy_frames_tool::Modal, - clear_frames: luminol_modals::animations::clear_frames_tool::Modal, - tween: luminol_modals::animations::tween_tool::Modal, - batch_edit: luminol_modals::animations::batch_edit_tool::Modal, - change_frame_count: luminol_modals::animations::change_frame_count_tool::Modal, - change_cell_number: luminol_modals::animations::change_cell_number_tool::Modal, + copy_frames: crate::modals::animations::copy_frames_tool::Modal, + clear_frames: crate::modals::animations::clear_frames_tool::Modal, + tween: crate::modals::animations::tween_tool::Modal, + batch_edit: crate::modals::animations::batch_edit_tool::Modal, + change_frame_count: crate::modals::animations::change_frame_count_tool::Modal, + change_cell_number: crate::modals::animations::change_cell_number_tool::Modal, } impl Modals { @@ -237,31 +239,31 @@ impl Default for Window { }, timing_edit_state: TimingEditState { previous_frame: None, - se_picker: luminol_modals::sound_picker::Modal::new( + se_picker: crate::modals::sound_picker::Modal::new( luminol_audio::Source::SE, "animations_timing_se_picker", ), }, - collapsing_view: luminol_components::CollapsingView::new(), + collapsing_view: CollapsingView::new(), modals: Modals { - copy_frames: luminol_modals::animations::copy_frames_tool::Modal::new( + copy_frames: crate::modals::animations::copy_frames_tool::Modal::new( "animations_copy_frames_tool", ), - clear_frames: luminol_modals::animations::clear_frames_tool::Modal::new( + clear_frames: crate::modals::animations::clear_frames_tool::Modal::new( "animations_clear_frames_tool", ), - tween: luminol_modals::animations::tween_tool::Modal::new("animations_tween_tool"), - batch_edit: luminol_modals::animations::batch_edit_tool::Modal::new( + tween: crate::modals::animations::tween_tool::Modal::new("animations_tween_tool"), + batch_edit: crate::modals::animations::batch_edit_tool::Modal::new( "animations_batch_edit_tool", ), - change_frame_count: luminol_modals::animations::change_frame_count_tool::Modal::new( + change_frame_count: crate::modals::animations::change_frame_count_tool::Modal::new( "change_frame_count_tool", ), - change_cell_number: luminol_modals::animations::change_cell_number_tool::Modal::new( + change_cell_number: crate::modals::animations::change_cell_number_tool::Modal::new( "change_cell_number_tool", ), }, - view: luminol_components::DatabaseView::new(), + view: crate::components::DatabaseView::new(), } } } diff --git a/crates/ui/src/windows/animations/timing.rs b/crates/ui/src/windows/animations/timing.rs index aaf9869d..2386a252 100644 --- a/crates/ui/src/windows/animations/timing.rs +++ b/crates/ui/src/windows/animations/timing.rs @@ -22,6 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::{EnumComboBox, Field}; use egui::Widget; use luminol_core::Modal; @@ -101,9 +102,9 @@ pub fn show_timing_body( columns[0].columns(2, |columns| { let old_condition = timing.condition; let changed = columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Condition", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (animation.id, timing_index, "condition"), &mut timing.condition, ), @@ -215,25 +216,22 @@ pub fn show_timing_body( let old_frame = timing.frame; let changed = columns[0] - .add(luminol_components::Field::new( - "Frame", - |ui: &mut egui::Ui| { - let mut frame = state.previous_frame.unwrap_or(timing.frame + 1); - let mut response = egui::DragValue::new(&mut frame) - .range(1..=animation.frames.len()) - .update_while_editing(false) - .ui(ui); - response.changed = false; - if response.dragged() { - state.previous_frame = Some(frame); - } else if state.previous_frame.is_some() { - timing.frame = frame - 1; - state.previous_frame = None; - response.changed = true; - } - response - }, - )) + .add(Field::new("Frame", |ui: &mut egui::Ui| { + let mut frame = state.previous_frame.unwrap_or(timing.frame + 1); + let mut response = egui::DragValue::new(&mut frame) + .range(1..=animation.frames.len()) + .update_while_editing(false) + .ui(ui); + response.changed = false; + if response.dragged() { + state.previous_frame = Some(frame); + } else if state.previous_frame.is_some() { + timing.frame = frame - 1; + state.previous_frame = None; + response.changed = true; + } + response + })) .changed(); if changed { update_flash_maps(timing.condition, |condition| match timing.flash_scope { @@ -265,7 +263,7 @@ pub fn show_timing_body( }); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "SE", state.se_picker.button(&mut timing.se, update_state), )) @@ -275,9 +273,9 @@ pub fn show_timing_body( let old_scope = timing.flash_scope; let (scope_changed, duration_changed) = if timing.flash_scope == Scope::None { ( - ui.add(luminol_components::Field::new( + ui.add(Field::new( "Flash", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (animation.id, timing_index, "flash_scope"), &mut timing.flash_scope, ), @@ -289,16 +287,16 @@ pub fn show_timing_body( ui.columns(2, |columns| { ( columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Flash", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (animation.id, timing_index, "flash_scope"), &mut timing.flash_scope, ), )) .changed(), columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Flash Duration", egui::DragValue::new(&mut timing.flash_duration) .range(1..=animation.frames.len()), @@ -390,26 +388,23 @@ pub fn show_timing_body( if matches!(timing.flash_scope, Scope::Target | Scope::Screen) { let changed = ui - .add(luminol_components::Field::new( - "Flash Color", - |ui: &mut egui::Ui| { - let mut color = [ - timing.flash_color.red.clamp(0., 255.).round() as u8, - timing.flash_color.green.clamp(0., 255.).round() as u8, - timing.flash_color.blue.clamp(0., 255.).round() as u8, - timing.flash_color.alpha.clamp(0., 255.).round() as u8, - ]; - ui.spacing_mut().interact_size.x = ui.available_width(); // make the color picker button as wide as possible - let response = ui.color_edit_button_srgba_unmultiplied(&mut color); - if response.changed() { - timing.flash_color.red = color[0] as f64; - timing.flash_color.green = color[1] as f64; - timing.flash_color.blue = color[2] as f64; - timing.flash_color.alpha = color[3] as f64; - } - response - }, - )) + .add(Field::new("Flash Color", |ui: &mut egui::Ui| { + let mut color = [ + timing.flash_color.red.clamp(0., 255.).round() as u8, + timing.flash_color.green.clamp(0., 255.).round() as u8, + timing.flash_color.blue.clamp(0., 255.).round() as u8, + timing.flash_color.alpha.clamp(0., 255.).round() as u8, + ]; + ui.spacing_mut().interact_size.x = ui.available_width(); // make the color picker button as wide as possible + let response = ui.color_edit_button_srgba_unmultiplied(&mut color); + if response.changed() { + timing.flash_color.red = color[0] as f64; + timing.flash_color.green = color[1] as f64; + timing.flash_color.blue = color[2] as f64; + timing.flash_color.alpha = color[3] as f64; + } + response + })) .changed(); if changed { update_flash_maps(timing.condition, |condition| match timing.flash_scope { diff --git a/crates/ui/src/windows/animations/window.rs b/crates/ui/src/windows/animations/window.rs index 74352070..2f73c806 100644 --- a/crates/ui/src/windows/animations/window.rs +++ b/crates/ui/src/windows/animations/window.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{Cellpicker, Field, UiExt}; use luminol_core::Modal; use strum::IntoEnumIterator; @@ -97,7 +97,7 @@ impl luminol_core::Window for super::Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut animation.name) .desired_width(f32::INFINITY), @@ -107,36 +107,31 @@ impl luminol_core::Window for super::Window { ui.with_padded_stripe(true, |ui| { let changed = ui - .add(luminol_components::Field::new( - "Battler Position", - |ui: &mut egui::Ui| { - let mut modified = false; - let mut response = egui::Frame::none() - .show(ui, |ui| { - ui.columns(Position::iter().count(), |columns| { - for (i, position) in - Position::iter().enumerate() + .add(Field::new("Battler Position", |ui: &mut egui::Ui| { + let mut modified = false; + let mut response = egui::Frame::none() + .show(ui, |ui| { + ui.columns(Position::iter().count(), |columns| { + for (i, position) in Position::iter().enumerate() { + if columns[i] + .radio_value( + &mut animation.position, + position, + position.to_string(), + ) + .changed() { - if columns[i] - .radio_value( - &mut animation.position, - position, - position.to_string(), - ) - .changed() - { - modified = true; - } + modified = true; } - }); - }) - .response; - if modified { - response.mark_changed(); - } - response - }, - )) + } + }); + }) + .response; + if modified { + response.mark_changed(); + } + response + })) .changed(); if changed { if let Some(frame_view) = &mut self.frame_edit_state.frame_view { @@ -255,12 +250,8 @@ impl luminol_core::Window for super::Window { .map(|cellpicker| cellpicker.selected_cell) .unwrap_or_default() .min(atlas.num_patterns().saturating_sub(1)); - let mut cellpicker = luminol_components::Cellpicker::new( - &update_state.graphics, - atlas, - None, - 0.5, - ); + let mut cellpicker = + Cellpicker::new(&update_state.graphics, atlas, None, 0.5); cellpicker.view.display.set_hue( &update_state.graphics.render_state, animation.animation_hue as f32 / 360., @@ -287,45 +278,42 @@ impl luminol_core::Window for super::Window { ui.with_padded_stripe(true, |ui| { let changed = ui - .add(luminol_components::Field::new( - "SE and Flash", - |ui: &mut egui::Ui| { - if *update_state.modified_during_prev_frame { - self.collapsing_view.request_sort(); - } - if self.previous_animation != Some(animation.id) { - self.collapsing_view.clear_animations(); - self.timing_edit_state.se_picker.close_window(); - } else if self.collapsing_view.is_animating() { - self.timing_edit_state.se_picker.close_window(); - } + .add(Field::new("SE and Flash", |ui: &mut egui::Ui| { + if *update_state.modified_during_prev_frame { + self.collapsing_view.request_sort(); + } + if self.previous_animation != Some(animation.id) { + self.collapsing_view.clear_animations(); + self.timing_edit_state.se_picker.close_window(); + } else if self.collapsing_view.is_animating() { + self.timing_edit_state.se_picker.close_window(); + } - let mut timings = std::mem::take(&mut animation.timings); - let egui::InnerResponse { inner, response } = - self.collapsing_view.show_with_sort( - ui, - animation.id, - &mut timings, - |ui, _i, timing| { - super::timing::show_timing_header(ui, timing) - }, - |ui, i, previous_timings, timing| { - super::timing::show_timing_body( - ui, - update_state, - animation, - flash_maps, - &mut self.timing_edit_state, - (i, previous_timings, timing), - ) - }, - |a, b| a.frame.cmp(&b.frame), - ); - collapsing_view_inner = inner; - animation.timings = timings; - response - }, - )) + let mut timings = std::mem::take(&mut animation.timings); + let egui::InnerResponse { inner, response } = + self.collapsing_view.show_with_sort( + ui, + animation.id, + &mut timings, + |ui, _i, timing| { + super::timing::show_timing_header(ui, timing) + }, + |ui, i, previous_timings, timing| { + super::timing::show_timing_body( + ui, + update_state, + animation, + flash_maps, + &mut self.timing_edit_state, + (i, previous_timings, timing), + ) + }, + |a, b| a.frame.cmp(&b.frame), + ); + collapsing_view_inner = inner; + animation.timings = timings; + response + })) .changed(); if changed { if let Some(frame_view) = &mut self.frame_edit_state.frame_view { diff --git a/crates/ui/src/windows/archive_manager.rs b/crates/ui/src/windows/archive_manager.rs index 473bbcaa..2e0dcb76 100644 --- a/crates/ui/src/windows/archive_manager.rs +++ b/crates/ui/src/windows/archive_manager.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{FileSystemView, UiExt}; use luminol_filesystem::{File, FileSystem, OpenFlags}; static CREATE_DEFAULT_SELECTED_DIRS: once_cell::sync::Lazy< @@ -44,7 +44,7 @@ pub struct Window { enum Mode { Extract { view: Option< - luminol_components::FileSystemView< + FileSystemView< luminol_filesystem::archiver::FileSystem, >, >, @@ -57,7 +57,7 @@ enum Mode { progress_total: usize, }, Create { - view: Option>, + view: Option>, load_promise: Option< poll_promise::Promise>, >, @@ -116,7 +116,7 @@ impl luminol_core::Window for Window { }) .transpose() })() { - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_archive_manager_extract_view".into(), archive, entry.path.to_string(), @@ -126,7 +126,7 @@ impl luminol_core::Window for Window { Mode::Create { view, .. } => { let name = host.root_path().to_string(); - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_archive_manager_create_view".into(), host, name, @@ -246,7 +246,7 @@ impl Window { Ok(Ok((handle, name))) => { match luminol_filesystem::archiver::FileSystem::new(handle) { Ok(archiver) => { - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_archive_manager_extract_view".into(), archiver, name, @@ -386,7 +386,7 @@ impl Window { match p.try_take() { Ok(Ok(handle)) => { let name = handle.root_path().to_string(); - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_archive_manager_create_view".into(), handle, name, @@ -551,7 +551,7 @@ impl Window { } fn find_files( - view: &luminol_components::FileSystemView, + view: &FileSystemView, ) -> luminol_filesystem::Result> { let mut vec = Vec::new(); for metadata in view { diff --git a/crates/ui/src/windows/armor.rs b/crates/ui/src/windows/armor.rs index e834c4b7..f9ca02c7 100644 --- a/crates/ui/src/windows/armor.rs +++ b/crates/ui/src/windows/armor.rs @@ -22,14 +22,14 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{EnumComboBox, Field, IdVecSelection, OptionalIdComboBox, UiExt}; #[derive(Default)] pub struct Window { selected_armor_name: Option, previous_armor: Option, - view: luminol_components::DatabaseView, + view: crate::components::DatabaseView, } impl Window { @@ -85,7 +85,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut armor.name) .desired_width(f32::INFINITY), @@ -93,7 +93,7 @@ impl luminol_core::Window for Window { .changed(); modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Description", egui::TextEdit::multiline(&mut armor.description) .desired_width(f32::INFINITY), @@ -104,19 +104,16 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Kind", - luminol_components::EnumComboBox::new( - (armor.id, "kind"), - &mut armor.kind, - ), + EnumComboBox::new((armor.id, "kind"), &mut armor.kind), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Auto State", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (armor.id, "auto_state"), &mut armor.auto_state_id, @@ -136,28 +133,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Price", egui::DragValue::new(&mut armor.price).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "EVA", egui::DragValue::new(&mut armor.eva).range(0..=i32::MAX), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "PDEF", egui::DragValue::new(&mut armor.pdef).range(0..=i32::MAX), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "MDEF", egui::DragValue::new(&mut armor.mdef).range(0..=i32::MAX), )) @@ -168,28 +165,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "STR+", egui::DragValue::new(&mut armor.str_plus), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "DEX+", egui::DragValue::new(&mut armor.dex_plus), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "AGI+", egui::DragValue::new(&mut armor.agi_plus), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "INT+", egui::DragValue::new(&mut armor.int_plus), )) @@ -199,7 +196,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (armor.id, "guard_element_set"), &mut armor.guard_element_set, @@ -215,13 +212,10 @@ impl luminol_core::Window for Window { selection.clear_search(); } modified |= columns[0] - .add(luminol_components::Field::new( - "Element Defense", - selection, - )) + .add(Field::new("Element Defense", selection)) .changed(); - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (armor.id, "guard_state_set"), &mut armor.guard_state_set, @@ -236,9 +230,8 @@ impl luminol_core::Window for Window { if self.previous_armor != Some(armor.id) { selection.clear_search(); } - modified |= columns[1] - .add(luminol_components::Field::new("States", selection)) - .changed(); + modified |= + columns[1].add(Field::new("States", selection)).changed(); }); }); diff --git a/crates/ui/src/windows/classes.rs b/crates/ui/src/windows/classes.rs index bb5f0c1c..73bad650 100644 --- a/crates/ui/src/windows/classes.rs +++ b/crates/ui/src/windows/classes.rs @@ -22,15 +22,18 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{ + CollapsingView, DatabaseView, EnumComboBox, Field, IdVecSelection, OptionalIdComboBox, + RankSelection, UiExt, +}; #[derive(Default)] pub struct Window { selected_class_name: Option, previous_class: Option, - collapsing_view: luminol_components::CollapsingView, - view: luminol_components::DatabaseView, + collapsing_view: CollapsingView, + view: DatabaseView, } impl Window { @@ -64,16 +67,16 @@ impl Window { .show(ui, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Level", egui::Slider::new(&mut learning.level, 1..=99), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Skill", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (class_id, learning_index, "skill_id"), &mut learning.skill_id, @@ -148,7 +151,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut class.name) .desired_width(f32::INFINITY), @@ -158,53 +161,45 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Position", - luminol_components::EnumComboBox::new( - (class.id, "position"), - &mut class.position, - ), + EnumComboBox::new((class.id, "position"), &mut class.position), )) .changed(); }); ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( - "Skills", - |ui: &mut egui::Ui| { - if self.previous_class != Some(class.id) { - self.collapsing_view.clear_animations(); - } - self.collapsing_view - .show( - ui, - class.id, - &mut class.learnings, - |ui, _i, learning| { - Self::show_learning_header( - ui, &skills, learning, - ) - }, - |ui, i, learning| { - Self::show_learning_body( - ui, - update_state, - &skills, - class.id, - (i, learning), - ) - }, - ) - .response - }, - )) + .add(Field::new("Skills", |ui: &mut egui::Ui| { + if self.previous_class != Some(class.id) { + self.collapsing_view.clear_animations(); + } + self.collapsing_view + .show( + ui, + class.id, + &mut class.learnings, + |ui, _i, learning| { + Self::show_learning_header(ui, &skills, learning) + }, + |ui, i, learning| { + Self::show_learning_body( + ui, + update_state, + &skills, + class.id, + (i, learning), + ) + }, + ) + .response + })) .changed(); }); ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (class.id, "weapon_set"), &mut class.weapon_set, @@ -220,13 +215,10 @@ impl luminol_core::Window for Window { selection.clear_search(); } modified |= columns[0] - .add(luminol_components::Field::new( - "Equippable Weapons", - selection, - )) + .add(Field::new("Equippable Weapons", selection)) .changed(); - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (class.id, "armor_set"), &mut class.armor_set, @@ -242,10 +234,7 @@ impl luminol_core::Window for Window { selection.clear_search(); } modified |= columns[1] - .add(luminol_components::Field::new( - "Equippable Armor", - selection, - )) + .add(Field::new("Equippable Armor", selection)) .changed(); }); }); @@ -255,7 +244,7 @@ impl luminol_core::Window for Window { class .element_ranks .resize_with_value(system.elements.len(), 3); - let mut selection = luminol_components::RankSelection::new( + let mut selection = RankSelection::new( update_state, (class.id, "element_ranks"), &mut class.element_ranks, @@ -269,14 +258,13 @@ impl luminol_core::Window for Window { if self.previous_class != Some(class.id) { selection.clear_search(); } - modified |= columns[0] - .add(luminol_components::Field::new("Elements", selection)) - .changed(); + modified |= + columns[0].add(Field::new("Elements", selection)).changed(); class .state_ranks .resize_with_value(states.data.len() + 1, 3); - let mut selection = luminol_components::RankSelection::new( + let mut selection = RankSelection::new( update_state, (class.id, "state_ranks"), &mut class.state_ranks, @@ -290,9 +278,8 @@ impl luminol_core::Window for Window { if self.previous_class != Some(class.id) { selection.clear_search(); } - modified |= columns[1] - .add(luminol_components::Field::new("States", selection)) - .changed(); + modified |= + columns[1].add(Field::new("States", selection)).changed(); }); }); diff --git a/crates/ui/src/windows/common_event_edit.rs b/crates/ui/src/windows/common_event_edit.rs index 35d06c98..a4e211b4 100644 --- a/crates/ui/src/windows/common_event_edit.rs +++ b/crates/ui/src/windows/common_event_edit.rs @@ -22,8 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::modals::database_modal; use luminol_core::Modal; -use luminol_modals::database_modal; /// The common event editor. pub struct Window { @@ -75,7 +75,7 @@ pub struct CommonEventTab { event: luminol_data::rpg::CommonEvent, force_close: bool, switch_modal: database_modal::SwitchModal, - command_view: luminol_components::CommandView, + command_view: crate::components::CommandView, } impl luminol_core::Tab for CommonEventTab { diff --git a/crates/ui/src/windows/enemies.rs b/crates/ui/src/windows/enemies.rs index 7e9626fe..f5e30737 100644 --- a/crates/ui/src/windows/enemies.rs +++ b/crates/ui/src/windows/enemies.rs @@ -22,9 +22,11 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{ + CollapsingView, DatabaseView, EnumComboBox, Field, OptionalIdComboBox, RankSelection, UiExt, +}; +use crate::modals::graphic_picker::hue::Modal as GraphicPicker; use luminol_core::Modal; -use luminol_modals::graphic_picker::hue::Modal as GraphicPicker; #[derive(Clone, Copy, Debug, Eq, PartialEq, Default)] #[derive(strum::Display, strum::EnumIter)] @@ -43,8 +45,8 @@ pub struct Window { graphic_picker: GraphicPicker, - collapsing_view: luminol_components::CollapsingView, - view: luminol_components::DatabaseView, + collapsing_view: CollapsingView, + view: DatabaseView, } impl Window { @@ -64,8 +66,8 @@ impl Window { "enemy_battler_picker", ), - collapsing_view: luminol_components::CollapsingView::new(), - view: luminol_components::DatabaseView::new(), + collapsing_view: CollapsingView::new(), + view: DatabaseView::new(), } } @@ -135,14 +137,14 @@ impl Window { .show(ui, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Turn Offset", egui::DragValue::new(&mut action.condition_turn_a).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Turn Interval", egui::DragValue::new(&mut action.condition_turn_b).range(0..=i32::MAX), )) @@ -151,14 +153,14 @@ impl Window { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Max HP %", egui::Slider::new(&mut action.condition_hp, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Min Level", egui::Slider::new(&mut action.condition_level, 1..=99), )) @@ -166,9 +168,9 @@ impl Window { }); modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Switch", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy_id, action_index, "condition_switch_id"), &mut action.condition_switch_id, @@ -185,21 +187,18 @@ impl Window { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Kind", - luminol_components::EnumComboBox::new( - (enemy_id, action_index, "kind"), - &mut action.kind, - ), + EnumComboBox::new((enemy_id, action_index, "kind"), &mut action.kind), )) .changed(); match action.kind { luminol_data::rpg::enemy::Kind::Basic => { modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Basic Type", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (enemy_id, action_index, "basic"), &mut action.basic, ), @@ -208,9 +207,9 @@ impl Window { } luminol_data::rpg::enemy::Kind::Skill => { modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Skill", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy_id, action_index, "skill_id"), &mut action.skill_id, @@ -229,7 +228,7 @@ impl Window { }); modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Rating", egui::Slider::new(&mut action.rating, 1..=10), )) @@ -297,7 +296,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.horizontal(|ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Graphic", self.graphic_picker.button( (&mut enemy.battler_name, &mut enemy.battler_hue), @@ -314,7 +313,7 @@ impl luminol_core::Window for Window { } modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut enemy.name) .desired_width(f32::INFINITY), @@ -326,9 +325,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Attacker Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy.id, "animation1_id"), &mut enemy.animation1_id, @@ -344,9 +343,9 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Target Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy.id, "animation2_id"), &mut enemy.animation2_id, @@ -366,28 +365,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "EXP", egui::DragValue::new(&mut enemy.exp).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Gold", egui::DragValue::new(&mut enemy.gold).range(0..=i32::MAX), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "Max HP", egui::DragValue::new(&mut enemy.maxhp).range(0..=i32::MAX), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "Max SP", egui::DragValue::new(&mut enemy.maxsp).range(0..=i32::MAX), )) @@ -398,28 +397,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "STR", egui::DragValue::new(&mut enemy.str).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "DEX", egui::DragValue::new(&mut enemy.dex).range(0..=i32::MAX), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "AGI", egui::DragValue::new(&mut enemy.agi).range(0..=i32::MAX), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "INT", egui::DragValue::new(&mut enemy.int).range(0..=i32::MAX), )) @@ -430,28 +429,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "ATK", egui::DragValue::new(&mut enemy.atk).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "EVA", egui::DragValue::new(&mut enemy.eva).range(0..=i32::MAX), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "PDEF", egui::DragValue::new(&mut enemy.pdef).range(0..=i32::MAX), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "MDEF", egui::DragValue::new(&mut enemy.mdef).range(0..=i32::MAX), )) @@ -472,9 +471,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Treasure Type", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (enemy.id, "treasure_type"), &mut treasure_type, ), @@ -482,7 +481,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Treasure Probability", egui::Slider::new(&mut enemy.treasure_prob, 0..=100) .suffix("%"), @@ -504,9 +503,9 @@ impl luminol_core::Window for Window { enemy.item_id = Some(0); } modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Treasure", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy.id, "item_id"), &mut enemy.item_id, @@ -530,9 +529,9 @@ impl luminol_core::Window for Window { enemy.weapon_id = Some(0); } modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Treasure", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy.id, "weapon_id"), &mut enemy.weapon_id, @@ -556,9 +555,9 @@ impl luminol_core::Window for Window { enemy.armor_id = Some(0); } modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Treasure", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (enemy.id, "armor_id"), &mut enemy.armor_id, @@ -579,34 +578,31 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( - "Actions", - |ui: &mut egui::Ui| { - if self.previous_enemy != Some(enemy.id) { - self.collapsing_view.clear_animations(); - } - self.collapsing_view - .show( - ui, - enemy.id, - &mut enemy.actions, - |ui, _i, action| { - Self::show_action_header(ui, &skills, action) - }, - |ui, i, action| { - Self::show_action_body( - ui, - update_state, - &system, - &skills, - enemy.id, - (i, action), - ) - }, - ) - .response - }, - )) + .add(Field::new("Actions", |ui: &mut egui::Ui| { + if self.previous_enemy != Some(enemy.id) { + self.collapsing_view.clear_animations(); + } + self.collapsing_view + .show( + ui, + enemy.id, + &mut enemy.actions, + |ui, _i, action| { + Self::show_action_header(ui, &skills, action) + }, + |ui, i, action| { + Self::show_action_body( + ui, + update_state, + &system, + &skills, + enemy.id, + (i, action), + ) + }, + ) + .response + })) .changed(); }); @@ -615,7 +611,7 @@ impl luminol_core::Window for Window { enemy .element_ranks .resize_with_value(system.elements.len(), 3); - let mut selection = luminol_components::RankSelection::new( + let mut selection = RankSelection::new( update_state, (enemy.id, "element_ranks"), &mut enemy.element_ranks, @@ -629,14 +625,13 @@ impl luminol_core::Window for Window { if self.previous_enemy != Some(enemy.id) { selection.clear_search(); } - modified |= columns[0] - .add(luminol_components::Field::new("Elements", selection)) - .changed(); + modified |= + columns[0].add(Field::new("Elements", selection)).changed(); enemy .state_ranks .resize_with_value(states.data.len() + 1, 3); - let mut selection = luminol_components::RankSelection::new( + let mut selection = RankSelection::new( update_state, (enemy.id, "state_ranks"), &mut enemy.state_ranks, @@ -650,9 +645,8 @@ impl luminol_core::Window for Window { if self.previous_enemy != Some(enemy.id) { selection.clear_search(); } - modified |= columns[1] - .add(luminol_components::Field::new("States", selection)) - .changed(); + modified |= + columns[1].add(Field::new("States", selection)).changed(); }); }); diff --git a/crates/ui/src/windows/event_edit.rs b/crates/ui/src/windows/event_edit.rs index 77f16d7f..c80b3ed2 100644 --- a/crates/ui/src/windows/event_edit.rs +++ b/crates/ui/src/windows/event_edit.rs @@ -22,12 +22,13 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use egui::Widget; -use luminol_core::prelude::*; -use luminol_modals::{ +use crate::components::{EnumComboBox, EnumMenuButton, EnumRadioList}; +use crate::modals::{ database_modal::{SwitchModal, VariableModal}, graphic_picker::event::Modal as GraphicPicker, }; +use egui::Widget; +use luminol_core::prelude::*; /// The event editor window. pub struct Window { @@ -191,7 +192,7 @@ impl luminol_core::Window for Window { let res = ui.add_enabled( // FIXME ensure shrink page.condition.self_switch_valid, - luminol_components::EnumMenuButton::new( + EnumMenuButton::new( &mut page.condition.self_switch_ch, id_source.with("self_switch_ch"), ), @@ -219,7 +220,7 @@ impl luminol_core::Window for Window { // FIXME these expand to fit, which is kinda annoying ui.horizontal(|ui| { ui.label("Move Type"); - modified |= luminol_components::EnumComboBox::new( + modified |= EnumComboBox::new( id_source.with("move_type"), &mut page.move_type, ) @@ -232,7 +233,7 @@ impl luminol_core::Window for Window { ); // TODO ui.horizontal(|ui| { ui.label("Move Speed"); - modified |= luminol_components::EnumComboBox::new( + modified |= EnumComboBox::new( id_source.with("move_speed"), &mut page.move_speed, ) @@ -241,7 +242,7 @@ impl luminol_core::Window for Window { }); ui.horizontal(|ui| { ui.label("Move Frequency"); - modified |= luminol_components::EnumComboBox::new( + modified |= EnumComboBox::new( id_source.with("move_frequency"), &mut page.move_frequency, ) @@ -278,9 +279,7 @@ impl luminol_core::Window for Window { right.label("Trigger"); right.group(|ui| { - modified |= luminol_components::EnumRadioList::new(&mut page.trigger) - .ui(ui) - .changed(); + modified |= EnumRadioList::new(&mut page.trigger).ui(ui).changed(); }); }); }); diff --git a/crates/ui/src/windows/items.rs b/crates/ui/src/windows/items.rs index a0716e60..4cb9d510 100644 --- a/crates/ui/src/windows/items.rs +++ b/crates/ui/src/windows/items.rs @@ -22,12 +22,15 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::{ + components::{ + DatabaseView, EnumComboBox, Field, IdVecPlusMinusSelection, IdVecSelection, + OptionalIdComboBox, UiExt, + }, + modals::{graphic_picker::basic::Modal as GraphicPicker, sound_picker::Modal as SoundPicker}, +}; use luminol_core::Modal; -use luminol_modals::graphic_picker::basic::Modal as GraphicPicker; -use luminol_modals::sound_picker::Modal as SoundPicker; - /// Database - Items management window. pub struct Window { selected_item_name: Option, @@ -37,7 +40,7 @@ pub struct Window { previous_item: Option, - view: luminol_components::DatabaseView, + view: DatabaseView, } impl Window { @@ -55,7 +58,7 @@ impl Window { "item_icon_picker", ), previous_item: None, - view: luminol_components::DatabaseView::new(), + view: DatabaseView::new(), } } } @@ -110,7 +113,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.horizontal(|ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Icon", self.graphic_picker .button(&mut item.icon_name, update_state), @@ -122,7 +125,7 @@ impl luminol_core::Window for Window { } modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut item.name) .desired_width(f32::INFINITY), @@ -131,7 +134,7 @@ impl luminol_core::Window for Window { }); modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Description", egui::TextEdit::multiline(&mut item.description) .desired_width(f32::INFINITY), @@ -142,19 +145,16 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Scope", - luminol_components::EnumComboBox::new( - (item.id, "scope"), - &mut item.scope, - ), + EnumComboBox::new((item.id, "scope"), &mut item.scope), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Occasion", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (item.id, "occasion"), &mut item.occasion, ), @@ -166,9 +166,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "User Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (item.id, "animation1_id"), &mut item.animation1_id, @@ -184,9 +184,9 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Target Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (item.id, "animation2_id"), &mut item.animation2_id, @@ -206,7 +206,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Menu Use SE", self.menu_se_picker.button(&mut item.menu_se, update_state), )) @@ -217,9 +217,9 @@ impl luminol_core::Window for Window { } modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Common Event", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (item.id, "common_event_id"), &mut item.common_event_id, @@ -239,14 +239,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Price", egui::DragValue::new(&mut item.price).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Consumable", egui::Checkbox::without_text(&mut item.consumable), )) @@ -257,9 +257,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { if item.parameter_type.is_none() { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Parameter", - luminol_components::EnumComboBox::new( + EnumComboBox::new( "parameter_type", &mut item.parameter_type, ), @@ -268,9 +268,9 @@ impl luminol_core::Window for Window { } else { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Parameter", - luminol_components::EnumComboBox::new( + EnumComboBox::new( "parameter_type", &mut item.parameter_type, ), @@ -278,7 +278,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Parameter Increment", egui::DragValue::new(&mut item.parameter_points) .range(0..=i32::MAX), @@ -291,7 +291,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Recover HP %", egui::Slider::new(&mut item.recover_hp_rate, 0..=100) .suffix("%"), @@ -299,7 +299,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Recover HP Points", egui::DragValue::new(&mut item.recover_hp) .range(0..=i32::MAX), @@ -311,7 +311,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Recover SP %", egui::Slider::new(&mut item.recover_sp_rate, 0..=100) .suffix("%"), @@ -319,7 +319,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Recover SP Points", egui::DragValue::new(&mut item.recover_sp) .range(0..=i32::MAX), @@ -331,14 +331,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Hit Rate", egui::Slider::new(&mut item.hit, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Variance", egui::Slider::new(&mut item.variance, 0..=100).suffix("%"), )) @@ -349,14 +349,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "PDEF-F", egui::Slider::new(&mut item.pdef_f, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "MDEF-F", egui::Slider::new(&mut item.mdef_f, 0..=100).suffix("%"), )) @@ -366,7 +366,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (item.id, "element_set"), &mut item.element_set, @@ -381,29 +381,27 @@ impl luminol_core::Window for Window { if self.previous_item != Some(item.id) { selection.clear_search(); } - modified |= columns[0] - .add(luminol_components::Field::new("Elements", selection)) - .changed(); + modified |= + columns[0].add(Field::new("Elements", selection)).changed(); - let mut selection = - luminol_components::IdVecPlusMinusSelection::new( - update_state, - (item.id, "state_set"), - &mut item.plus_state_set, - &mut item.minus_state_set, - 0..states.data.len(), - |id| { - states.data.get(id).map_or_else( - || "".into(), - |s| format!("{:0>4}: {}", id + 1, s.name), - ) - }, - ); + let mut selection = IdVecPlusMinusSelection::new( + update_state, + (item.id, "state_set"), + &mut item.plus_state_set, + &mut item.minus_state_set, + 0..states.data.len(), + |id| { + states.data.get(id).map_or_else( + || "".into(), + |s| format!("{:0>4}: {}", id + 1, s.name), + ) + }, + ); if self.previous_item != Some(item.id) { selection.clear_search(); } modified |= columns[1] - .add(luminol_components::Field::new("State Change", selection)) + .add(Field::new("State Change", selection)) .changed(); }); }); diff --git a/crates/ui/src/windows/preferences.rs b/crates/ui/src/windows/preferences.rs index a7b0acd5..82546dda 100644 --- a/crates/ui/src/windows/preferences.rs +++ b/crates/ui/src/windows/preferences.rs @@ -206,7 +206,7 @@ impl luminol_core::Window for Window { ui.vertical(|ui| { ui.label("Code sample"); - ui.label(luminol_components::syntax_highlighting::highlight( + ui.label(crate::components::syntax_highlighting::highlight( ui.ctx(), update_state.global_config.theme, CODE_SAMPLE, @@ -307,9 +307,9 @@ impl luminol_core::Window for Window { // config.font.size = self.font_size; // } // }); - luminol_components::Field::new( + crate::components::Field::new( "Cursor blinking", - luminol_components::EnumComboBox::new( + crate::components::EnumComboBox::new( "luminol_term_config_ui_cursor_blinking", &mut config.cursor_blinking, ) diff --git a/crates/ui/src/windows/reporter.rs b/crates/ui/src/windows/reporter.rs index 942023b8..7a9ecd5d 100644 --- a/crates/ui/src/windows/reporter.rs +++ b/crates/ui/src/windows/reporter.rs @@ -22,7 +22,7 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::UiExt; /// Crash reporter window. pub struct Window { diff --git a/crates/ui/src/windows/script_edit.rs b/crates/ui/src/windows/script_edit.rs index 50c48ff1..3fef2d5e 100644 --- a/crates/ui/src/windows/script_edit.rs +++ b/crates/ui/src/windows/script_edit.rs @@ -179,7 +179,7 @@ impl luminol_core::Tab for ScriptTab { }); let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| { - let mut layout_job = luminol_components::syntax_highlighting::highlight( + let mut layout_job = crate::components::syntax_highlighting::highlight( ui.ctx(), update_state.global_config.theme, string, diff --git a/crates/ui/src/windows/script_manager.rs b/crates/ui/src/windows/script_manager.rs index cc7228d8..93cba97b 100644 --- a/crates/ui/src/windows/script_manager.rs +++ b/crates/ui/src/windows/script_manager.rs @@ -22,8 +22,8 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. +use crate::components::{EnumComboBox, FileSystemView, UiExt}; use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt}; -use luminol_components::UiExt; use luminol_filesystem::{File, FileSystem, OpenFlags}; /// The script manager for creating and extracting Scripts.rxdata. @@ -37,14 +37,14 @@ type Scripts = Vec; enum Mode { Extract { - view: Option>, + view: Option>, load_promise: Option>>, save_promise: Option>>, progress_total: usize, }, Create { - view: Option>, + view: Option>, load_promise: Option< poll_promise::Promise>, >, @@ -272,7 +272,7 @@ impl luminol_core::Window for Window { Mode::Extract { view, .. } => { if let Some((path, vec)) = get_scripts_from_filesystem(scripts_path, &host) { - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_script_manager_extract_view".into(), ScriptsFileSystem::new(vec.into_iter()), path, @@ -282,7 +282,7 @@ impl luminol_core::Window for Window { Mode::Create { view, .. } => { let name = host.root_path().to_string(); - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_script_manager_create_view".into(), host, name, @@ -439,7 +439,7 @@ impl Window { if let Some(p) = load_promise.take() { match p.try_take() { Ok(Ok((fs, name))) => { - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_script_manager_extract_view".into(), fs, name, @@ -621,7 +621,7 @@ impl Window { match p.try_take() { Ok(Ok(handle)) => { let name = handle.root_path().to_string(); - *view = Some(luminol_components::FileSystemView::new( + *view = Some(FileSystemView::new( "luminol_script_manager_create_view".into(), handle, name, @@ -644,7 +644,7 @@ impl Window { ui.horizontal(|ui| { ui.label("Output Format:"); - ui.add(luminol_components::EnumComboBox::new( + ui.add(EnumComboBox::new( "luminol_script_manager_create_format", format, )); @@ -882,7 +882,7 @@ impl Window { ui.horizontal(|ui| { ui.label("Output Format:"); - ui.add(luminol_components::EnumComboBox::new( + ui.add(EnumComboBox::new( "luminol_script_manager_convert_format", format, )); @@ -1059,7 +1059,7 @@ impl Window { } fn find_files( - view: &luminol_components::FileSystemView, + view: &FileSystemView, ) -> luminol_filesystem::Result> { let mut vec = Vec::new(); for metadata in view { diff --git a/crates/ui/src/windows/skills.rs b/crates/ui/src/windows/skills.rs index 280303d9..89e8650e 100644 --- a/crates/ui/src/windows/skills.rs +++ b/crates/ui/src/windows/skills.rs @@ -22,10 +22,13 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{ + DatabaseView, EnumComboBox, Field, IdVecPlusMinusSelection, IdVecSelection, OptionalIdComboBox, + UiExt, +}; use luminol_core::Modal; -use luminol_modals::sound_picker::Modal as SoundPicker; +use crate::modals::sound_picker::Modal as SoundPicker; pub struct Window { selected_skill_name: Option, @@ -34,7 +37,7 @@ pub struct Window { previous_skill: Option, - view: luminol_components::DatabaseView, + view: DatabaseView, } impl Default for Window { @@ -43,7 +46,7 @@ impl Default for Window { selected_skill_name: None, menu_se_picker: SoundPicker::new(luminol_audio::Source::SE, "skill_menu_se_picker"), previous_skill: None, - view: luminol_components::DatabaseView::default(), + view: DatabaseView::default(), } } } @@ -103,7 +106,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut skill.name) .desired_width(f32::INFINITY), @@ -111,7 +114,7 @@ impl luminol_core::Window for Window { .changed(); modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Description", egui::TextEdit::multiline(&mut skill.description) .desired_width(f32::INFINITY), @@ -122,19 +125,16 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Scope", - luminol_components::EnumComboBox::new( - (skill.id, "scope"), - &mut skill.scope, - ), + EnumComboBox::new((skill.id, "scope"), &mut skill.scope), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Occasion", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (skill.id, "occasion"), &mut skill.occasion, ), @@ -146,9 +146,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "User Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (skill.id, "animation1_id"), &mut skill.animation1_id, @@ -164,9 +164,9 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Target Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (skill.id, "animation2_id"), &mut skill.animation2_id, @@ -186,7 +186,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Menu Use SE", self.menu_se_picker .button(&mut skill.menu_se, update_state), @@ -198,9 +198,9 @@ impl luminol_core::Window for Window { } modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Common Event", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (skill.id, "common_event_id"), &mut skill.common_event_id, @@ -220,7 +220,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "SP Cost", egui::DragValue::new(&mut skill.sp_cost) .range(0..=i32::MAX), @@ -228,7 +228,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Power", egui::DragValue::new(&mut skill.power), )) @@ -239,14 +239,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "ATK-F", egui::Slider::new(&mut skill.atk_f, 0..=200).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "EVA-F", egui::Slider::new(&mut skill.eva_f, 0..=100).suffix("%"), )) @@ -257,14 +257,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "STR-F", egui::Slider::new(&mut skill.str_f, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "DEX-F", egui::Slider::new(&mut skill.dex_f, 0..=100).suffix("%"), )) @@ -275,14 +275,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "AGI-F", egui::Slider::new(&mut skill.agi_f, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "INT-F", egui::Slider::new(&mut skill.int_f, 0..=100).suffix("%"), )) @@ -293,14 +293,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Hit Rate", egui::Slider::new(&mut skill.hit, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Variance", egui::Slider::new(&mut skill.variance, 0..=100).suffix("%"), )) @@ -311,14 +311,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "PDEF-F", egui::Slider::new(&mut skill.pdef_f, 0..=100).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "MDEF-F", egui::Slider::new(&mut skill.mdef_f, 0..=100).suffix("%"), )) @@ -328,7 +328,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (skill.id, "element_set"), &mut skill.element_set, @@ -343,29 +343,27 @@ impl luminol_core::Window for Window { if self.previous_skill != Some(skill.id) { selection.clear_search(); } - modified |= columns[0] - .add(luminol_components::Field::new("Elements", selection)) - .changed(); + modified |= + columns[0].add(Field::new("Elements", selection)).changed(); - let mut selection = - luminol_components::IdVecPlusMinusSelection::new( - update_state, - (skill.id, "state_set"), - &mut skill.plus_state_set, - &mut skill.minus_state_set, - 0..states.data.len(), - |id| { - states.data.get(id).map_or_else( - || "".into(), - |s| format!("{:0>4}: {}", id + 1, s.name), - ) - }, - ); + let mut selection = IdVecPlusMinusSelection::new( + update_state, + (skill.id, "state_set"), + &mut skill.plus_state_set, + &mut skill.minus_state_set, + 0..states.data.len(), + |id| { + states.data.get(id).map_or_else( + || "".into(), + |s| format!("{:0>4}: {}", id + 1, s.name), + ) + }, + ); if self.previous_skill != Some(skill.id) { selection.clear_search(); } modified |= columns[1] - .add(luminol_components::Field::new("State Change", selection)) + .add(Field::new("State Change", selection)) .changed(); }); }); diff --git a/crates/ui/src/windows/sound_test.rs b/crates/ui/src/windows/sound_test.rs index c42f888b..2e534252 100644 --- a/crates/ui/src/windows/sound_test.rs +++ b/crates/ui/src/windows/sound_test.rs @@ -29,7 +29,7 @@ use strum::IntoEnumIterator; /// A simple sound test window. pub struct Window { - sources: Vec, + sources: Vec, selected_source: luminol_audio::Source, } @@ -38,7 +38,7 @@ impl Window { Self { // Create all sources. sources: luminol_audio::Source::iter() - .map(|s| luminol_components::SoundTab::new(filesystem, s, Default::default())) + .map(|s| crate::components::SoundTab::new(filesystem, s, Default::default())) .collect(), // By default, bgm is selected. selected_source: luminol_audio::Source::BGM, diff --git a/crates/ui/src/windows/states.rs b/crates/ui/src/windows/states.rs index 42881a17..3e40c1e7 100644 --- a/crates/ui/src/windows/states.rs +++ b/crates/ui/src/windows/states.rs @@ -22,14 +22,16 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{ + EnumComboBox, Field, IdVecPlusMinusSelection, IdVecSelection, OptionalIdComboBox, UiExt, +}; #[derive(Default)] pub struct Window { selected_state_name: Option, previous_state: Option, - view: luminol_components::DatabaseView, + view: crate::components::DatabaseView, } impl Window { @@ -85,7 +87,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut state.name) .desired_width(f32::INFINITY), @@ -96,9 +98,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (state.id, "animation_id"), &mut state.animation_id, @@ -114,9 +116,9 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Restriction", - luminol_components::EnumComboBox::new( + EnumComboBox::new( (state.id, "restriction"), &mut state.restriction, ), @@ -128,14 +130,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Nonresistance", egui::Checkbox::without_text(&mut state.nonresistance), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Count as 0 HP", egui::Checkbox::without_text(&mut state.zero_hp), )) @@ -146,21 +148,21 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(3, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Can't Get EXP", egui::Checkbox::without_text(&mut state.cant_get_exp), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Can't Evade", egui::Checkbox::without_text(&mut state.cant_evade), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "Slip Damage", egui::Checkbox::without_text(&mut state.slip_damage), )) @@ -171,17 +173,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Rating", egui::DragValue::new(&mut state.rating).range(0..=10), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( - "EVA", - egui::DragValue::new(&mut state.eva), - )) + .add(Field::new("EVA", egui::DragValue::new(&mut state.eva))) .changed(); }); }); @@ -189,7 +188,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Max HP %", egui::Slider::new(&mut state.maxhp_rate, 0..=200) .suffix("%"), @@ -197,7 +196,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Max SP %", egui::Slider::new(&mut state.maxsp_rate, 0..=200) .suffix("%"), @@ -209,14 +208,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "STR %", egui::Slider::new(&mut state.str_rate, 0..=200).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "DEX %", egui::Slider::new(&mut state.dex_rate, 0..=200).suffix("%"), )) @@ -227,14 +226,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "AGI %", egui::Slider::new(&mut state.agi_rate, 0..=200).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "INT %", egui::Slider::new(&mut state.int_rate, 0..=200).suffix("%"), )) @@ -245,14 +244,14 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Hit Rate %", egui::Slider::new(&mut state.hit_rate, 0..=200).suffix("%"), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "ATK %", egui::Slider::new(&mut state.atk_rate, 0..=200).suffix("%"), )) @@ -263,7 +262,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "PDEF %", egui::Slider::new(&mut state.pdef_rate, 0..=200) .suffix("%"), @@ -271,7 +270,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "MDEF %", egui::Slider::new(&mut state.mdef_rate, 0..=200) .suffix("%"), @@ -283,7 +282,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Auto Release Probability", egui::Slider::new(&mut state.auto_release_prob, 0..=100) .suffix("%"), @@ -291,7 +290,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Auto Release Interval", egui::DragValue::new(&mut state.hold_turn) .range(0..=i32::MAX), @@ -303,7 +302,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Damage Release Probability", egui::Slider::new(&mut state.shock_release_prob, 0..=100) .suffix("%"), @@ -311,7 +310,7 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Battle Only", egui::Checkbox::without_text(&mut state.battle_only), )) @@ -322,7 +321,7 @@ impl luminol_core::Window for Window { let mut state = std::mem::take(state); ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (state.id, "guard_element_set"), &mut state.guard_element_set, @@ -338,35 +337,31 @@ impl luminol_core::Window for Window { selection.clear_search(); } modified |= columns[0] - .add(luminol_components::Field::new( - "Element Defense", - selection, - )) + .add(Field::new("Element Defense", selection)) .changed(); - let mut selection = - luminol_components::IdVecPlusMinusSelection::new( - update_state, - (state.id, "state_set"), - &mut state.plus_state_set, - &mut state.minus_state_set, - 0..states.len(), - |id| { - if id == state.id { - format!("{:0>4}: {}", id + 1, state.name) - } else { - states.get(id).map_or_else( - || "".into(), - |s| format!("{:0>4}: {}", id + 1, s.name), - ) - } - }, - ); + let mut selection = IdVecPlusMinusSelection::new( + update_state, + (state.id, "state_set"), + &mut state.plus_state_set, + &mut state.minus_state_set, + 0..states.len(), + |id| { + if id == state.id { + format!("{:0>4}: {}", id + 1, state.name) + } else { + states.get(id).map_or_else( + || "".into(), + |s| format!("{:0>4}: {}", id + 1, s.name), + ) + } + }, + ); if self.previous_state != Some(state.id) { selection.clear_search(); } modified |= columns[1] - .add(luminol_components::Field::new("State Change", selection)) + .add(Field::new("State Change", selection)) .changed(); }); }); diff --git a/crates/ui/src/windows/weapons.rs b/crates/ui/src/windows/weapons.rs index 300a02de..62a421cd 100644 --- a/crates/ui/src/windows/weapons.rs +++ b/crates/ui/src/windows/weapons.rs @@ -22,14 +22,16 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use luminol_components::UiExt; +use crate::components::{ + Field, IdVecPlusMinusSelection, IdVecSelection, OptionalIdComboBox, UiExt, +}; #[derive(Default)] pub struct Window { selected_weapon_name: Option, previous_weapon: Option, - view: luminol_components::DatabaseView, + view: crate::components::DatabaseView, } impl Window { @@ -86,7 +88,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Name", egui::TextEdit::singleline(&mut weapon.name) .desired_width(f32::INFINITY), @@ -94,7 +96,7 @@ impl luminol_core::Window for Window { .changed(); modified |= ui - .add(luminol_components::Field::new( + .add(Field::new( "Description", egui::TextEdit::multiline(&mut weapon.description) .desired_width(f32::INFINITY), @@ -105,9 +107,9 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(2, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "User Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (weapon.id, "animation1_id"), &mut weapon.animation1_id, @@ -123,9 +125,9 @@ impl luminol_core::Window for Window { .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "Target Animation", - luminol_components::OptionalIdComboBox::new( + OptionalIdComboBox::new( update_state, (weapon.id, "animation2_id"), &mut weapon.animation2_id, @@ -145,28 +147,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "Price", egui::DragValue::new(&mut weapon.price).range(0..=i32::MAX), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "ATK", egui::DragValue::new(&mut weapon.atk).range(0..=i32::MAX), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "PDEF", egui::DragValue::new(&mut weapon.pdef).range(0..=i32::MAX), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "MDEF", egui::DragValue::new(&mut weapon.mdef).range(0..=i32::MAX), )) @@ -177,28 +179,28 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(true, |ui| { ui.columns(4, |columns| { modified |= columns[0] - .add(luminol_components::Field::new( + .add(Field::new( "STR+", egui::DragValue::new(&mut weapon.str_plus), )) .changed(); modified |= columns[1] - .add(luminol_components::Field::new( + .add(Field::new( "DEX+", egui::DragValue::new(&mut weapon.dex_plus), )) .changed(); modified |= columns[2] - .add(luminol_components::Field::new( + .add(Field::new( "AGI+", egui::DragValue::new(&mut weapon.agi_plus), )) .changed(); modified |= columns[3] - .add(luminol_components::Field::new( + .add(Field::new( "INT+", egui::DragValue::new(&mut weapon.int_plus), )) @@ -208,7 +210,7 @@ impl luminol_core::Window for Window { ui.with_padded_stripe(false, |ui| { ui.columns(2, |columns| { - let mut selection = luminol_components::IdVecSelection::new( + let mut selection = IdVecSelection::new( update_state, (weapon.id, "element_set"), &mut weapon.element_set, @@ -223,29 +225,27 @@ impl luminol_core::Window for Window { if self.previous_weapon != Some(weapon.id) { selection.clear_search(); } - modified |= columns[0] - .add(luminol_components::Field::new("Elements", selection)) - .changed(); + modified |= + columns[0].add(Field::new("Elements", selection)).changed(); - let mut selection = - luminol_components::IdVecPlusMinusSelection::new( - update_state, - (weapon.id, "state_set"), - &mut weapon.plus_state_set, - &mut weapon.minus_state_set, - 0..states.data.len(), - |id| { - states.data.get(id).map_or_else( - || "".into(), - |s| format!("{:0>4}: {}", id + 1, s.name), - ) - }, - ); + let mut selection = IdVecPlusMinusSelection::new( + update_state, + (weapon.id, "state_set"), + &mut weapon.plus_state_set, + &mut weapon.minus_state_set, + 0..states.data.len(), + |id| { + states.data.get(id).map_or_else( + || "".into(), + |s| format!("{:0>4}: {}", id + 1, s.name), + ) + }, + ); if self.previous_weapon != Some(weapon.id) { selection.clear_search(); } modified |= columns[1] - .add(luminol_components::Field::new("State Change", selection)) + .add(Field::new("State Change", selection)) .changed(); }); });