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:
@@ -23,6 +23,12 @@ func _ready():
|
||||
_tween.connect("tween_all_completed", self, "_target_reached")
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
remove_child(_tween)
|
||||
if is_instance_valid(_tween):
|
||||
_tween.queue_free()
|
||||
|
||||
|
||||
# Update the position if the followed target is moving
|
||||
func _process(_delta):
|
||||
if is_instance_valid(_follow_target) and not _tween.is_active() and _follow_target.has_moved():
|
||||
@@ -103,20 +109,19 @@ func set_target(p_target, p_time : float = 0.0):
|
||||
_resolve_target_and_zoom(p_target)
|
||||
|
||||
escoria.logger.info(
|
||||
"Current camera position = %s " % str(self.global_position)
|
||||
self,
|
||||
"Current camera position = %s." % str(self.global_position)
|
||||
)
|
||||
|
||||
if p_time == 0.0:
|
||||
self.global_position = _target
|
||||
else:
|
||||
if _tween.is_active():
|
||||
escoria.logger.report_warnings(
|
||||
"esc_camera.gd:set_target()",
|
||||
[
|
||||
"Tween is still active: %f/%f" % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Tween is still active: %f seconds of %f completed." % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
)
|
||||
_tween.emit_signal("tween_completed")
|
||||
@@ -140,9 +145,9 @@ func set_target(p_target, p_time : float = 0.0):
|
||||
# - p_time: Number of seconds for the camera to reach the zoom level
|
||||
func set_camera_zoom(p_zoom_level: float, p_time: float):
|
||||
if p_zoom_level <= 0.0:
|
||||
escoria.logger.report_errors(
|
||||
"esc_camera.gd:set_camera_zoom()",
|
||||
["Tried to set negative or zero zoom level"]
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"Tried to set negative or zero zoom level."
|
||||
)
|
||||
|
||||
_zoom_target = Vector2(1, 1) * p_zoom_level
|
||||
@@ -151,13 +156,11 @@ func set_camera_zoom(p_zoom_level: float, p_time: float):
|
||||
self.zoom = _zoom_target
|
||||
else:
|
||||
if _tween.is_active():
|
||||
escoria.logger.report_warnings(
|
||||
"esc_camera.gd:set_camera_zoom()",
|
||||
[
|
||||
"Tween is still active: %f/%f" % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Tween is still active: %f/%f" % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
)
|
||||
_tween.emit_signal("tween_completed")
|
||||
@@ -199,13 +202,11 @@ func push(p_target, p_time: float = 0.0, p_type: int = 0):
|
||||
self.zoom = _zoom_target
|
||||
else:
|
||||
if _tween.is_active():
|
||||
escoria.logger.report_warnings(
|
||||
"esc_camera.gd:push()",
|
||||
[
|
||||
"Tween is still active: %f/%f" % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Tween is still active: %f seconds of %f completed." % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
)
|
||||
_tween.emit_signal("tween_completed", null, null)
|
||||
@@ -251,15 +252,13 @@ func shift(p_target: Vector2, p_time: float, p_type: int):
|
||||
_target = new_pos
|
||||
|
||||
if _tween.is_active():
|
||||
escoria.logger.report_warnings(
|
||||
"esc_camera.gd:set_camera_zoom()",
|
||||
[
|
||||
"Tween is still active: %f/%f" % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
]
|
||||
)
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Tween is still active: %f seconds of %f completed." % [
|
||||
_tween.tell(),
|
||||
_tween.get_runtime()
|
||||
]
|
||||
)
|
||||
_tween.emit_signal("tween_completed")
|
||||
|
||||
_tween.interpolate_property(
|
||||
@@ -276,6 +275,3 @@ func shift(p_target: Vector2, p_time: float, p_type: int):
|
||||
|
||||
func _target_reached():
|
||||
_tween.stop_all()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Describes a bounding box that limits the camera movement in the scene
|
||||
extends Object
|
||||
extends Reference
|
||||
class_name ESCCameraLimits
|
||||
|
||||
|
||||
|
||||
@@ -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."
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -17,9 +17,9 @@ var items_ids_in_inventory: Dictionary = {}
|
||||
# listen when a global has changed
|
||||
func _ready():
|
||||
if inventory_ui_container == null or inventory_ui_container.is_empty():
|
||||
escoria.logger.report_errors(
|
||||
self.get_path(),
|
||||
["Items container is empty."]
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"Inventory items container is empty."
|
||||
)
|
||||
return
|
||||
|
||||
@@ -43,8 +43,8 @@ func add_new_item_by_id(item_id: String) -> void:
|
||||
if not escoria.object_manager.has(item_id) or not is_instance_valid( \
|
||||
escoria.object_manager.get_object(item_id).node):
|
||||
var inventory_file = "%s/%s.tscn" % [
|
||||
escoria.project_settings_manager.get_setting(
|
||||
escoria.project_settings_manager.ITEMS_AUTOREGISTER_PATH
|
||||
ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH
|
||||
).trim_suffix("/"),
|
||||
item_id
|
||||
]
|
||||
@@ -58,11 +58,21 @@ func add_new_item_by_id(item_id: String) -> void:
|
||||
true
|
||||
)
|
||||
else:
|
||||
escoria.logger.report_errors(
|
||||
"inventory_ui.gd:add_new_item_by_id()",
|
||||
[
|
||||
"Item global id '%s' does not exist." % item_id
|
||||
]
|
||||
escoria.logger.error(
|
||||
self,
|
||||
(
|
||||
"Item global id '%s' is not registered because the item's scene file was not found.\n"
|
||||
+ "Attempted scene file path: %s.\n"
|
||||
+ "Please ensure that the '%s' project setting points at **your inventory items folder** (current is: \"%s\")."
|
||||
)
|
||||
% [
|
||||
item_id,
|
||||
inventory_file,
|
||||
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH,
|
||||
ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.ITEMS_AUTOREGISTER_PATH
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
var inventory_item = ESCInventoryItem.new(
|
||||
@@ -90,7 +100,10 @@ func add_new_item_by_id(item_id: String) -> void:
|
||||
# remove item fromInventory UI using its id set in its scene
|
||||
func remove_item_by_id(item_id: String) -> void:
|
||||
if items_ids_in_inventory.has(item_id):
|
||||
var item_inventory_button = items_ids_in_inventory[item_id]
|
||||
var item_inventory = items_ids_in_inventory[item_id]
|
||||
var item_inventory_button = get_node(
|
||||
inventory_ui_container
|
||||
).get_inventory_button(item_inventory)
|
||||
|
||||
if item_inventory_button.is_connected(
|
||||
"mouse_left_inventory_item",
|
||||
@@ -143,7 +156,7 @@ func remove_item_by_id(item_id: String) -> void:
|
||||
"_on_mouse_exited_inventory_item"
|
||||
)
|
||||
|
||||
get_node(inventory_ui_container).remove_item(item_inventory_button)
|
||||
get_node(inventory_ui_container).remove_item(item_inventory)
|
||||
items_ids_in_inventory.erase(item_id)
|
||||
|
||||
|
||||
@@ -158,10 +171,7 @@ func _on_escoria_global_changed(global: String, old_value, new_value) -> void:
|
||||
else:
|
||||
remove_item_by_id(item[0])
|
||||
else:
|
||||
escoria.logger.report_errors(
|
||||
"inventory_ui.gd:_on_escoria_global_changed()",
|
||||
[
|
||||
"Global must contain only one item name.",
|
||||
"(received: %s)" % global
|
||||
]
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"Global must contain only one item name (received: %s)." % global
|
||||
)
|
||||
|
||||
@@ -44,9 +44,9 @@ func set_state(p_state: String, p_force: bool = false) -> void:
|
||||
resource.loop_end = resource.mix_rate * resource.get_length()
|
||||
elif "loop" in resource:
|
||||
resource.loop = true
|
||||
if escoria.project_settings_manager.has_setting(escoria.project_settings_manager.MUSIC_VOLUME):
|
||||
stream.volume_db = escoria.project_settings_manager.get_setting(
|
||||
escoria.project_settings_manager.MUSIC_VOLUME
|
||||
if ESCProjectSettingsManager.has_setting(ESCProjectSettingsManager.MUSIC_VOLUME):
|
||||
stream.volume_db = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.MUSIC_VOLUME
|
||||
)
|
||||
stream.play()
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ func set_state(p_state: String, p_force: bool = false):
|
||||
resource.loop_mode = AudioStreamSample.LOOP_DISABLED
|
||||
elif "loop" in resource:
|
||||
resource.loop = false
|
||||
if escoria.project_settings_manager.has_setting(escoria.project_settings_manager.SFX_VOLUME):
|
||||
stream.volume_db = escoria.project_settings_manager.get_setting(
|
||||
escoria.project_settings_manager.SFX_VOLUME
|
||||
if ESCProjectSettingsManager.has_setting(ESCProjectSettingsManager.SFX_VOLUME):
|
||||
stream.volume_db = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.SFX_VOLUME
|
||||
)
|
||||
stream.play()
|
||||
|
||||
|
||||
@@ -67,14 +67,14 @@ func transition(
|
||||
_tween.connect("tween_all_completed", self, "_on_tween_completed")
|
||||
|
||||
if transition_name.empty():
|
||||
transition_name = escoria.project_settings_manager.get_setting(
|
||||
escoria.project_settings_manager.DEFAULT_TRANSITION
|
||||
transition_name = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DEFAULT_TRANSITION
|
||||
)
|
||||
|
||||
if not has_transition(transition_name):
|
||||
escoria.logger.report_errors(
|
||||
"transition: Transition %s not found" % transition_name,
|
||||
[]
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"transition: Transition %s not found" % transition_name
|
||||
)
|
||||
|
||||
# If this is an "instant" transition, we need to set the alpha of the base
|
||||
@@ -122,8 +122,8 @@ func transition(
|
||||
#
|
||||
# *Returns* the full path to the shader or an empty string, if it can't be found
|
||||
func get_transition(name: String) -> String:
|
||||
for directory in escoria.project_settings_manager.get_setting(
|
||||
escoria.project_settings_manager.TRANSITION_PATHS
|
||||
for directory in ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.TRANSITION_PATHS
|
||||
):
|
||||
if ResourceLoader.exists(directory.plus_file("%s.material" % name)):
|
||||
return directory.plus_file("%s.material" % name)
|
||||
@@ -154,5 +154,5 @@ func _on_tween_completed():
|
||||
if not _was_canceled:
|
||||
_tween.stop_all()
|
||||
_tween.remove_all()
|
||||
escoria.logger.debug("Transition %s done." % str(transition_id))
|
||||
escoria.logger.debug(self, "Transition %s done." % str(transition_id))
|
||||
emit_signal("transition_done", transition_id)
|
||||
|
||||
Reference in New Issue
Block a user