From db12ea1d33eb26f78797c1a2acbf5c7cab0f7600 Mon Sep 17 00:00:00 2001 From: Nertsal Date: Wed, 16 Aug 2023 21:30:29 +0300 Subject: [PATCH] Fix music play cancelling placement --- src/editor.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 912cb18a..1aa611f5 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -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, }, } @@ -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();