Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
67
addons/dialogic/Nodes/CharacterVoice.gd
Normal file
67
addons/dialogic/Nodes/CharacterVoice.gd
Normal file
|
@ -0,0 +1,67 @@
|
|||
extends AudioStreamPlayer
|
||||
|
||||
var stop_time:float
|
||||
|
||||
func play_voice(data:Dictionary)->void :
|
||||
if data == {}:
|
||||
stop_voice()
|
||||
return
|
||||
|
||||
if data.has("volume"):
|
||||
volume_db = data["volume"]
|
||||
|
||||
if data.has("audio_bus"):
|
||||
bus = data["audio_bus"]
|
||||
|
||||
if data.has("file"):
|
||||
if data["file"] == "":
|
||||
stop_voice()
|
||||
return
|
||||
|
||||
if SettingsSingleton.GetVoiceoverLanguage() == "none":
|
||||
stop_voice()
|
||||
return
|
||||
|
||||
if SettingsSingleton.GetVoiceoverLanguage() == "en":
|
||||
data["file"] = data["file"].replace("res://resources/audio/voice/", "res://resources/audio/voice/en/");
|
||||
|
||||
if not ResourceLoader.exists(data["file"]):
|
||||
print("!!!!!! VOICE FILE NOT FOUND " + data["file"]);
|
||||
stop_voice()
|
||||
return
|
||||
|
||||
var s:AudioStream = load(data["file"])
|
||||
if s != null:
|
||||
|
||||
stream = s
|
||||
|
||||
if data.has("start_time"):
|
||||
play(data["start_time"])
|
||||
else :
|
||||
play()
|
||||
|
||||
|
||||
|
||||
if data.has("stop_time"):
|
||||
stop_time = data["stop_time"]
|
||||
if stop_time <= 0:
|
||||
stop_time = s.get_length() - 0.1
|
||||
else :
|
||||
stop_time = s.get_length() - 0.1
|
||||
else :
|
||||
print("!!!!!! VOICE FILE NOT FOUND " + data["file"]);
|
||||
stop_voice()
|
||||
func stop_voice():
|
||||
stop()
|
||||
|
||||
|
||||
func remaining_time():
|
||||
if not playing:
|
||||
return 0
|
||||
return stop_time - get_playback_position()
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
if (playing and get_playback_position() >= stop_time):
|
||||
stop_voice()
|
Loading…
Add table
Add a link
Reference in a new issue