feat(audio): add built-in sound effects (bell, coin, chime, etc.), inspector sound presets, and preview player
checkpoint / checkpoint (push) Failing after 6m3s
checkpoint / checkpoint (push) Failing after 6m3s
This commit is contained in:
@@ -359,6 +359,47 @@ func _setup_rule_form() -> void:
|
||||
# 4. play_sound
|
||||
_action_sound_box = VBoxContainer.new()
|
||||
_action_sound_box.visible = false
|
||||
|
||||
var snd_preset_row := HBoxContainer.new()
|
||||
var snd_preset_lbl := Label.new()
|
||||
snd_preset_lbl.text = "Preset:"
|
||||
snd_preset_lbl.custom_minimum_size = Vector2(70, 0)
|
||||
snd_preset_row.add_child(snd_preset_lbl)
|
||||
|
||||
var snd_option := OptionButton.new()
|
||||
snd_option.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
snd_option.add_item("🔔 Bell Chime (bell)", 0)
|
||||
snd_option.set_item_metadata(0, "bell")
|
||||
snd_option.add_item("🪙 Coin Pickup (coin)", 1)
|
||||
snd_option.set_item_metadata(1, "coin")
|
||||
snd_option.add_item("🔘 Button Click (click)", 2)
|
||||
snd_option.set_item_metadata(2, "click")
|
||||
snd_option.add_item("✨ Magic Chime (chime)", 3)
|
||||
snd_option.set_item_metadata(3, "chime")
|
||||
snd_option.add_item("🎺 Victory Fanfare (fanfare)", 4)
|
||||
snd_option.set_item_metadata(4, "fanfare")
|
||||
snd_option.add_item("🚪 Door Open (door_open)", 5)
|
||||
snd_option.set_item_metadata(5, "door_open")
|
||||
snd_preset_row.add_child(snd_option)
|
||||
|
||||
var preview_btn := Button.new()
|
||||
preview_btn.text = "▶ Preview"
|
||||
preview_btn.tooltip_text = "Listen to this sound effect"
|
||||
preview_btn.pressed.connect(func():
|
||||
var snd_id := _sound_id_edit.text.strip_edges()
|
||||
var p := "res://assets/audio/%s.wav" % snd_id
|
||||
if ResourceLoader.exists(p):
|
||||
var st = load(p)
|
||||
if st is AudioStream:
|
||||
var asp := AudioStreamPlayer.new()
|
||||
asp.stream = st
|
||||
add_child(asp)
|
||||
asp.finished.connect(asp.queue_free)
|
||||
asp.play()
|
||||
)
|
||||
snd_preset_row.add_child(preview_btn)
|
||||
_action_sound_box.add_child(snd_preset_row)
|
||||
|
||||
var snd_row := HBoxContainer.new()
|
||||
var snd_lbl := Label.new()
|
||||
snd_lbl.text = "Sound ID:"
|
||||
@@ -369,6 +410,13 @@ func _setup_rule_form() -> void:
|
||||
_sound_id_edit.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
snd_row.add_child(_sound_id_edit)
|
||||
_action_sound_box.add_child(snd_row)
|
||||
|
||||
snd_option.item_selected.connect(func(idx: int):
|
||||
var meta = snd_option.get_item_metadata(idx)
|
||||
if meta != null:
|
||||
_sound_id_edit.text = str(meta)
|
||||
)
|
||||
|
||||
form_box.add_child(_action_sound_box)
|
||||
|
||||
# 5. spawn_from_catalog
|
||||
|
||||
Reference in New Issue
Block a user