Add addons
This commit is contained in:
parent
2c862b2235
commit
3367bad24f
527 changed files with 36197 additions and 0 deletions
91
Sprout/addons/dialogic/Events/Voice/event_voice.gd
Normal file
91
Sprout/addons/dialogic/Events/Voice/event_voice.gd
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
@tool
|
||||
class_name DialogicVoiceEvent
|
||||
extends DialogicEvent
|
||||
|
||||
## Event that allows to set the sound file to use for the next text event.
|
||||
|
||||
|
||||
### Settings
|
||||
|
||||
## The path to the sound file.
|
||||
var file_path: String = ""
|
||||
## The volume the sound will be played at.
|
||||
var volume: float = 0
|
||||
## The audio bus to play the sound on.
|
||||
var audio_bus: String = "Master"
|
||||
## The audio regions store in a strange as f*** format
|
||||
var regions : String
|
||||
|
||||
|
||||
################################################################################
|
||||
## EXECUTE
|
||||
################################################################################
|
||||
|
||||
func _execute() -> void:
|
||||
dialogic.Voice.set_file(file_path)
|
||||
dialogic.Voice.set_volume(volume)
|
||||
dialogic.Voice.set_bus(audio_bus)
|
||||
#NOTE need better way of reading the regiondata. This deems messy
|
||||
var regiondata := []
|
||||
|
||||
var stringfluff := ["[", "]", "start at", "stop at"]
|
||||
if not regions is String:
|
||||
printerr("Invalid data - (DialogicVoiceEvent): serial regiondata not string.")
|
||||
for f in stringfluff:
|
||||
regions = regions.replace(f, "")
|
||||
var data1:PackedStringArray = regions.split("region", false)
|
||||
for d in data1:
|
||||
var data2:PackedStringArray = d.split(",", false)
|
||||
regiondata.append([data2[0].to_float(), data2[1].to_float()])
|
||||
|
||||
dialogic.Voice.set_regions(regiondata)
|
||||
|
||||
finish()
|
||||
# the rest is executed by a text event
|
||||
|
||||
|
||||
################################################################################
|
||||
## INITIALIZE
|
||||
################################################################################
|
||||
|
||||
func _init() -> void:
|
||||
event_name = "Voice"
|
||||
set_default_color('Color1')
|
||||
event_category = Category.AudioVisual
|
||||
event_sorting_index = 5
|
||||
expand_by_default = false
|
||||
|
||||
|
||||
################################################################################
|
||||
## SAVING/LOADING
|
||||
################################################################################
|
||||
|
||||
func get_shortcode() -> String:
|
||||
return "voice"
|
||||
|
||||
|
||||
func get_shortcode_parameters() -> Dictionary:
|
||||
return {
|
||||
#param_name : property_info
|
||||
"path" : {"property": "file_path", "default": ""},
|
||||
"volume" : {"property": "volume", "default": 0},
|
||||
"bus" : {"property": "audio_bus", "default": "Master"},
|
||||
"regions" : {"property": "regions", "default": ""},
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
## EDITOR REPRESENTATION
|
||||
################################################################################
|
||||
|
||||
func build_event_editor():
|
||||
add_header_edit('file_path', ValueType.File, '', 'is the audio for the next text',
|
||||
{'file_filter' : "*.mp3, *.ogg, *.wav",
|
||||
'placeholder' : "Select file",
|
||||
'editor_icon' : ["AudioStreamPlayer", "EditorIcons"]})
|
||||
add_body_edit('volume', ValueType.Decibel, 'volume:', '', {}, '!file_path.is_empty()')
|
||||
add_body_edit('audio_bus', ValueType.SinglelineText, 'audio_bus:', '', {}, '!file_path.is_empty()')
|
||||
add_body_line_break()
|
||||
add_body_edit('regions', ValueType.Custom, 'Number of lines/audio regions:', '',
|
||||
{'path' : 'res://addons/dialogic/Events/Voice/ui_field_audio_region_list.tscn'},
|
||||
'!file_path.is_empty()')
|
||||
BIN
Sprout/addons/dialogic/Events/Voice/icon.png
Normal file
BIN
Sprout/addons/dialogic/Events/Voice/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
34
Sprout/addons/dialogic/Events/Voice/icon.png.import
Normal file
34
Sprout/addons/dialogic/Events/Voice/icon.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://vkvdtrxe5lxu"
|
||||
path="res://.godot/imported/icon.png-a5b60d538f8f19c6dea2cd25f67223e3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dialogic/Events/Voice/icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-a5b60d538f8f19c6dea2cd25f67223e3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
10
Sprout/addons/dialogic/Events/Voice/index.gd
Normal file
10
Sprout/addons/dialogic/Events/Voice/index.gd
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
@tool
|
||||
extends DialogicIndexer
|
||||
|
||||
|
||||
func _get_events() -> Array:
|
||||
return [this_folder.path_join('event_voice.gd')]
|
||||
|
||||
|
||||
func _get_subsystems() -> Array:
|
||||
return [{'name':'Voice', 'script':this_folder.path_join('subsystem_voice.gd')}]
|
||||
6
Sprout/addons/dialogic/Events/Voice/node_voice_player.gd
Normal file
6
Sprout/addons/dialogic/Events/Voice/node_voice_player.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class_name DialogicNode_VoicePlayer
|
||||
extends AudioStreamPlayer
|
||||
|
||||
|
||||
func _ready():
|
||||
add_to_group("dialogic_dialog_voice")
|
||||
106
Sprout/addons/dialogic/Events/Voice/subsystem_voice.gd
Normal file
106
Sprout/addons/dialogic/Events/Voice/subsystem_voice.gd
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
extends DialogicSubsystem
|
||||
|
||||
## Subsystem that manages setting voice lines for text events.
|
||||
|
||||
|
||||
## The group that voice players are added too.
|
||||
const audioplayer_name := "dialogic_dialog_voice"
|
||||
|
||||
## The current voice regions
|
||||
var voice_regions := []
|
||||
## The current voice timer
|
||||
var voice_timer:Timer
|
||||
## The current audio
|
||||
var current_audio_file:String
|
||||
|
||||
|
||||
####################################################################################################
|
||||
## STATE
|
||||
####################################################################################################
|
||||
|
||||
func pause() -> void:
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
audio_node.stream_paused = true
|
||||
if voice_timer:
|
||||
voice_timer.paused = true
|
||||
|
||||
|
||||
func resume() -> void:
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
audio_node.stream_paused = false
|
||||
if voice_timer:
|
||||
voice_timer.paused = false
|
||||
|
||||
|
||||
####################################################################################################
|
||||
## MAIN METHODS
|
||||
####################################################################################################
|
||||
|
||||
func is_voiced(index:int) -> bool:
|
||||
if dialogic.current_timeline_events[index] is DialogicTextEvent:
|
||||
if dialogic.current_timeline_events[index-1] is DialogicVoiceEvent:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func play_voice_region(index:int):
|
||||
if index >= len(voice_regions):
|
||||
return
|
||||
var start:float = voice_regions[index][0]
|
||||
var stop:float = voice_regions[index][1]
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
#do not play in invisible nodes. This allows audio (2d and 3d) to be used in styles
|
||||
if "visible" in audio_node and not audio_node.visible:
|
||||
continue
|
||||
audio_node.play(start)
|
||||
set_timer(stop - start)
|
||||
|
||||
|
||||
func set_file(path:String):
|
||||
if current_audio_file == path:
|
||||
return
|
||||
current_audio_file = path
|
||||
var audio:AudioStream = load(path)
|
||||
#TODO: check for faults in loaded audio
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
audio_node.stream = audio
|
||||
|
||||
|
||||
func set_volume(value:float):
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
audio_node.volume_db = value
|
||||
|
||||
|
||||
func set_regions(value:Array):
|
||||
voice_regions = value
|
||||
|
||||
|
||||
func set_bus(value:String):
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
audio_node.bus = value
|
||||
|
||||
|
||||
func stop_audio():
|
||||
for audio_node in get_tree().get_nodes_in_group(audioplayer_name):
|
||||
audio_node.stop()
|
||||
|
||||
|
||||
func set_timer(time:float):
|
||||
if !voice_timer:
|
||||
voice_timer = Timer.new()
|
||||
DialogicUtil.update_timer_process_callback(voice_timer)
|
||||
voice_timer.one_shot = true
|
||||
add_child(voice_timer)
|
||||
voice_timer.timeout.connect(stop_audio)
|
||||
voice_timer.stop()
|
||||
voice_timer.start(time)
|
||||
|
||||
|
||||
func get_remaining_time() -> float:
|
||||
if not voice_timer or voice_timer.is_stopped():
|
||||
return 0.0 #contingency
|
||||
return voice_timer.time_left
|
||||
|
||||
|
||||
func is_running() -> bool:
|
||||
return get_remaining_time() > 0.0
|
||||
43
Sprout/addons/dialogic/Events/Voice/ui_field_audio_region.gd
Normal file
43
Sprout/addons/dialogic/Events/Voice/ui_field_audio_region.gd
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
const max_value:float = 9999.0
|
||||
|
||||
var property_name
|
||||
signal value_changed
|
||||
|
||||
const stringfluff = ["[", "]", "start at", "stop at", "region"]
|
||||
|
||||
func set_value(value):
|
||||
if value == null:
|
||||
return
|
||||
#strip irrelevant parts
|
||||
for f in stringfluff:
|
||||
value = value.replace(f, "")
|
||||
var data:PackedStringArray = value.split(",", false) #value.replace("[", "").replace("]","").replace("region","").split(",", false)
|
||||
if len(data) < 2:
|
||||
printerr("Invalid data - %s (AudioRegion): no or incomplete set of timecodes found." % property_name)
|
||||
return
|
||||
$StartValue.set_value(data[0].to_float())
|
||||
$StopValue.set_value (data[1].to_float())
|
||||
|
||||
|
||||
func get_value():
|
||||
return "region start at %s, stop at %s" % [$StartValue.get_value(),$StopValue.get_value()]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$Number.text = str(get_index()+1)+':'
|
||||
$StartValue.use_timestamp_mode()
|
||||
$StartValue.set_max_value(max_value - 0.1)
|
||||
$StartValue.value_changed.connect(on_value_changed)
|
||||
$StopValue.use_timestamp_mode()
|
||||
$StopValue.set_min_value(0.1)
|
||||
$StopValue.set_max_value(max_value)
|
||||
$StopValue.value_changed.connect(on_value_changed)
|
||||
|
||||
func on_value_changed(property_name, value):
|
||||
$StopValue.set_min_value($StartValue.get_value() + 0.1)
|
||||
emit_signal("value_changed", property_name, get_value())
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Events/Voice/ui_field_audio_region.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://kdpp3mibml33" path="res://addons/dialogic/Editor/Events/Fields/Number.tscn" id="2"]
|
||||
|
||||
[node name="Auddioregion" type="HBoxContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Number" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
offset_top = 311.0
|
||||
offset_right = 38.0
|
||||
offset_bottom = 337.0
|
||||
text = "Start"
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 42.0
|
||||
offset_top = 311.0
|
||||
offset_right = 80.0
|
||||
offset_bottom = 337.0
|
||||
text = "Start"
|
||||
|
||||
[node name="StartValue" parent="." instance=ExtResource("2")]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = 84.0
|
||||
offset_right = 132.0
|
||||
offset_bottom = 648.0
|
||||
max = 9998.9
|
||||
suffix = " sec"
|
||||
|
||||
[node name="Label2" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 136.0
|
||||
offset_top = 311.0
|
||||
offset_right = 170.0
|
||||
offset_bottom = 337.0
|
||||
text = "stop"
|
||||
|
||||
[node name="StopValue" parent="." instance=ExtResource("2")]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = 174.0
|
||||
offset_right = 222.0
|
||||
offset_bottom = 648.0
|
||||
min = 0.1
|
||||
max = 9999.0
|
||||
suffix = " sec"
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var property_name : String
|
||||
signal value_changed
|
||||
|
||||
func on_value_changed(_p, value):
|
||||
var data:String = ""
|
||||
for i in range ($list.get_child_count()):
|
||||
var n:Node = $list.get_child(i)
|
||||
data += n.get_value() + " "
|
||||
#print(data)
|
||||
emit_signal("value_changed", property_name, data)
|
||||
|
||||
func _ready():
|
||||
$NumRegions/NumberValue.set_min_value(1)
|
||||
$NumRegions/NumberValue.value_changed.connect(_on_NumberValue_value_changed)
|
||||
if($list.get_child_count() < 1):
|
||||
repopulate(1) #Always have at least one audio region
|
||||
|
||||
|
||||
func set_value(value):
|
||||
if value == null:
|
||||
return
|
||||
if not value is String:
|
||||
printerr("Invalid data - %s (SerialAudioRegion): data incoming is not string." % property_name)
|
||||
var data:PackedStringArray = value.split("region", false)
|
||||
$NumRegions/NumberValue.set_value(len(data))
|
||||
repopulate(len(data))
|
||||
for i in range ($list.get_child_count()):
|
||||
var n:Node = $list.get_child(i)
|
||||
n.set_value(data[i])
|
||||
|
||||
func _on_NumberValue_value_changed(_p, value):
|
||||
repopulate(value)
|
||||
|
||||
func repopulate(num:int):
|
||||
var i = $list.get_child_count()
|
||||
#print ("found " + str(i) + " nodes")
|
||||
#add new audio regions
|
||||
while i < num:
|
||||
#print("adding node number " + str(i))
|
||||
var node = load("res://addons/dialogic/Events/Voice/ui_field_audio_region.tscn").instantiate()
|
||||
$list.add_child(node)
|
||||
#node.set_left_text("| " + str(i) + " Start")
|
||||
node.value_changed.connect(on_value_changed)
|
||||
i = i + 1
|
||||
#remove excess audio regions
|
||||
#print(str(i) + ">" + str(num) + "=" + str(i > num))
|
||||
while i > num:
|
||||
$list.get_child(i-1).queue_free()
|
||||
#print("removing node number " + str(i))
|
||||
i = i - 1
|
||||
|
||||
func set_left_text(text):
|
||||
$NumRegions/Label.text = text
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://kdpp3mibml33" path="res://addons/dialogic/Editor/Events/Fields/Number.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Events/Voice/ui_field_audio_region_list.gd" id="2"]
|
||||
|
||||
[node name="SerialAudioRegion" type="VBoxContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="NumRegions" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Label" type="Label" parent="NumRegions"]
|
||||
layout_mode = 2
|
||||
offset_top = 2.0
|
||||
offset_right = 240.0
|
||||
offset_bottom = 28.0
|
||||
text = "Number of lines/audio regions:"
|
||||
|
||||
[node name="NumberValue" parent="NumRegions" instance=ExtResource("1")]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = 244.0
|
||||
offset_right = 302.0
|
||||
offset_bottom = 31.0
|
||||
step = 1.0
|
||||
min = 1.0
|
||||
value = 1
|
||||
|
||||
[node name="list" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
offset_top = 35.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 66.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue