pir-serious-game-ethics/addons/dialogic/Editor/Events/BackgroundMusic.gd

43 lines
1.2 KiB
GDScript3
Raw Normal View History

2021-03-27 10:53:28 +01:00
tool
extends HBoxContainer
var editor_reference
var editorPopup
2021-04-10 18:29:03 +02:00
2021-03-27 10:53:28 +01:00
# This is the information of this event and it will get parsed and saved to the JSON file.
var event_data = {
2021-04-16 16:35:07 +02:00
'event_name':'BackgroundMusic',
2021-03-27 10:53:28 +01:00
'background-music': 'stop',
2021-04-16 16:35:07 +02:00
'file': '',
'audio_bus':'Master',
'volume':0,
'fade_length':1,
2021-03-27 10:53:28 +01:00
}
func _ready():
2021-04-16 16:35:07 +02:00
$PanelContainer/VBoxContainer/Header/VisibleToggle.set_visible(true)
$PanelContainer/VBoxContainer/Settings/AudioPicker.editor_reference = editor_reference
$PanelContainer/VBoxContainer/Settings/AudioPicker.connect("audio_changed", self, "update_audio_data")
2021-03-27 10:53:28 +01:00
func load_data(data):
event_data = data
2021-04-16 16:35:07 +02:00
$PanelContainer/VBoxContainer/Settings/FadeLength.value = event_data.get("fade_length", 1)
$PanelContainer/VBoxContainer/Settings/AudioPicker.load_data(data)
func update_audio_data(file, playing, audio_bus, volume):
event_data['background-music'] = playing
event_data['file'] = file
event_data['audio_bus'] = audio_bus
event_data['volume'] = volume
if file:
$PanelContainer/VBoxContainer/Header/Preview.text = 'Plays '+file.get_file()
2021-03-27 10:53:28 +01:00
else:
2021-04-16 16:35:07 +02:00
$PanelContainer/VBoxContainer/Header/Preview.text = 'Fades out previous background music'
2021-03-27 10:53:28 +01:00
2021-04-16 16:35:07 +02:00
func _on_FadeLength_value_changed(value):
event_data['fade_length'] = value
2021-03-27 10:53:28 +01:00