-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Audio Events: Implement audio preview fields (#2448)
Adds an audio preview field, that is used on the audio events.
- Loading branch information
Showing
7 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
addons/dialogic/Editor/Events/Fields/field_audio_preview.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@tool | ||
extends DialogicVisualEditorField | ||
|
||
|
||
var file_path: String | ||
|
||
|
||
func _ready() -> void: | ||
self.pressed.connect(_on_pressed) | ||
%AudioStreamPlayer.finished.connect(_on_finished) | ||
|
||
|
||
#region OVERWRITES | ||
################################################################################ | ||
|
||
|
||
## To be overwritten | ||
func _set_value(value:Variant) -> void: | ||
file_path = value | ||
self.disabled = file_path.is_empty() | ||
_stop() | ||
|
||
#endregion | ||
|
||
|
||
#region SIGNAL METHODS | ||
################################################################################ | ||
|
||
func _on_pressed() -> void: | ||
if %AudioStreamPlayer.playing: | ||
_stop() | ||
elif not file_path.is_empty(): | ||
_play() | ||
|
||
|
||
func _on_finished() -> void: | ||
_stop() | ||
|
||
#endregion | ||
|
||
|
||
func _stop() -> void: | ||
%AudioStreamPlayer.stop() | ||
%AudioStreamPlayer.stream = null | ||
self.icon = get_theme_icon("Play", "EditorIcons") | ||
|
||
|
||
func _play() -> void: | ||
if ResourceLoader.exists(file_path): | ||
%AudioStreamPlayer.stream = load(file_path) | ||
%AudioStreamPlayer.play() | ||
self.icon = get_theme_icon("Stop", "EditorIcons") |
12 changes: 12 additions & 0 deletions
12
addons/dialogic/Editor/Events/Fields/field_audio_preview.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://dotvrsumm5y5c"] | ||
|
||
[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_audio_preview.gd" id="1_7wm54"] | ||
|
||
[node name="Field_Audio_Preview" type="Button"] | ||
offset_right = 8.0 | ||
offset_bottom = 8.0 | ||
flat = true | ||
script = ExtResource("1_7wm54") | ||
|
||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] | ||
unique_name_in_owner = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters