diff options
author | ShyRed <ShyRed@users.noreply.github.com> | 2018-03-08 19:11:46 +0100 |
---|---|---|
committer | ShyRed <ShyRed@users.noreply.github.com> | 2018-03-16 15:26:23 +0100 |
commit | bc1522e26865c9b84159ff4b4bcde7896fd73496 (patch) | |
tree | 04dd02043a0354801f451606c7a4d6550c04bf53 /scene/2d | |
parent | 8ded15b035e9db959b7669ec72b38d1a94a8df30 (diff) | |
download | redot-engine-bc1522e26865c9b84159ff4b4bcde7896fd73496.tar.gz |
Use fake audio playing property in editor
It appears that some time ago users were supposed to be able to include the playback of sound effects in their animations by placing keys on the "playing" property. Back then the key frame editor took the value of the checkbox in the property_editor.
Somewhere / Sometime this behaviour changed and the key frame editor is now reading the actual value from the object instead of relying on the property editor.
This commit introduces a fake active field that is returned when reading the playing property in the editor. While the actual active flag is changed when playback is finished the fake one will stay the same thus allowing the user to take their time with setting the key in the animation editor.
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/audio_stream_player_2d.cpp | 11 | ||||
-rw-r--r-- | scene/2d/audio_stream_player_2d.h | 4 |
2 files changed, 14 insertions, 1 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index f998f23d3b..94db832e9f 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -233,7 +233,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { //stop playing if no longer active if (!active) { set_physics_process_internal(false); - //do not update, this makes it easier to animate (will shut off otherwise) //_change_notify("playing"); //update property in editor emit_signal("finished"); } @@ -313,6 +312,11 @@ void AudioStreamPlayer2D::stop() { bool AudioStreamPlayer2D::is_playing() const { +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) + return fake_active; +#endif + if (stream_playback.is_valid()) { return active; // && stream_playback->is_playing(); } @@ -357,11 +361,16 @@ bool AudioStreamPlayer2D::is_autoplay_enabled() { void AudioStreamPlayer2D::_set_playing(bool p_enable) { +#ifdef TOOLS_ENABLED + fake_active = p_enable; +#endif + if (p_enable) play(); else stop(); } + bool AudioStreamPlayer2D::_is_active() const { return active; diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h index 9ae8e3a518..eae18c8404 100644 --- a/scene/2d/audio_stream_player_2d.h +++ b/scene/2d/audio_stream_player_2d.h @@ -69,6 +69,10 @@ private: volatile bool active; volatile float setplay; +#ifdef TOOLS_ENABLED + volatile bool fake_active; +#endif + float volume_db; float pitch_scale; bool autoplay; |