2 class_name DialogicSoundEvent
5 ## Event that allows to play a sound effect. Requires the Audio subsystem!
10 ## The path to the file to play.
13 if file_path != value:
15 ui_update_needed.emit()
16 ## The volume to play the sound at.
18 ## The bus to play the sound on.
20 ## If true, the sound will loop infinitely. Not recommended (as there is no way to stop it).
24 ################################################################################
26 ################################################################################
28 func _execute() -> void:
29 dialogic.Audio.play_sound(file_path, volume, audio_bus, loop)
33 ################################################################################
35 ################################################################################
39 set_default_color('Color7')
40 event_category = "Audio"
41 event_sorting_index = 3
42 help_page_path = "https://dialogic.coppolaemilio.com"
45 func _get_icon() -> Resource:
46 return load(self.get_script().get_path().get_base_dir().path_join('icon_sound.png'))
48 ################################################################################
50 ################################################################################
52 func get_shortcode() -> String:
56 func get_shortcode_parameters() -> Dictionary:
58 #param_name : property_name
59 "path" : {"property": "file_path", "default": "",},
60 "volume" : {"property": "volume", "default": 0},
61 "bus" : {"property": "audio_bus", "default": "",
62 "suggestions": get_bus_suggestions},
63 "loop" : {"property": "loop", "default": false},
67 ################################################################################
68 ## EDITOR REPRESENTATION
69 ################################################################################
71 func build_event_editor() -> void:
72 add_header_edit('file_path', ValueType.FILE,
73 {'left_text' : 'Play',
74 'file_filter' : '*.mp3, *.ogg, *.wav; Supported Audio Files',
75 'placeholder' : "Select file",
76 'editor_icon' : ["AudioStreamPlayer", "EditorIcons"]})
77 add_header_edit('file_path', ValueType.AUDIO_PREVIEW)
78 add_body_edit('volume', ValueType.NUMBER, {'left_text':'Volume:', 'mode':2}, '!file_path.is_empty()')
79 add_body_edit('audio_bus', ValueType.SINGLELINE_TEXT, {'left_text':'Audio Bus:'}, '!file_path.is_empty()')
82 func get_bus_suggestions() -> Dictionary:
83 var bus_name_list := {}
84 for i in range(AudioServer.bus_count):
85 bus_name_list[AudioServer.get_bus_name(i)] = {'value':AudioServer.get_bus_name(i)}