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