mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 22:34:43 -04:00
Merge pull request #257 from Orama-Interactive/refactoring
Last refactoring merge
This commit is contained in:
commit
2e69e1a8c2
24 changed files with 727 additions and 692 deletions
|
@ -50,8 +50,8 @@ func _on_DeleteButton_pressed() -> void:
|
|||
Global.update_custom_brush(1)
|
||||
|
||||
var project_brush_index = custom_brush_index - Global.brushes_from_files
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Delete Custom Brush")
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Delete Custom Brush")
|
||||
for i in range(project_brush_index, Global.project_brush_container.get_child_count()):
|
||||
var bb = Global.project_brush_container.get_child(i)
|
||||
if Global.custom_brush_indexes[0] == bb.custom_brush_index:
|
||||
|
@ -59,17 +59,17 @@ func _on_DeleteButton_pressed() -> void:
|
|||
if Global.custom_brush_indexes[1] == bb.custom_brush_index:
|
||||
Global.custom_brush_indexes[1] -= 1
|
||||
|
||||
Global.undo_redo.add_do_property(bb, "custom_brush_index", bb.custom_brush_index - 1)
|
||||
Global.undo_redo.add_undo_property(bb, "custom_brush_index", bb.custom_brush_index)
|
||||
Global.current_project.undo_redo.add_do_property(bb, "custom_brush_index", bb.custom_brush_index - 1)
|
||||
Global.current_project.undo_redo.add_undo_property(bb, "custom_brush_index", bb.custom_brush_index)
|
||||
|
||||
var custom_brushes: Array = Global.custom_brushes.duplicate()
|
||||
var custom_brushes: Array = Global.current_project.brushes.duplicate()
|
||||
custom_brushes.remove(custom_brush_index)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "custom_brushes", custom_brushes)
|
||||
Global.undo_redo.add_undo_property(Global, "custom_brushes", Global.custom_brushes)
|
||||
Global.undo_redo.add_do_method(Global, "redo_custom_brush", self)
|
||||
Global.undo_redo.add_undo_method(Global, "undo_custom_brush", self)
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "brushes", custom_brushes)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "brushes", Global.current_project.brushes)
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo_custom_brush", self)
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo_custom_brush", self)
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_BrushButton_mouse_entered() -> void:
|
||||
|
|
|
@ -38,12 +38,12 @@ func _on_ColorDefaults_pressed() -> void:
|
|||
|
||||
|
||||
func _on_FitToFrameButton_pressed() -> void:
|
||||
Global.camera.fit_to_frame(Global.canvas.size)
|
||||
Global.camera.fit_to_frame(Global.current_project.size)
|
||||
|
||||
|
||||
func _on_100ZoomButton_pressed() -> void:
|
||||
Global.camera.zoom = Vector2.ONE
|
||||
Global.camera.offset = Global.canvas.size / 2
|
||||
Global.camera.offset = Global.current_project.size / 2
|
||||
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
||||
Global.horizontal_ruler.update()
|
||||
Global.vertical_ruler.update()
|
||||
|
|
|
@ -74,22 +74,22 @@ func _on_CreateNewImage_confirmed() -> void:
|
|||
var height : int = height_value.value
|
||||
var fill_color : Color = fill_color_node.color
|
||||
Global.clear_frames()
|
||||
Global.layers.clear()
|
||||
Global.layers.append(Layer.new())
|
||||
Global.canvas.size = Vector2(width, height).floor()
|
||||
Global.current_project.layers.clear()
|
||||
Global.current_project.layers.append(Layer.new())
|
||||
Global.current_project.size = Vector2(width, height).floor()
|
||||
Global.canvas.fill_color = fill_color
|
||||
var frame : Frame = Global.canvas.new_empty_frame()
|
||||
Global.canvas.camera_zoom()
|
||||
Global.frames.append(frame)
|
||||
Global.current_project.frames.append(frame)
|
||||
|
||||
Global.current_layer = 0
|
||||
Global.frames = Global.frames # To trigger Global.frames_changed()
|
||||
Global.current_frame = 0
|
||||
Global.layers = Global.layers # To trigger Global.layers_changed()
|
||||
Global.project_has_changed = false
|
||||
Global.current_project.current_layer = 0
|
||||
Global.current_project.frames = Global.current_project.frames # To trigger Global.frames_changed()
|
||||
Global.current_project.current_frame = 0
|
||||
Global.current_project.layers = Global.current_project.layers # To trigger Global.layers_changed()
|
||||
Global.current_project.has_changed = false
|
||||
if fill_color.a > 0:
|
||||
Global.frames[0].cels[0].image.fill(fill_color)
|
||||
Global.frames[0].cels[0].image.lock()
|
||||
Global.current_project.frames[0].cels[0].image.fill(fill_color)
|
||||
Global.current_project.frames[0].cels[0].image.lock()
|
||||
Global.canvas.update_texture(0)
|
||||
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ func show_tab() -> void:
|
|||
$VBoxContainer/File/FileFormat.selected = FileFormat.PNG
|
||||
$FrameTimer.stop()
|
||||
if not was_exported:
|
||||
frame_number = Global.current_frame + 1
|
||||
$VBoxContainer/FrameOptions/FrameNumber/FrameNumber.max_value = Global.frames.size() + 1
|
||||
frame_number = Global.current_project.current_frame + 1
|
||||
$VBoxContainer/FrameOptions/FrameNumber/FrameNumber.max_value = Global.current_project.frames.size() + 1
|
||||
var prev_frame_number = $VBoxContainer/FrameOptions/FrameNumber/FrameNumber.value
|
||||
$VBoxContainer/FrameOptions/FrameNumber/FrameNumber.value = frame_number
|
||||
if prev_frame_number == frame_number:
|
||||
|
@ -135,9 +135,9 @@ func external_export() -> void:
|
|||
|
||||
|
||||
func process_frame() -> void:
|
||||
var frame = Global.frames[frame_number - 1]
|
||||
var frame = Global.current_project.frames[frame_number - 1]
|
||||
var image := Image.new()
|
||||
image.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
image.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
blend_layers(image, frame)
|
||||
processed_images.clear()
|
||||
processed_images.append(image)
|
||||
|
@ -147,11 +147,11 @@ func process_spritesheet() -> void:
|
|||
# Range of frames determined by tags
|
||||
var frames := []
|
||||
if frame_current_tag > 0:
|
||||
var frame_start = Global.animation_tags[frame_current_tag - 1].from
|
||||
var frame_end = Global.animation_tags[frame_current_tag - 1].to
|
||||
frames = Global.frames.slice(frame_start-1, frame_end-1, 1, true)
|
||||
var frame_start = Global.current_project.animation_tags[frame_current_tag - 1].from
|
||||
var frame_end = Global.current_project.animation_tags[frame_current_tag - 1].to
|
||||
frames = Global.current_project.frames.slice(frame_start-1, frame_end-1, 1, true)
|
||||
else:
|
||||
frames = Global.frames
|
||||
frames = Global.current_project.frames
|
||||
|
||||
# Then store the size of frames for other functions
|
||||
number_of_frames = frames.size()
|
||||
|
@ -160,8 +160,8 @@ func process_spritesheet() -> void:
|
|||
var spritesheet_columns = lines_count if orientation == Orientation.ROWS else frames_divided_by_spritesheet_lines()
|
||||
var spritesheet_rows = lines_count if orientation == Orientation.COLUMNS else frames_divided_by_spritesheet_lines()
|
||||
|
||||
var width = Global.canvas.size.x * spritesheet_columns
|
||||
var height = Global.canvas.size.y * spritesheet_rows
|
||||
var width = Global.current_project.size.x * spritesheet_columns
|
||||
var height = Global.current_project.size.y * spritesheet_rows
|
||||
|
||||
var whole_image := Image.new()
|
||||
whole_image.create(width, height, false, Image.FORMAT_RGBA8)
|
||||
|
@ -173,22 +173,22 @@ func process_spritesheet() -> void:
|
|||
for frame in frames:
|
||||
if orientation == Orientation.ROWS:
|
||||
if vv < spritesheet_columns:
|
||||
origin.x = Global.canvas.size.x * vv
|
||||
origin.x = Global.current_project.size.x * vv
|
||||
vv += 1
|
||||
else:
|
||||
hh += 1
|
||||
origin.x = 0
|
||||
vv = 1
|
||||
origin.y = Global.canvas.size.y * hh
|
||||
origin.y = Global.current_project.size.y * hh
|
||||
else:
|
||||
if hh < spritesheet_rows:
|
||||
origin.y = Global.canvas.size.y * hh
|
||||
origin.y = Global.current_project.size.y * hh
|
||||
hh += 1
|
||||
else:
|
||||
vv += 1
|
||||
origin.y = 0
|
||||
hh = 1
|
||||
origin.x = Global.canvas.size.x * vv
|
||||
origin.x = Global.current_project.size.x * vv
|
||||
blend_layers(whole_image, frame, origin)
|
||||
|
||||
processed_images.clear()
|
||||
|
@ -197,9 +197,9 @@ func process_spritesheet() -> void:
|
|||
|
||||
func process_animation() -> void:
|
||||
processed_images.clear()
|
||||
for frame in Global.frames:
|
||||
for frame in Global.current_project.frames:
|
||||
var image := Image.new()
|
||||
image.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
image.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
blend_layers(image, frame)
|
||||
processed_images.append(image)
|
||||
|
||||
|
@ -280,7 +280,7 @@ func remove_previews() -> void:
|
|||
|
||||
func get_proccessed_image_animation_tag_and_start_id(processed_image_id : int) -> Array:
|
||||
var result_animation_tag_and_start_id = null
|
||||
for animation_tag in Global.animation_tags:
|
||||
for animation_tag in Global.current_project.animation_tags:
|
||||
# Check if processed image is in frame tag and assign frame tag and start id if yes
|
||||
# Then stop
|
||||
if (processed_image_id + 1) >= animation_tag.from and (processed_image_id + 1) <= animation_tag.to:
|
||||
|
@ -365,7 +365,7 @@ func blend_layers(image : Image, frame : Frame, origin : Vector2 = Vector2(0, 0)
|
|||
image.lock()
|
||||
var layer_i := 0
|
||||
for cel in frame.cels:
|
||||
if Global.layers[layer_i].visible:
|
||||
if Global.current_project.layers[layer_i].visible:
|
||||
var cel_image := Image.new()
|
||||
cel_image.copy_from(cel.image)
|
||||
cel_image.lock()
|
||||
|
@ -375,7 +375,7 @@ func blend_layers(image : Image, frame : Frame, origin : Vector2 = Vector2(0, 0)
|
|||
var pixel_color := cel_image.get_pixel(xx, yy)
|
||||
var alpha : float = pixel_color.a * cel.opacity
|
||||
cel_image.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha))
|
||||
DrawingAlgos.blend_rect(image, cel_image, Rect2(Global.canvas.location, Global.canvas.size), origin)
|
||||
DrawingAlgos.blend_rect(image, cel_image, Rect2(Global.canvas.location, Global.current_project.size), origin)
|
||||
layer_i += 1
|
||||
image.unlock()
|
||||
|
||||
|
@ -453,7 +453,7 @@ func create_frame_tag_list() -> void:
|
|||
frame_container.add_item("All Frames", 0) # Re-add removed 'All Frames' item
|
||||
|
||||
# Repopulate list with current tag list
|
||||
for item in Global.animation_tags:
|
||||
for item in Global.current_project.animation_tags:
|
||||
frame_container.add_item(item.name)
|
||||
|
||||
|
||||
|
@ -476,8 +476,8 @@ func store_export_settings() -> void:
|
|||
# Fill the dialog with previous export settings
|
||||
func restore_previous_export_settings() -> void:
|
||||
current_tab = exported_tab
|
||||
frame_number = exported_frame_number if exported_frame_number <= Global.frames.size() else Global.frames.size()
|
||||
frame_current_tag = exported_frame_current_tag if exported_frame_current_tag <= Global.animation_tags.size() else 0
|
||||
frame_number = exported_frame_number if exported_frame_number <= Global.current_project.frames.size() else Global.current_project.frames.size()
|
||||
frame_current_tag = exported_frame_current_tag if exported_frame_current_tag <= Global.current_project.animation_tags.size() else 0
|
||||
orientation = exported_orientation
|
||||
lines_count = exported_lines_count
|
||||
animation_type = exported_animation_type
|
||||
|
|
|
@ -23,7 +23,7 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func _on_HSVDialog_about_to_show() -> void:
|
||||
current_cel = Global.frames[Global.current_frame].cels[Global.current_layer].image
|
||||
current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
||||
preview_image.copy_from(current_cel)
|
||||
update_preview()
|
||||
|
||||
|
@ -38,7 +38,7 @@ func _on_Apply_pressed() -> void:
|
|||
DrawingAlgos.adjust_hsv(current_cel,0,hue_slider.value)
|
||||
DrawingAlgos.adjust_hsv(current_cel,1,sat_slider.value)
|
||||
DrawingAlgos.adjust_hsv(current_cel,2,val_slider.value)
|
||||
Global.canvas.update_texture(Global.current_layer)
|
||||
Global.canvas.update_texture(Global.current_project.current_layer)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
reset()
|
||||
visible = false
|
||||
|
|
|
@ -38,12 +38,12 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
|
|||
Global.control.opensprite_file_selected = true
|
||||
if !new_frame: # If we're not adding a new frame, delete the previous
|
||||
Global.clear_frames()
|
||||
Global.layers.clear()
|
||||
Global.layers.append(Layer.new())
|
||||
Global.current_layer = 0
|
||||
Global.current_project.layers.clear()
|
||||
Global.current_project.layers.append(Layer.new())
|
||||
Global.current_project.current_layer = 0
|
||||
|
||||
var first_path : String = paths[0]
|
||||
var i : int = Global.frames.size()
|
||||
var i : int = Global.current_project.frames.size()
|
||||
if !import_spritesheet:
|
||||
for path in paths:
|
||||
var image := Image.new()
|
||||
|
@ -55,20 +55,20 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
|
|||
Global.dialog_open(true)
|
||||
continue
|
||||
|
||||
Global.canvas.size = image.get_size()
|
||||
Global.current_project.size = image.get_size()
|
||||
var frame := Frame.new()
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
image.lock()
|
||||
frame.cels.append(Cel.new(image, 1))
|
||||
|
||||
for _i in range(1, Global.layers.size()):
|
||||
for _i in range(1, Global.current_project.layers.size()):
|
||||
var empty_sprite := Image.new()
|
||||
empty_sprite.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.fill(Color(0, 0, 0, 0))
|
||||
empty_sprite.lock()
|
||||
frame.cels.append(Cel.new(empty_sprite, 1))
|
||||
|
||||
Global.frames.append(frame)
|
||||
Global.current_project.frames.append(frame)
|
||||
|
||||
i += 1
|
||||
|
||||
|
@ -91,31 +91,31 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
|
|||
var frame := Frame.new()
|
||||
var cropped_image := Image.new()
|
||||
cropped_image = image.get_rect(Rect2(frame_width * xx, frame_height * yy, frame_width, frame_height))
|
||||
Global.canvas.size = cropped_image.get_size()
|
||||
Global.current_project.size = cropped_image.get_size()
|
||||
cropped_image.convert(Image.FORMAT_RGBA8)
|
||||
cropped_image.lock()
|
||||
frame.cels.append(Cel.new(cropped_image, 1))
|
||||
|
||||
for _i in range(1, Global.layers.size()):
|
||||
for _i in range(1, Global.current_project.layers.size()):
|
||||
var empty_sprite := Image.new()
|
||||
empty_sprite.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.fill(Color(0, 0, 0, 0))
|
||||
empty_sprite.lock()
|
||||
frame.cels.append(Cel.new(empty_sprite, 1))
|
||||
|
||||
Global.frames.append(frame)
|
||||
Global.current_project.frames.append(frame)
|
||||
|
||||
i += 1
|
||||
|
||||
Global.canvas.camera_zoom()
|
||||
|
||||
Global.frames = Global.frames # Just to call Global.frames_changed
|
||||
Global.current_frame = i - 1
|
||||
Global.current_project.frames = Global.current_project.frames # Just to call Global.frames_changed
|
||||
Global.current_project.current_frame = i - 1
|
||||
if !new_frame:
|
||||
Global.layers = Global.layers # Just to call Global.layers_changed
|
||||
Global.current_project.layers = Global.current_project.layers # Just to call Global.layers_changed
|
||||
|
||||
Global.window_title = first_path.get_file() + " (" + tr("imported") + ") - Pixelorama " + Global.current_version
|
||||
if Global.project_has_changed:
|
||||
if Global.current_project.has_changed:
|
||||
Global.window_title = Global.window_title + "(*)"
|
||||
var file_name := first_path.get_basename().get_file()
|
||||
var directory_path := first_path.get_basename().replace(file_name, "")
|
||||
|
|
|
@ -10,7 +10,7 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
var diagonal : bool = $OptionsContainer/DiagonalCheckBox.pressed
|
||||
var inside_image : bool = $OptionsContainer/InsideImageCheckBox.pressed
|
||||
|
||||
var image : Image = Global.frames[Global.current_frame].cels[Global.current_layer].image
|
||||
var image : Image = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
||||
if image.is_invisible():
|
||||
return
|
||||
var new_image := Image.new()
|
||||
|
@ -30,13 +30,13 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
var outline_pos : Vector2 = pos + Vector2.LEFT # Left
|
||||
if outline_pos.x < 0 || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.RIGHT * (i - 1)
|
||||
if new_pos.x < Global.canvas.size.x:
|
||||
if new_pos.x < Global.current_project.size.x:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + Vector2.RIGHT # Right
|
||||
if outline_pos.x >= Global.canvas.size.x || image.get_pixelv(outline_pos).a == 0:
|
||||
if outline_pos.x >= Global.current_project.size.x || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.LEFT * (i - 1)
|
||||
if new_pos.x >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
|
@ -46,13 +46,13 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
outline_pos = pos + Vector2.UP # Up
|
||||
if outline_pos.y < 0 || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.DOWN * (i - 1)
|
||||
if new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + Vector2.DOWN # Down
|
||||
if outline_pos.y >= Global.canvas.size.y || image.get_pixelv(outline_pos).a == 0:
|
||||
if outline_pos.y >= Global.current_project.size.y || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.UP * (i - 1)
|
||||
if new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
|
@ -63,29 +63,29 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
outline_pos = pos + (Vector2.LEFT + Vector2.UP) # Top left
|
||||
if (outline_pos.x < 0 && outline_pos.y < 0) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.RIGHT + Vector2.DOWN) * (i - 1)
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + (Vector2.LEFT + Vector2.DOWN) # Bottom left
|
||||
if (outline_pos.x < 0 && outline_pos.y >= Global.canvas.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
if (outline_pos.x < 0 && outline_pos.y >= Global.current_project.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.RIGHT + Vector2.UP) * (i - 1)
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y >= 0:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + (Vector2.RIGHT + Vector2.UP) # Top right
|
||||
if (outline_pos.x >= Global.canvas.size.x && outline_pos.y < 0) || image.get_pixelv(outline_pos).a == 0:
|
||||
if (outline_pos.x >= Global.current_project.size.x && outline_pos.y < 0) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.LEFT + Vector2.DOWN) * (i - 1)
|
||||
if new_pos.x >= 0 && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x >= 0 && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + (Vector2.RIGHT + Vector2.DOWN) # Bottom right
|
||||
if (outline_pos.x >= Global.canvas.size.x && outline_pos.y >= Global.canvas.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
if (outline_pos.x >= Global.current_project.size.x && outline_pos.y >= Global.current_project.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.LEFT + Vector2.UP) * (i - 1)
|
||||
if new_pos.x >= 0 && new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
|
@ -100,7 +100,7 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + Vector2.RIGHT * i # Right
|
||||
if new_pos.x < Global.canvas.size.x:
|
||||
if new_pos.x < Global.current_project.size.x:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
@ -112,7 +112,7 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + Vector2.DOWN * i # Down
|
||||
if new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
@ -125,19 +125,19 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + (Vector2.LEFT + Vector2.DOWN) * i # Bottom left
|
||||
if new_pos.x >= 0 && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x >= 0 && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + (Vector2.RIGHT + Vector2.UP) * i # Top right
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y >= 0:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + (Vector2.RIGHT + Vector2.DOWN) * i # Bottom right
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
|
|
@ -5,19 +5,19 @@ func _on_ScaleImage_confirmed() -> void:
|
|||
var width : int = $VBoxContainer/OptionsContainer/WidthValue.value
|
||||
var height : int = $VBoxContainer/OptionsContainer/HeightValue.value
|
||||
var interpolation : int = $VBoxContainer/OptionsContainer/InterpolationType.selected
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Scale")
|
||||
Global.undo_redo.add_do_property(Global.canvas, "size", Vector2(width, height).floor())
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Scale")
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor())
|
||||
|
||||
for f in Global.frames:
|
||||
for f in Global.current_project.frames:
|
||||
for i in range(f.cels.size() - 1, -1, -1):
|
||||
var sprite := Image.new()
|
||||
sprite.copy_from(f.cels[i].image)
|
||||
sprite.resize(width, height, interpolation)
|
||||
Global.undo_redo.add_do_property(f.cels[i].image, "data", sprite.data)
|
||||
Global.undo_redo.add_undo_property(f.cels[i].image, "data", f.cels[i].image.data)
|
||||
Global.current_project.undo_redo.add_do_property(f.cels[i].image, "data", sprite.data)
|
||||
Global.current_project.undo_redo.add_undo_property(f.cels[i].image, "data", f.cels[i].image.data)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global.canvas, "size", Global.canvas.size)
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "size", Global.current_project.size)
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
|
|
@ -27,7 +27,7 @@ func _input(_event : InputEvent):
|
|||
point0.x -= width * 3
|
||||
point1.x += width * 3
|
||||
if Global.can_draw and Global.has_focus and point_in_rectangle(mouse_pos, point0, point1) and Input.is_action_just_pressed("left_mouse"):
|
||||
if !point_in_rectangle(Global.canvas.current_pixel, Global.canvas.location, Global.canvas.location + Global.canvas.size):
|
||||
if !point_in_rectangle(Global.canvas.current_pixel, Global.canvas.location, Global.canvas.location + Global.current_project.size):
|
||||
has_focus = true
|
||||
Global.has_focus = false
|
||||
update()
|
||||
|
@ -62,11 +62,11 @@ func _draw() -> void:
|
|||
|
||||
func outside_canvas() -> bool:
|
||||
if type == Types.HORIZONTAL:
|
||||
if points[0].y < 0 || points[0].y > Global.canvas.size.y:
|
||||
if points[0].y < 0 || points[0].y > Global.current_project.size.y:
|
||||
queue_free()
|
||||
return true
|
||||
else:
|
||||
if points[0].x < 0 || points[0].x > Global.canvas.size.x:
|
||||
if points[0].x < 0 || points[0].x > Global.current_project.size.x:
|
||||
queue_free()
|
||||
return true
|
||||
return false
|
||||
|
|
|
@ -4,13 +4,14 @@ var fps := 6.0
|
|||
var animation_loop := 1 # 0 is no loop, 1 is cycle loop, 2 is ping-pong loop
|
||||
var animation_forward := true
|
||||
var first_frame := 0
|
||||
var last_frame : int = Global.frames.size() - 1
|
||||
var last_frame := 0
|
||||
|
||||
var timeline_scroll : ScrollContainer
|
||||
var tag_scroll_container : ScrollContainer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
last_frame = Global.current_project.frames.size() - 1
|
||||
timeline_scroll = Global.find_node_by_name(self, "TimelineScroll")
|
||||
tag_scroll_container = Global.find_node_by_name(self, "TagScroll")
|
||||
timeline_scroll.get_h_scrollbar().connect("value_changed", self, "_h_scroll_changed")
|
||||
|
@ -25,9 +26,9 @@ func _h_scroll_changed(value : float) -> void:
|
|||
|
||||
func add_frame() -> void:
|
||||
var frame : Frame = Global.canvas.new_empty_frame()
|
||||
var new_frames : Array = Global.frames.duplicate()
|
||||
var new_frames : Array = Global.current_project.frames.duplicate()
|
||||
new_frames.append(frame)
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
# Loop through the array to create new classes for each element, so that they
|
||||
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
|
||||
for i in new_layers.size():
|
||||
|
@ -40,37 +41,37 @@ func add_frame() -> void:
|
|||
frame.cels[l_i].image = new_layers[l_i].linked_cels[0].cels[l_i].image
|
||||
frame.cels[l_i].image_texture = new_layers[l_i].linked_cels[0].cels[l_i].image_texture
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Add Frame")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Add Frame")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "frames", new_frames)
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", new_frames.size() - 1)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", new_frames.size() - 1)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_DeleteFrame_pressed(frame := -1) -> void:
|
||||
if Global.frames.size() == 1:
|
||||
if Global.current_project.frames.size() == 1:
|
||||
return
|
||||
if frame == -1:
|
||||
frame = Global.current_frame
|
||||
frame = Global.current_project.current_frame
|
||||
|
||||
var frame_to_delete : Frame = Global.frames[frame]
|
||||
var new_frames : Array = Global.frames.duplicate()
|
||||
var frame_to_delete : Frame = Global.current_project.frames[frame]
|
||||
var new_frames : Array = Global.current_project.frames.duplicate()
|
||||
new_frames.erase(frame_to_delete)
|
||||
var current_frame := Global.current_frame
|
||||
var current_frame := Global.current_project.current_frame
|
||||
if current_frame > 0 && current_frame == new_frames.size(): # If it's the last frame
|
||||
current_frame -= 1
|
||||
|
||||
var new_animation_tags := Global.animation_tags.duplicate()
|
||||
var new_animation_tags := Global.current_project.animation_tags.duplicate()
|
||||
# Loop through the tags to create new classes for them, so that they won't be the same
|
||||
# as Global.animation_tags's classes. Needed for undo/redo to work properly.
|
||||
# as Global.current_project.animation_tags's classes. Needed for undo/redo to work properly.
|
||||
for i in new_animation_tags.size():
|
||||
new_animation_tags[i] = AnimationTag.new(new_animation_tags[i].name, new_animation_tags[i].color, new_animation_tags[i].from, new_animation_tags[i].to)
|
||||
|
||||
|
@ -88,7 +89,7 @@ func _on_DeleteFrame_pressed(frame := -1) -> void:
|
|||
# Check if one of the cels of the frame is linked
|
||||
# if they are, unlink them too
|
||||
# this prevents removed cels being kept in linked memory
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
# Loop through the array to create new classes for each element, so that they
|
||||
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
|
||||
for i in new_layers.size():
|
||||
|
@ -97,45 +98,45 @@ func _on_DeleteFrame_pressed(frame := -1) -> void:
|
|||
|
||||
for layer in new_layers:
|
||||
for linked in layer.linked_cels:
|
||||
if linked == Global.frames[frame]:
|
||||
if linked == Global.current_project.frames[frame]:
|
||||
layer.linked_cels.erase(linked)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Remove Frame")
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Remove Frame")
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "frames", new_frames)
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", current_frame)
|
||||
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", current_frame)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "animation_tags", new_animation_tags)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
|
||||
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "animation_tags", Global.current_project.animation_tags)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_CopyFrame_pressed(frame := -1) -> void:
|
||||
if frame == -1:
|
||||
frame = Global.current_frame
|
||||
frame = Global.current_project.current_frame
|
||||
|
||||
var new_frame := Frame.new()
|
||||
|
||||
var new_frames := Global.frames.duplicate()
|
||||
var new_frames := Global.current_project.frames.duplicate()
|
||||
new_frames.insert(frame + 1, new_frame)
|
||||
|
||||
for cel in Global.frames[frame].cels: # Copy every cel
|
||||
for cel in Global.current_project.frames[frame].cels: # Copy every cel
|
||||
var sprite := Image.new()
|
||||
sprite.copy_from(cel.image)
|
||||
sprite.lock()
|
||||
new_frame.cels.append(Cel.new(sprite, cel.opacity))
|
||||
|
||||
var new_animation_tags := Global.animation_tags.duplicate()
|
||||
var new_animation_tags := Global.current_project.animation_tags.duplicate()
|
||||
# Loop through the tags to create new classes for them, so that they won't be the same
|
||||
# as Global.animation_tags's classes. Needed for undo/redo to work properly.
|
||||
# as Global.current_project.animation_tags's classes. Needed for undo/redo to work properly.
|
||||
for i in new_animation_tags.size():
|
||||
new_animation_tags[i] = AnimationTag.new(new_animation_tags[i].name, new_animation_tags[i].color, new_animation_tags[i].from, new_animation_tags[i].to)
|
||||
|
||||
|
@ -144,23 +145,23 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
|
|||
if frame + 1 >= tag.from && frame + 1 <= tag.to:
|
||||
tag.to += 1
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Add Frame")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Add Frame")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "frames", new_frames)
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", frame + 1)
|
||||
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
|
||||
for i in range(Global.layers.size()):
|
||||
for child in Global.layers[i].frame_container.get_children():
|
||||
Global.undo_redo.add_do_property(child, "pressed", false)
|
||||
Global.undo_redo.add_undo_property(child, "pressed", child.pressed)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", frame + 1)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "animation_tags", new_animation_tags)
|
||||
for i in range(Global.current_project.layers.size()):
|
||||
for child in Global.current_project.layers[i].frame_container.get_children():
|
||||
Global.current_project.undo_redo.add_do_property(child, "pressed", false)
|
||||
Global.current_project.undo_redo.add_undo_property(child, "pressed", child.pressed)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", frame)
|
||||
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", frame)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "animation_tags", Global.current_project.animation_tags)
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_FrameTagButton_pressed() -> void:
|
||||
|
@ -222,8 +223,8 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
return
|
||||
|
||||
if animation_forward:
|
||||
if Global.current_frame < last_frame:
|
||||
Global.current_frame += 1
|
||||
if Global.current_project.current_frame < last_frame:
|
||||
Global.current_project.current_frame += 1
|
||||
else:
|
||||
match animation_loop:
|
||||
0: # No loop
|
||||
|
@ -231,14 +232,14 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
Global.play_backwards.pressed = false
|
||||
Global.animation_timer.stop()
|
||||
1: # Cycle loop
|
||||
Global.current_frame = first_frame
|
||||
Global.current_project.current_frame = first_frame
|
||||
2: # Ping pong loop
|
||||
animation_forward = false
|
||||
_on_AnimationTimer_timeout()
|
||||
|
||||
else:
|
||||
if Global.current_frame > first_frame:
|
||||
Global.current_frame -= 1
|
||||
if Global.current_project.current_frame > first_frame:
|
||||
Global.current_project.current_frame -= 1
|
||||
else:
|
||||
match animation_loop:
|
||||
0: # No loop
|
||||
|
@ -246,7 +247,7 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
Global.play_forward.pressed = false
|
||||
Global.animation_timer.stop()
|
||||
1: # Cycle loop
|
||||
Global.current_frame = last_frame
|
||||
Global.current_project.current_frame = last_frame
|
||||
2: # Ping pong loop
|
||||
animation_forward = true
|
||||
_on_AnimationTimer_timeout()
|
||||
|
@ -254,12 +255,12 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
|
||||
func play_animation(play : bool, forward_dir : bool) -> void:
|
||||
first_frame = 0
|
||||
last_frame = Global.frames.size() - 1
|
||||
last_frame = Global.current_project.frames.size() - 1
|
||||
if Global.play_only_tags:
|
||||
for tag in Global.animation_tags:
|
||||
if Global.current_frame + 1 >= tag.from && Global.current_frame + 1 <= tag.to:
|
||||
for tag in Global.current_project.animation_tags:
|
||||
if Global.current_project.current_frame + 1 >= tag.from && Global.current_project.current_frame + 1 <= tag.to:
|
||||
first_frame = tag.from - 1
|
||||
last_frame = min(Global.frames.size() - 1, tag.to - 1)
|
||||
last_frame = min(Global.current_project.frames.size() - 1, tag.to - 1)
|
||||
|
||||
if first_frame == last_frame:
|
||||
if forward_dir:
|
||||
|
@ -288,21 +289,21 @@ func play_animation(play : bool, forward_dir : bool) -> void:
|
|||
|
||||
|
||||
func _on_NextFrame_pressed() -> void:
|
||||
if Global.current_frame < Global.frames.size() - 1:
|
||||
Global.current_frame += 1
|
||||
if Global.current_project.current_frame < Global.current_project.frames.size() - 1:
|
||||
Global.current_project.current_frame += 1
|
||||
|
||||
|
||||
func _on_PreviousFrame_pressed() -> void:
|
||||
if Global.current_frame > 0:
|
||||
Global.current_frame -= 1
|
||||
if Global.current_project.current_frame > 0:
|
||||
Global.current_project.current_frame -= 1
|
||||
|
||||
|
||||
func _on_LastFrame_pressed() -> void:
|
||||
Global.current_frame = Global.frames.size() - 1
|
||||
Global.current_project.current_frame = Global.current_project.frames.size() - 1
|
||||
|
||||
|
||||
func _on_FirstFrame_pressed() -> void:
|
||||
Global.current_frame = 0
|
||||
Global.current_project.current_frame = 0
|
||||
|
||||
|
||||
func _on_FPSValue_value_changed(value : float) -> void:
|
||||
|
@ -328,142 +329,142 @@ func _on_BlueRedMode_toggled(button_pressed : bool) -> void:
|
|||
# Layer buttons
|
||||
|
||||
func add_layer(is_new := true) -> void:
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
var l := Layer.new()
|
||||
if !is_new: # Clone layer
|
||||
l.name = Global.layers[Global.current_layer].name + " (" + tr("copy") + ")"
|
||||
l.name = Global.current_project.layers[Global.current_project.current_layer].name + " (" + tr("copy") + ")"
|
||||
new_layers.append(l)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Add Layer")
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Add Layer")
|
||||
|
||||
for f in Global.frames:
|
||||
for f in Global.current_project.frames:
|
||||
var new_layer := Image.new()
|
||||
if is_new:
|
||||
new_layer.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
new_layer.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
else: # Clone layer
|
||||
new_layer.copy_from(f.cels[Global.current_layer].image)
|
||||
new_layer.copy_from(f.cels[Global.current_project.current_layer].image)
|
||||
|
||||
new_layer.lock()
|
||||
|
||||
var new_cels : Array = f.cels.duplicate()
|
||||
new_cels.append(Cel.new(new_layer, 1))
|
||||
Global.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
Global.current_project.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.current_project.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer + 1)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_layer", Global.current_project.current_layer + 1)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_layer", Global.current_project.current_layer)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_RemoveLayer_pressed() -> void:
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
new_layers.remove(Global.current_layer)
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Remove Layer")
|
||||
if Global.current_layer > 0:
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer - 1)
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
new_layers.remove(Global.current_project.current_layer)
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Remove Layer")
|
||||
if Global.current_project.current_layer > 0:
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_layer", Global.current_project.current_layer - 1)
|
||||
else:
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_layer", Global.current_project.current_layer)
|
||||
|
||||
for f in Global.frames:
|
||||
for f in Global.current_project.frames:
|
||||
var new_cels : Array = f.cels.duplicate()
|
||||
new_cels.remove(Global.current_layer)
|
||||
Global.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
new_cels.remove(Global.current_project.current_layer)
|
||||
Global.current_project.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.current_project.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_layer", Global.current_project.current_layer)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func change_layer_order(rate : int) -> void:
|
||||
var change = Global.current_layer + rate
|
||||
var change = Global.current_project.current_layer + rate
|
||||
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var temp = new_layers[Global.current_layer]
|
||||
new_layers[Global.current_layer] = new_layers[change]
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
var temp = new_layers[Global.current_project.current_layer]
|
||||
new_layers[Global.current_project.current_layer] = new_layers[change]
|
||||
new_layers[change] = temp
|
||||
Global.undo_redo.create_action("Change Layer Order")
|
||||
for f in Global.frames:
|
||||
Global.current_project.undo_redo.create_action("Change Layer Order")
|
||||
for f in Global.current_project.frames:
|
||||
var new_cels : Array = f.cels.duplicate()
|
||||
var temp_canvas = new_cels[Global.current_layer]
|
||||
new_cels[Global.current_layer] = new_cels[change]
|
||||
var temp_canvas = new_cels[Global.current_project.current_layer]
|
||||
new_cels[Global.current_project.current_layer] = new_cels[change]
|
||||
new_cels[change] = temp_canvas
|
||||
Global.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
Global.current_project.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.current_project.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", change)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_layer", change)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_layer", Global.current_project.current_layer)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_MergeDownLayer_pressed() -> void:
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
# Loop through the array to create new classes for each element, so that they
|
||||
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
|
||||
for i in new_layers.size():
|
||||
var new_linked_cels = new_layers[i].linked_cels.duplicate()
|
||||
new_layers[i] = Layer.new(new_layers[i].name, new_layers[i].visible, new_layers[i].locked, new_layers[i].frame_container, new_layers[i].new_cels_linked, new_linked_cels)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Merge Layer")
|
||||
for f in Global.frames:
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Merge Layer")
|
||||
for f in Global.current_project.frames:
|
||||
var new_cels : Array = f.cels.duplicate()
|
||||
for i in new_cels.size():
|
||||
new_cels[i] = Cel.new(new_cels[i].image, new_cels[i].opacity)
|
||||
var selected_layer := Image.new()
|
||||
selected_layer.copy_from(new_cels[Global.current_layer].image)
|
||||
selected_layer.copy_from(new_cels[Global.current_project.current_layer].image)
|
||||
selected_layer.lock()
|
||||
|
||||
if f.cels[Global.current_layer].opacity < 1: # If we have layer transparency
|
||||
if f.cels[Global.current_project.current_layer].opacity < 1: # If we have layer transparency
|
||||
for xx in selected_layer.get_size().x:
|
||||
for yy in selected_layer.get_size().y:
|
||||
var pixel_color : Color = selected_layer.get_pixel(xx, yy)
|
||||
var alpha : float = pixel_color.a * f.cels[Global.current_layer].opacity
|
||||
var alpha : float = pixel_color.a * f.cels[Global.current_project.current_layer].opacity
|
||||
selected_layer.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha))
|
||||
|
||||
var new_layer := Image.new()
|
||||
new_layer.copy_from(f.cels[Global.current_layer - 1].image)
|
||||
new_layer.copy_from(f.cels[Global.current_project.current_layer - 1].image)
|
||||
new_layer.lock()
|
||||
DrawingAlgos.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.location, Global.canvas.size), Vector2.ZERO)
|
||||
new_cels.remove(Global.current_layer)
|
||||
if !selected_layer.is_invisible() and Global.layers[Global.current_layer - 1].linked_cels.size() > 1 and (f in Global.layers[Global.current_layer - 1].linked_cels):
|
||||
new_layers[Global.current_layer - 1].linked_cels.erase(f)
|
||||
new_cels[Global.current_layer - 1].image = new_layer
|
||||
DrawingAlgos.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.location, Global.current_project.size), Vector2.ZERO)
|
||||
new_cels.remove(Global.current_project.current_layer)
|
||||
if !selected_layer.is_invisible() and Global.current_project.layers[Global.current_project.current_layer - 1].linked_cels.size() > 1 and (f in Global.current_project.layers[Global.current_project.current_layer - 1].linked_cels):
|
||||
new_layers[Global.current_project.current_layer - 1].linked_cels.erase(f)
|
||||
new_cels[Global.current_project.current_layer - 1].image = new_layer
|
||||
else:
|
||||
Global.undo_redo.add_do_property(f.cels[Global.current_layer - 1].image, "data", new_layer.data)
|
||||
Global.undo_redo.add_undo_property(f.cels[Global.current_layer - 1].image, "data", f.cels[Global.current_layer - 1].image.data)
|
||||
Global.current_project.undo_redo.add_do_property(f.cels[Global.current_project.current_layer - 1].image, "data", new_layer.data)
|
||||
Global.current_project.undo_redo.add_undo_property(f.cels[Global.current_project.current_layer - 1].image, "data", f.cels[Global.current_project.current_layer - 1].image.data)
|
||||
|
||||
Global.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
Global.current_project.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.current_project.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
|
||||
new_layers.remove(Global.current_layer)
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer - 1)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
new_layers.remove(Global.current_project.current_layer)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_layer", Global.current_project.current_layer - 1)
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_layer", Global.current_project.current_layer)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func _on_OpacitySlider_value_changed(value) -> void:
|
||||
Global.frames[Global.current_frame].cels[Global.current_layer].opacity = value / 100
|
||||
Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].opacity = value / 100
|
||||
Global.layer_opacity_slider.value = value
|
||||
Global.layer_opacity_slider.value = value
|
||||
Global.layer_opacity_spinbox.value = value
|
||||
|
|
|
@ -8,7 +8,7 @@ onready var popup_menu : PopupMenu = $PopupMenu
|
|||
|
||||
func _ready() -> void:
|
||||
hint_tooltip = "Frame: %s, Layer: %s" % [frame + 1, layer]
|
||||
if Global.frames[frame] in Global.layers[layer].linked_cels:
|
||||
if Global.current_project.frames[frame] in Global.current_project.layers[layer].linked_cels:
|
||||
get_node("LinkedIndicator").visible = true
|
||||
popup_menu.set_item_text(4, "Unlink Cel")
|
||||
popup_menu.set_item_metadata(4, "Unlink Cel")
|
||||
|
@ -20,10 +20,10 @@ func _ready() -> void:
|
|||
|
||||
func _on_CelButton_pressed() -> void:
|
||||
if Input.is_action_just_released("left_mouse"):
|
||||
Global.current_frame = frame
|
||||
Global.current_layer = layer
|
||||
Global.current_project.current_frame = frame
|
||||
Global.current_project.current_layer = layer
|
||||
elif Input.is_action_just_released("right_mouse"):
|
||||
if Global.frames.size() == 1:
|
||||
if Global.current_project.frames.size() == 1:
|
||||
popup_menu.set_item_disabled(0, true)
|
||||
popup_menu.set_item_disabled(2, true)
|
||||
popup_menu.set_item_disabled(3, true)
|
||||
|
@ -31,7 +31,7 @@ func _on_CelButton_pressed() -> void:
|
|||
popup_menu.set_item_disabled(0, false)
|
||||
if frame > 0:
|
||||
popup_menu.set_item_disabled(2, false)
|
||||
if frame < Global.frames.size() - 1:
|
||||
if frame < Global.current_project.frames.size() - 1:
|
||||
popup_menu.set_item_disabled(3, false)
|
||||
popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE))
|
||||
pressed = !pressed
|
||||
|
@ -53,9 +53,9 @@ func _on_PopupMenu_id_pressed(ID : int) -> void:
|
|||
3: # Move Right
|
||||
change_frame_order(1)
|
||||
4: # Unlink Cel
|
||||
var cel_index : int = Global.layers[layer].linked_cels.find(Global.frames[frame])
|
||||
var f = Global.frames[frame]
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
var cel_index : int = Global.current_project.layers[layer].linked_cels.find(Global.current_project.frames[frame])
|
||||
var f = Global.current_project.frames[frame]
|
||||
var new_layers : Array = Global.current_project.layers.duplicate()
|
||||
# Loop through the array to create new classes for each element, so that they
|
||||
# won't be the same as the original array's classes. Needed for undo/redo to work properly.
|
||||
for i in new_layers.size():
|
||||
|
@ -68,53 +68,53 @@ func _on_PopupMenu_id_pressed(ID : int) -> void:
|
|||
if popup_menu.get_item_metadata(4) == "Unlink Cel":
|
||||
new_layers[layer].linked_cels.remove(cel_index)
|
||||
var sprite := Image.new()
|
||||
sprite.copy_from(Global.frames[frame].cels[layer].image)
|
||||
sprite.copy_from(Global.current_project.frames[frame].cels[layer].image)
|
||||
sprite.lock()
|
||||
new_cels[layer].image = sprite
|
||||
|
||||
Global.undo_redo.create_action("Unlink Cel")
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
Global.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
Global.current_project.undo_redo.create_action("Unlink Cel")
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
Global.current_project.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
Global.current_project.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
elif popup_menu.get_item_metadata(4) == "Link Cel":
|
||||
new_layers[layer].linked_cels.append(Global.frames[frame])
|
||||
Global.undo_redo.create_action("Link Cel")
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
new_layers[layer].linked_cels.append(Global.current_project.frames[frame])
|
||||
Global.current_project.undo_redo.create_action("Link Cel")
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers)
|
||||
if new_layers[layer].linked_cels.size() > 1:
|
||||
# If there are already linked cels, set the current cel's image
|
||||
# to the first linked cel's image
|
||||
new_cels[layer].image = new_layers[layer].linked_cels[0].cels[layer].image
|
||||
new_cels[layer].image_texture = new_layers[layer].linked_cels[0].cels[layer].image_texture
|
||||
Global.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
Global.current_project.undo_redo.add_do_property(f, "cels", new_cels)
|
||||
Global.current_project.undo_redo.add_undo_property(f, "cels", f.cels)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.layers)
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "layers", Global.current_project.layers)
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
|
||||
func change_frame_order(rate : int) -> void:
|
||||
var change = frame + rate
|
||||
var new_frames : Array = Global.frames.duplicate()
|
||||
var new_frames : Array = Global.current_project.frames.duplicate()
|
||||
var temp = new_frames[frame]
|
||||
new_frames[frame] = new_frames[change]
|
||||
new_frames[change] = temp
|
||||
|
||||
Global.undo_redo.create_action("Change Frame Order")
|
||||
Global.undo_redo.add_do_property(Global, "frames", new_frames)
|
||||
Global.current_project.undo_redo.create_action("Change Frame Order")
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames)
|
||||
|
||||
if Global.current_frame == frame:
|
||||
Global.undo_redo.add_do_property(Global, "current_frame", change)
|
||||
Global.undo_redo.add_undo_property(Global, "current_frame", Global.current_frame)
|
||||
if Global.current_project.current_frame == frame:
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", change)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "frames", Global.frames)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames)
|
||||
|
||||
Global.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.undo_redo.add_do_method(Global, "redo")
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
|
|
@ -21,7 +21,7 @@ func _on_FrameTagDialog_about_to_show() -> void:
|
|||
tag_vboxes.clear()
|
||||
|
||||
var i := 0
|
||||
for tag in Global.animation_tags:
|
||||
for tag in Global.current_project.animation_tags:
|
||||
var vbox_cont := VBoxContainer.new()
|
||||
var hbox_cont := HBoxContainer.new()
|
||||
var tag_label := Label.new()
|
||||
|
@ -62,18 +62,18 @@ func _on_FrameTagDialog_popup_hide() -> void:
|
|||
|
||||
func _on_AddTag_pressed() -> void:
|
||||
options_dialog.popup_centered()
|
||||
current_tag_id = Global.animation_tags.size()
|
||||
options_dialog.get_node("GridContainer/FromSpinBox").value = Global.current_frame + 1
|
||||
options_dialog.get_node("GridContainer/ToSpinBox").value = Global.current_frame + 1
|
||||
current_tag_id = Global.current_project.animation_tags.size()
|
||||
options_dialog.get_node("GridContainer/FromSpinBox").value = Global.current_project.current_frame + 1
|
||||
options_dialog.get_node("GridContainer/ToSpinBox").value = Global.current_project.current_frame + 1
|
||||
|
||||
|
||||
func _on_EditButton_pressed(_tag_id : int) -> void:
|
||||
options_dialog.popup_centered()
|
||||
current_tag_id = _tag_id
|
||||
options_dialog.get_node("GridContainer/NameLineEdit").text = Global.animation_tags[_tag_id].name
|
||||
options_dialog.get_node("GridContainer/ColorPickerButton").color = Global.animation_tags[_tag_id].color
|
||||
options_dialog.get_node("GridContainer/FromSpinBox").value = Global.animation_tags[_tag_id].from
|
||||
options_dialog.get_node("GridContainer/ToSpinBox").value = Global.animation_tags[_tag_id].to
|
||||
options_dialog.get_node("GridContainer/NameLineEdit").text = Global.current_project.animation_tags[_tag_id].name
|
||||
options_dialog.get_node("GridContainer/ColorPickerButton").color = Global.current_project.animation_tags[_tag_id].color
|
||||
options_dialog.get_node("GridContainer/FromSpinBox").value = Global.current_project.animation_tags[_tag_id].from
|
||||
options_dialog.get_node("GridContainer/ToSpinBox").value = Global.current_project.animation_tags[_tag_id].to
|
||||
if !delete_tag_button:
|
||||
delete_tag_button = options_dialog.add_button("Delete Tag", true, "delete_tag")
|
||||
else:
|
||||
|
@ -86,19 +86,19 @@ func _on_TagOptions_confirmed() -> void:
|
|||
var tag_from : int = options_dialog.get_node("GridContainer/FromSpinBox").value
|
||||
var tag_to : int = options_dialog.get_node("GridContainer/ToSpinBox").value
|
||||
|
||||
if tag_to > Global.frames.size():
|
||||
tag_to = Global.frames.size()
|
||||
if tag_to > Global.current_project.frames.size():
|
||||
tag_to = Global.current_project.frames.size()
|
||||
|
||||
if tag_from > tag_to:
|
||||
tag_from = tag_to
|
||||
|
||||
var new_animation_tags := Global.animation_tags.duplicate()
|
||||
var new_animation_tags := Global.current_project.animation_tags.duplicate()
|
||||
# Loop through the tags to create new classes for them, so that they won't be the same
|
||||
# as Global.animation_tags's classes. Needed for undo/redo to work properly.
|
||||
# as Global.current_project.animation_tags's classes. Needed for undo/redo to work properly.
|
||||
for i in new_animation_tags.size():
|
||||
new_animation_tags[i] = AnimationTag.new(new_animation_tags[i].name, new_animation_tags[i].color, new_animation_tags[i].from, new_animation_tags[i].to)
|
||||
|
||||
if current_tag_id == Global.animation_tags.size():
|
||||
if current_tag_id == Global.current_project.animation_tags.size():
|
||||
new_animation_tags.append(AnimationTag.new(tag_name, tag_color, tag_from, tag_to))
|
||||
else:
|
||||
new_animation_tags[current_tag_id].name = tag_name
|
||||
|
@ -107,28 +107,28 @@ func _on_TagOptions_confirmed() -> void:
|
|||
new_animation_tags[current_tag_id].to = tag_to
|
||||
|
||||
# Handle Undo/Redo
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Modify Frame Tag")
|
||||
Global.undo_redo.add_do_method(Global, "general_redo")
|
||||
Global.undo_redo.add_undo_method(Global, "general_undo")
|
||||
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
|
||||
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Modify Frame Tag")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "general_redo")
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "general_undo")
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "animation_tags", new_animation_tags)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "animation_tags", Global.current_project.animation_tags)
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
_on_FrameTagDialog_about_to_show()
|
||||
|
||||
|
||||
func _on_TagOptions_custom_action(action : String) -> void:
|
||||
if action == "delete_tag":
|
||||
var new_animation_tags := Global.animation_tags.duplicate()
|
||||
var new_animation_tags := Global.current_project.animation_tags.duplicate()
|
||||
new_animation_tags.remove(current_tag_id)
|
||||
# Handle Undo/Redo
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Delete Frame Tag")
|
||||
Global.undo_redo.add_do_method(Global, "general_redo")
|
||||
Global.undo_redo.add_undo_method(Global, "general_undo")
|
||||
Global.undo_redo.add_do_property(Global, "animation_tags", new_animation_tags)
|
||||
Global.undo_redo.add_undo_property(Global, "animation_tags", Global.animation_tags)
|
||||
Global.undo_redo.commit_action()
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Delete Frame Tag")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "general_redo")
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "general_undo")
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "animation_tags", new_animation_tags)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "animation_tags", Global.current_project.animation_tags)
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
||||
options_dialog.hide()
|
||||
_on_FrameTagDialog_about_to_show()
|
||||
|
|
|
@ -16,7 +16,7 @@ func _ready() -> void:
|
|||
label = Global.find_node_by_name(self, "Label")
|
||||
line_edit = Global.find_node_by_name(self, "LineEdit")
|
||||
|
||||
if Global.layers[i].visible:
|
||||
if Global.current_project.layers[i].visible:
|
||||
Global.change_button_texturerect(visibility_button.get_child(0), "layer_visible.png")
|
||||
visibility_button.get_child(0).rect_size = Vector2(24, 14)
|
||||
visibility_button.get_child(0).rect_position = Vector2(4, 9)
|
||||
|
@ -25,12 +25,12 @@ func _ready() -> void:
|
|||
visibility_button.get_child(0).rect_size = Vector2(24, 8)
|
||||
visibility_button.get_child(0).rect_position = Vector2(4, 12)
|
||||
|
||||
if Global.layers[i].locked:
|
||||
if Global.current_project.layers[i].locked:
|
||||
Global.change_button_texturerect(lock_button.get_child(0), "lock.png")
|
||||
else:
|
||||
Global.change_button_texturerect(lock_button.get_child(0), "unlock.png")
|
||||
|
||||
if Global.layers[i].new_cels_linked: # If new layers will be linked
|
||||
if Global.current_project.layers[i].new_cels_linked: # If new layers will be linked
|
||||
Global.change_button_texturerect(linked_button.get_child(0), "linked_layer.png")
|
||||
else:
|
||||
Global.change_button_texturerect(linked_button.get_child(0), "unlinked_layer.png")
|
||||
|
@ -59,21 +59,21 @@ func save_layer_name(new_name : String) -> void:
|
|||
line_edit.editable = false
|
||||
label.text = new_name
|
||||
Global.layers_changed_skip = true
|
||||
Global.layers[i].name = new_name
|
||||
Global.current_project.layers[i].name = new_name
|
||||
|
||||
|
||||
func _on_VisibilityButton_pressed() -> void:
|
||||
Global.layers[i].visible = !Global.layers[i].visible
|
||||
Global.current_project.layers[i].visible = !Global.current_project.layers[i].visible
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func _on_LockButton_pressed() -> void:
|
||||
Global.layers[i].locked = !Global.layers[i].locked
|
||||
Global.current_project.layers[i].locked = !Global.current_project.layers[i].locked
|
||||
|
||||
|
||||
func _on_LinkButton_pressed() -> void:
|
||||
Global.layers[i].new_cels_linked = !Global.layers[i].new_cels_linked
|
||||
if Global.layers[i].new_cels_linked && !Global.layers[i].linked_cels:
|
||||
Global.current_project.layers[i].new_cels_linked = !Global.current_project.layers[i].new_cels_linked
|
||||
if Global.current_project.layers[i].new_cels_linked && !Global.current_project.layers[i].linked_cels:
|
||||
# If button is pressed and there are no linked cels in the layer
|
||||
Global.layers[i].linked_cels.append(Global.frames[Global.current_frame])
|
||||
Global.layers[i].frame_container.get_child(Global.current_frame)._ready()
|
||||
Global.current_project.layers[i].linked_cels.append(Global.current_project.frames[Global.current_project.current_frame])
|
||||
Global.current_project.layers[i].frame_container.get_child(Global.current_project.current_frame)._ready()
|
||||
|
|
|
@ -2,7 +2,7 @@ extends ColorRect
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
rect_size = Global.canvas.size
|
||||
rect_size = Global.current_project.size
|
||||
material.set_shader_param("size", Global.checker_size)
|
||||
material.set_shader_param("color1", Global.checker_color_1)
|
||||
material.set_shader_param("color2", Global.checker_color_2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue