introduced auxiliary feature 'sliders'
This commit is contained in:
+6
-3
@@ -16,18 +16,21 @@ default = ["osu", "taiko", "fruits", "mania", "no_leniency"]
|
|||||||
# game modes
|
# game modes
|
||||||
osu = []
|
osu = []
|
||||||
taiko = []
|
taiko = []
|
||||||
fruits = []
|
fruits = ["sliders"]
|
||||||
mania = []
|
mania = []
|
||||||
|
|
||||||
# osu!standard version
|
# osu!standard version
|
||||||
all_included = []
|
all_included = ["sliders"]
|
||||||
no_leniency = []
|
no_leniency = ["sliders"]
|
||||||
no_sliders_no_leniency = []
|
no_sliders_no_leniency = []
|
||||||
|
|
||||||
# async version
|
# async version
|
||||||
async_std = ["async-std"]
|
async_std = ["async-std"]
|
||||||
async_tokio = ["tokio"]
|
async_tokio = ["tokio"]
|
||||||
|
|
||||||
|
# auxiliary, no need to set yourself
|
||||||
|
sliders = []
|
||||||
|
|
||||||
[dependencies.async-std]
|
[dependencies.async-std]
|
||||||
version = "1.9"
|
version = "1.9"
|
||||||
optional = true
|
optional = true
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ impl<'p> ControlPointIter<'p> {
|
|||||||
pub(crate) enum ControlPoint {
|
pub(crate) enum ControlPoint {
|
||||||
Timing {
|
Timing {
|
||||||
time: f32,
|
time: f32,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)] // not used in `no_sliders_no_leniency` feature
|
||||||
beat_len: f32,
|
beat_len: f32,
|
||||||
},
|
},
|
||||||
Difficulty {
|
Difficulty {
|
||||||
@@ -51,7 +51,7 @@ pub(crate) enum ControlPoint {
|
|||||||
|
|
||||||
impl ControlPoint {
|
impl ControlPoint {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(dead_code)]
|
#[cfg(not(feature = "no_sliders_no_leniency"))]
|
||||||
pub(crate) fn time(&self) -> f32 {
|
pub(crate) fn time(&self) -> f32 {
|
||||||
match self {
|
match self {
|
||||||
Self::Timing { time, .. } => *time,
|
Self::Timing { time, .. } => *time,
|
||||||
|
|||||||
+1
-4
@@ -1,7 +1,4 @@
|
|||||||
#![cfg(any(
|
#![cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
|
|
||||||
use std::{borrow::Cow, cmp::Ordering, convert::identity, f32::consts::PI, iter};
|
use std::{borrow::Cow, cmp::Ordering, convert::identity, f32::consts::PI, iter};
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,3 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
|
|
||||||
|
|
||||||
//! A standalone crate to calculate star ratings and performance points for all [osu!](https://osu.ppy.sh/home) gamemodes.
|
//! A standalone crate to calculate star ratings and performance points for all [osu!](https://osu.ppy.sh/home) gamemodes.
|
||||||
//!
|
//!
|
||||||
//! Conversions between gamemodes are generally not supported.
|
//! Conversions between gamemodes are generally not supported.
|
||||||
@@ -135,6 +133,8 @@
|
|||||||
//! - \[x\] benchmarking
|
//! - \[x\] benchmarking
|
||||||
//! - \[x\] async parsing
|
//! - \[x\] async parsing
|
||||||
|
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
|
||||||
|
|
||||||
#[cfg(feature = "fruits")]
|
#[cfg(feature = "fruits")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "fruits")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "fruits")))]
|
||||||
pub mod fruits;
|
pub mod fruits;
|
||||||
|
|||||||
+1
-4
@@ -1,7 +1,4 @@
|
|||||||
#[cfg(any(
|
#[cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn is_linear(
|
pub(crate) fn is_linear(
|
||||||
p0: crate::parse::Pos2,
|
p0: crate::parse::Pos2,
|
||||||
|
|||||||
+3
-15
@@ -1,11 +1,5 @@
|
|||||||
use super::Pos2;
|
use super::Pos2;
|
||||||
|
|
||||||
#[cfg(any(
|
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
use super::PathControlPoint;
|
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
/// "Intermediate" hitobject created through parsing.
|
/// "Intermediate" hitobject created through parsing.
|
||||||
@@ -56,19 +50,13 @@ impl PartialOrd for HitObject {
|
|||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum HitObjectKind {
|
pub enum HitObjectKind {
|
||||||
Circle,
|
Circle,
|
||||||
#[cfg(any(
|
#[cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
Slider {
|
Slider {
|
||||||
pixel_len: f32,
|
pixel_len: f32,
|
||||||
repeats: usize,
|
repeats: usize,
|
||||||
control_points: Vec<PathControlPoint>,
|
control_points: Vec<super::PathControlPoint>,
|
||||||
},
|
},
|
||||||
#[cfg(not(any(
|
#[cfg(not(feature = "sliders"))]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
)))]
|
|
||||||
Slider {
|
Slider {
|
||||||
pixel_len: f32,
|
pixel_len: f32,
|
||||||
repeats: usize,
|
repeats: usize,
|
||||||
|
|||||||
+6
-25
@@ -25,10 +25,7 @@ use tokio::io::{AsyncBufReadExt, AsyncRead, BufReader};
|
|||||||
#[cfg(feature = "async_std")]
|
#[cfg(feature = "async_std")]
|
||||||
use async_std::io::{prelude::BufReadExt, BufReader as AsyncBufReader, Read as AsyncRead};
|
use async_std::io::{prelude::BufReadExt, BufReader as AsyncBufReader, Read as AsyncRead};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
pub use osu_fruits::*;
|
pub use osu_fruits::*;
|
||||||
|
|
||||||
fn sort_unstable<T: PartialOrd>(slice: &mut [T]) {
|
fn sort_unstable<T: PartialOrd>(slice: &mut [T]) {
|
||||||
@@ -761,20 +758,14 @@ impl Beatmap {
|
|||||||
let mut prev_time = 0.0;
|
let mut prev_time = 0.0;
|
||||||
let mut empty = true;
|
let mut empty = true;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
// `point_split` will be of type `Vec<&str>
|
// `point_split` will be of type `Vec<&str>
|
||||||
// with each element having its lifetime bound to `buf`.
|
// with each element having its lifetime bound to `buf`.
|
||||||
// To cirvumvent this, `point_split_raw` will contain
|
// To cirvumvent this, `point_split_raw` will contain
|
||||||
// the actual `&str` elements transmuted into `usize`.
|
// the actual `&str` elements transmuted into `usize`.
|
||||||
let mut point_split_raw: Vec<usize> = Vec::new();
|
let mut point_split_raw: Vec<usize> = Vec::new();
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
// Buffer to re-use for all sliders
|
// Buffer to re-use for all sliders
|
||||||
let mut vertices = Vec::new();
|
let mut vertices = Vec::new();
|
||||||
|
|
||||||
@@ -816,10 +807,7 @@ impl Beatmap {
|
|||||||
} else if kind & Self::SLIDER_FLAG > 0 {
|
} else if kind & Self::SLIDER_FLAG > 0 {
|
||||||
self.n_sliders += 1;
|
self.n_sliders += 1;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(feature = "sliders")]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
{
|
{
|
||||||
let mut control_points = Vec::new();
|
let mut control_points = Vec::new();
|
||||||
|
|
||||||
@@ -904,10 +892,7 @@ impl Beatmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(
|
#[cfg(not(feature = "sliders"))]
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
)))]
|
|
||||||
{
|
{
|
||||||
let repeats = split.nth(1).next_field("repeats")?.parse()?;
|
let repeats = split.nth(1).next_field("repeats")?.parse()?;
|
||||||
let pixel_len = split.next().next_field("pixel len")?.parse()?;
|
let pixel_len = split.next().next_field("pixel len")?.parse()?;
|
||||||
@@ -960,11 +945,7 @@ impl Beatmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Replace with `sliders` auxiliary feature
|
#[cfg(feature = "sliders")]
|
||||||
#[cfg(any(
|
|
||||||
feature = "fruits",
|
|
||||||
all(feature = "osu", not(feature = "no_sliders_no_leniency"))
|
|
||||||
))]
|
|
||||||
mod osu_fruits {
|
mod osu_fruits {
|
||||||
use crate::{math_util::is_linear, ParseError};
|
use crate::{math_util::is_linear, ParseError};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user