Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove audio region #1437

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions addons/dialogic/Events/Text/event_text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,19 @@ func _execute() -> void:
dialogic.Portraits.update_rpg_portrait_mode(character, portrait)

# RENDER DIALOG
# Placeholder wrap. Replace with a loop iterating over text event's lines. - KvaGram
var index: int = 0
if true:
var final_text: String = get_property_translated('text')
if dialogic.has_subsystem('VAR'):
final_text = dialogic.VAR.parse_variables(final_text)
if dialogic.has_subsystem('Glossary'):
final_text = dialogic.Glossary.parse_glossary(final_text)

dialogic.Text.update_dialog_text(final_text)

#Plays the audio region for the current line.
if dialogic.has_subsystem('Voice') and dialogic.Voice.is_voiced(dialogic.current_event_idx):
dialogic.Voice.play_voice_region(index) #voice data is set by voice event.

await dialogic.Text.text_finished
var final_text: String = get_property_translated('text')
if dialogic.has_subsystem('VAR'):
final_text = dialogic.VAR.parse_variables(final_text)
if dialogic.has_subsystem('Glossary'):
final_text = dialogic.Glossary.parse_glossary(final_text)

dialogic.Text.update_dialog_text(final_text)

#Plays the audio region for the current line.
if dialogic.has_subsystem('Voice') and dialogic.Voice.is_voiced(dialogic.current_event_idx):
dialogic.Voice.play_voice()

await dialogic.Text.text_finished

#end of dialog
if dialogic.has_subsystem('Choices') and dialogic.Choices.is_question(dialogic.current_event_idx):
Expand Down
24 changes: 1 addition & 23 deletions addons/dialogic/Events/Voice/event_voice.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ var file_path: String = ""
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


################################################################################
Expand All @@ -25,21 +23,6 @@ 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

Expand Down Expand Up @@ -69,8 +52,7 @@ func get_shortcode_parameters() -> Dictionary:
#param_name : property_info
"path" : {"property": "file_path", "default": ""},
"volume" : {"property": "volume", "default": 0},
"bus" : {"property": "audio_bus", "default": "Master"},
"regions" : {"property": "regions", "default": ""},
"bus" : {"property": "audio_bus", "default": "Master"}
}


Expand All @@ -85,7 +67,3 @@ func build_event_editor():
'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()')
16 changes: 3 additions & 13 deletions addons/dialogic/Events/Voice/subsystem_voice.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ extends DialogicSubsystem

## Subsystem that manages setting voice lines for text events.


## The current voice regions
var voice_regions := []
## The current voice timer
var voice_timer:Timer
## The current audio
Expand Down Expand Up @@ -43,11 +40,9 @@ func is_voiced(index:int) -> bool:
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]
func play_voice():
var start:float = 0
var stop:float = voice_player.stream.get_length()
voice_player.play(start)
set_timer(stop - start)

Expand All @@ -64,11 +59,6 @@ func set_file(path:String):
func set_volume(value:float):
voice_player.volume_db = value


func set_regions(value:Array):
voice_regions = value


func set_bus(value:String):
voice_player.bus = value

Expand Down
43 changes: 0 additions & 43 deletions addons/dialogic/Events/Voice/ui_field_audio_region.gd

This file was deleted.

56 changes: 0 additions & 56 deletions addons/dialogic/Events/Voice/ui_field_audio_region.tscn

This file was deleted.

56 changes: 0 additions & 56 deletions addons/dialogic/Events/Voice/ui_field_audio_region_list.gd

This file was deleted.

43 changes: 0 additions & 43 deletions addons/dialogic/Events/Voice/ui_field_audio_region_list.tscn

This file was deleted.