Big refactor: Fix plugin issues when disabling/reenabling plugins (#598)

Co-authored-by: balloonpopper <5151242+balloonpopper@users.noreply.github.com>
Co-authored-by: Duncan Brown <duncan@prometheussoftware.ca>
This commit is contained in:
Julian Murgia
2022-07-10 20:40:08 +02:00
committed by GitHub
parent dfbceadd1c
commit ad79aa69d1
113 changed files with 2977 additions and 2072 deletions

View File

@@ -26,9 +26,15 @@ func set_dialog(new_dialog: ESCDialog) -> void:
# Show the dialog chooser UI
func show_chooser() -> void:
escoria.logger.error("Dialog chooser did not implement the show method.")
escoria.logger.error(
self,
"Dialog chooser does not implement the show method."
)
# Hide the dialog chooser UI
func hide_chooser() -> void:
escoria.logger.error("Dialog chooser did not implement the hide method.")
escoria.logger.error(
self,
"Dialog chooser does not implement the hide method."
)

View File

@@ -62,8 +62,8 @@ func _input(event):
# *Returns* The path to the matching voice file
func _get_voice_file(key: String, start: String = "") -> String:
if start == "":
start = escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.SPEECH_FOLDER
start = ESCProjectSettingsManager.get_setting(
ESCProjectSettingsManager.SPEECH_FOLDER
)
var _dir = Directory.new()
if _dir.open(start) == OK:
@@ -80,8 +80,8 @@ func _get_voice_file(key: String, start: String = "") -> String:
else:
if file_name == "%s.%s.import" % [
key,
escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.SPEECH_EXTENSION
ESCProjectSettingsManager.get_setting(
ESCProjectSettingsManager.SPEECH_EXTENSION
)
]:
return start.plus_file(file_name.trim_suffix(".import"))
@@ -98,12 +98,12 @@ func _get_voice_file(key: String, start: String = "") -> String:
# - text: Text to say
func say(character: String, type: String, text: String) -> void:
if type == "":
type = escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.DEFAULT_DIALOG_TYPE
type = ESCProjectSettingsManager.get_setting(
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE
)
is_speaking = true
for _manager_class in escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.DIALOG_MANAGERS
for _manager_class in ESCProjectSettingsManager.get_setting(
ESCProjectSettingsManager.DIALOG_MANAGERS
):
if ResourceLoader.exists(_manager_class):
var _manager: ESCDialogManager = load(_manager_class).new()
@@ -113,22 +113,18 @@ func say(character: String, type: String, text: String) -> void:
_dialog_manager = null
if _dialog_manager == null:
escoria.logger.report_errors(
"esc_dialog_player.gd:say",
[
"No dialog manager supports the type %s" % type
]
escoria.logger.error(
self,
"No dialog manager called %s configured." % type
)
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
var matches = _keytext_regex.search(text)
if not matches:
escoria.logger.report_errors(
"esc_dialog_player.gd:say",
[
"Unexpected text encountered %s" % text
]
escoria.logger.error(
self,
"Unexpected text encountered : %s." % text
)
var key = matches.get_string("key")
if matches.get_string("key") != "":
@@ -136,11 +132,9 @@ func say(character: String, type: String, text: String) -> void:
matches.get_string("key")
)
if _speech_resource == "":
escoria.logger.report_warnings(
"esc_dialog_player.gd:say",
[
"Unable to find voice file with key '%s'." % matches.get_string("key")
]
escoria.logger.warn(
self,
"Unable to find voice file with key '%s'." % matches.get_string("key")
)
else:
(
@@ -153,11 +147,9 @@ func say(character: String, type: String, text: String) -> void:
# Only update the text if the translated text was found; otherwise, raise
# a warning and use the original, untranslated text.
if translated_text == matches.get_string("key"):
escoria.logger.report_warnings(
"esc_dialog_player.gd:say",
[
"Unable to find translation key '%s'. Using untranslated text." % matches.get_string("key")
]
escoria.logger.warn(
self,
"Unable to find translation key '%s'. Using untranslated text." % matches.get_string("key")
)
text = matches.get_string("text")
else:
@@ -165,8 +157,8 @@ func say(character: String, type: String, text: String) -> void:
else:
text = matches.get_string("text")
_dialog_manager.say(self, character, text, type)
_dialog_manager.say(self, character, text, type)
# Handles the end of a say function after it has emitted say_finished.
func _on_say_finished():
@@ -189,15 +181,15 @@ func speedup() -> void:
# - dialog: The dialog to start
func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
if dialog.options.empty():
escoria.logger.report_errors(
"esc_dialog_player.gd:start_dialog_choices()",
["Received answers array was empty."]
escoria.logger.error(
self,
"Received dialog options array was empty."
)
var _dialog_chooser_ui: ESCDialogManager = null
for _manager_class in escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.DIALOG_MANAGERS
for _manager_class in ESCProjectSettingsManager.get_setting(
ESCProjectSettingsManager.DIALOG_MANAGERS
):
if ResourceLoader.exists(_manager_class):
var _manager: ESCDialogManager = load(_manager_class).new()
@@ -205,11 +197,9 @@ func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
_dialog_chooser_ui = _manager
if _dialog_chooser_ui == null:
escoria.logger.report_errors(
"esc_dialog_player.gd: Unknown chooser type",
[
"No dialog manager supports the chooser type %s" % type
]
escoria.logger.error(
self,
"No dialog manager supports the chooser type %s." % type
)
_dialog_chooser_ui.choose(self, dialog)