From 689b1cb8fe3525f584b2bc32fa847bf516f193ee Mon Sep 17 00:00:00 2001 From: Lily Lyons Date: Wed, 4 Oct 2023 18:10:54 -0700 Subject: [PATCH] Sorta figure out dependencies --- Cargo.lock | 418 ++++++++++++++++-- Cargo.toml | 11 +- crates/luminol-audio/Cargo.toml | 2 + crates/luminol-audio/src/lib.rs | 6 +- crates/luminol-commands/Cargo.toml | 12 - .../src/command_view/command_ui.rs | 0 .../src/command_view/macros.rs | 0 .../src/command_view/mod.rs | 1 - .../src/command_view/parameter_ui.rs | 6 +- .../src/command_view/ui.rs | 0 crates/luminol-config/Cargo.toml | 19 + .../src}/command_db.rs | 4 +- .../src}/commands/ace.ron | 0 .../src}/commands/vx.ron | 0 .../src}/commands/xp.ron | 0 .../config => luminol-config/src}/global.rs | 5 +- crates/luminol-config/src/lib.rs | 91 ++++ crates/luminol-config/src/project.rs | 162 +++++++ crates/luminol-core/Cargo.toml | 12 + crates/luminol-core/src/config/mod.rs | 245 ---------- crates/luminol-core/src/config/project.rs | 54 --- .../src/{filesystem/mod.rs => filesystem.rs} | 28 +- crates/luminol-core/src/lib.rs | 101 +---- .../src/modal.rs | 0 .../{luminol-tabs => luminol-core}/src/tab.rs | 16 +- .../src/window.rs | 0 crates/luminol-data/Cargo.toml | 2 + .../lib.rs => luminol-data/src/commands.rs} | 0 crates/luminol-data/src/data_cache.rs | 383 +--------------- crates/luminol-data/src/lib.rs | 4 + crates/luminol-filesystem/Cargo.toml | 30 ++ .../src}/archiver.rs | 8 +- .../src}/erased.rs | 6 +- .../src}/host.rs | 5 +- crates/luminol-filesystem/src/lib.rs | 25 ++ .../src}/list.rs | 8 +- .../src}/overlay.rs | 0 .../src}/path_cache.rs | 14 +- .../src}/project.rs | 284 +++++------- crates/luminol-graphics/Cargo.toml | 3 + crates/luminol-graphics/src/atlas_cache.rs | 12 +- crates/luminol-graphics/src/event.rs | 9 +- crates/luminol-graphics/src/image_cache.rs | 7 +- .../src/primitives/tiles/mod.rs | 5 +- .../src/primitives/tiles/shader.rs | 6 +- .../src/command_gen/mod.rs | 15 +- .../src/command_gen/parameter_ui.rs | 0 .../src/command_gen/ui_example.rs | 0 48 files changed, 962 insertions(+), 1057 deletions(-) delete mode 100644 crates/luminol-commands/Cargo.toml rename crates/{luminol-commands => luminol-components}/src/command_view/command_ui.rs (100%) rename crates/{luminol-commands => luminol-components}/src/command_view/macros.rs (100%) rename crates/{luminol-commands => luminol-components}/src/command_view/mod.rs (98%) rename crates/{luminol-commands => luminol-components}/src/command_view/parameter_ui.rs (98%) rename crates/{luminol-commands => luminol-components}/src/command_view/ui.rs (100%) create mode 100644 crates/luminol-config/Cargo.toml rename crates/{luminol-core/src/config => luminol-config/src}/command_db.rs (97%) rename crates/{luminol-core/src/config => luminol-config/src}/commands/ace.ron (100%) rename crates/{luminol-core/src/config => luminol-config/src}/commands/vx.ron (100%) rename crates/{luminol-core/src/config => luminol-config/src}/commands/xp.ron (100%) rename crates/{luminol-core/src/config => luminol-config/src}/global.rs (92%) create mode 100644 crates/luminol-config/src/lib.rs create mode 100644 crates/luminol-config/src/project.rs delete mode 100644 crates/luminol-core/src/config/mod.rs delete mode 100644 crates/luminol-core/src/config/project.rs rename crates/luminol-core/src/{filesystem/mod.rs => filesystem.rs} (87%) rename crates/{luminol-modals => luminol-core}/src/modal.rs (100%) rename crates/{luminol-tabs => luminol-core}/src/tab.rs (93%) rename crates/{luminol-windows => luminol-core}/src/window.rs (100%) rename crates/{luminol-commands/src/lib.rs => luminol-data/src/commands.rs} (100%) create mode 100644 crates/luminol-filesystem/Cargo.toml rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/archiver.rs (98%) rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/erased.rs (96%) rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/host.rs (96%) create mode 100644 crates/luminol-filesystem/src/lib.rs rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/list.rs (95%) rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/overlay.rs (100%) rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/path_cache.rs (93%) rename crates/{luminol-core/src/filesystem => luminol-filesystem/src}/project.rs (59%) rename crates/{luminol-commands => luminol-windows}/src/command_gen/mod.rs (96%) rename crates/{luminol-commands => luminol-windows}/src/command_gen/parameter_ui.rs (100%) rename crates/{luminol-commands => luminol-windows}/src/command_gen/ui_example.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 6ef560bb0..2e2d662ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -380,6 +380,18 @@ dependencies = [ "syn 2.0.29", ] +[[package]] +name = "atk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "251e0b7d90e33e0ba930891a505a9a35ece37b2dd37a14f3ffc306c13b980009" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + [[package]] name = "atomic" version = "0.5.3" @@ -604,6 +616,16 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[package]] +name = "cairo-sys-rs" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "calloop" version = "0.10.6" @@ -649,6 +671,16 @@ dependencies = [ "nom", ] +[[package]] +name = "cfg-expr" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -761,15 +793,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "command-lib" -version = "0.1.0" -dependencies = [ - "rand", - "serde", - "strum", -] - [[package]] name = "concurrent-queue" version = "2.2.0" @@ -779,6 +802,28 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-random" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" +dependencies = [ + "getrandom", + "once_cell", + "proc-macro-hack", + "tiny-keccak", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -1103,12 +1148,31 @@ dependencies = [ "libloading 0.8.0", ] +[[package]] +name = "dlv-list" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aead04dc46b5f263c25721cf25c9e595951d15055f8063f92392fa0d7f64cf4" +dependencies = [ + "const-random", +] + [[package]] name = "downcast-rs" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "duplicate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb" +dependencies = [ + "heck", + "proc-macro-error", +] + [[package]] name = "ecolor" version = "0.22.0" @@ -1201,6 +1265,27 @@ dependencies = [ "winit", ] +[[package]] +name = "egui_dock" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c257477084601e557ba4c905a79f66e9010b584ab7ef0e720d098d819c25cc33" +dependencies = [ + "duplicate", + "egui", + "paste", +] + +[[package]] +name = "egui_extras" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9278f4337b526f0d57e5375e5a7340a311fa6ee8f9fcc75721ac50af13face02" +dependencies = [ + "egui", + "serde", +] + [[package]] name = "egui_glow" version = "0.22.0" @@ -1516,6 +1601,36 @@ dependencies = [ "slab", ] +[[package]] +name = "gdk-pixbuf-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ff856cb3386dae1703a920f803abafcc580e9b5f711ca62ed1620c25b51ff2" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1565,6 +1680,19 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "gio-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + [[package]] name = "gl_generator" version = "0.14.0" @@ -1585,6 +1713,16 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "glib-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "glob" version = "0.3.1" @@ -1667,6 +1805,17 @@ dependencies = [ "gl_generator", ] +[[package]] +name = "gobject-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + [[package]] name = "gpu-alloc" version = "0.5.4" @@ -1719,6 +1868,24 @@ dependencies = [ "bitflags 2.4.0", ] +[[package]] +name = "gtk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771437bf1de2c1c0b496c11505bdf748e26066bbe942dfc8f614c9460f6d7722" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps", +] + [[package]] name = "half" version = "2.2.1" @@ -1737,6 +1904,12 @@ dependencies = [ "ahash 0.7.6", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + [[package]] name = "hashbrown" version = "0.14.0" @@ -2123,8 +2296,6 @@ version = "0.4.0" dependencies = [ "eframe", "egui", - "windows 0.51.1", - "winreg 0.51.0", "winres", ] @@ -2133,6 +2304,7 @@ name = "luminol-audio" version = "0.1.0" dependencies = [ "camino", + "luminol-core", "once_cell", "parking_lot", "rodio", @@ -2150,9 +2322,32 @@ dependencies = [ "strum", ] +[[package]] +name = "luminol-config" +version = "0.1.0" +dependencies = [ + "luminol-core", + "luminol-data", + "once_cell", + "ron", + "rust-ini", + "serde", + "strum", +] + [[package]] name = "luminol-core" version = "0.1.0" +dependencies = [ + "bitflags 2.4.0", + "camino", + "egui", + "egui_dock", + "parking_lot", + "serde", + "strum", + "thiserror", +] [[package]] name = "luminol-data" @@ -2162,6 +2357,7 @@ dependencies = [ "bytemuck", "camino", "flate2", + "luminol-core", "num-derive 0.4.0", "num_enum 0.7.0", "paste", @@ -2171,15 +2367,36 @@ dependencies = [ "strum", ] +[[package]] +name = "luminol-filesystem" +version = "0.1.0" +dependencies = [ + "alox-48", + "bitflags 2.4.0", + "camino", + "dashmap", + "egui", + "itertools", + "luminol-config", + "luminol-core", + "luminol-data", + "rfd", + "serde", + "thiserror", + "winreg 0.51.0", +] + [[package]] name = "luminol-graphics" version = "0.1.0" dependencies = [ "bytemuck", + "camino", "crossbeam", "dashmap", "egui", "egui-wgpu", + "egui_extras", "glam", "image 0.24.7", "itertools", @@ -2755,6 +2972,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "ordered-multimap" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" +dependencies = [ + "dlv-list", + "hashbrown 0.13.2", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -2774,6 +3001,18 @@ dependencies = [ "ttf-parser", ] +[[package]] +name = "pango-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + [[package]] name = "parking" version = "2.1.0" @@ -3041,9 +3280,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.14", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", ] +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + [[package]] name = "proc-macro2" version = "1.0.66" @@ -3205,6 +3474,29 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" +[[package]] +name = "rfd" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241a0deb168c88050d872294f7b3106c1dfa8740942bcc97bc91b98e97b5c501" +dependencies = [ + "block", + "dispatch", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "log", + "objc", + "objc-foundation", + "objc_id", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rodio" version = "0.17.1" @@ -3230,6 +3522,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "rust-ini" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" +dependencies = [ + "cfg-if", + "ordered-multimap", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -3364,6 +3666,15 @@ dependencies = [ "syn 2.0.29", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde", +] + [[package]] name = "serial" version = "0.4.0" @@ -3705,6 +4016,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "system-deps" +version = "6.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af52f9402f94aac4948a2518b43359be8d9ce6cd9efc1c4de3b2f7b7e897d6" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.8.2", + "version-compare", +] + +[[package]] +name = "target-lexicon" +version = "0.12.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" + [[package]] name = "tempfile" version = "3.8.0" @@ -3843,6 +4173,15 @@ dependencies = [ "weezl", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tiny-skia" version = "0.8.4" @@ -3892,11 +4231,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.2", +] + [[package]] name = "toml_datetime" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -3909,6 +4263,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" version = "0.1.37" @@ -4050,6 +4417,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "version_check" version = "0.9.4" @@ -4527,25 +4900,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" -dependencies = [ - "windows-core", - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-core" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-implement" version = "0.48.0" @@ -4769,7 +5123,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 173dbfdf7..449b0ca65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,11 @@ build = "build.rs" [workspace] members = [ "crates/luminol-audio", - "crates/luminol-commands", "crates/luminol-components", + "crates/luminol-config", "crates/luminol-core", "crates/luminol-data", + "crates/luminol-filesystem", "crates/luminol-graphics", "crates/luminol-modals", "crates/luminol-macros", @@ -33,6 +34,7 @@ members = [ [workspace.dependencies] egui = "0.22.0" +egui_extras = "0.22.0" eframe = { version = "0.22.0", features = [ "wgpu", @@ -57,12 +59,16 @@ bytemuck = { version = "1.14.0", features = [ strum = { version = "0.25.0", features = ["derive"] } paste = "1.0.14" +thiserror = "1.0" +bitflags = "2.4.0" parking_lot = "0.12.1" once_cell = "1.18.0" crossbeam = "0.8.2" dashmap = "5.5.3" +poll-promise = "0.3.0" + camino = "1.1.6" slab = { version = "0.4.9", features = ["serde"] } @@ -78,9 +84,6 @@ egui.workspace = true [features] steamworks = [] # ["dep:steamworks", "crc"] -[target.'cfg(windows)'.dependencies] -windows = { version = "0.51.1", features = ["Win32_System_Registry"] } -winreg = "0.51.0" [target.'cfg(windows)'.build-dependencies] winres = "0.1" diff --git a/crates/luminol-audio/Cargo.toml b/crates/luminol-audio/Cargo.toml index 72eb89134..16ac12169 100644 --- a/crates/luminol-audio/Cargo.toml +++ b/crates/luminol-audio/Cargo.toml @@ -14,3 +14,5 @@ strum.workspace = true parking_lot.workspace = true camino.workspace = true once_cell.workspace = true + +luminol-core = { version = "0.1.0", path = "../luminol-core/" } diff --git a/crates/luminol-audio/src/lib.rs b/crates/luminol-audio/src/lib.rs index e3cd09373..c5c3b1968 100644 --- a/crates/luminol-audio/src/lib.rs +++ b/crates/luminol-audio/src/lib.rs @@ -75,6 +75,7 @@ impl Audio { pub fn play( &self, path: impl AsRef, + filesystem: &'static impl luminol_core::filesystem::FileSystem, // FIXME volume: u8, pitch: u8, source: Source, @@ -84,9 +85,8 @@ impl Audio { let sink = rodio::Sink::try_new(&inner.output_stream_handle).map_err(|e| e.to_string())?; let path = path.as_ref(); - let file = state!() - .filesystem - .open_file(path, filesystem::OpenFlags::Read) + let file = filesystem + .open_file(path, luminol_core::filesystem::OpenFlags::Read) .map_err(|e| e.to_string())?; // Select decoder type based on sound source diff --git a/crates/luminol-commands/Cargo.toml b/crates/luminol-commands/Cargo.toml deleted file mode 100644 index 453ad1952..000000000 --- a/crates/luminol-commands/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "command-lib" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = { version = "1.0", features = ["derive"] } -strum = { version = "0.25", features = ["derive"] } - -rand = "0.8.5" diff --git a/crates/luminol-commands/src/command_view/command_ui.rs b/crates/luminol-components/src/command_view/command_ui.rs similarity index 100% rename from crates/luminol-commands/src/command_view/command_ui.rs rename to crates/luminol-components/src/command_view/command_ui.rs diff --git a/crates/luminol-commands/src/command_view/macros.rs b/crates/luminol-components/src/command_view/macros.rs similarity index 100% rename from crates/luminol-commands/src/command_view/macros.rs rename to crates/luminol-components/src/command_view/macros.rs diff --git a/crates/luminol-commands/src/command_view/mod.rs b/crates/luminol-components/src/command_view/mod.rs similarity index 98% rename from crates/luminol-commands/src/command_view/mod.rs rename to crates/luminol-components/src/command_view/mod.rs index 1f61b61b2..26daea826 100644 --- a/crates/luminol-commands/src/command_view/mod.rs +++ b/crates/luminol-components/src/command_view/mod.rs @@ -28,7 +28,6 @@ mod command_ui; mod parameter_ui; mod ui; -pub use crate::prelude::*; use std::collections::HashMap; pub struct CommandView { diff --git a/crates/luminol-commands/src/command_view/parameter_ui.rs b/crates/luminol-components/src/command_view/parameter_ui.rs similarity index 98% rename from crates/luminol-commands/src/command_view/parameter_ui.rs rename to crates/luminol-components/src/command_view/parameter_ui.rs index 7713d6b77..547ba036f 100644 --- a/crates/luminol-commands/src/command_view/parameter_ui.rs +++ b/crates/luminol-components/src/command_view/parameter_ui.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::prelude::*; +use super::CommandView; -use command_lib::{Parameter, ParameterKind}; +use crate::{Parameter, ParameterKind}; impl CommandView { #[allow(clippy::only_used_in_recursion)] @@ -32,7 +32,7 @@ impl CommandView { &mut self, ui: &mut egui::Ui, parameter: &Parameter, - command: &mut rpg::EventCommand, + command: &mut luminol_data::rpg::EventCommand, ) { match parameter { Parameter::Selection { diff --git a/crates/luminol-commands/src/command_view/ui.rs b/crates/luminol-components/src/command_view/ui.rs similarity index 100% rename from crates/luminol-commands/src/command_view/ui.rs rename to crates/luminol-components/src/command_view/ui.rs diff --git a/crates/luminol-config/Cargo.toml b/crates/luminol-config/Cargo.toml new file mode 100644 index 000000000..9eb398b78 --- /dev/null +++ b/crates/luminol-config/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "luminol-config" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rust-ini = "0.19.0" + +serde.workspace = true + +strum.workspace = true +ron.workspace = true + +once_cell.workspace = true + +luminol-core = { version = "0.1.0", path = "../luminol-core/" } +luminol-data = { version = "0.1.0", path = "../luminol-data/" } diff --git a/crates/luminol-core/src/config/command_db.rs b/crates/luminol-config/src/command_db.rs similarity index 97% rename from crates/luminol-core/src/config/command_db.rs rename to crates/luminol-config/src/command_db.rs index d0d47172a..f3f6dc912 100644 --- a/crates/luminol-core/src/config/command_db.rs +++ b/crates/luminol-config/src/command_db.rs @@ -22,8 +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 command_lib::CommandDescription; +use luminol_data::commands::CommandDescription; use once_cell::sync::Lazy; + use serde::{Deserialize, Serialize}; use super::RMVer; @@ -51,6 +52,7 @@ pub struct CommandDB { /// Default commands default: Vec, /// User defined commands + // FIXME: visible to user? pub user: Vec, } diff --git a/crates/luminol-core/src/config/commands/ace.ron b/crates/luminol-config/src/commands/ace.ron similarity index 100% rename from crates/luminol-core/src/config/commands/ace.ron rename to crates/luminol-config/src/commands/ace.ron diff --git a/crates/luminol-core/src/config/commands/vx.ron b/crates/luminol-config/src/commands/vx.ron similarity index 100% rename from crates/luminol-core/src/config/commands/vx.ron rename to crates/luminol-config/src/commands/vx.ron diff --git a/crates/luminol-core/src/config/commands/xp.ron b/crates/luminol-config/src/commands/xp.ron similarity index 100% rename from crates/luminol-core/src/config/commands/xp.ron rename to crates/luminol-config/src/commands/xp.ron diff --git a/crates/luminol-core/src/config/global.rs b/crates/luminol-config/src/global.rs similarity index 92% rename from crates/luminol-core/src/config/global.rs rename to crates/luminol-config/src/global.rs index 723ad5956..a6faf9751 100644 --- a/crates/luminol-core/src/config/global.rs +++ b/crates/luminol-config/src/global.rs @@ -22,7 +22,6 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::prelude::*; use std::collections::HashMap; use std::collections::VecDeque; @@ -33,7 +32,7 @@ pub struct Config { /// Recently open projects. pub recent_projects: VecDeque, /// The current code theme - pub theme: syntax_highlighting::CodeTheme, + // pub theme: syntax_highlighting::CodeTheme, pub rtp_paths: HashMap, } @@ -47,7 +46,7 @@ impl Config { pub fn new() -> Self { Self { recent_projects: VecDeque::new(), - theme: syntax_highlighting::CodeTheme::dark(), + // theme: syntax_highlighting::CodeTheme::dark(), rtp_paths: HashMap::new(), } } diff --git a/crates/luminol-config/src/lib.rs b/crates/luminol-config/src/lib.rs new file mode 100644 index 000000000..58bdd0270 --- /dev/null +++ b/crates/luminol-config/src/lib.rs @@ -0,0 +1,91 @@ +// Copyright (C) 2023 Lily Lyons +// +// This file is part of Luminol. +// +// Luminol is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Luminol is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Luminol. If not, see . + +pub mod command_db; +pub mod global; +pub mod project; + +#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(strum::EnumIter, strum::Display)] +#[allow(missing_docs)] +pub enum RGSSVer { + #[strum(to_string = "ModShot")] + ModShot, + #[strum(to_string = "mkxp-oneshot")] + MKXPOneShot, + #[strum(to_string = "rsgss")] + RSGSS, + #[strum(to_string = "mkxp")] + MKXP, + #[strum(to_string = "mkxp-freebird")] + MKXPFreebird, + #[strum(to_string = "mkxp-z")] + MKXPZ, + #[default] + #[strum(to_string = "Stock RGSS1")] + RGSS1, +} + +#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(strum::EnumIter, strum::Display)] +#[allow(missing_docs)] +pub enum RMVer { + #[default] + #[strum(to_string = "RPG Maker XP")] + XP = 1, + #[strum(to_string = "RPG Maker VX")] + VX = 2, + #[strum(to_string = "RPG Maker VX Ace")] + Ace = 3, +} + +impl RMVer { + pub fn detect_from_filesystem( + filesystem: &impl luminol_core::filesystem::FileSystem, + ) -> Option { + if filesystem.exists("Data/Actors.rxdata").ok()? { + return Some(RMVer::XP); + } + + if filesystem.exists("Data/Actors.rvdata").ok()? { + return Some(RMVer::VX); + } + + if filesystem.exists("Data/Actors.rvdata2").ok()? { + return Some(RMVer::Ace); + } + + for path in filesystem.read_dir("").ok()? { + let path = path.path(); + if path.extension() == Some("rgssad") { + return Some(RMVer::XP); + } + + if path.extension() == Some("rgss2a") { + return Some(RMVer::VX); + } + + if path.extension() == Some("rgss3a") { + return Some(RMVer::Ace); + } + } + + None + } +} diff --git a/crates/luminol-config/src/project.rs b/crates/luminol-config/src/project.rs new file mode 100644 index 000000000..792ce8c6a --- /dev/null +++ b/crates/luminol-config/src/project.rs @@ -0,0 +1,162 @@ +// Copyright (C) 2023 Lily Lyons +// +// This file is part of Luminol. +// +// Luminol is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Luminol is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Luminol. If not, see . +// +// Additional permission under GNU GPL version 3 section 7 +// +// If you modify this Program, or any covered work, by linking or combining +// 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 serde::{Deserialize, Serialize}; + +use super::{command_db, RGSSVer, RMVer}; + +#[derive(Debug, Clone)] +#[allow(clippy::large_enum_variant)] +pub struct Config { + pub project: Project, + pub command_db: command_db::CommandDB, + pub game_ini: ini::Ini, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(default)] +/// Local luminol project config +#[allow(missing_docs)] +pub struct Project { + pub project_name: String, + pub scripts_path: String, + pub use_ron: bool, + pub rgss_ver: RGSSVer, + pub editor_ver: RMVer, + pub playtest_exe: String, + pub prefer_rgssad: bool, +} + +impl Default for Project { + fn default() -> Self { + Self { + project_name: String::new(), + scripts_path: "Scripts".to_string(), + use_ron: false, + rgss_ver: RGSSVer::RGSS1, + editor_ver: RMVer::XP, + playtest_exe: "game".to_string(), + prefer_rgssad: false, + } + } +} + +impl Config { + pub fn load(filesystem: &impl luminol_core::filesystem::FileSystem) -> Result { + if !filesystem.exists(".luminol").map_err(|e| e.to_string())? { + filesystem + .create_dir(".luminol") + .map_err(|e| e.to_string())?; + } + + let project = match filesystem + .read_to_string(".luminol/config") + .ok() + .and_then(|s| ron::from_str(&s).ok()) + { + Some(c) => c, + None => { + let Some(editor_ver) = RMVer::detect_from_filesystem(filesystem) else { + return Err("Unable to detect RPG Maker version".to_string()); + }; + let config = Project { + editor_ver, + ..Default::default() + }; + filesystem + .write(".luminol/config", ron::to_string(&config).unwrap()) + .map_err(|e| e.to_string())?; + config + } + }; + + let command_db = match filesystem + .read_to_string(".luminol/commands") + .ok() + .and_then(|s| ron::from_str(&s).ok()) + { + Some(c) => c, + None => { + let command_db = command_db::CommandDB::new(project.editor_ver); + filesystem + .write(".luminol/commands", ron::to_string(&command_db).unwrap()) + .map_err(|e| e.to_string())?; + command_db + } + }; + + let game_ini = match filesystem + .read_to_string("Game.ini") + .ok() + .and_then(|i| ini::Ini::load_from_str_noescape(&i).ok()) + { + Some(i) => i, + None => { + let mut ini = ini::Ini::new(); + ini.with_section(Some("Game")) + .set("Library", "RGSS104E.dll") + .set("Scripts", &project.scripts_path) + .set("Title", &project.project_name) + .set("RTP1", "") + .set("RTP2", "") + .set("RTP3", ""); + + ini + } + }; + + Ok(Self { + project, + command_db, + game_ini, + }) + } + + pub fn save( + &self, + filesystem: &impl luminol_core::filesystem::FileSystem, + ) -> Result<(), String> { + filesystem + .write( + ".luminol/commands", + ron::to_string(&self.command_db).map_err(|e| e.to_string())?, + ) + .map_err(|e| e.to_string())?; + + filesystem + .write( + ".luminol/config", + ron::to_string(&self.project).map_err(|e| e.to_string())?, + ) + .map_err(|e| e.to_string())?; + + let mut ini_file = filesystem + .open_file("Game.ini", luminol_core::filesystem::OpenFlags::Create) + .map_err(|e| e.to_string())?; + self.game_ini + .write_to(&mut ini_file) + .map_err(|e| e.to_string())?; + + Ok(()) + } +} diff --git a/crates/luminol-core/Cargo.toml b/crates/luminol-core/Cargo.toml index 60860dd3a..5e951d47a 100644 --- a/crates/luminol-core/Cargo.toml +++ b/crates/luminol-core/Cargo.toml @@ -2,7 +2,19 @@ name = "luminol-core" version = "0.1.0" edition = "2021" +description = "Core luminol traits and data types" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +egui.workspace = true +egui_dock = "0.7.3" + +parking_lot.workspace = true + +thiserror.workspace = true +camino.workspace = true +bitflags.workspace = true + +strum.workspace = true +serde.workspace = true diff --git a/crates/luminol-core/src/config/mod.rs b/crates/luminol-core/src/config/mod.rs deleted file mode 100644 index 4ae5b30f1..000000000 --- a/crates/luminol-core/src/config/mod.rs +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (C) 2023 Lily Lyons -// -// This file is part of Luminol. -// -// Luminol is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Luminol is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Luminol. If not, see . -use crate::prelude::*; - -mod command_db; -pub mod global; -pub mod project; - -pub use command_db::CommandDB; -pub use global::Config; - -#[derive(Default, Debug, Clone)] -#[allow(clippy::large_enum_variant)] -pub enum Project { - #[default] - Unloaded, - Loaded { - config: project::Config, - command_db: CommandDB, - game_ini: ini::Ini, - }, -} - -impl Project { - pub fn load() -> Result<(), String> { - let filesystem = &state!().filesystem; - - if !filesystem.exists(".luminol").map_err(|e| e.to_string())? { - filesystem - .create_dir(".luminol") - .map_err(|e| e.to_string())?; - } - - let config = match filesystem - .read_to_string(".luminol/config") - .ok() - .and_then(|s| ron::from_str(&s).ok()) - { - Some(c) => c, - None => { - let Some(editor_ver) = filesystem.detect_rm_ver() else { - return Err("Unable to detect RPG Maker version".to_string()); - }; - let config = project::Config { - editor_ver, - ..Default::default() - }; - filesystem - .write(".luminol/config", ron::to_string(&config).unwrap()) - .map_err(|e| e.to_string())?; - config - } - }; - - let command_db = match filesystem - .read_to_string(".luminol/commands") - .ok() - .and_then(|s| ron::from_str(&s).ok()) - { - Some(c) => c, - None => { - let command_db = CommandDB::new(config.editor_ver); - filesystem - .write(".luminol/commands", ron::to_string(&command_db).unwrap()) - .map_err(|e| e.to_string())?; - command_db - } - }; - - let game_ini = match filesystem - .read_to_string("Game.ini") - .ok() - .and_then(|i| ini::Ini::load_from_str_noescape(&i).ok()) - { - Some(i) => i, - None => { - let mut ini = ini::Ini::new(); - ini.with_section(Some("Game")) - .set("Library", "RGSS104E.dll") - .set("Scripts", &config.scripts_path) - .set("Title", &config.project_name) - .set("RTP1", "") - .set("RTP2", "") - .set("RTP3", ""); - - ini - } - }; - - *PROJECT.borrow_mut() = Project::Loaded { - config, - command_db, - game_ini, - }; - - Ok(()) - } - - pub fn save() -> Result<(), String> { - match &*PROJECT.borrow() { - Project::Unloaded => return Err("Project not loaded".to_string()), - Project::Loaded { - config, - command_db, - game_ini, - } => { - state!() - .filesystem - .write( - ".luminol/commands", - ron::to_string(command_db).map_err(|e| e.to_string())?, - ) - .map_err(|e| e.to_string())?; - - state!() - .filesystem - .write( - ".luminol/config", - ron::to_string(config).map_err(|e| e.to_string())?, - ) - .map_err(|e| e.to_string())?; - - let mut ini_file = state!() - .filesystem - .open_file("Game.ini", filesystem::OpenFlags::Create) - .map_err(|e| e.to_string())?; - game_ini - .write_to(&mut ini_file) - .map_err(|e| e.to_string())?; - } - } - - Ok(()) - } -} - -pub static PROJECT: AtomicRefCell = AtomicRefCell::new(Project::Unloaded); - -#[macro_export] -macro_rules! project_config { - () => {{ - AtomicRefMut::map($crate::config::PROJECT.borrow_mut(), |c| match c { - $crate::config::Project::Unloaded => panic!("Project not loaded"), - $crate::config::Project::Loaded { config, .. } => config, - }) - }}; -} - -#[macro_export] -macro_rules! command_db { - () => { - AtomicRefMut::map($crate::config::PROJECT.borrow_mut(), |c| match c { - $crate::config::Project::Unloaded => panic!("Project not loaded"), - $crate::config::Project::Loaded { command_db, .. } => command_db, - }) - }; -} - -#[macro_export] -macro_rules! game_ini { - () => { - AtomicRefMut::map($crate::config::PROJECT.borrow_mut(), |c| match c { - $crate::config::Project::Unloaded => panic!("Project not loaded"), - $crate::config::Project::Loaded { game_ini, .. } => game_ini, - }) - }; -} - -pub static GLOBAL: Lazy> = - Lazy::new(|| AtomicRefCell::new(global::Config::new())); - -#[macro_export] -macro_rules! global_config { - () => { - $crate::config::GLOBAL.borrow_mut() - }; -} - -#[derive( - Clone, - Copy, - PartialEq, - Eq, - Hash, - serde::Serialize, - serde::Deserialize, - strum::EnumIter, - strum::Display, - Debug -)] -#[allow(missing_docs)] -pub enum RGSSVer { - #[strum(to_string = "ModShot")] - ModShot, - #[strum(to_string = "mkxp-oneshot")] - MKXPOneShot, - #[strum(to_string = "rsgss")] - RSGSS, - #[strum(to_string = "mkxp")] - MKXP, - #[strum(to_string = "mkxp-freebird")] - MKXPFreebird, - #[strum(to_string = "mkxp-z")] - MKXPZ, - #[strum(to_string = "Stock RGSS1")] - RGSS1, -} - -#[derive( - Clone, - Copy, - PartialEq, - Eq, - Hash, - serde::Serialize, - serde::Deserialize, - strum::EnumIter, - strum::Display, - Default, - Debug -)] -#[allow(missing_docs)] -pub enum RMVer { - #[default] - #[strum(to_string = "RPG Maker XP")] - XP = 1, - #[strum(to_string = "RPG Maker VX")] - VX = 2, - #[strum(to_string = "RPG Maker VX Ace")] - Ace = 3, -} diff --git a/crates/luminol-core/src/config/project.rs b/crates/luminol-core/src/config/project.rs deleted file mode 100644 index cd0bf1a45..000000000 --- a/crates/luminol-core/src/config/project.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2023 Lily Lyons -// -// This file is part of Luminol. -// -// Luminol is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Luminol is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Luminol. If not, see . -// -// Additional permission under GNU GPL version 3 section 7 -// -// If you modify this Program, or any covered work, by linking or combining -// 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 super::{RGSSVer, RMVer}; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(default)] -/// Local luminol project config -#[allow(missing_docs)] -pub struct Config { - pub project_name: String, - pub scripts_path: String, - pub use_ron: bool, - pub rgss_ver: RGSSVer, - pub editor_ver: RMVer, - pub playtest_exe: String, - pub prefer_rgssad: bool, -} - -impl Default for Config { - fn default() -> Self { - Self { - project_name: String::new(), - scripts_path: "Scripts".to_string(), - use_ron: false, - rgss_ver: RGSSVer::RGSS1, - editor_ver: RMVer::XP, - playtest_exe: "game".to_string(), - prefer_rgssad: false, - } - } -} diff --git a/crates/luminol-core/src/filesystem/mod.rs b/crates/luminol-core/src/filesystem.rs similarity index 87% rename from crates/luminol-core/src/filesystem/mod.rs rename to crates/luminol-core/src/filesystem.rs index 7c45862da..42e511f77 100644 --- a/crates/luminol-core/src/filesystem/mod.rs +++ b/crates/luminol-core/src/filesystem.rs @@ -14,15 +14,13 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use std::io::prelude::*; - -mod erased; -mod host; -mod list; -mod path_cache; -pub mod project; - -mod archiver; +// +// Additional permission under GNU GPL version 3 section 7 +// +// If you modify this Program, or any covered work, by linking or combining +// 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. #[derive(thiserror::Error, Debug)] pub enum Error { @@ -50,12 +48,12 @@ pub struct Metadata { #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub struct DirEntry { - path: camino::Utf8PathBuf, - metadata: Metadata, + pub path: camino::Utf8PathBuf, + pub metadata: Metadata, } impl DirEntry { - fn new(path: camino::Utf8PathBuf, metadata: Metadata) -> Self { + pub fn new(path: camino::Utf8PathBuf, metadata: Metadata) -> Self { Self { path, metadata } } @@ -89,7 +87,7 @@ bitflags::bitflags! { } pub trait FileSystem: Send + Sync { - type File<'fs>: Read + Write + Seek + Send + Sync + 'fs + type File<'fs>: std::io::Read + std::io::Write + std::io::Seek + Send + Sync + 'fs where Self: 'fs; @@ -130,6 +128,8 @@ pub trait FileSystem: Send + Sync { /// Corresponds to [`std::fs::read()`]. /// Will open a file at the path and read the entire file into a buffer. fn read(&self, path: impl AsRef) -> Result, Error> { + use std::io::Read; + let path = path.as_ref(); let mut buf = Vec::with_capacity(self.metadata(path)?.size as usize); @@ -151,6 +151,8 @@ pub trait FileSystem: Send + Sync { path: impl AsRef, data: impl AsRef<[u8]>, ) -> Result<(), Error> { + use std::io::Write; + let mut file = self.open_file( path, OpenFlags::Write | OpenFlags::Truncate | OpenFlags::Create, diff --git a/crates/luminol-core/src/lib.rs b/crates/luminol-core/src/lib.rs index c4673830e..68cb01e58 100644 --- a/crates/luminol-core/src/lib.rs +++ b/crates/luminol-core/src/lib.rs @@ -1,10 +1,3 @@ -//! Luminol is a supercharged FOSS version of the RPG Maker XP editor. -//! -//! Authors: -//! Lily Madeline Lyons -//! -// #![warn(missing_docs)] - // Copyright (C) 2023 Lily Lyons // // This file is part of Luminol. @@ -29,50 +22,21 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -pub use prelude::*; - -/// The main Luminol application. -pub mod luminol; - -pub mod prelude; - -/// Audio related structs and funtions. -pub mod audio; - -pub mod config; - -pub mod cache; - -pub mod components; - -pub mod command_gen; - /// Floating windows to be displayed anywhere. -pub mod windows; +pub mod window; /// Stack defined windows that edit values. -pub mod modals; +pub mod modal; /// Tabs to be displayed in the center of Luminol. -pub mod tabs; +pub mod tab; /// Filesystem related structs. /// Swaps between filesystem_native and filesystem_wasm depending on the target arch. pub mod filesystem; -/// The code for handling lumi, the friendly world machine! -pub mod lumi; - -#[cfg(feature = "steamworks")] -pub mod steam; - -pub mod graphics; - -pub use luminol::Luminol; -use tabs::tab::Tab; - /// Embedded icon 256x256 in size. -pub const ICON: &[u8] = include_bytes!("../assets/icon-256.png"); +pub const ICON: &[u8] = include_bytes!("../../../assets/icon-256.png"); #[allow(missing_docs)] #[derive(Default)] @@ -90,60 +54,3 @@ pub enum Pencil { Rectangle, Fill, } - -/// Passed to windows and widgets when updating. -pub struct State { - /// Filesystem to be passed around. - pub filesystem: filesystem::project::FileSystem, - /// The data cache. - pub data_cache: data::Cache, - pub image_cache: image_cache::Cache, - pub atlas_cache: atlas::Cache, - /// Windows that are displayed. - pub windows: window::Windows, - /// Tabs that are displayed. - pub tabs: tabs::tab::Tabs>, - /// Audio that's played. - pub audio: audio::Audio, - /// Toasts to be displayed. - pub toasts: Toasts, - pub render_state: egui_wgpu::RenderState, - /// Toolbar state - pub toolbar: AtomicRefCell, -} - -static_assertions::assert_impl_all!(State: Send, Sync); - -impl State { - /// Create a new UpdateInfo. - pub fn new(render_state: egui_wgpu::RenderState) -> Self { - Self { - filesystem: filesystem::project::FileSystem::default(), - data_cache: data::Cache::default(), - image_cache: image_cache::Cache::default(), - atlas_cache: atlas::Cache::default(), - windows: windows::window::Windows::default(), - tabs: tab::Tabs::new("global_tabs", vec![Box::new(started::Tab::new())]), - audio: audio::Audio::default(), - toasts: Toasts::default(), - render_state, - toolbar: AtomicRefCell::default(), - } - } -} - -static STATE: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); - -#[allow(clippy::panic)] -fn set_state(info: State) { - if STATE.set(info).is_err() { - panic!("failed to set updateinfo") - } -} - -#[macro_export] -macro_rules! state { - () => { - $crate::STATE.get().expect("failed to get updateinfo") - }; -} diff --git a/crates/luminol-modals/src/modal.rs b/crates/luminol-core/src/modal.rs similarity index 100% rename from crates/luminol-modals/src/modal.rs rename to crates/luminol-core/src/modal.rs diff --git a/crates/luminol-tabs/src/tab.rs b/crates/luminol-core/src/tab.rs similarity index 93% rename from crates/luminol-tabs/src/tab.rs rename to crates/luminol-core/src/tab.rs index 0766b228c..71774a2e2 100644 --- a/crates/luminol-tabs/src/tab.rs +++ b/crates/luminol-core/src/tab.rs @@ -45,14 +45,14 @@ where /// Display all tabs. pub fn ui(&self, ui: &mut egui::Ui) { - egui_dock::DockArea::new(&mut self.tree.lock()) - .id(self.id) - .show_inside( - ui, - &mut TabViewer { - marker: std::marker::PhantomData, - }, - ); + // egui_dock::DockArea::new(&mut self.tree.lock()) + // .id(self.id) + // .show_inside( + // ui, + // &mut TabViewer { + // marker: std::marker::PhantomData, + // }, + // ); } /// Add a tab. diff --git a/crates/luminol-windows/src/window.rs b/crates/luminol-core/src/window.rs similarity index 100% rename from crates/luminol-windows/src/window.rs rename to crates/luminol-core/src/window.rs diff --git a/crates/luminol-data/Cargo.toml b/crates/luminol-data/Cargo.toml index e5ff27178..cee1032ff 100644 --- a/crates/luminol-data/Cargo.toml +++ b/crates/luminol-data/Cargo.toml @@ -19,3 +19,5 @@ slab.workspace = true strum.workspace = true paste.workspace = true camino.workspace = true + +luminol-core = { version = "0.1.0", path = "../luminol-core/" } diff --git a/crates/luminol-commands/src/lib.rs b/crates/luminol-data/src/commands.rs similarity index 100% rename from crates/luminol-commands/src/lib.rs rename to crates/luminol-data/src/commands.rs diff --git a/crates/luminol-data/src/data_cache.rs b/crates/luminol-data/src/data_cache.rs index d7d599685..1dbafc955 100644 --- a/crates/luminol-data/src/data_cache.rs +++ b/crates/luminol-data/src/data_cache.rs @@ -22,321 +22,36 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use crate::prelude::*; -use core::ops::{Deref, DerefMut}; +use crate::rpg; #[derive(Default, Debug)] -pub struct Cache { - state: AtomicRefCell, -} - -// Loaded is used 99% of the time. The size discrepancy is okay. -#[allow(clippy::large_enum_variant)] -#[derive(Default, Debug)] -enum State { - #[default] - Unloaded, - Loaded { - actors: AtomicRefCell, - animations: AtomicRefCell, - armors: AtomicRefCell, - classes: AtomicRefCell, - common_events: AtomicRefCell, - enemies: AtomicRefCell, - items: AtomicRefCell, - mapinfos: AtomicRefCell, - scripts: AtomicRefCell>, - skills: AtomicRefCell, - states: AtomicRefCell, - system: AtomicRefCell, - tilesets: AtomicRefCell, - troops: AtomicRefCell, - weapons: AtomicRefCell, - - maps: dashmap::DashMap, - }, -} +pub struct Cache {} impl Cache { /// Load all data required when opening a project. /// Does not load config. That is expected to have been loaded beforehand. pub fn load(&self) -> Result<(), String> { - let filesystem = &state!().filesystem; - let ext = self.rxdata_ext(); - - let mut scripts = None; - let scripts_paths = [ - project_config!().scripts_path.clone(), - "xScripts".to_string(), - "Scripts".to_string(), - ]; - for file in scripts_paths { - match filesystem.read_data(format!("Data/{file}.{ext}")) { - Ok(s) => { - scripts = Some(s); - project_config!().scripts_path = file; - break; - } - Err(e) => { - eprintln!("Error loading Data/{file}.{ext}: {e:#?}"); - } - } - } - let Some(scripts) = scripts else { - return Err("Unable to load scripts, tried scripts file from config, then xScripts, then Scripts".to_string()); - }; - - let actors = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Actors.{ext}")) - .map_err(|e| format!("Failed to load Actors.{ext}: {e}"))?, - ); - let animations = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Animations.{ext}")) - .map_err(|e| format!("Failed to load Animations.{ext}: {e}"))?, - ); - let armors = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Armors.{ext}")) - .map_err(|e| format!("Failed to load Armors.{ext}: {e}"))?, - ); - let classes = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Classes.{ext}")) - .map_err(|e| format!("Failed to load Classes.{ext}: {e}"))?, - ); - let common_events = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/CommonEvents.{ext}")) - .map_err(|e| format!("Failed to load CommonEvents.{ext}: {e}"))?, - ); - let enemies = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Enemies.{ext}")) - .map_err(|e| format!("Failed to load Enemies.{ext}: {e}"))?, - ); - let items = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Items.{ext}")) - .map_err(|e| format!("Failed to load Items.{ext}: {e}"))?, - ); - let mapinfos = AtomicRefCell::new( - filesystem - .read_data(format!("Data/MapInfos.{ext}")) - .map_err(|e| format!("Failed to load MapInfos.{ext}: {e}"))?, - ); - let skills = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Skills.{ext}")) - .map_err(|e| format!("Failed to load Skills.{ext}: {e}"))?, - ); - let states = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/States.{ext}")) - .map_err(|e| format!("Failed to load States.{ext}: {e}"))?, - ); - let system = AtomicRefCell::new( - filesystem - .read_data(format!("Data/System.{ext}")) - .map_err(|e| format!("Failed to load System.{ext}: {e}"))?, - ); - let tilesets = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Tilesets.{ext}")) - .map_err(|e| format!("Failed to load Tilesets.{ext}: {e}"))?, - ); - let troops = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Troops.{ext}")) - .map_err(|e| format!("Failed to load Troops.{ext}: {e}"))?, - ); - let weapons = AtomicRefCell::new( - filesystem - .read_nil_padded(format!("Data/Weapons.{ext}")) - .map_err(|e| format!("Failed to load Weapons.{ext}: {e}"))?, - ); - - *self.state.borrow_mut() = State::Loaded { - actors, - animations, - armors, - classes, - common_events, - enemies, - items, - mapinfos, - skills, - states, - system, - tilesets, - troops, - weapons, - - maps: Default::default(), - scripts: AtomicRefCell::new(scripts), - }; - - Ok(()) + todo!() } pub fn rxdata_ext(&self) -> &'static str { - match project_config!().editor_ver { - config::RMVer::XP => "rxdata", - config::RMVer::VX => "rvdata", - config::RMVer::Ace => "rvdata2", - } + todo!() } /// Save all cached data to disk. /// Will flush the cache too. pub fn save(&self) -> Result<(), String> { - config::Project::save()?; - - let filesystem = &state!().filesystem; - - let state = self.state.borrow(); - let State::Loaded { - actors, - animations, - armors, - classes, - common_events, - enemies, - items, - mapinfos, - scripts, - skills, - states, - system, - tilesets, - troops, - weapons, - maps, - } = &*state - else { - return Err("Project not loaded".to_string()); - }; - - let ext = self.rxdata_ext(); - - filesystem.save_nil_padded(format!("Data/Actors.{ext}"), &actors.borrow())?; - filesystem.save_nil_padded(format!("Data/Animations.{ext}"), &animations.borrow())?; - filesystem.save_nil_padded(format!("Data/Armors.{ext}"), &armors.borrow())?; - filesystem.save_nil_padded(format!("Data/Classes.{ext}"), &classes.borrow())?; - filesystem.save_nil_padded(format!("Data/CommonEvents.{ext}"), &common_events.borrow())?; - filesystem.save_nil_padded(format!("Data/Enemies.{ext}"), &enemies.borrow())?; - filesystem.save_nil_padded(format!("Data/Items.{ext}"), &items.borrow())?; - filesystem.save_data(format!("Data/MapInfos.{ext}"), &*mapinfos.borrow())?; - filesystem.save_nil_padded(format!("Data/Scripts.{ext}"), &scripts.borrow())?; - filesystem.save_nil_padded(format!("Data/Skills.{ext}"), &skills.borrow())?; - filesystem.save_nil_padded(format!("Data/States.{ext}"), &states.borrow())?; - filesystem.save_data(format!("Data/System.{ext}"), &*system.borrow())?; - filesystem.save_nil_padded(format!("Data/Tilesets.{ext}"), &tilesets.borrow())?; - filesystem.save_nil_padded(format!("Data/Troops.{ext}"), &troops.borrow())?; - filesystem.save_nil_padded(format!("Data/Weapons.{ext}"), &weapons.borrow())?; - - for entry in maps.iter() { - filesystem.save_data(format!("Data/Map{:0>3}.{ext}", entry.key()), entry.value())? - } - maps.clear(); - - Ok(()) + todo!() } - pub async fn create_project(&self, config: config::project::Config) -> Result<(), String> { - if let Some(path) = rfd::AsyncFileDialog::default().pick_folder().await { - let path = path.path().join(&config.project_name); - std::fs::create_dir(path).map_err(|e| e.to_string())?; - - let command_db = config::CommandDB::new(config.editor_ver); - - let mut game_ini = ini::Ini::new(); - game_ini - .with_section(Some("Game")) - .set("Library", "RGSS104E.dll") - .set("Scripts", &config.scripts_path) - .set("Title", &config.project_name) - .set("RTP1", "") - .set("RTP2", "") - .set("RTP3", ""); - - *config::PROJECT.borrow_mut() = config::Project::Loaded { - command_db, - config, - game_ini, - }; - - self.setup_defaults(); - self.save()?; - } else { - return Err("Cancelled picking a project directory".to_string()); - } - - Ok(()) + pub async fn create_project(&self) -> Result<(), String> { + todo!() } /// Setup default values // FIXME: Code jank pub fn setup_defaults(&self) { - let mut mapinfos = rpg::MapInfos::new(); - mapinfos.insert( - 1, - rpg::MapInfo { - parent_id: 0, - name: "Map 001".to_string(), - order: 0, - expanded: false, - scroll_x: 0, - scroll_y: 0, - }, - ); - let mapinfos = mapinfos.into(); - - let maps = dashmap::DashMap::new(); - maps.insert( - 1, - rpg::Map { - tileset_id: 1, - width: 20, - height: 15, - data: rmxp_types::Table3::new(20, 15, 3), - ..Default::default() - }, - ); - - let system = rpg::System { - magic_number: rand::random(), - ..Default::default() - } - .into(); - - let scripts = match project_config!().editor_ver { - config::RMVer::XP => alox_48::from_bytes(include_bytes!("Scripts.rxdata")).unwrap(), - config::RMVer::VX => todo!(), - config::RMVer::Ace => todo!(), - }; - let scripts = AtomicRefCell::new(scripts); - - *self.state.borrow_mut() = State::Loaded { - actors: AtomicRefCell::new(vec![rpg::Actor::default()]), - animations: AtomicRefCell::new(vec![rpg::Animation::default()]), - armors: AtomicRefCell::new(vec![rpg::Armor::default()]), - classes: AtomicRefCell::new(vec![rpg::Class::default()]), - common_events: AtomicRefCell::new(vec![rpg::CommonEvent::default()]), - enemies: AtomicRefCell::new(vec![rpg::Enemy::default()]), - items: AtomicRefCell::new(vec![rpg::Item::default()]), - skills: AtomicRefCell::new(vec![rpg::Skill::default()]), - states: AtomicRefCell::new(vec![rpg::State::default()]), - tilesets: AtomicRefCell::new(vec![rpg::Tileset::default()]), - troops: AtomicRefCell::new(vec![rpg::Troop::default()]), - weapons: AtomicRefCell::new(vec![rpg::Weapon::default()]), - - mapinfos, - maps, - system, - scripts, - }; + todo!() } } @@ -346,39 +61,8 @@ macro_rules! nested_ref_getter { );*) => { $( #[allow(unsafe_code, dead_code)] - pub fn $name<'a>(&'a self) -> impl core::ops::DerefMut + 'a { - struct _Ref<'b> { - _this_ref: atomic_refcell::AtomicRef<'b, State>, - _other_ref: atomic_refcell::AtomicRefMut<'b, $typ>, - } - impl<'b> core::ops::Deref for _Ref<'b> { - type Target = $typ; - - fn deref(&self) -> &Self::Target { - &self._other_ref - } - } - impl<'b> core::ops::DerefMut for _Ref<'b> { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self._other_ref - } - } - - let _this_ref = self.state.borrow(); - let _other_ref: atomic_refcell::AtomicRefMut<'a, $typ> = unsafe { - // See Self::map for safety - match &*(&*_this_ref as *const _) { - $( - $enum_type::$variant { $name, .. } => $name.borrow_mut(), - )+ - _ => panic!("Project not loaded"), - } - }; - - _Ref { - _this_ref, - _other_ref, - } + pub fn $name(&self) -> &mut $typ { + todo!() } )+ }; @@ -405,51 +89,8 @@ impl Cache { } /// Load a map. - #[allow(unsafe_code)] #[allow(clippy::panic)] - pub fn map<'a>(&'a self, id: usize) -> impl DerefMut + 'a { - struct Ref<'b> { - _state: atomic_refcell::AtomicRef<'b, State>, - map_ref: dashmap::mapref::one::RefMut<'b, usize, rpg::Map>, - } - impl<'b> Deref for Ref<'b> { - type Target = rpg::Map; - - fn deref(&self) -> &Self::Target { - &self.map_ref - } - } - impl<'b> DerefMut for Ref<'b> { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.map_ref - } - } - - let state = self.state.borrow(); - let State::Loaded { ref maps, .. } = &*state else { - panic!("project not loaded") - }; - //? # SAFETY - // For starters, this has been tested against miri. Miri is okay with it. - // Ref is self referential- map_ref borrows from _state. We need to store _state so it gets dropped at the same time as map_ref. - // If it didn't, map_ref would invalidate the refcell. We could unload the project, changing State while map_ref is live. Storing _state prevents this. - // Because the rust borrow checker isn't smart enough for this, we need to create an unbounded reference to maps to get a map out. We're not actually using this reference - // for any longer than it would be valid for (notice the fact that we assign map_ref a lifetime of 'a, which is the lifetime it should have anyway) so this is okay. - let map_ref: dashmap::mapref::one::RefMut<'a, _, _> = unsafe { - let unsafe_maps_ref: &dashmap::DashMap = &*(maps as *const _); - unsafe_maps_ref - .entry(id) - .or_try_insert_with(|| { - state!() - .filesystem - .read_data(format!("Data/Map{id:0>3}.{}", self.rxdata_ext())) - }) - .expect("failed to load map") // FIXME - }; - - Ref { - _state: state, - map_ref, - } + pub fn map(&self, _id: usize) -> &mut rpg::Map { + todo!() } } diff --git a/crates/luminol-data/src/lib.rs b/crates/luminol-data/src/lib.rs index c694fe458..12efc1997 100644 --- a/crates/luminol-data/src/lib.rs +++ b/crates/luminol-data/src/lib.rs @@ -13,6 +13,10 @@ mod rgss_structs; mod helpers; +pub mod data_cache; + +pub mod commands; + pub use helpers::*; pub use option_vec::OptionVec; pub use rgss_structs::{Color, Table1, Table2, Table3, Tone}; diff --git a/crates/luminol-filesystem/Cargo.toml b/crates/luminol-filesystem/Cargo.toml new file mode 100644 index 000000000..1293ba549 --- /dev/null +++ b/crates/luminol-filesystem/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "luminol-filesystem" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rfd = "0.12.0" + +thiserror.workspace = true +bitflags.workspace = true + +camino.workspace = true + +itertools.workspace = true + +dashmap.workspace = true + +egui.workspace = true + +serde.workspace = true +alox-48.workspace = true + +luminol-core = { version = "0.1.0", path = "../luminol-core/" } +luminol-data = { version = "0.1.0", path = "../luminol-data/" } +luminol-config = { version = "0.1.0", path = "../luminol-config/" } + +[target.'cfg(windows)'.dependencies] +winreg = "0.51.0" \ No newline at end of file diff --git a/crates/luminol-core/src/filesystem/archiver.rs b/crates/luminol-filesystem/src/archiver.rs similarity index 98% rename from crates/luminol-core/src/filesystem/archiver.rs rename to crates/luminol-filesystem/src/archiver.rs index f13391c9e..4afddc68f 100644 --- a/crates/luminol-core/src/filesystem/archiver.rs +++ b/crates/luminol-filesystem/src/archiver.rs @@ -14,12 +14,12 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use super::FileSystem as FileSystemTrait; -use super::{DirEntry, Error, Metadata, OpenFlags}; use itertools::Itertools; use std::io::{prelude::*, Cursor, SeekFrom}; +use luminol_core::filesystem::{DirEntry, Error, Metadata, OpenFlags}; + #[derive(Debug, Default)] pub struct FileSystem { files: dashmap::DashMap, @@ -236,7 +236,7 @@ impl std::io::Seek for File { } } -impl FileSystemTrait for FileSystem { +impl luminol_core::filesystem::FileSystem for FileSystem { type File<'fs> = File where Self: 'fs; fn open_file( @@ -263,7 +263,7 @@ impl FileSystemTrait for FileSystem { magic = magic.wrapping_mul(7).wrapping_add(3); } - *byte ^= bytemuck::cast::<_, [u8; 4]>(magic)[j]; + *byte ^= magic.to_le_bytes()[j]; j += 1; } diff --git a/crates/luminol-core/src/filesystem/erased.rs b/crates/luminol-filesystem/src/erased.rs similarity index 96% rename from crates/luminol-core/src/filesystem/erased.rs rename to crates/luminol-filesystem/src/erased.rs index db4379343..9e3791e75 100644 --- a/crates/luminol-core/src/filesystem/erased.rs +++ b/crates/luminol-filesystem/src/erased.rs @@ -14,7 +14,7 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use super::{DirEntry, Error, FileSystem, Metadata, OpenFlags}; +use luminol_core::filesystem::{DirEntry, Error, FileSystem, Metadata, OpenFlags}; pub trait File: std::io::Read + std::io::Write + std::io::Seek + Send + Sync {} impl File for T where T: std::io::Read + std::io::Write + std::io::Seek + Send + Sync {} @@ -51,7 +51,7 @@ pub trait ErasedFilesystem: Send + Sync { impl ErasedFilesystem for T where - T: FileSystem, + T: luminol_core::filesystem::FileSystem, { fn open_file( &self, @@ -107,7 +107,7 @@ where } } -impl FileSystem for dyn ErasedFilesystem { +impl luminol_core::filesystem::FileSystem for dyn ErasedFilesystem { type File<'fs> = Box where Self: 'fs; fn open_file( diff --git a/crates/luminol-core/src/filesystem/host.rs b/crates/luminol-filesystem/src/host.rs similarity index 96% rename from crates/luminol-core/src/filesystem/host.rs rename to crates/luminol-filesystem/src/host.rs index 52d06035c..321fede88 100644 --- a/crates/luminol-core/src/filesystem/host.rs +++ b/crates/luminol-filesystem/src/host.rs @@ -14,10 +14,11 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use super::{DirEntry, Error, Metadata, OpenFlags}; use itertools::Itertools; use std::fs::File; +use luminol_core::filesystem::{DirEntry, Error, Metadata, OpenFlags}; + #[derive(Debug, Clone)] pub struct FileSystem { root_path: camino::Utf8PathBuf, @@ -35,7 +36,7 @@ impl FileSystem { } } -impl super::FileSystem for FileSystem { +impl luminol_core::filesystem::FileSystem for FileSystem { type File<'fs> = File where Self: 'fs; fn open_file( diff --git a/crates/luminol-filesystem/src/lib.rs b/crates/luminol-filesystem/src/lib.rs new file mode 100644 index 000000000..fda1c32bd --- /dev/null +++ b/crates/luminol-filesystem/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright (C) 2023 Lily Lyons +// +// This file is part of Luminol. +// +// Luminol is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Luminol is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Luminol. If not, see . +use std::io::prelude::*; + +mod erased; +mod host; +mod list; +mod path_cache; +pub mod project; + +mod archiver; diff --git a/crates/luminol-core/src/filesystem/list.rs b/crates/luminol-filesystem/src/list.rs similarity index 95% rename from crates/luminol-core/src/filesystem/list.rs rename to crates/luminol-filesystem/src/list.rs index 20725c287..3912c1e4a 100644 --- a/crates/luminol-core/src/filesystem/list.rs +++ b/crates/luminol-filesystem/src/list.rs @@ -15,9 +15,9 @@ // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . use super::erased::{ErasedFilesystem, File}; -use super::FileSystem as FileSystemTrait; -use super::{DirEntry, Error, Metadata, OpenFlags}; + use itertools::Itertools; +use luminol_core::filesystem::{DirEntry, Error, Metadata, OpenFlags}; #[derive(Default)] pub struct FileSystem { @@ -29,12 +29,12 @@ impl FileSystem { Self::default() } - pub fn push(&mut self, fs: impl FileSystemTrait + 'static) { + pub fn push(&mut self, fs: impl luminol_core::filesystem::FileSystem + 'static) { self.filesystems.push(Box::new(fs)) } } -impl FileSystemTrait for FileSystem { +impl luminol_core::filesystem::FileSystem for FileSystem { type File<'fs> = Box where Self: 'fs; fn open_file( diff --git a/crates/luminol-core/src/filesystem/overlay.rs b/crates/luminol-filesystem/src/overlay.rs similarity index 100% rename from crates/luminol-core/src/filesystem/overlay.rs rename to crates/luminol-filesystem/src/overlay.rs diff --git a/crates/luminol-core/src/filesystem/path_cache.rs b/crates/luminol-filesystem/src/path_cache.rs similarity index 93% rename from crates/luminol-core/src/filesystem/path_cache.rs rename to crates/luminol-filesystem/src/path_cache.rs index 90009be9d..d334f452b 100644 --- a/crates/luminol-core/src/filesystem/path_cache.rs +++ b/crates/luminol-filesystem/src/path_cache.rs @@ -14,8 +14,8 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use super::FileSystem as FileSystemTrait; -use super::{DirEntry, Error, Metadata, OpenFlags}; + +use luminol_core::filesystem::{DirEntry, Error, Metadata, OpenFlags}; #[derive(Debug, Clone)] pub struct FileSystem { @@ -25,7 +25,7 @@ pub struct FileSystem { impl FileSystem where - F: FileSystemTrait, + F: luminol_core::filesystem::FileSystem, { pub fn new(fs: F) -> Result { let this = FileSystem { @@ -42,12 +42,12 @@ where pub fn regen_cache(&self) -> Result<(), Error> { fn read_dir_recursive( - fs: &(impl FileSystemTrait + ?Sized), + fs: &(impl luminol_core::filesystem::FileSystem + ?Sized), path: impl AsRef, mut f: impl FnMut(&camino::Utf8Path), ) -> Result<(), Error> { fn internal( - fs: &(impl FileSystemTrait + ?Sized), + fs: &(impl luminol_core::filesystem::FileSystem + ?Sized), path: impl AsRef, f: &mut impl FnMut(&camino::Utf8Path), ) -> Result<(), Error> { @@ -107,9 +107,9 @@ pub fn to_lowercase(p: impl AsRef) -> camino::Utf8PathBuf { p.as_ref().as_str().to_lowercase().into() } -impl FileSystemTrait for FileSystem +impl luminol_core::filesystem::FileSystem for FileSystem where - F: FileSystemTrait, + F: luminol_core::filesystem::FileSystem, { type File<'fs> = F::File<'fs> where Self: 'fs; diff --git a/crates/luminol-core/src/filesystem/project.rs b/crates/luminol-filesystem/src/project.rs similarity index 59% rename from crates/luminol-core/src/filesystem/project.rs rename to crates/luminol-filesystem/src/project.rs index 7db468460..9ab548076 100644 --- a/crates/luminol-core/src/filesystem/project.rs +++ b/crates/luminol-filesystem/src/project.rs @@ -14,18 +14,13 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use crate::prelude::*; -use super::FileSystem as FileSystemTrait; -use super::{archiver, host, list, path_cache, DirEntry, Error, Metadata, OpenFlags}; +use super::{archiver, host, list, path_cache}; +use luminol_core::filesystem::FileSystem as _; +use luminol_core::filesystem::{DirEntry, Error, Metadata, OpenFlags}; #[derive(Default)] -pub struct FileSystem { - state: AtomicRefCell, -} - -#[derive(Default)] -enum State { +enum FileSystem { #[default] Unloaded, HostLoaded(host::FileSystem), @@ -35,17 +30,13 @@ enum State { }, } -#[ouroboros::self_referencing] -pub struct File<'fs> { - state: AtomicRef<'fs, State>, - #[borrows(state)] - #[not_covariant] - file: FileType<'this>, -} - -enum FileType<'fs> { - Host(::File<'fs>), - Loaded( as FileSystemTrait>::File<'fs>), +enum File<'fs> { + Host(::File<'fs>), + Loaded( + as luminol_core::filesystem::FileSystem>::File< + 'fs, + >, + ), } impl FileSystem { @@ -69,7 +60,7 @@ impl FileSystem { let data = self.read(path).map_err(|e| e.to_string())?; alox_48::Deserializer::new(&data) - .and_then(|mut de| rmxp_types::nil_padded::deserialize(&mut de)) + .and_then(|mut de| luminol_data::nil_padded::deserialize(&mut de)) .map_err(|e| e.to_string()) } @@ -90,74 +81,48 @@ impl FileSystem { T: serde::ser::Serialize, { let mut ser = alox_48::Serializer::new(); - rmxp_types::nil_padded::serialize(data, &mut ser).map_err(|e| e.to_string())?; + luminol_data::nil_padded::serialize(data, &mut ser).map_err(|e| e.to_string())?; self.write(path, ser.output).map_err(|e| e.to_string()) } pub fn project_path(&self) -> Option { - let state = self.state.borrow(); - match &*state { - State::Unloaded => None, - State::HostLoaded(h) => Some(h.root_path().to_path_buf()), - State::Loaded { project_path, .. } => Some(project_path.clone()), + match self { + FileSystem::Unloaded => None, + FileSystem::HostLoaded(h) => Some(h.root_path().to_path_buf()), + FileSystem::Loaded { project_path, .. } => Some(project_path.clone()), } } pub fn project_loaded(&self) -> bool { - !matches!(&*self.state.borrow(), State::Unloaded) + !matches!(self, FileSystem::Unloaded) } - pub fn unload_project(&self) { - *self.state.borrow_mut() = State::Unloaded; + pub fn unload_project(&mut self) { + *self = FileSystem::Unloaded; } - pub fn detect_rm_ver(&self) -> Option { - if self.exists("Data/Actors.rxdata").ok()? { - return Some(config::RMVer::XP); - } - - if self.exists("Data/Actors.rvdata").ok()? { - return Some(config::RMVer::VX); - } - - if self.exists("Data/Actors.rvdata2").ok()? { - return Some(config::RMVer::Ace); - } - - for path in self.read_dir("").ok()? { - let path = path.path(); - if path.extension() == Some("rgssad") { - return Some(config::RMVer::XP); - } - - if path.extension() == Some("rgss2a") { - return Some(config::RMVer::VX); - } - - if path.extension() == Some("rgss3a") { - return Some(config::RMVer::Ace); - } - } - - None - } - - pub async fn spawn_project_file_picker(&self) -> Result<(), String> { + pub async fn spawn_project_file_picker( + &mut self, + project_config: &mut Option, + global_config: &mut luminol_config::global::Config, + ) -> Result<(), String> { if let Some(path) = rfd::AsyncFileDialog::default() .add_filter("project file", &["rxproj", "rvproj", "rvproj2", "lumproj"]) .pick_file() .await { - self.load_project(path.path()) + self.load_project(project_config, global_config, path.path()) } else { Err("Cancelled loading project".to_string()) } } #[cfg(windows)] - fn find_rtp_paths() -> Vec { - let ini = game_ini!(); - let Some(section) = ini.section(Some("Game")) else { + fn find_rtp_paths( + config: &luminol_config::project::Config, + global_config: &luminol_config::global::Config, + ) -> Vec { + let Some(section) = config.game_ini.section(Some("Game")) else { return vec![]; }; let mut paths = vec![]; @@ -206,7 +171,7 @@ impl FileSystem { } } - if let Some(path) = global_config!().rtp_paths.get(rtp) { + if let Some(path) = global_config.rtp_paths.get(rtp) { let path = camino::Utf8PathBuf::from(path); if path.exists() { paths.push(path); @@ -226,7 +191,7 @@ impl FileSystem { } #[cfg(not(windows))] - fn find_rtp_paths() -> Vec { + fn find_rtp_paths(config: &luminol_config::project::Config) -> Vec { let ini = game_ini!(); let Some(section) = ini.section(Some("Game")) else { return vec![]; @@ -260,19 +225,24 @@ impl FileSystem { paths } - pub fn load_project(&self, project_path: impl AsRef) -> Result<(), String> { + pub fn load_project( + &mut self, + project_config: &mut Option, + global_config: &mut luminol_config::global::Config, + project_path: impl AsRef, + ) -> Result<(), String> { let original_path = camino::Utf8Path::from_path(project_path.as_ref()).unwrap(); let path = original_path.parent().unwrap_or(original_path); - *self.state.borrow_mut() = State::HostLoaded(host::FileSystem::new(path)); + *self = FileSystem::HostLoaded(host::FileSystem::new(path)); - config::Project::load()?; + let config = luminol_config::project::Config::load(self)?; let mut list = list::FileSystem::new(); list.push(host::FileSystem::new(path)); - for path in Self::find_rtp_paths() { + for path in Self::find_rtp_paths(&config, &global_config) { list.push(host::FileSystem::new(path)) } @@ -284,42 +254,43 @@ impl FileSystem { let path_cache = path_cache::FileSystem::new(list).map_err(|e| e.to_string())?; - *self.state.borrow_mut() = State::Loaded { + *self = FileSystem::Loaded { filesystem: path_cache, project_path: path.to_path_buf(), }; - let mut projects: std::collections::VecDeque<_> = global_config!() + if let Err(e) = state!().data_cache.load() { + *self = FileSystem::Unloaded; + return Err(e); + } + + let mut projects: std::collections::VecDeque<_> = global_config .recent_projects .iter() .filter(|p| p.as_str() != original_path) .cloned() .collect(); projects.push_front(original_path.to_string()); - global_config!().recent_projects = projects; + global_config.recent_projects = projects; - if let Err(e) = state!().data_cache.load() { - *self.state.borrow_mut() = State::Unloaded; - return Err(e); - } + *project_config = Some(config); Ok(()) } pub fn debug_ui(&self, ui: &mut egui::Ui) { - let state = self.state.borrow(); - match &*state { - State::Unloaded => { + match self { + FileSystem::Unloaded => { ui.label("Unloaded"); } - State::HostLoaded(fs) => { + FileSystem::HostLoaded(fs) => { ui.label("Host Filesystem Loaded"); ui.horizontal(|ui| { ui.label("Project path: "); ui.label(fs.root_path().as_str()); }); } - State::Loaded { filesystem, .. } => { + FileSystem::Loaded { filesystem, .. } => { ui.label("Loaded"); filesystem.debug_ui(ui); } @@ -329,67 +300,67 @@ impl FileSystem { impl<'fs> std::io::Write for File<'fs> { fn write(&mut self, buf: &[u8]) -> std::io::Result { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.write(buf), - FileType::Loaded(f) => f.write(buf), - }) + match self { + File::Host(f) => f.write(buf), + File::Loaded(f) => f.write(buf), + } } fn write_vectored(&mut self, bufs: &[std::io::IoSlice<'_>]) -> std::io::Result { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.write_vectored(bufs), - FileType::Loaded(f) => f.write_vectored(bufs), - }) + match self { + File::Host(f) => f.write_vectored(bufs), + File::Loaded(f) => f.write_vectored(bufs), + } } fn flush(&mut self) -> std::io::Result<()> { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.flush(), - FileType::Loaded(f) => f.flush(), - }) + match self { + File::Host(f) => f.flush(), + File::Loaded(f) => f.flush(), + } } } impl<'fs> std::io::Read for File<'fs> { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.read(buf), - FileType::Loaded(f) => f.read(buf), - }) + match self { + File::Host(f) => f.read(buf), + File::Loaded(f) => f.read(buf), + } } fn read_vectored(&mut self, bufs: &mut [std::io::IoSliceMut<'_>]) -> std::io::Result { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.read_vectored(bufs), - FileType::Loaded(f) => f.read_vectored(bufs), - }) + match self { + File::Host(f) => f.read_vectored(bufs), + File::Loaded(f) => f.read_vectored(bufs), + } } fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.read_exact(buf), - FileType::Loaded(f) => f.read_exact(buf), - }) + match self { + File::Host(f) => f.read_exact(buf), + File::Loaded(f) => f.read_exact(buf), + } } } impl<'fs> std::io::Seek for File<'fs> { fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.seek(pos), - FileType::Loaded(f) => f.seek(pos), - }) + match self { + File::Host(f) => f.seek(pos), + File::Loaded(f) => f.seek(pos), + } } fn stream_position(&mut self) -> std::io::Result { - self.with_file_mut(|f| match f { - FileType::Host(f) => f.stream_position(), - FileType::Loaded(f) => f.stream_position(), - }) + match self { + File::Host(f) => f.stream_position(), + File::Loaded(f) => f.stream_position(), + } } } -impl FileSystemTrait for FileSystem { +impl luminol_core::filesystem::FileSystem for FileSystem { type File<'fs> = File<'fs> where Self: 'fs; fn open_file( @@ -397,25 +368,18 @@ impl FileSystemTrait for FileSystem { path: impl AsRef, flags: OpenFlags, ) -> Result, Error> { - let state = self.state.borrow(); - File::try_new(state, |state| { - // - match &**state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.open_file(path, flags).map(FileType::Host), - State::Loaded { filesystem: f, .. } => { - f.open_file(path, flags).map(FileType::Loaded) - } - } - }) + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.open_file(path, flags).map(File::Host), + FileSystem::Loaded { filesystem: f, .. } => f.open_file(path, flags).map(File::Loaded), + } } fn metadata(&self, path: impl AsRef) -> Result { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.metadata(path), - State::Loaded { filesystem: f, .. } => f.metadata(path), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.metadata(path), + FileSystem::Loaded { filesystem: f, .. } => f.metadata(path), } } @@ -424,56 +388,50 @@ impl FileSystemTrait for FileSystem { from: impl AsRef, to: impl AsRef, ) -> Result<(), Error> { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.rename(from, to), - State::Loaded { filesystem, .. } => filesystem.rename(from, to), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.rename(from, to), + FileSystem::Loaded { filesystem, .. } => filesystem.rename(from, to), } } fn exists(&self, path: impl AsRef) -> Result { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.exists(path), - State::Loaded { filesystem, .. } => filesystem.exists(path), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.exists(path), + FileSystem::Loaded { filesystem, .. } => filesystem.exists(path), } } fn create_dir(&self, path: impl AsRef) -> Result<(), Error> { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.create_dir(path), - State::Loaded { filesystem, .. } => filesystem.create_dir(path), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.create_dir(path), + FileSystem::Loaded { filesystem, .. } => filesystem.create_dir(path), } } fn remove_dir(&self, path: impl AsRef) -> Result<(), Error> { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.remove_dir(path), - State::Loaded { filesystem, .. } => filesystem.remove_dir(path), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.remove_dir(path), + FileSystem::Loaded { filesystem, .. } => filesystem.remove_dir(path), } } fn remove_file(&self, path: impl AsRef) -> Result<(), Error> { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.remove_file(path), - State::Loaded { filesystem, .. } => filesystem.remove_file(path), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.remove_file(path), + FileSystem::Loaded { filesystem, .. } => filesystem.remove_file(path), } } fn read_dir(&self, path: impl AsRef) -> Result, Error> { - let state = self.state.borrow(); - match &*state { - State::Unloaded => Err(Error::NotLoaded), - State::HostLoaded(f) => f.read_dir(path), - State::Loaded { filesystem, .. } => filesystem.read_dir(path), + match self { + FileSystem::Unloaded => Err(Error::NotLoaded), + FileSystem::HostLoaded(f) => f.read_dir(path), + FileSystem::Loaded { filesystem, .. } => filesystem.read_dir(path), } } } diff --git a/crates/luminol-graphics/Cargo.toml b/crates/luminol-graphics/Cargo.toml index 71b688c7b..beb46d755 100644 --- a/crates/luminol-graphics/Cargo.toml +++ b/crates/luminol-graphics/Cargo.toml @@ -13,6 +13,7 @@ image = "0.24.7" glam = { version = "0.24.2", features = ["bytemuck"] } egui.workspace = true +egui_extras.workspace = true egui-wgpu.workspace = true wgpu.workspace = true @@ -25,3 +26,5 @@ slab.workspace = true bytemuck.workspace = true itertools.workspace = true + +camino.workspace = true diff --git a/crates/luminol-graphics/src/atlas_cache.rs b/crates/luminol-graphics/src/atlas_cache.rs index fcd721fd9..aa6b73de5 100644 --- a/crates/luminol-graphics/src/atlas_cache.rs +++ b/crates/luminol-graphics/src/atlas_cache.rs @@ -14,7 +14,7 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use crate::prelude::*; +use crate::primitives; #[derive(Default, Debug)] pub struct Cache { @@ -22,7 +22,10 @@ pub struct Cache { } impl Cache { - pub fn load_atlas(&self, tileset: &rpg::Tileset) -> Result { + pub fn load_atlas( + &self, + tileset: &luminol_data::rpg::Tileset, + ) -> Result { Ok(self .atlases .entry(tileset.id) @@ -30,7 +33,10 @@ impl Cache { .clone()) } - pub fn reload_atlas(&self, tileset: &rpg::Tileset) -> Result { + pub fn reload_atlas( + &self, + tileset: &luminol_data::rpg::Tileset, + ) -> Result { Ok(self .atlases .entry(tileset.id) diff --git a/crates/luminol-graphics/src/event.rs b/crates/luminol-graphics/src/event.rs index b402b9dea..7983881c5 100644 --- a/crates/luminol-graphics/src/event.rs +++ b/crates/luminol-graphics/src/event.rs @@ -14,8 +14,10 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . +use once_cell::sync::OnceCell; +use std::sync::Arc; -use crate::prelude::*; +use crate::primitives; #[derive(Debug)] pub struct Event { @@ -33,7 +35,10 @@ type ResourcesSlab = slab::Slab>; impl Event { // code smell, fix - pub fn new(event: &rpg::Event, atlas: &primitives::Atlas) -> Result, String> { + pub fn new( + event: &luminol_data::rpg::Event, + atlas: &primitives::Atlas, + ) -> Result, String> { let Some(page) = event.pages.first() else { return Err("event does not have first page".to_string()); }; diff --git a/crates/luminol-graphics/src/image_cache.rs b/crates/luminol-graphics/src/image_cache.rs index ad30612b4..c68bcd456 100644 --- a/crates/luminol-graphics/src/image_cache.rs +++ b/crates/luminol-graphics/src/image_cache.rs @@ -22,10 +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 eframe::wgpu::util::DeviceExt; -use once_cell::sync::Lazy; +use std::sync::Arc; -use crate::prelude::*; +use egui_extras::RetainedImage; +use once_cell::sync::Lazy; +use wgpu::util::DeviceExt; #[derive(Default)] pub struct Cache { diff --git a/crates/luminol-graphics/src/primitives/tiles/mod.rs b/crates/luminol-graphics/src/primitives/tiles/mod.rs index ec2f41f94..e7fb13e80 100644 --- a/crates/luminol-graphics/src/primitives/tiles/mod.rs +++ b/crates/luminol-graphics/src/primitives/tiles/mod.rs @@ -14,7 +14,6 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use crate::prelude::*; pub use atlas::Atlas; @@ -36,7 +35,7 @@ pub struct Tiles { } impl Tiles { - pub fn new(atlas: Atlas, tiles: &Table3) -> Self { + pub fn new(atlas: Atlas, tiles: &luminol_data::Table3) -> Self { let autotiles = Autotiles::new(&atlas); let instances = Instances::new(tiles, atlas.atlas_texture.size()); @@ -53,7 +52,7 @@ impl Tiles { pub fn draw<'rpass>( &'rpass self, - viewport: &primitives::Viewport, + viewport: &crate::primitives::Viewport, enabled_layers: &[bool], selected_layer: Option, render_pass: &mut wgpu::RenderPass<'rpass>, diff --git a/crates/luminol-graphics/src/primitives/tiles/shader.rs b/crates/luminol-graphics/src/primitives/tiles/shader.rs index 6e68d88be..0017421b2 100644 --- a/crates/luminol-graphics/src/primitives/tiles/shader.rs +++ b/crates/luminol-graphics/src/primitives/tiles/shader.rs @@ -14,10 +14,10 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use crate::prelude::*; +use once_cell::sync::Lazy; use super::instance::Instances; -use primitives::Vertex; +use crate::primitives::Vertex; #[derive(Debug)] pub struct Shader { @@ -37,7 +37,7 @@ impl Shader { .device .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Tilemap Render Pipeline Layout"), - bind_group_layouts: &[image_cache::Cache::bind_group_layout()], + bind_group_layouts: &[crate::image_cache::Cache::bind_group_layout()], push_constant_ranges: &[ // Viewport + Autotiles wgpu::PushConstantRange { diff --git a/crates/luminol-commands/src/command_gen/mod.rs b/crates/luminol-windows/src/command_gen/mod.rs similarity index 96% rename from crates/luminol-commands/src/command_gen/mod.rs rename to crates/luminol-windows/src/command_gen/mod.rs index 1e30f4809..7cb6fef83 100644 --- a/crates/luminol-commands/src/command_gen/mod.rs +++ b/crates/luminol-windows/src/command_gen/mod.rs @@ -14,12 +14,10 @@ // // You should have received a copy of the GNU General Public License // along with Luminol. If not, see . -use command_lib::{CommandDescription, CommandKind, Index, Parameter}; +use super::{CommandDescription, CommandKind, Index, Parameter}; use ui_example::UiExample; -use crate::prelude::*; - pub mod parameter_ui; pub mod ui_example; @@ -28,15 +26,6 @@ pub struct CommandGeneratorWindow { ui_examples: Vec, } -impl Default for CommandGeneratorWindow { - fn default() -> Self { - Self { - commands: command_db!().user.clone(), - ui_examples: vec![], - } - } -} - impl CommandGeneratorWindow { /// Updates all of the parameter indexes, if they are assumed fn recalculate_parameter_index(parameter: &mut Parameter, passed_index: &mut u8) { @@ -80,7 +69,7 @@ impl CommandGeneratorWindow { } } -impl window::Window for CommandGeneratorWindow { +impl luminol_core::window::Window for CommandGeneratorWindow { fn name(&self) -> String { String::from("Luminol Command Maker") } diff --git a/crates/luminol-commands/src/command_gen/parameter_ui.rs b/crates/luminol-windows/src/command_gen/parameter_ui.rs similarity index 100% rename from crates/luminol-commands/src/command_gen/parameter_ui.rs rename to crates/luminol-windows/src/command_gen/parameter_ui.rs diff --git a/crates/luminol-commands/src/command_gen/ui_example.rs b/crates/luminol-windows/src/command_gen/ui_example.rs similarity index 100% rename from crates/luminol-commands/src/command_gen/ui_example.rs rename to crates/luminol-windows/src/command_gen/ui_example.rs