From 2d6a11406da4171c8cb3c9da3d916e0fa3db22fd Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 25 Jan 2021 16:04:36 -0600 Subject: [PATCH] what --- Cargo.lock | 746 +++++++++++++++++++++++++++++++++----- framework/Cargo.toml | 8 +- framework/src/game.rs | 33 ++ framework/src/graphics.rs | 7 - src/game/mod.rs | 5 +- src/game/seeker.rs | 108 +++--- 6 files changed, 760 insertions(+), 147 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b3d418..a060a85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,6 +68,20 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "andrew" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" +dependencies = [ + "bitflags", + "line_drawing", + "rusttype 0.7.9", + "walkdir", + "xdg", + "xml-rs", +] + [[package]] name = "andrew" version = "0.3.1" @@ -75,7 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c4afb09dd642feec8408e33f92f3ffc4052946f6b20f32fb99c1f58cd4fa7cf" dependencies = [ "bitflags", - "rusttype", + "rusttype 0.9.2", "walkdir", "xdg", "xml-rs", @@ -102,6 +116,15 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits", +] + [[package]] name = "approx" version = "0.4.0" @@ -201,8 +224,8 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "regex", "rustc-hash", "shlex", @@ -355,6 +378,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "cgl" version = "0.3.2" @@ -415,6 +444,60 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bfbf56724aa9eca8afa4fcfadeb479e722935bb2a0900c2d37e0cc477af0688" +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "cocoa" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" +dependencies = [ + "bitflags", + "block", + "core-foundation 0.6.4", + "core-graphics 0.17.3", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29f7768b2d1be17b96158e3285951d366b40211320fb30826a76cb7a0da6400" +dependencies = [ + "bitflags", + "block", + "core-foundation 0.6.4", + "core-graphics 0.17.3", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8" +dependencies = [ + "bitflags", + "block", + "core-foundation 0.7.0", + "core-graphics 0.19.2", + "foreign-types", + "libc", + "objc", +] + [[package]] name = "cocoa" version = "0.23.0" @@ -584,6 +667,18 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +[[package]] +name = "core-graphics" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" +dependencies = [ + "bitflags", + "core-foundation 0.6.4", + "foreign-types", + "libc", +] + [[package]] name = "core-graphics" version = "0.19.2" @@ -671,7 +766,7 @@ dependencies = [ "ndk-glue", "nix 0.15.0", "oboe", - "parking_lot", + "parking_lot 0.11.1", "stdweb 0.1.3", "thiserror", "web-sys", @@ -762,8 +857,8 @@ checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ "fnv", "ident_case", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "strsim 0.9.3", "syn", ] @@ -775,7 +870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", - "quote", + "quote 1.0.8", "syn", ] @@ -795,8 +890,8 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -806,8 +901,8 @@ version = "0.99.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -843,6 +938,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "display-link" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303de632386f9c82eb7823456f5932bd40b4de9521078901767bf16a9f331491" +dependencies = [ + "foreign-types", + "objc", + "objc-foundation", + "time-point", +] + [[package]] name = "dlib" version = "0.4.2" @@ -881,7 +988,7 @@ dependencies = [ "libosu", "log", "num", - "ordered-float", + "ordered-float 2.0.1", "stderrlog", "structopt", ] @@ -912,6 +1019,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "euclid" +version = "0.20.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb7ef65b3777a325d1eeefefab5b6d4959da54747e33bd6258e789640f307ad" +dependencies = [ + "num-traits", +] + [[package]] name = "euclid" version = "0.22.1" @@ -982,10 +1098,12 @@ dependencies = [ "anyhow", "bass-sys", "gfx-backend-dx12", + "gfx-backend-gl", "gfx-backend-metal", "gfx-backend-vulkan", "gfx-hal", - "winit", + "web-sys", + "winit 0.24.0", ] [[package]] @@ -1081,11 +1199,35 @@ dependencies = [ "log", "range-alloc", "raw-window-handle", - "smallvec", + "smallvec 1.6.1", "spirv_cross", "winapi 0.3.9", ] +[[package]] +name = "gfx-backend-gl" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ff8f4774c8c123b2faa0bdd59ed9152be0e43448063fa5db392ff09b0e9d1" +dependencies = [ + "arrayvec", + "bitflags", + "cfg_aliases", + "gfx-auxil", + "gfx-hal", + "glow", + "js-sys", + "lazy_static", + "log", + "parking_lot 0.11.1", + "raw-window-handle", + "smallvec 1.6.1", + "spirv_cross", + "surfman", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "gfx-backend-metal" version = "0.6.5" @@ -1102,12 +1244,12 @@ dependencies = [ "gfx-hal", "lazy_static", "log", - "metal", + "metal 0.20.0", "objc", - "parking_lot", + "parking_lot 0.11.1", "range-alloc", "raw-window-handle", - "smallvec", + "smallvec 1.6.1", "spirv_cross", "storage-map", ] @@ -1128,7 +1270,7 @@ dependencies = [ "log", "objc", "raw-window-handle", - "smallvec", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -1170,7 +1312,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2d38164670920cfb7491bc0cf6f49f0554bd1c44cdbedc6c78d2bf91691ff5e" dependencies = [ - "gl_generator", + "gl_generator 0.14.0", ] [[package]] @@ -1178,7 +1320,7 @@ name = "ggez" version = "0.6.0-rc0" source = "git+https://github.com/ggez/ggez?branch=devel#32b480356d04911234c8a70c79a72942e76830a8" dependencies = [ - "approx", + "approx 0.4.0", "bitflags", "directories", "gfx", @@ -1199,7 +1341,7 @@ dependencies = [ "skeptic", "smart-default", "toml", - "winit", + "winit 0.24.0", "zip", ] @@ -1252,6 +1394,17 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +[[package]] +name = "gl_generator" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + [[package]] name = "gl_generator" version = "0.14.0" @@ -1273,12 +1426,33 @@ dependencies = [ "version_check", ] +[[package]] +name = "gleam" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea4f9ba7411ae3f00516401fb811b4f4f37f5c926357f2a033d27f96b74c849" +dependencies = [ + "gl_generator 0.13.1", +] + [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "glow" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1625b792e2f9267116dd41eb7d325e0ea2572ceba5069451906745e04f852f33" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "glutin" version = "0.26.0" @@ -1299,11 +1473,11 @@ dependencies = [ "log", "objc", "osmesa-sys", - "parking_lot", - "wayland-client", + "parking_lot 0.11.1", + "wayland-client 0.28.3", "wayland-egl", "winapi 0.3.9", - "winit", + "winit 0.24.0", ] [[package]] @@ -1312,7 +1486,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211" dependencies = [ - "gl_generator", + "gl_generator 0.14.0", "winapi 0.3.9", ] @@ -1328,7 +1502,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" dependencies = [ - "gl_generator", + "gl_generator 0.14.0", "objc", ] @@ -1338,7 +1512,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351" dependencies = [ - "gl_generator", + "gl_generator 0.14.0", "x11-dl", ] @@ -1348,7 +1522,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" dependencies = [ - "gl_generator", + "gl_generator 0.14.0", ] [[package]] @@ -1360,7 +1534,7 @@ dependencies = [ "glyph_brush_draw_cache", "glyph_brush_layout", "log", - "ordered-float", + "ordered-float 2.0.1", "rustc-hash", "twox-hash", ] @@ -1386,7 +1560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10bc06d530bf20c1902f1b02799ab7372ff43f6119770c49b0bc3f21bd148820" dependencies = [ "ab_glyph", - "approx", + "approx 0.4.0", "xi-unicode", ] @@ -1458,7 +1632,7 @@ checksum = "92a0077d3bb882960467aed0bc6eaf5d4033cb9b61bfdbb99c32d1288380032f" dependencies = [ "bitflags", "imgui-sys", - "parking_lot", + "parking_lot 0.11.1", ] [[package]] @@ -1477,7 +1651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0669ee7f52b80aa33d5f45507790223380c253a8fd981ddf67d1427ab8ebc8bc" dependencies = [ "imgui", - "winit", + "winit 0.24.0", ] [[package]] @@ -1508,6 +1682,19 @@ dependencies = [ "mach 0.2.3", ] +[[package]] +name = "io-surface" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2279a6faecd06034f88218f77f7a767693e0957bce0323a96d92747e2760b445" +dependencies = [ + "cgl", + "core-foundation 0.6.4", + "gleam", + "leaky-cow", + "libc", +] + [[package]] name = "iovec" version = "0.1.4" @@ -1613,6 +1800,21 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "leak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd100e01f1154f2908dfa7d02219aeab25d0b9c7fa955164192e3245255a0c73" + +[[package]] +name = "leaky-cow" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a8225d44241fd324a8af2806ba635fc7c8a7e9a7de4d5cf3ef54e71f5926fc" +dependencies = [ + "leak", +] + [[package]] name = "lewton" version = "0.10.1" @@ -1671,7 +1873,7 @@ dependencies = [ "num-derive", "num-rational", "num-traits", - "ordered-float", + "ordered-float 2.0.1", "quickcheck", "quickcheck_macros", "regex", @@ -1690,12 +1892,30 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "line_drawing" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" +dependencies = [ + "num-traits", +] + [[package]] name = "linked-hash-map" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + [[package]] name = "lock_api" version = "0.4.2" @@ -1741,7 +1961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce4e12203c428a58200b8cf1c0a3aad1cda907008ea11310bb3729593e5f933" dependencies = [ "arrayvec", - "euclid", + "euclid 0.22.1", "num-traits", ] @@ -1810,6 +2030,16 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "memmap2" version = "0.1.0" @@ -1828,6 +2058,21 @@ dependencies = [ "autocfg", ] +[[package]] +name = "metal" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0" +dependencies = [ + "bitflags", + "block", + "cocoa 0.20.2", + "core-graphics 0.19.2", + "foreign-types", + "log", + "objc", +] + [[package]] name = "metal" version = "0.20.0" @@ -1968,8 +2213,8 @@ checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" dependencies = [ "darling", "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -1990,6 +2235,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nix" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" +dependencies = [ + "bitflags", + "cc", + "cfg-if 0.1.10", + "libc", + "void", +] + [[package]] name = "nix" version = "0.15.0" @@ -2075,8 +2333,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -2149,8 +2407,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" dependencies = [ "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -2164,6 +2422,17 @@ dependencies = [ "objc_exception", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc_exception" version = "0.1.2" @@ -2173,6 +2442,15 @@ dependencies = [ "cc", ] +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "object" version = "0.22.0" @@ -2228,6 +2506,15 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +[[package]] +name = "ordered-float" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-float" version = "2.0.1" @@ -2264,6 +2551,27 @@ dependencies = [ "ttf-parser 0.9.0", ] +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api 0.3.4", + "parking_lot_core 0.6.2", + "rustc_version", +] + +[[package]] +name = "parking_lot" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api 0.3.4", + "parking_lot_core 0.7.2", +] + [[package]] name = "parking_lot" version = "0.11.1" @@ -2271,8 +2579,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", - "lock_api", - "parking_lot_core", + "lock_api 0.4.2", + "parking_lot_core 0.8.2", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "rustc_version", + "smallvec 0.6.14", + "winapi 0.3.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "smallvec 1.6.1", + "winapi 0.3.9", ] [[package]] @@ -2285,7 +2622,7 @@ dependencies = [ "instant", "libc", "redox_syscall 0.1.57", - "smallvec", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -2360,8 +2697,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", "version_check", ] @@ -2372,8 +2709,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "version_check", ] @@ -2383,13 +2720,22 @@ version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.1", ] [[package]] @@ -2440,18 +2786,27 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", ] [[package]] @@ -2708,6 +3063,26 @@ dependencies = [ "webpki", ] +[[package]] +name = "rusttype" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" +dependencies = [ + "rusttype 0.8.3", +] + +[[package]] +name = "rusttype" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" +dependencies = [ + "approx 0.3.2", + "ordered-float 1.1.1", + "stb_truetype", +] + [[package]] name = "rusttype" version = "0.9.2" @@ -2803,8 +3178,8 @@ version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "552954ce79a059ddd5fd68c271592374bd15cab2274970380c000118aeffe1cd" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -2882,6 +3257,21 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "slotmap" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c46a3482db8f247956e464d783693ece164ca056e6e67563ee5505bdb86452cd" + +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] + [[package]] name = "smallvec" version = "1.6.1" @@ -2894,18 +3284,35 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] +[[package]] +name = "smithay-client-toolkit" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" +dependencies = [ + "andrew 0.2.1", + "bitflags", + "dlib", + "lazy_static", + "memmap", + "nix 0.14.1", + "wayland-client 0.21.13", + "wayland-commons 0.21.13", + "wayland-protocols 0.21.13", +] + [[package]] name = "smithay-client-toolkit" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "316e13a3eb853ce7bf72ad3530dc186cb2005c57c521ef5f4ada5ee4eed74de6" dependencies = [ - "andrew", + "andrew 0.3.1", "bitflags", "calloop", "dlib", @@ -2913,9 +3320,9 @@ dependencies = [ "log", "memmap2", "nix 0.18.0", - "wayland-client", + "wayland-client 0.28.3", "wayland-cursor", - "wayland-protocols", + "wayland-protocols 0.28.3", ] [[package]] @@ -2950,6 +3357,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stb_truetype" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" +dependencies = [ + "byteorder", +] + [[package]] name = "stderrlog" version = "0.5.1" @@ -2991,8 +3407,8 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "serde", "serde_derive", "syn", @@ -3005,8 +3421,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" dependencies = [ "base-x", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "serde", "serde_derive", "serde_json", @@ -3026,7 +3442,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "418bb14643aa55a7841d5303f72cf512cfb323b8cc221d51580500a1ca75206c" dependencies = [ - "lock_api", + "lock_api 0.4.2", ] [[package]] @@ -3060,20 +3476,50 @@ checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" dependencies = [ "heck", "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] +[[package]] +name = "surfman" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d85bf0eb91b66b93dda5c04627f00074ea1fa008c2980b132a065fafe7a1ab" +dependencies = [ + "bitflags", + "cfg_aliases", + "cgl", + "cocoa 0.19.1", + "core-foundation 0.6.4", + "core-graphics 0.17.3", + "display-link", + "euclid 0.20.14", + "gl_generator 0.14.0", + "io-surface", + "lazy_static", + "libc", + "log", + "mach 0.3.2", + "metal 0.18.0", + "objc", + "parking_lot 0.10.2", + "raw-window-handle", + "wayland-sys 0.24.1", + "winapi 0.3.9", + "winit 0.19.3", + "wio", +] + [[package]] name = "syn" version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "proc-macro2 1.0.24", + "quote 1.0.8", + "unicode-xid 0.2.1", ] [[package]] @@ -3135,8 +3581,8 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", ] @@ -3202,12 +3648,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" dependencies = [ "proc-macro-hack", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "standback", "syn", ] +[[package]] +name = "time-point" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06535c958d6abe68dc4b4ef9e6845f758fc42fe463d0093d0aca40254f03fb14" + [[package]] name = "tinyvec" version = "0.3.4" @@ -3291,6 +3743,12 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.1" @@ -3409,8 +3867,8 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", "wasm-bindgen-shared", ] @@ -3421,7 +3879,7 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" dependencies = [ - "quote", + "quote 1.0.8", "wasm-bindgen-macro-support", ] @@ -3431,8 +3889,8 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -3444,6 +3902,21 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +[[package]] +name = "wayland-client" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix 0.14.1", + "wayland-commons 0.21.13", + "wayland-scanner 0.21.13", + "wayland-sys 0.21.13", +] + [[package]] name = "wayland-client" version = "0.28.3" @@ -3455,9 +3928,19 @@ dependencies = [ "libc", "nix 0.18.0", "scoped-tls", - "wayland-commons", - "wayland-scanner", - "wayland-sys", + "wayland-commons 0.28.3", + "wayland-scanner 0.28.3", + "wayland-sys 0.28.3", +] + +[[package]] +name = "wayland-commons" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" +dependencies = [ + "nix 0.14.1", + "wayland-sys 0.21.13", ] [[package]] @@ -3468,8 +3951,8 @@ checksum = "480450f76717edd64ad04a4426280d737fc3d10a236b982df7b1aee19f0e2d56" dependencies = [ "nix 0.18.0", "once_cell", - "smallvec", - "wayland-sys", + "smallvec 1.6.1", + "wayland-sys 0.28.3", ] [[package]] @@ -3479,7 +3962,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6eb122c160223a7660feeaf949d0100281d1279acaaed3720eb3c9894496e5f" dependencies = [ "nix 0.18.0", - "wayland-client", + "wayland-client 0.28.3", "xcursor", ] @@ -3489,8 +3972,21 @@ version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c653507447113c967a1aeee413699acb42d96d6302ec967c6d51930eae8aa7f5" dependencies = [ - "wayland-client", - "wayland-sys", + "wayland-client 0.28.3", + "wayland-sys 0.28.3", +] + +[[package]] +name = "wayland-protocols" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" +dependencies = [ + "bitflags", + "wayland-client 0.21.13", + "wayland-commons 0.21.13", + "wayland-scanner 0.21.13", + "wayland-sys 0.21.13", ] [[package]] @@ -3500,9 +3996,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "319a82b4d3054dd25acc32d9aee0f84fa95b63bc983fffe4703b6b8d47e01a30" dependencies = [ "bitflags", - "wayland-client", - "wayland-commons", - "wayland-scanner", + "wayland-client 0.28.3", + "wayland-commons 0.28.3", + "wayland-scanner 0.28.3", +] + +[[package]] +name = "wayland-scanner" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "xml-rs", ] [[package]] @@ -3511,11 +4018,31 @@ version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7010ba5767b3fcd350decc59055390b4ebe6bd1b9279a9feb1f1888987f1133d" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.24", + "quote 1.0.8", "xml-rs", ] +[[package]] +name = "wayland-sys" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" +dependencies = [ + "dlib", + "lazy_static", +] + +[[package]] +name = "wayland-sys" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537500923d50be11d95a63c4cb538145e4c82edf61296b7debc1f94a1a6514ed" +dependencies = [ + "dlib", + "lazy_static", +] + [[package]] name = "wayland-sys" version = "0.28.3" @@ -3605,6 +4132,30 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winit" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d0da905e61ae52d55c5ca6f8bea1e09daf5e325b6c77b0947c65a5179b49f5f" +dependencies = [ + "android_glue", + "backtrace", + "bitflags", + "cocoa 0.18.5", + "core-foundation 0.6.4", + "core-graphics 0.17.3", + "lazy_static", + "libc", + "log", + "objc", + "parking_lot 0.9.0", + "percent-encoding", + "smithay-client-toolkit 0.4.6", + "wayland-client 0.21.13", + "winapi 0.3.9", + "x11-dl", +] + [[package]] name = "winit" version = "0.24.0" @@ -3627,17 +4178,26 @@ dependencies = [ "ndk-glue", "ndk-sys", "objc", - "parking_lot", + "parking_lot 0.11.1", "percent-encoding", "raw-window-handle", - "smithay-client-toolkit", + "smithay-client-toolkit 0.12.2", "wasm-bindgen", - "wayland-client", + "wayland-client 0.28.3", "web-sys", "winapi 0.3.9", "x11-dl", ] +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/framework/Cargo.toml b/framework/Cargo.toml index 4c97566..5dba9eb 100644 --- a/framework/Cargo.toml +++ b/framework/Cargo.toml @@ -9,10 +9,16 @@ anyhow = "1.0.38" gfx-hal = "0.6.0" winit = { version = "0.24.0", features = ["web-sys"] } bass-sys = { path = "../bass-sys" } -gfx-backend-vulkan = "0.6.5" + +[target.'cfg(target_arch = "wasm32")'.dependencies] +gfx-backend-gl = "0.6.1" +web-sys = "0.3.46" [target.'cfg(target_os = "macos")'.dependencies] gfx-backend-metal = "0.6.5" [target.'cfg(windows)'.dependencies] gfx-backend-dx12 = "0.6.13" + +[target.'cfg(not(any(window, target_os = "macos", target_arch = "wasm32")))'.dependencies] +gfx-backend-vulkan = "0.6.5" diff --git a/framework/src/game.rs b/framework/src/game.rs index df96d44..d967a4f 100644 --- a/framework/src/game.rs +++ b/framework/src/game.rs @@ -1,10 +1,22 @@ +#[cfg(windows)] +pub use gfx_backend_dx12 as back; +#[cfg(target_arch = "wasm32")] +pub use gfx_backend_gl as back; +#[cfg(target_os = "macos")] +pub use gfx_backend_metal as back; +#[cfg(not(any(windows, target_os = "macos", target_arch = "wasm32")))] +pub use gfx_backend_vulkan as back; + use anyhow::Result; +use gfx_hal::Instance; use winit::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::{Window, WindowBuilder}, }; +use crate::graphics::Renderer; + pub struct ObjectWrapper { id: usize, inner: Box, @@ -29,6 +41,27 @@ impl Game { let event_loop = EventLoop::new(); let window = WindowBuilder::new().build(&event_loop)?; + #[cfg(target_arch = "wasm32")] + web_sys::window() + .unwrap() + .document() + .unwrap() + .body() + .unwrap() + .append_child(&winit::platform::web::WindowExtWebSys::canvas(&window)) + .unwrap(); + + // let instance = back::Instance::create("osu", 1).unwrap(); + // let surface = unsafe { instance.create_surface(&window) }?; + // let adapter = { + // let mut adapters = instance.enumerate_adapters(); + // for adapter in adapters.iter() { + // println!("{:?}", adapter.info); + // } + // adapters.remove(0) + // }; + // let renderer = Renderer::new(instance, surface, adapter)?; + Ok(Game { objects: vec![], event_loop, diff --git a/framework/src/graphics.rs b/framework/src/graphics.rs index 301b66b..42cba66 100644 --- a/framework/src/graphics.rs +++ b/framework/src/graphics.rs @@ -1,10 +1,3 @@ -#[cfg(windows)] -use gfx_backend_dx12 as back; -#[cfg(target_os = "macos")] -use gfx_backend_metal as back; -#[cfg(not(any(windows, target_os = "macos")))] -use gfx_backend_vulkan as back; - use std::mem::ManuallyDrop; use std::ptr; diff --git a/src/game/mod.rs b/src/game/mod.rs index af49c8a..dbdd701 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -16,7 +16,8 @@ use anyhow::Result; use ggez::{ event::{KeyCode, MouseButton}, graphics::{ - self, Color, DrawMode, DrawParam, FilterMode, Image, Mesh, Rect, StrokeOptions, Text, WHITE, + self, CanvasGeneric, Color, DrawMode, DrawParam, FilterMode, GlBackendSpec, Image, Mesh, + Rect, StrokeOptions, Text, WHITE, }, Context, }; @@ -69,6 +70,7 @@ pub struct Game { frame: usize, slider_cache: SliderCache, + seeker_cache: Option>, combo_colors: Vec, selected_objects: Vec, tool: Tool, @@ -98,6 +100,7 @@ impl Game { skin, frame: 0, slider_cache: SliderCache::default(), + seeker_cache: None, combo_colors: DEFAULT_COLORS .iter() .map(|(r, g, b)| Color::new(*r, *g, *b, 1.0)) diff --git a/src/game/seeker.rs b/src/game/seeker.rs index 859e824..9b24d1c 100644 --- a/src/game/seeker.rs +++ b/src/game/seeker.rs @@ -1,6 +1,7 @@ use anyhow::Result; use ggez::{ - graphics::{self, Color, DrawMode, DrawParam, FillOptions, Mesh, Rect}, + conf::NumSamples, + graphics::{self, Canvas, Color, DrawMode, DrawParam, FillOptions, Mesh, Rect}, mint::Point2, Context, }; @@ -11,63 +12,80 @@ use super::Game; pub const BOUNDS: Rect = Rect::new(46.0, 732.0, 932.0, 36.0); impl Game { - pub(super) fn draw_seeker(&self, ctx: &mut Context) -> Result<()> { - let rect = Mesh::new_rectangle( - ctx, - DrawMode::Fill(FillOptions::default()), - Rect::new(0.0, 732.0, 1024.0, 36.0), - Color::new(0.0, 0.0, 0.0, 0.7), - )?; - graphics::draw(ctx, &rect, DrawParam::default())?; + pub(super) fn draw_seeker(&mut self, ctx: &mut Context) -> Result<()> { + if self.seeker_cache.is_none() { + println!("drawing seeker"); + let format = graphics::get_window_color_format(ctx); + let canvas = Canvas::new( + ctx, + BOUNDS.w as u16, + BOUNDS.h as u16, + NumSamples::Sixteen, + format, + )?; + graphics::set_canvas(ctx, Some(&canvas)); - let line_y = BOUNDS.y + BOUNDS.h / 2.0; - let line = Mesh::new_line( - ctx, - &[ - Point2::from([BOUNDS.x, line_y]), - Point2::from([BOUNDS.x + BOUNDS.w, line_y]), - ], - 1.0, - graphics::WHITE, - )?; - graphics::draw(ctx, &line, DrawParam::default())?; + let rect = Mesh::new_rectangle( + ctx, + DrawMode::Fill(FillOptions::default()), + Rect::new(0.0, 732.0, 1024.0, 36.0), + Color::new(0.0, 0.0, 0.0, 0.7), + )?; + graphics::draw(ctx, &rect, DrawParam::default())?; - if let Some(song) = &self.song { - let len = song.length()?; + let line_y = BOUNDS.h / 2.0; + let line = Mesh::new_line( + ctx, + &[ + Point2::from([0.0, line_y]), + Point2::from([BOUNDS.w, line_y]), + ], + 1.0, + graphics::WHITE, + )?; + graphics::draw(ctx, &line, DrawParam::default())?; - for timing_point in self.beatmap.inner.timing_points.iter() { - let color = match timing_point.kind { - TimingPointKind::Inherited(_) => Color::new(0.0, 0.8, 0.0, 0.5), - TimingPointKind::Uninherited(_) => Color::new(0.8, 0.0, 0.0, 0.5), - }; + if let Some(song) = &self.song { + let len = song.length()?; - let percent = timing_point.time.as_seconds().0.into_inner() / len; - let x = BOUNDS.x + percent as f32 * BOUNDS.w; + for timing_point in self.beatmap.inner.timing_points.iter() { + let color = match timing_point.kind { + TimingPointKind::Inherited(_) => Color::new(0.0, 0.8, 0.0, 0.4), + TimingPointKind::Uninherited(_) => Color::new(0.8, 0.0, 0.0, 0.6), + }; + let percent = timing_point.time.as_seconds().0.into_inner() / len; + let x = percent as f32 * BOUNDS.w; + + let line = Mesh::new_line( + ctx, + &[Point2::from([x, 0.0]), Point2::from([x, BOUNDS.h / 2.0])], + 1.0, + color, + )?; + graphics::draw(ctx, &line, DrawParam::default())?; + } + + let percent = song.position()? / len; + let x = percent as f32 * BOUNDS.w; let line = Mesh::new_line( ctx, &[ - Point2::from([x, BOUNDS.y]), - Point2::from([x, BOUNDS.y + BOUNDS.h]), + Point2::from([x, 0.2 * BOUNDS.h]), + Point2::from([x, 0.8 * BOUNDS.h]), ], - 1.0, - color, + 4.0, + graphics::WHITE, )?; graphics::draw(ctx, &line, DrawParam::default())?; } - let percent = song.position()? / len; - let x = BOUNDS.x + percent as f32 * BOUNDS.w; - let line = Mesh::new_line( - ctx, - &[ - Point2::from([x, BOUNDS.y + 0.2 * BOUNDS.h]), - Point2::from([x, BOUNDS.y + 0.8 * BOUNDS.h]), - ], - 4.0, - graphics::WHITE, - )?; - graphics::draw(ctx, &line, DrawParam::default())?; + graphics::set_canvas(ctx, None); + self.seeker_cache = Some(canvas); + }; + + if let Some(canvas) = &self.seeker_cache { + graphics::draw(ctx, canvas, DrawParam::default().dest([BOUNDS.x, BOUNDS.y]).scale([1.0, 10.0]))?; } Ok(()) }