From 494021d0e1db0e76764aeae3a066e1468b9a1614 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sat, 9 Jan 2021 14:03:04 -0600 Subject: [PATCH] libosu update --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- README.md | 4 ++++ src/beatmap.rs | 4 ++-- src/game/mod.rs | 24 +++++++++++++++--------- src/game/sliders.rs | 6 +++++- src/game/timeline.rs | 4 ++-- src/{hit_object.rs => hitobject.rs} | 2 +- src/main.rs | 3 ++- 9 files changed, 34 insertions(+), 19 deletions(-) rename src/{hit_object.rs => hitobject.rs} (90%) diff --git a/Cargo.lock b/Cargo.lock index 0f23c8d..635a1b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,8 +1071,8 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" [[package]] name = "libosu" -version = "0.0.13" -source = "git+https://github.com/iptq/libosu?rev=dee4d05eeaba1313a17eefbbd7679a947b52fbc1#dee4d05eeaba1313a17eefbbd7679a947b52fbc1" +version = "0.0.14" +source = "git+https://github.com/iptq/libosu?rev=a54cfbdaa07265802bb47e35fbdc252337a5adcf#a54cfbdaa07265802bb47e35fbdc252337a5adcf" dependencies = [ "anyhow", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index 013643a..d5a1a34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,4 +21,4 @@ structopt = "0.3.21" [dependencies.libosu] git = "https://github.com/iptq/libosu" -rev = "dee4d05eeaba1313a17eefbbd7679a947b52fbc1" +rev = "a54cfbdaa07265802bb47e35fbdc252337a5adcf" diff --git a/README.md b/README.md index 34a1c21..642fd77 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,7 @@ license not sure yet, probably gpl includes code ported from ppy/osu, which is mit-licensed + +uses [libosu][1] + +[1]: https://github.com/iptq/libosu diff --git a/src/beatmap.rs b/src/beatmap.rs index 504efd6..499765c 100644 --- a/src/beatmap.rs +++ b/src/beatmap.rs @@ -1,6 +1,6 @@ -use libosu::{Beatmap, HitObjectKind, Point}; +use libosu::{beatmap::Beatmap, hitobject::HitObjectKind, math::Point}; -use crate::hit_object::HitObjectExt; +use crate::hitobject::HitObjectExt; pub const STACK_DISTANCE: f64 = 3.0; diff --git a/src/game/mod.rs b/src/game/mod.rs index e6cd4ec..831384a 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -10,16 +10,19 @@ use std::path::Path; use anyhow::Result; use ggez::{ event::{EventHandler, KeyCode, KeyMods}, - graphics::{ - self, Color, DrawMode, DrawParam, FilterMode, Mesh, Rect, StrokeOptions, Text, WHITE, - }, + graphics::{self, Color, DrawParam, FilterMode, Rect, Text, WHITE}, Context, GameError, GameResult, }; -use libosu::{Beatmap, HitObjectKind, Point, SpinnerInfo, Spline}; +use libosu::{ + beatmap::Beatmap, + hitobject::{HitObjectKind, SpinnerInfo}, + math::Point, + spline::Spline, +}; use crate::audio::{AudioEngine, Sound}; use crate::beatmap::{BeatmapExt, STACK_DISTANCE}; -use crate::hit_object::HitObjectExt; +use crate::hitobject::HitObjectExt; use crate::skin::Skin; use self::sliders::render_slider; @@ -89,7 +92,7 @@ impl Game { } } - fn priv_draw(&mut self, ctx: &mut Context) -> Result<()> { + fn draw_helper(&mut self, ctx: &mut Context) -> Result<()> { // TODO: lol graphics::clear(ctx, [0.0, 0.0, 0.0, 1.0].into()); @@ -250,13 +253,16 @@ impl EventHandler for Game { } fn key_up_event(&mut self, _: &mut Context, keycode: KeyCode, _: KeyMods) { - if let KeyCode::Space = keycode { - self.toggle_playing(); + use KeyCode::*; + match keycode { + Space => self.toggle_playing(), + Colon => {} + _ => {} } } fn draw(&mut self, ctx: &mut Context) -> GameResult { - if let Err(err) = self.priv_draw(ctx) { + if let Err(err) = self.draw_helper(ctx) { return Err(GameError::RenderError(err.to_string())); }; Ok(()) diff --git a/src/game/sliders.rs b/src/game/sliders.rs index 07770dd..83c0426 100644 --- a/src/game/sliders.rs +++ b/src/game/sliders.rs @@ -6,7 +6,11 @@ use ggez::{ nalgebra::Point2, Context, }; -use libosu::{Beatmap, HitObject, HitObjectKind, Spline}; +use libosu::{ + beatmap::Beatmap, + hitobject::{HitObject, HitObjectKind}, + spline::Spline, +}; use crate::game::SliderCache; diff --git a/src/game/timeline.rs b/src/game/timeline.rs index 21b6102..da2aca3 100644 --- a/src/game/timeline.rs +++ b/src/game/timeline.rs @@ -4,9 +4,9 @@ use ggez::{ nalgebra::Point2, Context, }; -use libosu::{HitObjectKind, TimingPointKind}; +use libosu::{hitobject::HitObjectKind, timing::TimingPointKind}; -use crate::hit_object::HitObjectExt; +use crate::hitobject::HitObjectExt; use super::Game; diff --git a/src/hit_object.rs b/src/hitobject.rs similarity index 90% rename from src/hit_object.rs rename to src/hitobject.rs index 15f9acd..068ced8 100644 --- a/src/hit_object.rs +++ b/src/hitobject.rs @@ -1,4 +1,4 @@ -use libosu::{Color, HitObject}; +use libosu::hitobject::HitObject; pub struct HitObjectExt { pub inner: HitObject, diff --git a/src/main.rs b/src/main.rs index 5ff88f6..2c4ca70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #[macro_use] extern crate anyhow; +#[allow(unused_macros, unused_imports)] #[macro_use] extern crate log; extern crate bass_sys as bass; @@ -7,7 +8,7 @@ extern crate bass_sys as bass; mod audio; mod beatmap; mod game; -mod hit_object; +mod hitobject; mod skin; use std::path::PathBuf;