allow scrolling before the first timing point

This commit is contained in:
Michael Zhang 2021-01-10 02:15:17 -06:00
parent 99b6a02d8e
commit 8cc1d578ab
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

View file

@ -84,6 +84,7 @@ impl Game {
let song = Sound::create(dir.join(&self.beatmap.inner.audio_filename))?;
self.song = Some(song);
self.timestamp_changed()?;
Ok(())
}
@ -292,10 +293,18 @@ impl Game {
if let Some(song) = &self.song {
let pos = song.position()?;
if let Some(timing_point) = self.beatmap.inner.timing_points.first() {
if pos < timing_point.time.as_seconds() {
if let TimingPointKind::Uninherited(_) = &timing_point.kind {
self.current_uninherited_timing_point = Some(timing_point.clone());
}
}
}
let mut found_uninherited = false;
let mut found_inherited = false;
for timing_point in self.beatmap.inner.timing_points.iter() {
if timing_point.time.as_seconds() > pos {
if pos < timing_point.time.as_seconds() {
continue;
}
@ -329,7 +338,6 @@ impl Game {
..
}) = &self.current_uninherited_timing_point
{
if pos > time.as_seconds() {
let diff = pos - time.as_seconds();
let tick = info.mpb / 1000.0 / info.meter as f64;
let beats = (diff / tick).round();
@ -344,7 +352,6 @@ impl Game {
}
}
}
}
if let Some(delta) = delta {
song.set_position(pos + delta)?;
self.timestamp_changed()?;
@ -378,7 +385,8 @@ impl EventHandler for Game {
..
}) = &self.current_uninherited_timing_point
{
let steps = -1 * if mods.contains(KeyMods::SHIFT) {
let steps = -1
* if mods.contains(KeyMods::SHIFT) {
info.meter as i32
} else {
1