diff --git a/addons/draw_gd/src/Autoload/DrawGD.gd b/addons/draw_gd/src/Autoload/DrawGD.gd index 9357489..b4ad9f4 100644 --- a/addons/draw_gd/src/Autoload/DrawGD.gd +++ b/addons/draw_gd/src/Autoload/DrawGD.gd @@ -127,10 +127,6 @@ var frames_container : VBoxContainer var tag_container : Control var tag_dialog : AcceptDialog -var remove_frame_button : BaseButton -var move_left_frame_button : BaseButton -var move_right_frame_button : BaseButton - var remove_layer_button : BaseButton var move_up_layer_button : BaseButton var move_down_layer_button : BaseButton @@ -236,10 +232,6 @@ func refresh_nodes(): tag_container = find_node_by_name(animation_timeline, "TagContainer") tag_dialog = find_node_by_name(animation_timeline, "FrameTagDialog") - remove_frame_button = find_node_by_name(animation_timeline, "DeleteFrame") - move_left_frame_button = find_node_by_name(animation_timeline, "MoveLeft") - move_right_frame_button = find_node_by_name(animation_timeline, "MoveRight") - remove_layer_button = find_node_by_name(animation_timeline, "RemoveLayer") move_up_layer_button = find_node_by_name(animation_timeline, "MoveUpLayer") move_down_layer_button = find_node_by_name(animation_timeline, "MoveDownLayer") diff --git a/addons/draw_gd/src/Autoload/Import.gd b/addons/draw_gd/src/Autoload/Import.gd index 72521c3..33bf621 100644 --- a/addons/draw_gd/src/Autoload/Import.gd +++ b/addons/draw_gd/src/Autoload/Import.gd @@ -107,7 +107,7 @@ func add_randomised_brush(fpaths : Array, tooltip_name : String) -> void: if len(loaded_images) > 0: # actually have images # to use. - Brushes.add_file_brush(loaded_images, tooltip_name) + Brushes.add_file_brush(DrawGD, loaded_images, tooltip_name) # Add a plain brush from the given path to the list of brushes. # Taken, again, from find_brushes @@ -118,7 +118,7 @@ func add_plain_brush(path: String, tooltip_name: String) -> void: return # do the standard conversion thing... image.convert(Image.FORMAT_RGBA8) - Brushes.add_file_brush([image], tooltip_name) + Brushes.add_file_brush(DrawGD, [image], tooltip_name) # Import brushes, in priority order, from the paths in question in priority order diff --git a/addons/draw_gd/src/Autoload/OpenSave.gd b/addons/draw_gd/src/Autoload/OpenSave.gd index 3e71c1f..6465aa9 100644 --- a/addons/draw_gd/src/Autoload/OpenSave.gd +++ b/addons/draw_gd/src/Autoload/OpenSave.gd @@ -103,7 +103,7 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void: var image := Image.new() image.create_from_data(b_width, b_height, false, Image.FORMAT_RGBA8, buffer) new_project.brushes.append(image) - Brushes.add_project_brush(image) + Brushes.add_project_brush(DrawGD, image) file.close() if !empty_project: @@ -259,7 +259,7 @@ func open_old_pxo_file(file : File, new_project : Project, first_line : String) var image := Image.new() image.create_from_data(b_width, b_height, false, Image.FORMAT_RGBA8, buffer) new_project.brushes.append(image) - Brushes.add_project_brush(image) + Brushes.add_project_brush(DrawGD, image) brush_line = file.get_line() if file_major_version >= 0 and file_minor_version > 6: diff --git a/addons/draw_gd/src/Classes/Project.gd b/addons/draw_gd/src/Classes/Project.gd index b6be544..04123d1 100644 --- a/addons/draw_gd/src/Classes/Project.gd +++ b/addons/draw_gd/src/Classes/Project.gd @@ -2,7 +2,8 @@ tool class_name Project extends Reference # A class for project properties. -var Export = preload("res://addons/draw_gd/src/Autoload/Export.gd") +var export_script = preload("res://addons/draw_gd/src/Autoload/Export.gd") +var Export = export_script.new() var DrawGD : Node = null @@ -120,7 +121,7 @@ func change_project() -> void: var cel_button = load("res://addons/draw_gd/src/UI/Timeline/CelButton.tscn").instance() cel_button.frame = j cel_button.layer = i - cel_button.get_child(0).texture = frames[j].cels[i].image_texture + cel_button.texture = frames[j].cels[i].image_texture if j == current_frame and i == current_layer: cel_button.pressed = true @@ -131,8 +132,10 @@ func change_project() -> void: label.rect_min_size.x = 36 label.align = Label.ALIGN_CENTER label.text = str(j + 1) - if j == current_frame: - label.add_color_override("font_color", DrawGD.control.theme.get_color("Selected Color", "Label")) + + #if j == current_frame: + #label.add_color_override("font_color", DrawGD.control.theme.get_color("Selected Color", "Label")) + DrawGD.frame_ids.add_child(label) var layer_button = DrawGD.layers_container.get_child(DrawGD.layers_container.get_child_count() - 1 - current_layer) @@ -140,9 +143,6 @@ func change_project() -> void: DrawGD.current_frame_mark_label.text = "%s/%s" % [str(current_frame + 1), frames.size()] - DrawGD.disable_button(DrawGD.remove_frame_button, frames.size() == 1) - DrawGD.disable_button(DrawGD.move_left_frame_button, frames.size() == 1 or current_frame == 0) - DrawGD.disable_button(DrawGD.move_right_frame_button, frames.size() == 1 or current_frame == frames.size() - 1) toggle_layer_buttons_layers() toggle_layer_buttons_current_layer() @@ -165,9 +165,9 @@ func change_project() -> void: guide.visible = false # Change the project brushes - Brushes.clear_project_brush() + Brushes.clear_project_brush(DrawGD) for brush in brushes: - Brushes.add_project_brush(brush) + Brushes.add_project_brush(DrawGD, brush) var cameras = [DrawGD.camera, DrawGD.camera2, DrawGD.camera_preview] var i := 0 diff --git a/addons/draw_gd/src/SelectionRectangle.gd b/addons/draw_gd/src/SelectionRectangle.gd index 0fdb1da..455679c 100644 --- a/addons/draw_gd/src/SelectionRectangle.gd +++ b/addons/draw_gd/src/SelectionRectangle.gd @@ -13,7 +13,14 @@ var _undo_data := {} var DrawGD : Node = null -func _ready() -> void: +func _enter_tree(): + var n : Node = get_parent() + while n: + if n.name == "DrawGDSingleton": + DrawGD = n + break + n = n.get_parent() + _clear_image.create(1, 1, false, Image.FORMAT_RGBA8) _clear_image.fill(Color(0, 0, 0, 0)) @@ -40,6 +47,7 @@ func set_rect(rect : Rect2) -> void: visible = not rect.has_no_area() var project : Project = DrawGD.current_project + if rect.has_no_area(): project.select_all_pixels() else: @@ -116,7 +124,7 @@ func copy() -> void: return var brush = _clipboard.get_rect(_clipboard.get_used_rect()) project.brushes.append(brush) - Brushes.add_project_brush(brush) + Brushes.add_project_brush(DrawGD, brush) func cut() -> void: # This is basically the same as copy + delete if _selected_rect.has_no_area(): @@ -134,7 +142,7 @@ func cut() -> void: # This is basically the same as copy + delete _clear_image.resize(size.x, size.y, Image.INTERPOLATE_NEAREST) var brush = _clipboard.get_rect(_clipboard.get_used_rect()) project.brushes.append(brush) - Brushes.add_project_brush(brush) + Brushes.add_project_brush(DrawGD, brush) move_end() # The selection_rectangle can be used while is moving, this prevents malfunctioning image.blit_rect(_clear_image, rect, _selected_rect.position) commit_undo("Draw", undo_data) diff --git a/addons/draw_gd/src/UI/BrushesPopup.gd b/addons/draw_gd/src/UI/BrushesPopup.gd index 2927218..ddb4c71 100644 --- a/addons/draw_gd/src/UI/BrushesPopup.gd +++ b/addons/draw_gd/src/UI/BrushesPopup.gd @@ -70,9 +70,7 @@ static func create_button(image : Image) -> Node: return button -static func add_file_brush(images : Array, hint := "") -> void: - var DrawGD : Node = null - +static func add_file_brush(DrawGD : Node, images : Array, hint := "") -> void: var button = create_button(images[0]) button.brush.type = FILE if images.size() == 1 else RANDOM_FILE button.brush.image = images[0] @@ -83,9 +81,7 @@ static func add_file_brush(images : Array, hint := "") -> void: button.brush.index = button.get_index() -static func add_project_brush(image : Image, hint := "") -> void: - var DrawGD : Node = null - +static func add_project_brush(DrawGD : Node, image : Image, hint := "") -> void: var button = create_button(image) button.brush.type = CUSTOM button.brush.image = image @@ -95,9 +91,7 @@ static func add_project_brush(image : Image, hint := "") -> void: button.brush.index = button.get_index() -static func clear_project_brush() -> void: - var DrawGD : Node = null - +static func clear_project_brush(DrawGD : Node) -> void: var container = DrawGD.brushes_popup.get_node("TabContainer/Project/ProjectBrushContainer") for child in container.get_children(): child.queue_free() diff --git a/addons/draw_gd/src/UI/Dialogs/PreviewDialog.gd b/addons/draw_gd/src/UI/Dialogs/PreviewDialog.gd index 71f1f90..c599515 100644 --- a/addons/draw_gd/src/UI/Dialogs/PreviewDialog.gd +++ b/addons/draw_gd/src/UI/Dialogs/PreviewDialog.gd @@ -172,7 +172,7 @@ func add_brush() -> void: file_name_ext = file_name_replace(file_name_ext, "Brushes") var file_name : String = file_name_ext.get_basename() - Brushes.add_file_brush([image], file_name) + Brushes.add_file_brush(DrawGD, [image], file_name) # Copy the image file into the "pixelorama/Brushes" directory var location := "Brushes".plus_file(file_name_ext) @@ -182,7 +182,7 @@ func add_brush() -> void: elif brush_type == BrushTypes.PROJECT: var file_name : String = path.get_file().get_basename() DrawGD.current_project.brushes.append(image) - Brushes.add_project_brush(image, file_name) + Brushes.add_project_brush(DrawGD, image, file_name) elif brush_type == BrushTypes.RANDOM: var brush_name = new_brush_name.get_node("BrushNameLineEdit").text.to_lower() diff --git a/addons/draw_gd/src/UI/Tabs.gd b/addons/draw_gd/src/UI/Tabs.gd index fb9c4c6..e93b9f7 100644 --- a/addons/draw_gd/src/UI/Tabs.gd +++ b/addons/draw_gd/src/UI/Tabs.gd @@ -3,6 +3,14 @@ extends Tabs var DrawGD : Node = null +func _enter_tree(): + var n : Node = get_parent() + while n: + if n.name == "DrawGDSingleton": + DrawGD = n + break + n = n.get_parent() + func _on_Tabs_tab_changed(tab : int) -> void: DrawGD.current_project_index = tab