From bc1522e26865c9b84159ff4b4bcde7896fd73496 Mon Sep 17 00:00:00 2001 From: ShyRed Date: Thu, 8 Mar 2018 19:11:46 +0100 Subject: 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. --- scene/audio/audio_player.cpp | 13 ++++++++++++- scene/audio/audio_player.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'scene/audio') diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 408c00334a..e7ace82fc0 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -127,6 +127,7 @@ void AudioStreamPlayer::_notification(int p_what) { if (!active || (setseek < 0 && !stream_playback->is_playing())) { active = false; set_process_internal(false); + //_change_notify("playing"); //update property in editor emit_signal("finished"); } } @@ -211,8 +212,13 @@ void AudioStreamPlayer::stop() { bool AudioStreamPlayer::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(); + return active; // && stream_playback->is_playing(); } return false; @@ -265,11 +271,16 @@ AudioStreamPlayer::MixTarget AudioStreamPlayer::get_mix_target() const { void AudioStreamPlayer::_set_playing(bool p_enable) { +#ifdef TOOLS_ENABLED + fake_active = p_enable; +#endif + if (p_enable) play(); else stop(); } + bool AudioStreamPlayer::_is_active() const { return active; diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h index 21189aea6d..f2e2684642 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_player.h @@ -53,6 +53,10 @@ private: volatile float setseek; volatile bool active; +#ifdef TOOLS_ENABLED + volatile bool fake_active; +#endif + float mix_volume_db; float pitch_scale; float volume_db; -- cgit v1.2.3