Skip to content

Commit

Permalink
Fix music play cancelling placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Nertsal committed Aug 16, 2023
1 parent 854ff9d commit db12ea1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ enum State {
/// Place a new light.
Place,
/// Specify a movement path for the light.
Movement {
start_beat: Time,
light: LightEvent,
},
Movement { start_beat: Time, light: LightEvent },
Playing {
start_beat: Time,
old_state: Box<State>,
},
}

Expand Down Expand Up @@ -328,13 +326,18 @@ impl geng::State for Editor {
geng::Key::Q => self.place_rotation += Angle::from_degrees(r32(15.0)),
geng::Key::E => self.place_rotation += Angle::from_degrees(r32(-15.0)),
geng::Key::Space => {
if let State::Playing { start_beat } = &self.state {
if let State::Playing {
start_beat,
old_state,
} = &self.state
{
self.current_beat = *start_beat;
self.state = State::Place;
self.state = *old_state.clone();
self.music.stop();
} else {
self.state = State::Playing {
start_beat: self.current_beat,
old_state: Box::new(self.state.clone()),
};
self.music.stop();
self.music = self.assets.music.effect();
Expand Down

0 comments on commit db12ea1

Please sign in to comment.