refactor: Whitespace removal from all .gd files (#494)

Co-authored-by: Balloonpopper <balloonpopper@git.com>
This commit is contained in:
balloonpopper
2022-02-18 09:00:53 +11:00
committed by GitHub
parent f01733d23b
commit 21df2af2c8
112 changed files with 1103 additions and 1103 deletions

View File

@@ -56,10 +56,10 @@ func _resolve_target_and_zoom(p_target) -> void:
_target = Vector2()
_zoom_target = Vector2()
_follow_target = null
if p_target is Node and "is_movable" in p_target and p_target.is_movable:
_follow_target = p_target
if p_target is Vector2:
_target = p_target
elif p_target is Array and p_target.size() > 0:
@@ -90,9 +90,9 @@ func set_drag_margin_enabled(p_dm_h_enabled, p_dm_v_enabled):
# - p_speed: Number of seconds for the camera to reach the target
func set_target(p_target, p_speed : float = 0.0):
var speed = p_speed
_resolve_target_and_zoom(p_target)
escoria.logger.info(
"Current camera position = %s " % str(self.global_position)
)
@@ -104,7 +104,7 @@ func set_target(p_target, p_speed : float = 0.0):
if _tween.is_active():
escoria.logger.report_warnings(
"esc_camera.gd:set_target()",
"esc_camera.gd:set_target()",
[
"Tween is still active: %f/%f" % [
_tween.tell(),
@@ -115,12 +115,12 @@ func set_target(p_target, p_speed : float = 0.0):
_tween.emit_signal("tween_completed")
_tween.interpolate_property(
self,
"global_position",
self.global_position,
_target,
time,
Tween.TRANS_LINEAR,
self,
"global_position",
self.global_position,
_target,
time,
Tween.TRANS_LINEAR,
Tween.EASE_IN_OUT
)
_tween.start()
@@ -134,7 +134,7 @@ func set_target(p_target, p_speed : float = 0.0):
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()",
"esc_camera.gd:set_camera_zoom()",
["Tried to set negative or zero zoom level"]
)
@@ -145,7 +145,7 @@ func set_camera_zoom(p_zoom_level: float, p_time: float):
else:
if _tween.is_active():
escoria.logger.report_warnings(
"esc_camera.gd:set_camera_zoom()",
"esc_camera.gd:set_camera_zoom()",
[
"Tween is still active: %f/%f" % [
_tween.tell(),
@@ -156,12 +156,12 @@ func set_camera_zoom(p_zoom_level: float, p_time: float):
_tween.emit_signal("tween_completed")
_tween.interpolate_property(
self,
"zoom",
self.zoom,
_zoom_target,
p_time,
Tween.TRANS_LINEAR,
self,
"zoom",
self.zoom,
_zoom_target,
p_time,
Tween.TRANS_LINEAR,
Tween.EASE_IN_OUT
)
_tween.start()
@@ -169,18 +169,18 @@ func set_camera_zoom(p_zoom_level: float, p_time: float):
# Push the camera towards the target in terms of position and zoom level
# using a given transition type and time.
# See
# See
# https://docs.godotengine.org/en/stable/classes/class_tween.html#enumerations
#
# #### Parameters
# - p_target: Target to push to
# - p_time: Number of seconds for the transition to take
# - p_type: Tween transition type
# - p_type: Tween transition type
func push(p_target, p_time: float = 0.0, p_type: int = 0):
_resolve_target_and_zoom(p_target)
var push_target = null
if _follow_target != null:
push_target = p_target.position
else:
@@ -193,7 +193,7 @@ func push(p_target, p_time: float = 0.0, p_type: int = 0):
else:
if _tween.is_active():
escoria.logger.report_warnings(
"esc_camera.gd:push()",
"esc_camera.gd:push()",
[
"Tween is still active:" % [
_tween.tell(),
@@ -205,32 +205,32 @@ func push(p_target, p_time: float = 0.0, p_type: int = 0):
if _zoom_target != Vector2():
_tween.interpolate_property(
self,
"zoom",
self.zoom,
_zoom_target,
p_time,
p_type,
self,
"zoom",
self.zoom,
_zoom_target,
p_time,
p_type,
Tween.EASE_IN_OUT
)
_tween.interpolate_property(
self,
"global_position",
self.global_position,
push_target,
p_time,
self,
"global_position",
self.global_position,
push_target,
p_time,
p_type,
Tween.EASE_IN_OUT
)
_tween.start()
# Shift the camera by the given vector in a given time and using a specific
# Tween transition type.
#
# See
# See
# https://docs.godotengine.org/en/stable/classes/class_tween.html#enumerations
#
# #### Parameters
@@ -245,7 +245,7 @@ func shift(p_target: Vector2, p_time: float, p_type: int):
if _tween.is_active():
escoria.logger.report_warnings(
"esc_camera.gd:set_camera_zoom()",
"esc_camera.gd:set_camera_zoom()",
[
"Tween is still active: %f/%f" % [
_tween.tell(),
@@ -254,14 +254,14 @@ func shift(p_target: Vector2, p_time: float, p_type: int):
]
)
_tween.emit_signal("tween_completed")
_tween.interpolate_property(
self,
"global_position",
self.global_position,
new_pos,
p_time,
p_type,
self,
"global_position",
self.global_position,
new_pos,
p_time,
p_type,
Tween.EASE_IN_OUT
)
_tween.start()

View File

@@ -17,9 +17,9 @@ var limit_bottom: int = 10000
func _init(
left: int,
right: int,
top: int,
left: int,
right: int,
top: int,
bottom: int
):
limit_left = left

View File

@@ -6,7 +6,7 @@ class_name ESCDialogManager
# Emitted when the say function has completed showing the text
signal say_finished
# Emitted when the player has chosen an option
# Emitted when the player has chosen an option
signal option_chosen(option)
@@ -18,7 +18,7 @@ signal option_chosen(option)
# *Returns* Wether the type is supported or not
func has_type(type: String) -> bool:
return false
# Check wether a specific chooser type is supported by the
# dialog plugin
@@ -56,7 +56,7 @@ func choose(dialog_player: Node, dialog: ESCDialog):
# Trigger running the dialog faster
func speedup():
pass
# The say command has been interrupted, cancel the dialog display
func interrupt():

View File

@@ -8,7 +8,7 @@ const KEYTEXT_REGEX = "^((?<key>[^:]+):)?\"(?<text>.+)\""
# Emitted when an answer as chosem
#
#
# ##### Parameters
#
# - option: The dialog option that was chosen
@@ -46,7 +46,7 @@ func _input(event):
if event is InputEventMouseButton and event.pressed and is_speaking:
speedup()
get_tree().set_input_as_handled()
# Find the matching voice output file for the given key
#
@@ -57,7 +57,7 @@ func _input(event):
#
# *Returns* The path to the matching voice file
func _get_voice_file(key: String, start: String = "") -> String:
if start == "":
if start == "":
start = escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.SPEECH_FOLDER
)
@@ -68,14 +68,14 @@ func _get_voice_file(key: String, start: String = "") -> String:
while file_name != "":
if _dir.current_is_dir():
var _voice_file = _get_voice_file(
key,
key,
start.plus_file(file_name)
)
if _voice_file != "":
return _voice_file
else:
if file_name == "%s.%s.import" % [
key,
key,
escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.SPEECH_EXTENSION
)
@@ -93,11 +93,11 @@ func _get_voice_file(key: String, start: String = "") -> String:
# - type: UI to use for the dialog
# - text: Text to say
func say(character: String, type: String, text: String) -> void:
if type == "":
if type == "":
type = escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.DEFAULT_DIALOG_TYPE
)
is_speaking = true
is_speaking = true
for _manager_class in escoria.project_settings_manager.get_setting(
escoria.project_settings_manager.DIALOG_MANAGERS
):
@@ -105,7 +105,7 @@ func say(character: String, type: String, text: String) -> void:
var _manager: ESCDialogManager = load(_manager_class).new()
if _manager.has_type(type):
_dialog_manager = _manager
if _dialog_manager == null:
escoria.logger.report_errors(
"esc_dialog_player.gd:say",
@@ -113,9 +113,9 @@ func say(character: String, type: String, text: String) -> void:
"No dialog manager supports the type %s" % 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(
@@ -137,7 +137,7 @@ func say(character: String, type: String, text: String) -> void:
text = tr(matches.get_string("key"))
else:
text = matches.get_string("text")
_dialog_manager.say(self, character, text, type)
@@ -163,12 +163,12 @@ func speedup() -> void:
func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
if dialog.options.empty():
escoria.logger.report_errors(
"esc_dialog_player.gd:start_dialog_choices()",
"esc_dialog_player.gd:start_dialog_choices()",
["Received answers 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
):
@@ -176,7 +176,7 @@ func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
var _manager: ESCDialogManager = load(_manager_class).new()
if _manager.has_chooser_type(type):
_dialog_chooser_ui = _manager
if _dialog_chooser_ui == null:
escoria.logger.report_errors(
"esc_dialog_player.gd: Unknown chooser type",
@@ -184,7 +184,7 @@ func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
"No dialog manager supports the chooser type %s" % type
]
)
_dialog_chooser_ui.choose(self, dialog)
var option = yield(_dialog_chooser_ui, "option_chosen")
emit_signal("option_chosen", option)

View File

@@ -24,18 +24,18 @@ func _ready() -> void:
func _on_command_text_entered(p_command_str : String):
if p_command_str.empty():
return
command.text = ""
past_actions.text += "\n"
past_actions.text += "# " + p_command_str
past_actions.text += "\n"
var errors = []
var script = escoria.esc_compiler.compile([
"%s%s" % [ESCEvent.PREFIX, _debug.get_command_name()],
p_command_str
])
if script:
escoria.event_manager.queue_event(script.events[escoria.event_manager.EVENT_DEBUG])
var ret = yield(escoria.event_manager, "event_finished")

View File

@@ -4,7 +4,7 @@ extends Control
class_name ESCInventory
# Define the actual container node to add items as children of.
# Define the actual container node to add items as children of.
# Should be a Container.
export(NodePath) var inventory_ui_container
@@ -18,19 +18,19 @@ var items_ids_in_inventory: Dictionary = {}
func _ready():
if inventory_ui_container == null or inventory_ui_container.is_empty():
escoria.logger.report_errors(
self.get_path(),
self.get_path(),
["Items container is empty."]
)
return
for item_id in escoria.inventory_manager.items_in_inventory():
call_deferred("add_new_item_by_id", item_id)
escoria.inventory = self
escoria.globals_manager.connect(
"global_changed", #
self,
self,
"_on_escoria_global_changed"
)
@@ -63,25 +63,25 @@ func add_new_item_by_id(item_id: String) -> void:
"Item global id '%s' does not exist." % item_id
]
)
var inventory_item = ESCInventoryItem.new(
escoria.object_manager.get_object(item_id).node
)
var inventory_item_button = get_node(
inventory_ui_container
).add_item(inventory_item)
items_ids_in_inventory[item_id] = inventory_item
if not escoria.object_manager.has(item_id):
escoria.object_manager.register_object(
ESCObject.new(
item_id,
item_id,
inventory_item_button
),
true
)
escoria.inputs_manager.register_inventory_item(inventory_item_button)
@@ -89,58 +89,58 @@ func add_new_item_by_id(item_id: String) -> void:
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]
if item_inventory_button.is_connected(
"mouse_left_inventory_item",
escoria.inputs_manager,
"mouse_left_inventory_item",
escoria.inputs_manager,
"_on_mouse_left_click_inventory_item"
):
item_inventory_button.disconnect(
"mouse_left_inventory_item",
escoria.inputs_manager,
"mouse_left_inventory_item",
escoria.inputs_manager,
"_on_mouse_left_click_inventory_item"
)
if item_inventory_button.is_connected(
"mouse_double_left_inventory_item",
escoria.inputs_manager,
"mouse_double_left_inventory_item",
escoria.inputs_manager,
"_on_mouse_double_left_click_inventory_item"
):
item_inventory_button.disconnect(
"mouse_double_left_inventory_item",
escoria.inputs_manager,
"mouse_double_left_inventory_item",
escoria.inputs_manager,
"_on_mouse_double_left_click_inventory_item"
)
if item_inventory_button.is_connected(
"mouse_right_inventory_item",
escoria.inputs_manager,
"mouse_right_inventory_item",
escoria.inputs_manager,
"_on_mouse_right_click_inventory_item"
):
item_inventory_button.disconnect(
"mouse_right_inventory_item",
escoria.inputs_manager,
"mouse_right_inventory_item",
escoria.inputs_manager,
"_on_mouse_right_click_inventory_item"
)
if item_inventory_button.is_connected(
"inventory_item_focused",
escoria.inputs_manager,
"inventory_item_focused",
escoria.inputs_manager,
"_on_mouse_entered_inventory_item"
):
item_inventory_button.disconnect(
"inventory_item_focused",
escoria.inputs_manager,
"inventory_item_focused",
escoria.inputs_manager,
"_on_mouse_entered_inventory_item"
)
if item_inventory_button.is_connected(
"inventory_item_unfocused",
escoria.inputs_manager,
"inventory_item_unfocused",
escoria.inputs_manager,
"_on_mouse_exited_inventory_item"
):
item_inventory_button.disconnect(
"inventory_item_unfocused",
escoria.inputs_manager,
"inventory_item_unfocused",
escoria.inputs_manager,
"_on_mouse_exited_inventory_item"
)
get_node(inventory_ui_container).remove_item(item_inventory_button)
items_ids_in_inventory.erase(item_id)
@@ -148,7 +148,7 @@ func remove_item_by_id(item_id: String) -> void:
# React to changes to inventory globals adding items or removing them
func _on_escoria_global_changed(global: String, old_value, new_value) -> void:
if !global.begins_with("i/"):
return
return
var item = global.rsplit("i/", false)
if item.size() == 1:
if new_value:
@@ -157,9 +157,9 @@ func _on_escoria_global_changed(global: String, old_value, new_value) -> void:
remove_item_by_id(item[0])
else:
escoria.logger.report_errors(
"inventory_ui.gd:_on_escoria_global_changed()",
"inventory_ui.gd:_on_escoria_global_changed()",
[
"Global must contain only one item name.",
"Global must contain only one item name.",
"(received: %s)" % global
]
)

View File

@@ -42,7 +42,7 @@ func set_state(p_state: String, p_force: bool = false):
if resource is AudioStreamSample:
resource.loop_mode = AudioStreamSample.LOOP_DISABLED
elif "loop" in resource:
resource.loop = false
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

View File

@@ -5,7 +5,7 @@ class_name ESCTransitionPlayer
# Emitted when the transition was played
signal transition_done(transition_id)
# Id of the transition. Allows keeping track of the actual transition
# Id of the transition. Allows keeping track of the actual transition
# being played or finished
var transition_id: int = 0
@@ -34,20 +34,20 @@ func _ready() -> void:
_tween = Tween.new()
add_child(_tween)
_tween.connect("tween_all_completed", self, "_on_tween_completed")
transition()
# Play a transition animation
#
# ## Parameters
#
#
# - transition_name: name of the transition to play (if empty string, uses
# the default transition)
# - mode: Mode to transition (in/out)
# - duration: The duration the transition should take
func transition(
transition_name: String = "",
transition_name: String = "",
mode: int = TRANSITION_MODE.IN,
duration: float = 1.0
) -> int:
@@ -56,23 +56,23 @@ func transition(
"transition: Transition %s not found" % transition_name,
[]
)
material = ResourceLoader.load(get_transition(transition_name))
transition_id += 1
var start = 0.0
var end = 1.0
if mode == TRANSITION_MODE.OUT:
start = 1.0
end = 0.0
if _tween.is_active():
_was_canceled = true
_tween.stop_all()
_tween.remove_all()
emit_signal("transition_done", transition_id-1)
_tween.interpolate_property(
$".",
"material:shader_param/cutoff",
@@ -105,7 +105,7 @@ func get_transition(name: String) -> String:
return ""
# Returns true whether the transition scene has a transition corresponding
# Returns true whether the transition scene has a transition corresponding
# to name provided.
#
# ## Parameters
@@ -115,7 +115,7 @@ func get_transition(name: String) -> String:
# *Returns* true if a transition exists with given name.
func has_transition(name: String) -> bool:
return not get_transition(name) == ""
func _on_tween_completed():
if not _was_canceled: