From e2902f91e3b4afb0fb21b0dfbc164b0f0a973533 Mon Sep 17 00:00:00 2001 From: Dukantic Date: Tue, 19 Aug 2025 17:45:42 +0200 Subject: [PATCH] use folder manager for load, save and sound --- Cargo.lock | 686 ++++++++++++++++++++++--- Cargo.toml | 2 + assets/{tick.ogg => Default_Sound.ogg} | Bin src/gui.rs | 61 +-- src/main.rs | 117 +++-- src/message.rs | 5 +- src/music.rs | 14 +- src/polygon_draw.rs | 17 +- src/utils.rs | 2 +- 9 files changed, 743 insertions(+), 161 deletions(-) rename assets/{tick.ogg => Default_Sound.ogg} (100%) diff --git a/Cargo.lock b/Cargo.lock index 1005201..b5ed551 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,6 +172,28 @@ dependencies = [ "libloading 0.7.4", ] +[[package]] +name = "ashpd" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbdf310d77fd3aaee6ea2093db7011dc2d35d2eb3481e5607f1f8d942ed99df" +dependencies = [ + "async-fs", + "async-net", + "enumflags2", + "futures-channel", + "futures-util", + "rand 0.9.2", + "raw-window-handle", + "serde", + "serde_repr", + "url", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "zbus 5.9.0", +] + [[package]] name = "async-broadcast" version = "0.7.2" @@ -251,6 +273,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-net" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" +dependencies = [ + "async-io", + "blocking", + "futures-lite", +] + [[package]] name = "async-process" version = "2.3.0" @@ -415,7 +448,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "objc2", + "objc2 0.5.2", +] + +[[package]] +name = "block2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2" +dependencies = [ + "objc2 0.6.2", ] [[package]] @@ -588,9 +630,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7f4aaa047ba3c3630b080bb9860894732ff23e2aee290a418909aa6d5df38f" dependencies = [ - "objc2", - "objc2-app-kit", - "objc2-foundation", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -907,7 +949,7 @@ dependencies = [ "rust-ini", "web-sys", "winreg", - "zbus", + "zbus 4.4.0", ] [[package]] @@ -964,6 +1006,29 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "dispatch2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" +dependencies = [ + "bitflags 2.9.1", + "block2 0.6.1", + "libc", + "objc2 0.6.2", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "dlib" version = "0.5.2" @@ -1236,6 +1301,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.31" @@ -1818,6 +1892,113 @@ dependencies = [ "winit", ] +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.9.0" @@ -2014,6 +2195,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + [[package]] name = "lock_api" version = "0.4.12" @@ -2253,6 +2440,19 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "cfg_aliases 0.2.1", + "libc", + "memoffset", +] + [[package]] name = "nom" version = "7.1.3" @@ -2351,6 +2551,15 @@ dependencies = [ "objc2-encode", ] +[[package]] +name = "objc2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc" +dependencies = [ + "objc2-encode", +] + [[package]] name = "objc2-app-kit" version = "0.2.2" @@ -2358,15 +2567,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ "bitflags 2.9.1", - "block2", + "block2 0.5.1", "libc", - "objc2", + "objc2 0.5.2", "objc2-core-data", "objc2-core-image", - "objc2-foundation", + "objc2-foundation 0.2.2", "objc2-quartz-core", ] +[[package]] +name = "objc2-app-kit" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc" +dependencies = [ + "bitflags 2.9.1", + "block2 0.6.1", + "objc2 0.6.2", + "objc2-foundation 0.3.1", +] + [[package]] name = "objc2-cloud-kit" version = "0.2.2" @@ -2374,10 +2595,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ "bitflags 2.9.1", - "block2", - "objc2", + "block2 0.5.1", + "objc2 0.5.2", "objc2-core-location", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -2386,9 +2607,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" dependencies = [ - "block2", - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -2398,9 +2619,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ "bitflags 2.9.1", - "block2", - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" +dependencies = [ + "bitflags 2.9.1", + "dispatch2", + "objc2 0.6.2", ] [[package]] @@ -2409,9 +2641,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" dependencies = [ - "block2", - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "objc2-metal", ] @@ -2421,10 +2653,10 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" dependencies = [ - "block2", - "objc2", + "block2 0.5.1", + "objc2 0.5.2", "objc2-contacts", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -2440,10 +2672,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ "bitflags 2.9.1", - "block2", + "block2 0.5.1", "dispatch", "libc", - "objc2", + "objc2 0.5.2", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" +dependencies = [ + "bitflags 2.9.1", + "objc2 0.6.2", + "objc2-core-foundation", ] [[package]] @@ -2452,10 +2695,10 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" dependencies = [ - "block2", - "objc2", - "objc2-app-kit", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -2465,9 +2708,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ "bitflags 2.9.1", - "block2", - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -2477,9 +2720,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ "bitflags 2.9.1", - "block2", - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "objc2-metal", ] @@ -2489,8 +2732,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" dependencies = [ - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -2500,13 +2743,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ "bitflags 2.9.1", - "block2", - "objc2", + "block2 0.5.1", + "objc2 0.5.2", "objc2-cloud-kit", "objc2-core-data", "objc2-core-image", "objc2-core-location", - "objc2-foundation", + "objc2-foundation 0.2.2", "objc2-link-presentation", "objc2-quartz-core", "objc2-symbols", @@ -2520,9 +2763,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" dependencies = [ - "block2", - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -2532,10 +2775,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ "bitflags 2.9.1", - "block2", - "objc2", + "block2 0.5.1", + "objc2 0.5.2", "objc2-core-location", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -2707,6 +2950,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2730,7 +2979,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", - "rand", + "rand 0.8.5", ] [[package]] @@ -2832,6 +3081,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "pollster" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + [[package]] name = "polymusic" version = "1.2.0" @@ -2840,7 +3095,9 @@ dependencies = [ "iced_aw", "iced_fonts 0.2.1", "kira", + "pathdiff", "regex", + "rfd", "serde", "serde_json", "smol_str 0.3.2", @@ -2848,6 +3105,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -2918,8 +3184,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -2929,7 +3205,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -2941,6 +3227,15 @@ dependencies = [ "getrandom 0.2.16", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] + [[package]] name = "range-alloc" version = "0.1.4" @@ -3062,6 +3357,30 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "rfd" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2bee61e6cffa4635c72d7d81a84294e28f0930db0ddcb0f66d10244674ebed" +dependencies = [ + "ashpd", + "block2 0.6.1", + "dispatch2", + "js-sys", + "log", + "objc2 0.6.2", + "objc2-app-kit 0.3.1", + "objc2-core-foundation", + "objc2-foundation 0.3.1", + "pollster", + "raw-window-handle", + "urlencoding", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.59.0", +] + [[package]] name = "roxmltree" version = "0.20.0" @@ -3389,8 +3708,8 @@ dependencies = [ "js-sys", "log", "memmap2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "objc2-quartz-core", "raw-window-handle", "redox_syscall 0.5.12", @@ -3414,6 +3733,12 @@ dependencies = [ "bitflags 2.9.1", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -3586,6 +3911,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "sys-locale" version = "0.3.2" @@ -3676,6 +4012,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.9.0" @@ -3853,6 +4199,30 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "version_check" version = "0.9.5" @@ -4643,7 +5013,7 @@ dependencies = [ "android-activity", "atomic-waker", "bitflags 2.9.1", - "block2", + "block2 0.5.1", "bytemuck", "calloop", "cfg_aliases 0.2.1", @@ -4656,9 +5026,9 @@ dependencies = [ "libc", "memmap2", "ndk 0.9.0", - "objc2", - "objc2-app-kit", - "objc2-foundation", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", "objc2-ui-kit", "orbclient", "percent-encoding", @@ -4712,6 +5082,12 @@ dependencies = [ "bitflags 2.9.1", ] +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + [[package]] name = "x11-dl" version = "2.21.0" @@ -4791,6 +5167,30 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c94451ac9513335b5e23d7a8a2b61a7102398b8cca5160829d313e84c9d98be1" +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", + "synstructure", +] + [[package]] name = "zbus" version = "4.4.0" @@ -4813,9 +5213,9 @@ dependencies = [ "futures-sink", "futures-util", "hex", - "nix", + "nix 0.29.0", "ordered-stream", - "rand", + "rand 0.8.5", "serde", "serde_repr", "sha1", @@ -4824,9 +5224,42 @@ dependencies = [ "uds_windows", "windows-sys 0.52.0", "xdg-home", - "zbus_macros", - "zbus_names", - "zvariant", + "zbus_macros 4.4.0", + "zbus_names 3.0.0", + "zvariant 4.2.0", +] + +[[package]] +name = "zbus" +version = "5.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb4f9a464286d42851d18a605f7193b8febaf5b0919d71c6399b7b26e5b0aad" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "nix 0.30.1", + "ordered-stream", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "windows-sys 0.59.0", + "winnow", + "zbus_macros 5.9.0", + "zbus_names 4.2.0", + "zvariant 5.6.0", ] [[package]] @@ -4839,7 +5272,22 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.101", - "zvariant_utils", + "zvariant_utils 2.1.0", +] + +[[package]] +name = "zbus_macros" +version = "5.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef9859f68ee0c4ee2e8cde84737c78e3f4c54f946f2a38645d0d4c7a95327659" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.101", + "zbus_names 4.2.0", + "zvariant 5.6.0", + "zvariant_utils 3.2.0", ] [[package]] @@ -4850,7 +5298,19 @@ checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" dependencies = [ "serde", "static_assertions", - "zvariant", + "zvariant 4.2.0", +] + +[[package]] +name = "zbus_names" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" +dependencies = [ + "serde", + "static_assertions", + "winnow", + "zvariant 5.6.0", ] [[package]] @@ -4879,6 +5339,60 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "zvariant" version = "4.2.0" @@ -4889,7 +5403,22 @@ dependencies = [ "enumflags2", "serde", "static_assertions", - "zvariant_derive", + "zvariant_derive 4.2.0", +] + +[[package]] +name = "zvariant" +version = "5.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91b3680bb339216abd84714172b5138a4edac677e641ef17e1d8cb1b3ca6e6f" +dependencies = [ + "endi", + "enumflags2", + "serde", + "url", + "winnow", + "zvariant_derive 5.6.0", + "zvariant_utils 3.2.0", ] [[package]] @@ -4902,7 +5431,20 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.101", - "zvariant_utils", + "zvariant_utils 2.1.0", +] + +[[package]] +name = "zvariant_derive" +version = "5.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8c68501be459a8dbfffbe5d792acdd23b4959940fc87785fb013b32edbc208" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.101", + "zvariant_utils 3.2.0", ] [[package]] @@ -4915,3 +5457,17 @@ dependencies = [ "quote", "syn 2.0.101", ] + +[[package]] +name = "zvariant_utils" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16edfee43e5d7b553b77872d99bc36afdda75c223ca7ad5e3fbecd82ca5fc34" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "static_assertions", + "syn 2.0.101", + "winnow", +] diff --git a/Cargo.toml b/Cargo.toml index bcaa113..586b168 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ iced_aw = {version = "0.12.2", default-features = true} iced_fonts = "0.2.1" smol_str = "0.3.2" winapi = {version = "0.3", features = ["wincon", "winuser"]} +rfd = "0.15.4" +pathdiff = "0.2.3" [profile.release] opt-level = 3 diff --git a/assets/tick.ogg b/assets/Default_Sound.ogg similarity index 100% rename from assets/tick.ogg rename to assets/Default_Sound.ogg diff --git a/src/gui.rs b/src/gui.rs index ca3286b..e57b235 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -40,10 +40,14 @@ pub fn music_view(app: &Polymusic) -> iced::Element { Message::CancelColor(i), move |color| Message::ChooseColor(i, color) ), - pick_list(entries.clone(), Some(&polygon.sound_name), move |s| { - Message::ChangeSound(current_index, s) - }) - .text_size(20), + button(text( + polygon + .sound_name + .rsplit(['/', '\\']) + .next() + .unwrap_or(&polygon.sound_name) + )) + .on_press(Message::ChangeSound(current_index)), ] .spacing(20), row![ @@ -183,11 +187,6 @@ pub fn music_view(app: &Polymusic) -> iced::Element { ] .spacing(20), column![ - /* - slider(0.0..=app.music.length, self.current_delta, move |f| { - Message::ChangeDelta(f) - }) - .step(&app.music.length / 10_000.),*/ canvas(&app.music) .height(Length::FillPortion(1)) .width(Length::FillPortion(1)) @@ -208,40 +207,16 @@ pub fn load_file_view(app: &Polymusic) -> iced::Element { column![ text("Polymusic").size(42), row![ - column![ - TextInput::new("Name File", &app.file_name_to_creat) - .on_input(|new_value| Message::SetFileNameCreat(new_value)), - button("Create File").on_press(Message::CreatFile), - text(if app.show_warning_message_creat { - "Warning: File already exists. Delete it or change the file name!" - } else { - "" - }) - .style(|theme: &Theme| { - let palette = theme.extended_palette(); - - text::Style { - color: Some(palette.danger.strong.color), - } - },) - ] - .spacing(10) - .width(200) - .height(200) - .align_x(Horizontal::Center), - column![ - pick_list( - app.all_saves.clone(), - Some(&app.music.file_name), - move |s| Message::FileNameChanged(s), - ), - button("Load File").on_press(Message::Load), - text("") - ] - .spacing(10) - .width(200) - .height(200) - .align_x(Horizontal::Center) + column![button("Create File").on_press(Message::CreatFile),] + .spacing(10) + .width(200) + .height(200) + .align_x(Horizontal::Center), + column![button("Load File").on_press(Message::Load),] + .spacing(10) + .width(200) + .height(200) + .align_x(Horizontal::Center) ] .spacing(32) .align_y(Vertical::Center), diff --git a/src/main.rs b/src/main.rs index 4999847..2380e21 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ mod polygon_draw; use iced::keyboard::Modifiers; +use pathdiff::diff_paths; use polygon_draw::Polygon; +use std::path::PathBuf; mod music; use music::Music; @@ -14,6 +16,7 @@ mod message; use message::Message; mod utils; +use rfd::FileDialog; use utils::{delta_to_string, is_delta_format_valid, str_to_sec}; use std::fs; @@ -24,15 +27,15 @@ use gui::{load_file_view, music_view}; use iced::Font; use iced::Theme; use iced::{ - event::{self, Status}, - keyboard::{key::Named, Key}, Color, Event, Task, + event::{self, Status}, + keyboard::{Key, key::Named}, }; use std::time::Instant; use kira::{ - sound::static_sound::StaticSoundData, AudioManager, AudioManagerSettings, DefaultBackend, + AudioManager, AudioManagerSettings, DefaultBackend, sound::static_sound::StaticSoundData, }; const FONT_BYTES: &[u8] = include_bytes!("../fonts/EnvyCodeRNerdFontMono-Regular.ttf"); const FONT: Font = Font::with_name("EnvyCodeR Nerd Font Mono"); @@ -80,9 +83,9 @@ struct Polymusic { can_unpaused: bool, already_save: bool, mode_file_load: bool, - file_name_to_creat: String, show_warning_message_creat: bool, historic: Historic, + root: String, } impl Polymusic { @@ -103,9 +106,9 @@ impl Polymusic { can_unpaused: true, already_save: true, mode_file_load: true, - file_name_to_creat: "Default File Name".to_string(), show_warning_message_creat: false, historic: Historic::new(), + root: String::from("/"), }, Task::none(), ) @@ -156,52 +159,99 @@ impl Polymusic { self.current_delta, ); } - - Message::ChangeSound(i, s) => { - let sound = StaticSoundData::from_file(format!("./assets/{s}")) - .expect("Fail to load audio"); - let old_sound = self - .music + Message::ReChangeSound(i, s) => { + dbg!(format!("{0}/{1}", self.root, s.clone())); + let sound = if s == String::from("Default_Sound.ogg") { + StaticSoundData::from_file(String::from("./assets/Default_Sound.ogg")) + .expect("Fail to load audio") + } else { + StaticSoundData::from_file(format!("{0}/{1}", self.root, s.clone())) + .expect("Fail to load audio") + }; + self.music .set_sound(self.current_delta, i, sound, s.clone()); self.already_save = false; - self.historic.add( - Message::ChangeSound(i, old_sound), - Message::ChangeSound(i, s), - self.current_delta, - ); + } + + Message::ChangeSound(i) => { + let file = FileDialog::new() + .add_filter("Audio Files", &["mp3", "wav", "ogg"]) + .set_directory("./") + .pick_file(); + match file { + Some(s) => { + let root_path = PathBuf::from(&self.root); + let relative_path = diff_paths(&s, &root_path) + .expect("Impossible de calculer le chemin relatif"); + let path_string = relative_path.to_string_lossy().into_owned(); + let sound = StaticSoundData::from_file(format!( + "{0}/{1}", + self.root, + path_string.clone() + )) + .expect("Fail to load audio"); + let old_sound = + self.music + .set_sound(self.current_delta, i, sound, path_string.clone()); + self.already_save = false; + self.historic.add( + Message::ReChangeSound(i, old_sound), + Message::ReChangeSound(i, path_string), + self.current_delta, + ); + } + none => eprintln!("fail to load file"), + } } Message::Save => { let json = serde_json::to_string_pretty(&self.music).unwrap(); - fs::write(format!("./saves/{0}.pmx", &self.music.file_name), json).unwrap(); + dbg!(format!("{0}/{1}", &self.root, self.music.file_name)); + fs::write(format!("{0}/{1}", &self.root, self.music.file_name), json).unwrap(); self.all_saves = load_path_saves(); self.already_save = true; } Message::Load => { - let json = fs::read_to_string(format!("./saves/{0}.pmx", &self.music.file_name)); - match json { - Ok(j) => { - let decoded: Music = serde_json::from_str(&j).unwrap(); - self.music = decoded; - self.music.update_frame(); - self.mode_file_load = false; - } - Err(e) => { - eprintln!("Error, no saves with this name to load, {e} "); + let file = FileDialog::new() + .add_filter("Polymusic File", &["pmx"]) + .set_directory("./") + .pick_file(); + if let Some(path) = file { + let path_string = path.to_string_lossy().into_owned(); + let json = fs::read_to_string(path_string.clone()); + if let Some(path_parent) = path.parent() { + self.root = path_parent.to_string_lossy().into_owned(); + match json { + Ok(j) => { + let decoded: Music = serde_json::from_str(&j).unwrap(); + self.music = decoded; + self.music.update_frame(&self.root); + self.mode_file_load = false; + } + Err(e) => { + eprintln!("Error, no saves with this name to load, {e} "); + } + } } } } - Message::SetFileNameCreat(s) => self.file_name_to_creat = s, + Message::CreatFile => { - if self.all_saves.contains(&self.file_name_to_creat) { - self.show_warning_message_creat = true; - } else { + let file = FileDialog::new() + .add_filter("Polymusic File", &["pmx"]) + .set_directory("./") + .save_file(); + if let Some(path) = file { + if let Some(path_parent) = path.parent() { + self.root = path_parent.to_string_lossy().into_owned(); + } self.mode_file_load = false; self.music = Music::default(); - self.music.file_name = self.file_name_to_creat.clone(); + if let Some(name) = path.file_name() { + self.music.file_name = name.to_string_lossy().into_owned(); + } self.update(Message::Save); } } - Message::FileNameChanged(s) => self.music.file_name = s, Message::LengthChange(s) => { if is_delta_format_valid(&s) { let sec = str_to_sec(&s); @@ -345,7 +395,6 @@ impl Polymusic { if self.already_save { self.historic = Historic::new(); self.paused = true; - self.file_name_to_creat = "Default File Name".to_string(); self.show_warning_message_creat = false; self.mode_file_load = true } diff --git a/src/message.rs b/src/message.rs index 563f698..f6b2bae 100644 --- a/src/message.rs +++ b/src/message.rs @@ -6,13 +6,11 @@ use crate::polygon_draw::Polygon; pub enum Message { None, CreatFile, - SetFileNameCreat(String), GoToLoadView, ForceToQuit, Tick, Save, Load, - FileNameChanged(String), TogglePaused, ChangeDelta(f32), ClickedOnTimeLine(f32), @@ -23,7 +21,8 @@ pub enum Message { ReAddPolygon(Polygon), ChangeTeta(usize, f32), Remove(usize), - ChangeSound(usize, String), + ChangeSound(usize), + ReChangeSound(usize, String), LengthChange(String), AddPoint, RemovePoint, diff --git a/src/music.rs b/src/music.rs index bec2187..4f15464 100644 --- a/src/music.rs +++ b/src/music.rs @@ -3,16 +3,16 @@ use crate::polygon_draw::*; use crate::utils::string_to_polygon; use serde::{Deserialize, Serialize}; -use kira::{sound::static_sound::StaticSoundData, AudioManager}; +use kira::{AudioManager, sound::static_sound::StaticSoundData}; use iced::event::Status; use iced::mouse::Cursor; use iced::widget::canvas::{Event, Geometry}; -use iced::{keyboard, Vector}; use iced::{ - mouse::{self, ScrollDelta}, Size, + mouse::{self, ScrollDelta}, }; +use iced::{Vector, keyboard}; use iced::widget::canvas; use iced::widget::canvas::Stroke; @@ -83,9 +83,9 @@ impl Music { } } - pub fn update_frame(&mut self) { + pub fn update_frame(&mut self, path_of_project: &str) { for (_, p) in &mut self.poly_frame { - p.update(); + p.update(path_of_project); } } @@ -174,8 +174,8 @@ impl Music { pub fn add_polygon(&mut self, delta: f32, polygon_name: String) { let current_frame = self.find_poly_frame(delta); - let mut poly = string_to_polygon(polygon_name); - poly.update(); + let poly = string_to_polygon(polygon_name); + //poly.update(); current_frame.polygons.push(poly); } diff --git a/src/polygon_draw.rs b/src/polygon_draw.rs index 31c1c0c..9492888 100644 --- a/src/polygon_draw.rs +++ b/src/polygon_draw.rs @@ -3,11 +3,11 @@ use crate::utils::string_to_color; use crate::color::color_serde; use std::f32::consts::PI; +use iced::Size; +use iced::Vector; use iced::mouse; use iced::widget::canvas; use iced::widget::canvas::{Frame, Stroke, Style}; -use iced::Size; -use iced::Vector; use iced::{Color, Point, Rectangle, Renderer, Theme}; use kira::sound::static_sound::StaticSoundData; use serde::{Deserialize, Serialize}; @@ -38,9 +38,9 @@ impl PolygonFrame { } all_sound } - pub fn update(&mut self) { + pub fn update(&mut self, path_of_project: &str) { for poly in &mut self.polygons { - poly.update(); + poly.update(path_of_project); } } @@ -199,9 +199,10 @@ pub struct Polygon { } #[warn(dead_code)] impl Polygon { - pub fn update(&mut self) { - let path = format!("./assets/{0}", &self.sound_name); - self.sound = StaticSoundData::from_file(&path).expect("fail to load the sound"); + pub fn update(&mut self, path_of_project: &str) { + let path = format!("{0}", &self.sound_name); + self.sound = StaticSoundData::from_file(format!("{0}/{1}", path_of_project, path)) + .expect("fail to load the sound"); } pub fn sound_to_play_btw(&self, before: f32, after: f32) -> Vec<&StaticSoundData> { let mut sound_to_play: Vec<&StaticSoundData> = vec![]; @@ -224,7 +225,7 @@ impl Polygon { global_teta: 0., points_teta: vec![], sound: sound, - sound_name: "tick.ogg".to_string(), + sound_name: "Default_Sound.ogg".to_string(), name: "".to_string(), color: Color::BLACK, show_color_picker: false, diff --git a/src/utils.rs b/src/utils.rs index 927983f..137571c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -95,5 +95,5 @@ pub fn string_to_polygon>(str: S) -> Polygon { poly } fn dummy_sound() -> StaticSoundData { - StaticSoundData::from_file("assets/tick.ogg").expect("Fail to load audio") + StaticSoundData::from_file("assets/Default_Sound.ogg").expect("Fail to load audio") }