doc: adjusted crate-level docs & readme
This commit is contained in:
@@ -79,11 +79,12 @@ Sometimes you might want to calculate the difficulty of a map or performance of
|
|||||||
This could be done by using `passed_objects` as the amount of objects that were passed so far.
|
This could be done by using `passed_objects` as the amount of objects that were passed so far.
|
||||||
However, this requires to recalculate the beginning again and again, we can be more efficient than that.
|
However, this requires to recalculate the beginning again and again, we can be more efficient than that.
|
||||||
|
|
||||||
Instead, you should use `GradualDifficultyAttributes` and `GradualPerformanceAttributes`:
|
Instead, you should enable the `gradual` feature and use `GradualDifficulty` and `GradualPerformance`:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use rosu_pp::{
|
use rosu_pp::{
|
||||||
Beatmap, BeatmapExt, GradualPerformanceAttributes, ScoreState, taiko::TaikoScoreState,
|
Beatmap, BeatmapExt, GradualDifficulty, GradualPerformance, ScoreState,
|
||||||
|
taiko::TaikoScoreState,
|
||||||
};
|
};
|
||||||
|
|
||||||
let map = match Beatmap::from_path("/path/to/file.osu") {
|
let map = match Beatmap::from_path("/path/to/file.osu") {
|
||||||
@@ -94,11 +95,10 @@ let map = match Beatmap::from_path("/path/to/file.osu") {
|
|||||||
let mods = 8 + 64; // HDDT
|
let mods = 8 + 64; // HDDT
|
||||||
|
|
||||||
// If you're only interested in the star rating or other difficulty value,
|
// If you're only interested in the star rating or other difficulty value,
|
||||||
// use `GradualDifficultyAttributes`, either through its function `new`
|
// use `GradualDifficulty`.
|
||||||
// or through the method `BeatmapExt::gradual_difficulty`.
|
let gradual_difficulty = GradualDifficulty::new(&map, mods);
|
||||||
let gradual_difficulty = map.gradual_difficulty(mods);
|
|
||||||
|
|
||||||
// Since `GradualDifficultyAttributes` implements `Iterator`, you can use
|
// Since `GradualDifficulty` implements `Iterator`, you can use
|
||||||
// any iterate function on it, use it in loops, collect them into a `Vec`, ...
|
// any iterate function on it, use it in loops, collect them into a `Vec`, ...
|
||||||
for (i, difficulty) in gradual_difficulty.enumerate() {
|
for (i, difficulty) in gradual_difficulty.enumerate() {
|
||||||
println!("Stars after object {}: {}", i, difficulty.stars());
|
println!("Stars after object {}: {}", i, difficulty.stars());
|
||||||
@@ -107,7 +107,7 @@ for (i, difficulty) in gradual_difficulty.enumerate() {
|
|||||||
// Gradually calculating performance values does the same as calculating
|
// Gradually calculating performance values does the same as calculating
|
||||||
// difficulty attributes but it goes the extra step and also evaluates
|
// difficulty attributes but it goes the extra step and also evaluates
|
||||||
// the state of a score for these difficulty attributes.
|
// the state of a score for these difficulty attributes.
|
||||||
let mut gradual_performance = map.gradual_performance(mods);
|
let mut gradual_performance = GradualPerformance::new(&map, mods);
|
||||||
|
|
||||||
// The default score state is kinda chunky because it considers all modes.
|
// The default score state is kinda chunky because it considers all modes.
|
||||||
let state = ScoreState {
|
let state = ScoreState {
|
||||||
@@ -121,7 +121,7 @@ let state = ScoreState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Process the score state after the first object
|
// Process the score state after the first object
|
||||||
let curr_performance = match gradual_performance.process_next_object(state) {
|
let curr_performance = match gradual_performance.next(state) {
|
||||||
Some(perf) => perf,
|
Some(perf) => perf,
|
||||||
None => panic!("the map has no hit objects"),
|
None => panic!("the map has no hit objects"),
|
||||||
};
|
};
|
||||||
@@ -131,8 +131,8 @@ println!("PP after the first object: {}", curr_performance.pp());
|
|||||||
// If you're only interested in maps of a specific mode, consider
|
// If you're only interested in maps of a specific mode, consider
|
||||||
// using the mode's gradual calculator instead of the general one.
|
// using the mode's gradual calculator instead of the general one.
|
||||||
// Let's assume it's a taiko map.
|
// Let's assume it's a taiko map.
|
||||||
// Instead of starting off with `BeatmapExt::gradual_performance` one could have
|
// Instead of starting off with `GradualPerformance` one could have
|
||||||
// created the struct via `TaikoGradualPerformanceAttributes::new`.
|
// used `TaikoGradualPerformance`.
|
||||||
let mut gradual_performance = match gradual_performance {
|
let mut gradual_performance = match gradual_performance {
|
||||||
GradualPerformanceAttributes::Taiko(gradual) => gradual,
|
GradualPerformanceAttributes::Taiko(gradual) => gradual,
|
||||||
_ => panic!("the map was not taiko but {:?}", map.mode),
|
_ => panic!("the map was not taiko but {:?}", map.mode),
|
||||||
@@ -146,10 +146,10 @@ let state = TaikoScoreState {
|
|||||||
n_misses: 1,
|
n_misses: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process the next 10 objects in one go
|
// Process the next 10 objects in one go (`nth` takes a zero-based value).
|
||||||
let curr_performance = match gradual_performance.process_next_n_objects(state, 10) {
|
let curr_performance = match gradual_performance.nth(state, 9) {
|
||||||
Some(perf) => perf,
|
Some(perf) => perf,
|
||||||
None => panic!("the last `process_next_object` already processed the last object"),
|
None => panic!("the previous `next` already processed the last object"),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("PP after the first 11 objects: {}", curr_performance.pp());
|
println!("PP after the first 11 objects: {}", curr_performance.pp());
|
||||||
|
|||||||
+98
-97
@@ -1,3 +1,15 @@
|
|||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
#![deny(
|
||||||
|
clippy::all,
|
||||||
|
nonstandard_style,
|
||||||
|
rust_2018_idioms,
|
||||||
|
unused,
|
||||||
|
warnings,
|
||||||
|
missing_debug_implementations,
|
||||||
|
missing_docs,
|
||||||
|
rustdoc::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.
|
||||||
//!
|
//!
|
||||||
//! Async is supported through features, see below.
|
//! Async is supported through features, see below.
|
||||||
@@ -74,91 +86,92 @@
|
|||||||
//! println!("PP: {}", result.pp());
|
//! println!("PP: {}", result.pp());
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! ## Gradual calculation
|
#![cfg_attr(feature = "gradual", doc = r#"
|
||||||
//! Sometimes you might want to calculate the difficulty of a map or performance of a score after each hit object.
|
## Gradual calculation
|
||||||
//! This could be done by using `passed_objects` as the amount of objects that were passed so far.
|
Sometimes you might want to calculate the difficulty of a map or performance of a score after each hit object.
|
||||||
//! However, this requires to recalculate the beginning again and again, we can be more efficient than that.
|
This could be done by using `passed_objects` as the amount of objects that were passed so far.
|
||||||
//!
|
However, this requires to recalculate the beginning again and again, we can be more efficient than that.
|
||||||
//! Instead, you should use [`GradualDifficulty`] and [`GradualPerformance`]:
|
|
||||||
//!
|
Instead, you should enable the `gradual` feature and use [`GradualDifficulty`] and [`GradualPerformance`]:
|
||||||
//! ```no_run
|
|
||||||
//! use rosu_pp::{
|
```no_run
|
||||||
//! Beatmap, BeatmapExt, GradualPerformance, ScoreState,
|
use rosu_pp::{
|
||||||
//! taiko::TaikoScoreState,
|
Beatmap, BeatmapExt, GradualDifficulty, GradualPerformance, ScoreState,
|
||||||
//! };
|
taiko::TaikoScoreState,
|
||||||
//!
|
};
|
||||||
//! # /*
|
|
||||||
//! let map = match Beatmap::from_path("/path/to/file.osu") {
|
# /*
|
||||||
//! Ok(map) => map,
|
let map = match Beatmap::from_path("/path/to/file.osu") {
|
||||||
//! Err(why) => panic!("Error while parsing map: {}", why),
|
Ok(map) => map,
|
||||||
//! };
|
Err(why) => panic!("Error while parsing map: {}", why),
|
||||||
//! # */
|
};
|
||||||
//! # let map = Beatmap::default();
|
# */
|
||||||
//!
|
# let map = Beatmap::default();
|
||||||
//! let mods = 8 + 64; // HDDT
|
|
||||||
//!
|
let mods = 8 + 64; // HDDT
|
||||||
//! // If you're only interested in the star rating or other difficulty value,
|
|
||||||
//! // use `GradualDifficultyAttributes`, either through its function `new`
|
// If you're only interested in the star rating or other difficulty value,
|
||||||
//! // or through the method `BeatmapExt::gradual_difficulty`.
|
// use `GradualDifficulty`.
|
||||||
//! let gradual_difficulty = map.gradual_difficulty(mods);
|
let gradual_difficulty = GradualDifficulty::new(&map, mods);
|
||||||
//!
|
|
||||||
//! // Since `GradualDifficultyAttributes` implements `Iterator`, you can use
|
// Since `GradualDifficulty` implements `Iterator`, you can use
|
||||||
//! // any iterate function on it, use it in loops, collect them into a `Vec`, ...
|
// any iterate function on it, use it in loops, collect them into a `Vec`, ...
|
||||||
//! for (i, difficulty) in gradual_difficulty.enumerate() {
|
for (i, difficulty) in gradual_difficulty.enumerate() {
|
||||||
//! println!("Stars after object {}: {}", i, difficulty.stars());
|
println!("Stars after object {}: {}", i, difficulty.stars());
|
||||||
//! }
|
}
|
||||||
//!
|
|
||||||
//! // Gradually calculating performance values does the same as calculating
|
// Gradually calculating performance values does the same as calculating
|
||||||
//! // difficulty attributes but it goes the extra step and also evaluates
|
// difficulty attributes but it goes the extra step and also evaluates
|
||||||
//! // the state of a score for these difficulty attributes.
|
// the state of a score for these difficulty attributes.
|
||||||
//! let mut gradual_performance = map.gradual_performance(mods);
|
let mut gradual_performance = GradualPerformance::new(&map, mods);
|
||||||
//!
|
|
||||||
//! // The default score state is kinda chunky because it considers all modes.
|
// The default score state is kinda chunky because it considers all modes.
|
||||||
//! let state = ScoreState {
|
let state = ScoreState {
|
||||||
//! max_combo: 1,
|
max_combo: 1,
|
||||||
//! n_geki: 0, // only relevant for mania
|
n_geki: 0, // only relevant for mania
|
||||||
//! n_katu: 0, // only relevant for mania and ctb
|
n_katu: 0, // only relevant for mania and ctb
|
||||||
//! n300: 1,
|
n300: 1,
|
||||||
//! n100: 0,
|
n100: 0,
|
||||||
//! n50: 0,
|
n50: 0,
|
||||||
//! n_misses: 0,
|
n_misses: 0,
|
||||||
//! };
|
};
|
||||||
//!
|
|
||||||
//! // Process the score state after the first object
|
// Process the score state after the first object
|
||||||
//! let curr_performance = match gradual_performance.process_next_object(state) {
|
let curr_performance = match gradual_performance.next(state) {
|
||||||
//! Some(perf) => perf,
|
Some(perf) => perf,
|
||||||
//! None => panic!("the map has no hit objects"),
|
None => panic!("the map has no hit objects"),
|
||||||
//! };
|
};
|
||||||
//!
|
|
||||||
//! println!("PP after the first object: {}", curr_performance.pp());
|
println!("PP after the first object: {}", curr_performance.pp());
|
||||||
//!
|
|
||||||
//! // If you're only interested in maps of a specific mode, consider
|
// If you're only interested in maps of a specific mode, consider
|
||||||
//! // using the mode's gradual calculator instead of the general one.
|
// using the mode's gradual calculator instead of the general one.
|
||||||
//! // Let's assume it's a taiko map.
|
// Let's assume it's a taiko map.
|
||||||
//! // Instead of starting off with `BeatmapExt::gradual_performance` one could have
|
// Instead of starting off with `GradualPerformance` one could have
|
||||||
//! // created the struct via `TaikoGradualPerformanceAttributes::new`.
|
// used `TaikoGradualPerformance`.
|
||||||
//! let mut gradual_performance = match gradual_performance {
|
let mut gradual_performance = match gradual_performance {
|
||||||
//! GradualPerformance::Taiko(gradual) => gradual,
|
GradualPerformance::Taiko(gradual) => gradual,
|
||||||
//! _ => panic!("the map was not taiko but {:?}", map.mode),
|
_ => panic!("the map was not taiko but {:?}", map.mode),
|
||||||
//! };
|
};
|
||||||
//!
|
|
||||||
//! // A little simpler than the general score state.
|
// A little simpler than the general score state.
|
||||||
//! let state = TaikoScoreState {
|
let state = TaikoScoreState {
|
||||||
//! max_combo: 11,
|
max_combo: 11,
|
||||||
//! n300: 9,
|
n300: 9,
|
||||||
//! n100: 1,
|
n100: 1,
|
||||||
//! n_misses: 1,
|
n_misses: 1,
|
||||||
//! };
|
};
|
||||||
//!
|
|
||||||
//! // Process the next 10 objects in one go
|
// Process the next 10 objects in one go (`nth` takes a zero-based value).
|
||||||
//! let curr_performance = match gradual_performance.nth(state, 10) {
|
let curr_performance = match gradual_performance.nth(state, 9) {
|
||||||
//! Some(perf) => perf,
|
Some(perf) => perf,
|
||||||
//! None => panic!("the last `process_next_object` already processed the last object"),
|
None => panic!("the last `next` already processed the last object"),
|
||||||
//! };
|
};
|
||||||
//!
|
|
||||||
//! println!("PP after the first 11 objects: {}", curr_performance.pp());
|
println!("PP after the first 11 objects: {}", curr_performance.pp());
|
||||||
//! ```
|
```
|
||||||
//!
|
|
||||||
|
"#)]
|
||||||
//! ## Features
|
//! ## Features
|
||||||
//!
|
//!
|
||||||
//! | Flag | Description |
|
//! | Flag | Description |
|
||||||
@@ -169,18 +182,6 @@
|
|||||||
//! | `gradual` | Enable gradual difficulty and performance calculation |
|
//! | `gradual` | Enable gradual difficulty and performance calculation |
|
||||||
//!
|
//!
|
||||||
|
|
||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
|
||||||
#![deny(
|
|
||||||
clippy::all,
|
|
||||||
nonstandard_style,
|
|
||||||
rust_2018_idioms,
|
|
||||||
unused,
|
|
||||||
warnings,
|
|
||||||
missing_debug_implementations,
|
|
||||||
missing_docs,
|
|
||||||
rustdoc::broken_intra_doc_links
|
|
||||||
)]
|
|
||||||
|
|
||||||
/// Everything about osu!catch.
|
/// Everything about osu!catch.
|
||||||
pub mod catch;
|
pub mod catch;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user