Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions midi-file/src/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ impl PlaybackState {
self.running = time;
}

pub fn is_finished(&self) -> bool {
self.time() >= self.length()
}

pub fn percentage(&self) -> f32 {
self.running.as_secs_f32() / self.length().as_secs_f32()
}
Expand Down
4 changes: 4 additions & 0 deletions neothesia/src/scene/playing_scene/midi_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ impl MidiPlayer {
self.playback.percentage()
}

pub fn is_finished(&self) -> bool {
self.playback.is_finished()
}

pub fn time(&self) -> Duration {
self.playback.time()
}
Expand Down
4 changes: 4 additions & 0 deletions neothesia/src/scene/playing_scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ impl Scene for PlayingScene {

self.bg_quad_pipeline.prepare(&ctx.gpu.queue);
self.fg_quad_pipeline.prepare(&ctx.gpu.queue);

if self.player.is_finished() {
ctx.proxy.send_event(NeothesiaEvent::MainMenu).ok();
}
}

fn render<'pass>(
Expand Down