allow scrolling before the first timing point
This commit is contained in:
parent
99b6a02d8e
commit
8cc1d578ab
1 changed files with 27 additions and 19 deletions
|
@ -84,6 +84,7 @@ impl Game {
|
||||||
|
|
||||||
let song = Sound::create(dir.join(&self.beatmap.inner.audio_filename))?;
|
let song = Sound::create(dir.join(&self.beatmap.inner.audio_filename))?;
|
||||||
self.song = Some(song);
|
self.song = Some(song);
|
||||||
|
self.timestamp_changed()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -292,10 +293,18 @@ impl Game {
|
||||||
if let Some(song) = &self.song {
|
if let Some(song) = &self.song {
|
||||||
let pos = song.position()?;
|
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_uninherited = false;
|
||||||
let mut found_inherited = false;
|
let mut found_inherited = false;
|
||||||
for timing_point in self.beatmap.inner.timing_points.iter() {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +338,6 @@ impl Game {
|
||||||
..
|
..
|
||||||
}) = &self.current_uninherited_timing_point
|
}) = &self.current_uninherited_timing_point
|
||||||
{
|
{
|
||||||
if pos > time.as_seconds() {
|
|
||||||
let diff = pos - time.as_seconds();
|
let diff = pos - time.as_seconds();
|
||||||
let tick = info.mpb / 1000.0 / info.meter as f64;
|
let tick = info.mpb / 1000.0 / info.meter as f64;
|
||||||
let beats = (diff / tick).round();
|
let beats = (diff / tick).round();
|
||||||
|
@ -344,7 +352,6 @@ impl Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if let Some(delta) = delta {
|
if let Some(delta) = delta {
|
||||||
song.set_position(pos + delta)?;
|
song.set_position(pos + delta)?;
|
||||||
self.timestamp_changed()?;
|
self.timestamp_changed()?;
|
||||||
|
@ -378,7 +385,8 @@ impl EventHandler for Game {
|
||||||
..
|
..
|
||||||
}) = &self.current_uninherited_timing_point
|
}) = &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
|
info.meter as i32
|
||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
|
|
Loading…
Add table
Reference in a new issue