Skip to content

Commit

Permalink
fix f5 music
Browse files Browse the repository at this point in the history
  • Loading branch information
Nertsal committed May 31, 2024
1 parent 231e02e commit a814f4d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum ConfirmAction {
pub struct EditorState {
context: Context,
transition: Option<geng::state::Transition>,
/// Stop music on the next `update` frame. Used when returning from F5 play to stop music.
stop_music_next_frame: bool,
render: EditorRender,
editor: Editor,
framebuffer_size: vec2<usize>,
Expand Down Expand Up @@ -183,6 +185,7 @@ impl EditorState {
) -> Self {
Self {
transition: None,
stop_music_next_frame: true,
render: EditorRender::new(&context.geng, &context.assets),
framebuffer_size: vec2(1, 1),
delta_time: r32(0.1),
Expand Down Expand Up @@ -341,6 +344,7 @@ impl EditorState {
Leaderboard::new(&self.context.geng, None),
),
)));
self.stop_music_next_frame = true;
}
}

Expand All @@ -353,6 +357,10 @@ impl geng::State for EditorState {
let delta_time = Time::new(delta_time as f32);
self.delta_time = delta_time;

if self.transition.is_none() && std::mem::take(&mut self.stop_music_next_frame) {
self.context.music.stop();
}

self.ui_context
.update(self.context.geng.window(), delta_time.as_f32());

Expand Down

0 comments on commit a814f4d

Please sign in to comment.