diff --git a/Cargo.lock b/Cargo.lock index bafd535..c19436a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" [[package]] name = "approx" @@ -522,6 +522,17 @@ dependencies = [ "byteorder", ] +[[package]] +name = "derive_more" +version = "0.99.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.8", + "syn 1.0.58", +] + [[package]] name = "directories" version = "2.0.2" @@ -588,6 +599,16 @@ dependencies = [ "structopt", ] +[[package]] +name = "env_logger" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" +dependencies = [ + "log", + "regex", +] + [[package]] name = "error-chain" version = "0.12.4" @@ -669,6 +690,17 @@ dependencies = [ "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.1+wasi-snapshot-preview1", +] + [[package]] name = "gfx" version = "0.18.2" @@ -1075,17 +1107,19 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" [[package]] name = "libosu" -version = "0.0.15" -source = "git+https://github.com/iptq/libosu?rev=557d0a321405516f12c3939c1207c7341f796f35#557d0a321405516f12c3939c1207c7341f796f35" +version = "0.0.16" +source = "git+https://github.com/iptq/libosu?rev=df7ffa4b51328479addde0804930ec76112b3b69#df7ffa4b51328479addde0804930ec76112b3b69" dependencies = [ - "anyhow", "bitflags", + "derive_more", "lazy_static", "num", "num-derive 0.3.3", "num-rational 0.3.2", "num-traits 0.2.14", "ordered-float 2.0.1", + "quickcheck", + "quickcheck_macros", "regex", "serde", "serde_json", @@ -1128,9 +1162,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2" dependencies = [ "cfg-if 0.1.10", ] @@ -1563,7 +1597,7 @@ dependencies = [ "cfg-if 0.1.10", "cloudabi", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "rustc_version", "smallvec", "winapi", @@ -1681,6 +1715,28 @@ dependencies = [ "bitflags", ] +[[package]] +name = "quickcheck" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e10546770d370e4eb8ac183a4bdbf9044059afdcbbba3c98627412f93461e3" +dependencies = [ + "env_logger", + "log", + "rand 0.8.2", +] + +[[package]] +name = "quickcheck_macros" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.8", + "syn 1.0.58", +] + [[package]] name = "quote" version = "0.6.13" @@ -1724,13 +1780,25 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc 0.2.0", ] +[[package]] +name = "rand" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18519b42a40024d661e1714153e9ad0c3de27cd495760ceb09710920f1098b1e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.1", + "rand_hc 0.3.0", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1751,6 +1819,16 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.1", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1772,7 +1850,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" +dependencies = [ + "getrandom 0.2.1", ] [[package]] @@ -1793,6 +1880,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.1", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -1876,14 +1972,23 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom", - "redox_syscall", + "getrandom 0.1.16", + "redox_syscall 0.1.57", "rust-argon2", ] @@ -2037,18 +2142,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "9bdd36f49e35b61d49efd8aa7fc068fd295961fd2286d0b2ee9a4c7a14e99cc3" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "552954ce79a059ddd5fd68c271592374bd15cab2274970380c000118aeffe1cd" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", @@ -2177,9 +2282,9 @@ dependencies = [ [[package]] name = "stderrlog" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b02f316286ae558d83acc93dd81eaba096e746987a7961d4a9ae026842bae67f" +checksum = "45a53e2eff3e94a019afa6265e8ee04cb05b9d33fe9f5078b14e4e391d155a38" dependencies = [ "atty", "chrono", @@ -2299,14 +2404,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand 0.7.3", - "redox_syscall", + "rand 0.8.2", + "redox_syscall 0.2.4", "remove_dir_all", "winapi", ] @@ -2372,12 +2477,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", "winapi", ] @@ -2433,9 +2537,9 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "uuid" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "vec_map" @@ -2474,9 +2578,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" [[package]] name = "wasm-bindgen" diff --git a/Cargo.toml b/Cargo.toml index a6dec7b..8fa2564 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,18 +14,18 @@ members = [ ] [dependencies] -anyhow = "1.0.37" +anyhow = "1.0.38" bass-sys = { path = "bass-sys" } ggez = "0.5.1" -log = "0.4.11" -stderrlog = "0.5.0" +log = "0.4.13" +stderrlog = "0.5.1" num = "0.3.1" ordered-float = "2.0.1" structopt = "0.3.21" [dependencies.libosu] git = "https://github.com/iptq/libosu" -rev = "557d0a321405516f12c3939c1207c7341f796f35" +rev = "df7ffa4b51328479addde0804930ec76112b3b69" [features] clippy = [] diff --git a/framework/Cargo.toml b/framework/Cargo.toml index 2901370..40cbec9 100644 --- a/framework/Cargo.toml +++ b/framework/Cargo.toml @@ -4,6 +4,4 @@ version = "0.1.0" authors = ["Michael Zhang "] edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] diff --git a/framework/src/lib.rs b/framework/src/lib.rs index e69de29..8b13789 100644 --- a/framework/src/lib.rs +++ b/framework/src/lib.rs @@ -0,0 +1 @@ + diff --git a/framework/src/renderer.rs b/framework/src/renderer.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/audio.rs b/src/audio.rs index 21e1987..4982fe3 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -4,6 +4,8 @@ use std::ptr; use anyhow::Result; use bass::constants::*; +use libosu::timing::TimestampSec; +use ordered_float::NotNan; pub struct AudioEngine { current_device: AudioDevice, diff --git a/src/game/mod.rs b/src/game/mod.rs index 02019aa..9d657c1 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -7,6 +7,7 @@ use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::Read; use std::path::Path; +use std::str::FromStr; use anyhow::Result; use ggez::{ @@ -86,7 +87,7 @@ impl Game { let mut contents = String::new(); file.read_to_string(&mut contents)?; - let beatmap = Beatmap::from_osz(&contents)?; + let beatmap = Beatmap::from_str(&contents)?; self.beatmap = BeatmapExt::new(beatmap); self.beatmap.compute_stacking(); @@ -214,8 +215,8 @@ impl Game { let ho_time = (ho.inner.start_time.0 as f64) / 1000.0; let stacking = ho.stacking as f32 * STACK_DISTANCE as f32; let pos = [ - PLAYFIELD_BOUNDS.x + osupx_scale_x * (ho.inner.pos.0 as f32 - stacking), - PLAYFIELD_BOUNDS.y + osupx_scale_y * (ho.inner.pos.1 as f32 - stacking), + PLAYFIELD_BOUNDS.x + osupx_scale_x * (ho.inner.pos.x as f32 - stacking), + PLAYFIELD_BOUNDS.y + osupx_scale_y * (ho.inner.pos.y as f32 - stacking), ]; let color = draw_info.color; @@ -240,8 +241,8 @@ impl Game { let end_pos = ho.inner.end_pos().unwrap(); let end_pos = [ - PLAYFIELD_BOUNDS.x + osupx_scale_x * end_pos.0 as f32, - PLAYFIELD_BOUNDS.y + osupx_scale_y * end_pos.1 as f32, + PLAYFIELD_BOUNDS.x + osupx_scale_x * end_pos.x as f32, + PLAYFIELD_BOUNDS.y + osupx_scale_y * end_pos.y as f32, ]; self.skin.hitcircle.draw( ctx, @@ -283,8 +284,8 @@ impl Game { let travel_length = travel_percent * info.pixel_length; let pos = spline.point_at_length(travel_length); let ball_pos = [ - PLAYFIELD_BOUNDS.x + osupx_scale_x * pos.0 as f32, - PLAYFIELD_BOUNDS.y + osupx_scale_y * pos.1 as f32, + PLAYFIELD_BOUNDS.x + osupx_scale_x * pos.x as f32, + PLAYFIELD_BOUNDS.y + osupx_scale_y * pos.y as f32, ]; self.skin.sliderb.draw_frame( ctx, @@ -322,7 +323,7 @@ impl Game { let pos = song.position()?; if let Some(timing_point) = self.beatmap.inner.timing_points.first() { - if pos < timing_point.time.as_seconds() { + if pos < timing_point.time.as_seconds().0.into_inner() { if let TimingPointKind::Uninherited(_) = &timing_point.kind { self.current_uninherited_timing_point = Some(timing_point.clone()); } @@ -332,7 +333,7 @@ impl Game { let mut found_uninherited = false; let mut found_inherited = false; for timing_point in self.beatmap.inner.timing_points.iter() { - if pos < timing_point.time.as_seconds() { + if pos < timing_point.time.as_seconds().0.into_inner() { continue; } @@ -366,7 +367,7 @@ impl Game { .. }) = &self.current_uninherited_timing_point { - let diff = pos - time.as_seconds(); + let diff = pos - time.as_seconds().0.into_inner(); let tick = info.mpb / 1000.0 / info.meter as f64; let beats = (diff / tick).round(); let frac = diff - beats * tick; diff --git a/src/game/seeker.rs b/src/game/seeker.rs index e0204d3..a3f1b53 100644 --- a/src/game/seeker.rs +++ b/src/game/seeker.rs @@ -33,7 +33,7 @@ impl Game { TimingPointKind::Uninherited(_) => Color::new(0.8, 0.0, 0.0, 0.5), }; - let percent = timing_point.time.as_seconds() / len; + let percent = timing_point.time.as_seconds().0.into_inner() / len; let x = BOUNDS.x + percent as f32 * BOUNDS.w; let line = Mesh::new_line( diff --git a/src/game/sliders.rs b/src/game/sliders.rs index 7d029c3..a2f411c 100644 --- a/src/game/sliders.rs +++ b/src/game/sliders.rs @@ -47,9 +47,8 @@ impl Game { .spline_points .iter() .map(|point| { - let (x, y) = (point.0, point.1); - let x2 = rect.x as f64 + osupx_scale_x * x; - let y2 = rect.y as f64 + osupx_scale_y * y; + let x2 = rect.x as f64 + osupx_scale_x * point.x; + let y2 = rect.y as f64 + osupx_scale_y * point.y; boundx = boundx.min(x2 - cs_osupx); boundy = boundy.min(y2 - cs_osupx); boundw = boundw.max(x2 + cs_osupx - boundx); @@ -104,16 +103,15 @@ impl Game { control_points: &[Point], rect: Rect, ) -> Result<()> { - let osupx_scale_x = rect.w as f64 / 512.0; - let osupx_scale_y = rect.h as f64 / 384.0; + let osupx_scale_x = rect.w as f32 / 512.0; + let osupx_scale_y = rect.h as f32 / 384.0; let points_mapped = control_points .iter() .map(|point| { - let (x, y) = (point.0 as f64, point.1 as f64); - let x2 = rect.x as f64 + osupx_scale_x * x; - let y2 = rect.y as f64 + osupx_scale_y * y; - [x2 as f32, y2 as f32].into() + let x2 = rect.x as f32 + osupx_scale_x * point.x as f32; + let y2 = rect.y as f32 + osupx_scale_y * point.y as f32; + [x2, y2].into() }) .collect::>>(); diff --git a/src/game/timeline.rs b/src/game/timeline.rs index 1938f00..0d9d119 100644 --- a/src/game/timeline.rs +++ b/src/game/timeline.rs @@ -4,7 +4,10 @@ use ggez::{ nalgebra::Point2, Context, }; -use libosu::{hitobject::HitObjectKind, timing::TimingPointKind}; +use libosu::{ + hitobject::HitObjectKind, + timing::{Duration, TimestampSec, TimingPointKind}, +}; use crate::hitobject::HitObjectExt; @@ -56,13 +59,13 @@ impl Game { &uninherited_timing_points[i], uninherited_timing_points.get(i + 1), ); - let fst_time = fst.time.as_seconds(); + let fst_time = fst.time.as_seconds().0.into_inner(); if let TimingPointKind::Uninherited(info) = &fst.kind { last_uninherited = Some(info); } let snd_time = if let Some(snd) = snd { - let snd_time = snd.time.as_seconds(); + let snd_time = snd.time.as_seconds().0.into_inner(); if snd_time >= timeline_left && snd_time <= timeline_right { Some(snd_time) } else { @@ -85,7 +88,7 @@ impl Game { let beat = last_uninherited.mpb / 1000.0; let ticks = TICKS[last_uninherited.meter as usize]; - let mut time = fst.time.as_seconds(); + let mut time = fst.time.as_seconds().0.into_inner(); let passed_measures = ((timeline_left - time) / beat).floor(); time += passed_measures * beat; @@ -158,7 +161,9 @@ impl Game { .beatmap .inner .get_hitobject_end_time(&ho.inner) - .as_seconds(); + .as_seconds() + .0 + .into_inner(); let color = self.combo_colors[ho.color_idx];