-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement audio/image preview fields
- Loading branch information
Showing
10 changed files
with
138 additions
and
6 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 |
28 changes: 28 additions & 0 deletions
28
addons/dialogic/Editor/Events/Fields/field_image_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,28 @@ | ||
@tool | ||
extends DialogicVisualEditorField | ||
|
||
|
||
func _ready() -> void: | ||
pass | ||
|
||
|
||
#region OVERWRITES | ||
################################################################################ | ||
|
||
|
||
## To be overwritten | ||
func _set_value(value:Variant) -> void: | ||
if ResourceLoader.exists(value): | ||
self.texture = load(value) | ||
minimum_size_changed.emit() | ||
else: | ||
self.texture = null | ||
minimum_size_changed.emit() | ||
|
||
#endregion | ||
|
||
|
||
#region SIGNAL METHODS | ||
################################################################################ | ||
|
||
#endregion |
16 changes: 16 additions & 0 deletions
16
addons/dialogic/Editor/Events/Fields/field_image_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,16 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://slgruoy74a7m"] | ||
|
||
[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_image_preview.gd" id="1_12y73"] | ||
|
||
[node name="Field_Image_Preview" type="TextureRect"] | ||
custom_minimum_size = Vector2(0, 100) | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 0 | ||
expand_mode = 2 | ||
stretch_mode = 4 | ||
script = ExtResource("1_12y73") |
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
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