diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index 79c5c7775..377cd4a4b 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -68,11 +68,11 @@ func handle_loading_file(file: String) -> void: func add_import_option(import_name: StringName, import_scene: PackedScene) -> int: # Change format name if another one uses the same name - var existing_format_names = ( + var existing_format_names := ( ImportPreviewDialog.ImageImportOptions.keys() + custom_import_names.keys() ) for i in range(existing_format_names.size()): - var test_name = import_name + var test_name := import_name if i != 0: test_name = str(test_name, "_", i) if !existing_format_names.has(test_name): @@ -82,7 +82,7 @@ func add_import_option(import_name: StringName, import_scene: PackedScene) -> in # Obtain a unique id var id := ImportPreviewDialog.ImageImportOptions.size() for i in custom_import_names.size(): - var format_id = id + i + var format_id := id + i if !custom_import_names.values().has(i): id = format_id # Add to custom_file_formats @@ -514,7 +514,7 @@ func open_image_as_spritesheet_layer_smart( # Create new frames (if needed) var new_frames_size := maxi(project.frames.size(), start_frame + sliced_rects.size()) var frames := [] - var frame_indices := [] + var frame_indices := PackedInt32Array([]) if new_frames_size > project.frames.size(): var required_frames := new_frames_size - project.frames.size() frame_indices = range( @@ -595,7 +595,7 @@ func open_image_as_spritesheet_layer( # Create new frames (if needed) var new_frames_size := maxi(project.frames.size(), start_frame + (vertical * horizontal)) var frames := [] - var frame_indices := [] + var frame_indices := PackedInt32Array([]) if new_frames_size > project.frames.size(): var required_frames := new_frames_size - project.frames.size() frame_indices = range( diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index df03767b9..2fae6ddc8 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -586,7 +586,8 @@ func _z_index_sort(a: int, b: int, frame_index: int) -> bool: # use remove, and vice versa. To undo a move or swap, use move or swap with the parameters swapped. -func add_frames(new_frames: Array, indices: Array) -> void: # indices should be in ascending order +# indices should be in ascending order +func add_frames(new_frames: Array, indices: PackedInt32Array) -> void: Global.canvas.selection.transform_content_confirm() selected_cels.clear() for i in new_frames.size(): @@ -603,14 +604,14 @@ func add_frames(new_frames: Array, indices: Array) -> void: # indices should be _update_frame_ui() -func remove_frames(indices: Array) -> void: # indices should be in ascending order +func remove_frames(indices: PackedInt32Array) -> void: # indices should be in ascending order Global.canvas.selection.transform_content_confirm() selected_cels.clear() for i in indices.size(): # With each removed index, future indices need to be lowered, so subtract by i # For each linked cel in the frame, update its layer's cel_link_sets for l in layers.size(): - var cel: BaseCel = frames[indices[i] - i].cels[l] + var cel := frames[indices[i] - i].cels[l] cel.on_remove() if cel.link_set != null: cel.link_set["cels"].erase(cel) @@ -650,11 +651,11 @@ func swap_frame(a_index: int, b_index: int) -> void: _set_timeline_first_and_last_frames() -func reverse_frames(frame_indices: Array) -> void: +func reverse_frames(frame_indices: PackedInt32Array) -> void: Global.canvas.selection.transform_content_confirm() for i in frame_indices.size() / 2: - var index: int = frame_indices[i] - var reverse_index: int = frame_indices[-i - 1] + var index := frame_indices[i] + var reverse_index := frame_indices[-i - 1] var temp := frames[index] frames[index] = frames[reverse_index] frames[reverse_index] = temp @@ -666,7 +667,8 @@ func reverse_frames(frame_indices: Array) -> void: change_cel(-1) -func add_layers(new_layers: Array, indices: Array, cels: Array) -> void: # cels is 2d Array of cels +## [param cels] is 2d Array of [BaseCel]s +func add_layers(new_layers: Array, indices: PackedInt32Array, cels: Array) -> void: Global.canvas.selection.transform_content_confirm() selected_cels.clear() for i in indices.size(): @@ -678,7 +680,7 @@ func add_layers(new_layers: Array, indices: Array, cels: Array) -> void: # cels _update_layer_ui() -func remove_layers(indices: Array) -> void: +func remove_layers(indices: PackedInt32Array) -> void: Global.canvas.selection.transform_content_confirm() selected_cels.clear() for i in indices.size(): @@ -692,7 +694,9 @@ func remove_layers(indices: Array) -> void: # from_indices and to_indicies should be in ascending order -func move_layers(from_indices: Array, to_indices: Array, to_parents: Array) -> void: +func move_layers( + from_indices: PackedInt32Array, to_indices: PackedInt32Array, to_parents: Array +) -> void: Global.canvas.selection.transform_content_confirm() selected_cels.clear() var removed_layers := [] diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 65c9ed3e2..876d5535c 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -300,7 +300,7 @@ func _on_DeleteFrame_pressed() -> void: delete_frames() -func delete_frames(indices := []) -> void: +func delete_frames(indices: PackedInt32Array = []) -> void: var project := Global.current_project if project.frames.size() == 1: return @@ -551,7 +551,7 @@ func move_frames(frame: int, rate: int) -> void: project.undo_redo.commit_action() -func reverse_frames(indices := []) -> void: +func reverse_frames(indices: PackedInt32Array = []) -> void: var project := Global.current_project project.undo_redo.create_action("Change Frame Order") project.undo_redo.add_do_method(project.reverse_frames.bind(indices)) @@ -885,7 +885,9 @@ func _on_CloneLayer_pressed() -> void: else: # Add (Copy) to the name if its not a child of another copied layer cl_layer.name = str(cl_layer.name, " (", tr("copy"), ")") - var indices := range(project.current_layer + 1, project.current_layer + clones.size() + 1) + var indices: PackedInt32Array = range( + project.current_layer + 1, project.current_layer + clones.size() + 1 + ) project.undos += 1 project.undo_redo.create_action("Add Layer") @@ -934,7 +936,7 @@ func change_layer_order(up: bool) -> void: var project := Global.current_project var layer := project.layers[project.current_layer] var child_count := layer.get_child_count(true) - var from_indices := range(layer.index - child_count, layer.index + 1) + var from_indices: PackedInt32Array = range(layer.index - child_count, layer.index + 1) var from_parents := [] for l in from_indices: from_parents.append(project.layers[l].parent) @@ -971,7 +973,7 @@ func change_layer_order(up: bool) -> void: else: to_index = to_index - 1 - var to_indices := range(to_index, to_index + child_count + 1) + var to_indices: PackedInt32Array = range(to_index, to_index + child_count + 1) project.undo_redo.create_action("Change Layer Order") project.undo_redo.add_do_method(project.move_layers.bind(from_indices, to_indices, to_parents)) diff --git a/src/UI/Timeline/FrameButton.gd b/src/UI/Timeline/FrameButton.gd index d64db5e57..2b462c0d5 100644 --- a/src/UI/Timeline/FrameButton.gd +++ b/src/UI/Timeline/FrameButton.gd @@ -169,7 +169,7 @@ func _get_region_rect(x_begin: float, x_end: float) -> Rect2: return rect -func _get_frame_indices() -> Array: +func _get_frame_indices() -> PackedInt32Array: var indices := [] for cel in Global.current_project.selected_cels: var f: int = cel[0] diff --git a/src/UI/Timeline/LayerMainButton.gd b/src/UI/Timeline/LayerMainButton.gd index f6acd6d5f..e3dbccfcc 100644 --- a/src/UI/Timeline/LayerMainButton.gd +++ b/src/UI/Timeline/LayerMainButton.gd @@ -72,8 +72,8 @@ func _drop_data(_pos: Vector2, data) -> void: var drop_layer: int = data[1] var project := Global.current_project project.undo_redo.create_action("Change Layer Order") - var layers: Array = project.layers # This shouldn't be modified directly - var drop_from_indices := range( + var layers := project.layers # This shouldn't be modified directly + var drop_from_indices: PackedInt32Array = range( drop_layer - layers[drop_layer].get_child_count(true), drop_layer + 1 ) var drop_from_parents := [] @@ -99,7 +99,7 @@ func _drop_data(_pos: Vector2, data) -> void: for l in a.from: a_from_parents.append(layers[l].parent) - # to_parents starts as a dulpicate of from_parents, set the root layer's (with one layer or + # to_parents starts as a duplicate of from_parents, set the root layer's (with one layer or # group with its children, this will always be the last layer [-1]) parent to the other # root layer's parent a["to_parents"] = a_from_parents.duplicate() @@ -144,7 +144,7 @@ func _drop_data(_pos: Vector2, data) -> void: if drop_layer < layer_index: to_index -= drop_from_indices.size() - var drop_to_indices := range(to_index, to_index + drop_from_indices.size()) + var drop_to_indices: PackedInt32Array = range(to_index, to_index + drop_from_indices.size()) var to_parents := drop_from_parents.duplicate() to_parents[-1] = to_parent diff --git a/src/UI/Timeline/PasteTagPopup.gd b/src/UI/Timeline/PasteTagPopup.gd index e8d77039d..113280535 100644 --- a/src/UI/Timeline/PasteTagPopup.gd +++ b/src/UI/Timeline/PasteTagPopup.gd @@ -112,7 +112,8 @@ func add_animation(indices: Array, destination: int, from_tag: AnimationTag = nu var combined_copy := Array() # Makes calculations easy combined_copy.append_array(project.layers) var added_layers := Array() # Array of layers - var added_idx := Array() # Array of indices to add the respective layers (in added_layers) to + # Array of indices to add the respective layers (in added_layers) to + var added_idx := PackedInt32Array() var added_cels := Array() # Array of an Array of cels (added in same order as their layer) if layer_from_to.values().count(-1) > 0: