Implement freeze
This commit is contained in:
parent
dc27f999c5
commit
b7f60302ee
|
@ -32,8 +32,6 @@ Batch conversion is possible with the included shell script `batch_convert.sh`
|
||||||
* Since *osu!mania* does not support shock arrows, it either ignores them or
|
* Since *osu!mania* does not support shock arrows, it either ignores them or
|
||||||
(by default) replaces them with a two-key combination (↑↓ or ←→); you can
|
(by default) replaces them with a two-key combination (↑↓ or ←→); you can
|
||||||
change this with the (`--shock-action` option)
|
change this with the (`--shock-action` option)
|
||||||
* Freezes do not work (I do not know how to get the start time yet) and
|
|
||||||
therefore are disabled in code (`ddr::ssq::FREEZE`)
|
|
||||||
* Known problems listed for unxwb (for wave banks without entry names having
|
* Known problems listed for unxwb (for wave banks without entry names having
|
||||||
2 entries, which often are preview and full song, the longest one is used by
|
2 entries, which often are preview and full song, the longest one is used by
|
||||||
default).
|
default).
|
||||||
|
|
|
@ -13,7 +13,6 @@ use crate::mini_parser::{MiniParser, MiniParserError};
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
|
|
||||||
const MEASURE_LENGTH: i32 = 4096;
|
const MEASURE_LENGTH: i32 = 4096;
|
||||||
const FREEZE: bool = false;
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
@ -231,6 +230,10 @@ impl Chart {
|
||||||
|
|
||||||
let mut parsed_steps = Vec::new();
|
let mut parsed_steps = Vec::new();
|
||||||
|
|
||||||
|
// indices of (normal) steps that start a freeze (they are not needed after processing all
|
||||||
|
// steps as they are already included in the freezes)
|
||||||
|
let mut freeze_steps = Vec::new();
|
||||||
|
|
||||||
for step in 0..count {
|
for step in 0..count {
|
||||||
let beats = measure_to_beats(measures[step]);
|
let beats = measure_to_beats(measures[step]);
|
||||||
|
|
||||||
|
@ -256,32 +259,24 @@ impl Chart {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if FREEZE {
|
match Self::find_last(parsed_steps.clone(), &row) {
|
||||||
match Self::find_last(parsed_steps.clone(), &row) {
|
Some(last_step) => {
|
||||||
Some(last_step) => {
|
parsed_steps.push(Step::Freeze {
|
||||||
parsed_steps.push(Step::Freeze {
|
start: if let Step::Step { beats, .. } = parsed_steps[last_step] {
|
||||||
start: if let Step::Step { beats, .. } = parsed_steps[last_step]
|
beats
|
||||||
{
|
} else {
|
||||||
beats
|
unreachable!()
|
||||||
} else {
|
},
|
||||||
unreachable!()
|
end: beats,
|
||||||
},
|
row,
|
||||||
end: beats,
|
});
|
||||||
row,
|
|
||||||
});
|
|
||||||
|
|
||||||
parsed_steps.remove(last_step);
|
freeze_steps.push(last_step);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
warn!(
|
warn!("Could not find previous step for freeze, adding normal step");
|
||||||
"Could not find previous step for freeze, adding normal step"
|
parsed_steps.push(Step::Step { beats, row });
|
||||||
);
|
|
||||||
parsed_steps.push(Step::Step { beats, row });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
trace!("Freeze disabled, adding normal step");
|
|
||||||
parsed_steps.push(Step::Step { beats, row });
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -300,6 +295,12 @@ impl Chart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove steps that start a freeze
|
||||||
|
freeze_steps.dedup();
|
||||||
|
for i in freeze_steps.iter().rev() {
|
||||||
|
parsed_steps.remove(*i);
|
||||||
|
}
|
||||||
|
|
||||||
debug!("Parsed {} steps", parsed_steps.len());
|
debug!("Parsed {} steps", parsed_steps.len());
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -376,10 +377,6 @@ pub struct SSQ {
|
||||||
|
|
||||||
impl SSQ {
|
impl SSQ {
|
||||||
pub fn parse(data: &[u8]) -> Result<Self, Error> {
|
pub fn parse(data: &[u8]) -> Result<Self, Error> {
|
||||||
debug!(
|
|
||||||
"Configuration: measure length: {}, use freezes: {}",
|
|
||||||
MEASURE_LENGTH, FREEZE
|
|
||||||
);
|
|
||||||
let mut cursor = Cursor::new(data);
|
let mut cursor = Cursor::new(data);
|
||||||
|
|
||||||
let mut ssq = Self {
|
let mut ssq = Self {
|
||||||
|
|
Reference in a new issue