mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 22:54:44 -04:00
Project brushes change when switching projects
A new Global.file_brushes array is used for the file brushes, and the Project class has its own brushes array for the project brushes
This commit is contained in:
parent
736521246d
commit
4af130bc61
7 changed files with 67 additions and 63 deletions
|
@ -1,7 +1,7 @@
|
|||
extends BaseButton
|
||||
|
||||
|
||||
export var brush_type = 0 # Global.Brush_Types.PIXEL
|
||||
export var brush_type := 0 # Global.Brush_Types.PIXEL
|
||||
export var custom_brush_index := -3
|
||||
var random_brushes := []
|
||||
|
||||
|
@ -15,61 +15,49 @@ func _on_BrushButton_pressed() -> void:
|
|||
# Change brush
|
||||
Global.current_brush_types[Global.brush_type_window_position] = brush_type
|
||||
Global.custom_brush_indexes[Global.brush_type_window_position] = custom_brush_index
|
||||
if custom_brush_index > -1: # Custom brush
|
||||
if brush_type == Global.Brush_Types.FILE or brush_type == Global.Brush_Types.RANDOM_FILE or brush_type == Global.Brush_Types.CUSTOM:
|
||||
if Global.current_tools[Global.brush_type_window_position] == Global.Tools.PENCIL:
|
||||
Global.color_interpolation_containers[Global.brush_type_window_position].visible = true
|
||||
# if hint_tooltip == "":
|
||||
# Global.left_brush_type_label.text = tr("Custom brush")
|
||||
# else:
|
||||
# Global.left_brush_type_label.text = tr("Brush:") + " %s" % hint_tooltip
|
||||
elif custom_brush_index == -3: # Pixel brush
|
||||
else:
|
||||
Global.color_interpolation_containers[Global.brush_type_window_position].visible = false
|
||||
# Global.left_brush_type_label.text = tr("Brush: Pixel")
|
||||
elif custom_brush_index == -2: # Circle brush
|
||||
Global.color_interpolation_containers[Global.brush_type_window_position].visible = false
|
||||
# Global.left_brush_type_label.text = tr("Brush: Circle")
|
||||
elif custom_brush_index == -1: # Filled Circle brush
|
||||
Global.color_interpolation_containers[Global.brush_type_window_position].visible = false
|
||||
# Global.left_brush_type_label.text = tr("Brush: Filled Circle")
|
||||
|
||||
Global.update_custom_brush(Global.brush_type_window_position)
|
||||
Global.brushes_popup.hide()
|
||||
|
||||
|
||||
func _on_DeleteButton_pressed() -> void:
|
||||
if brush_type == Global.Brush_Types.CUSTOM:
|
||||
if Global.custom_brush_indexes[0] == custom_brush_index:
|
||||
Global.custom_brush_indexes[0] = -3
|
||||
Global.current_brush_types[0] = Global.Brush_Types.PIXEL
|
||||
# Global.left_brush_type_label.text = "Brush: Pixel"
|
||||
Global.update_custom_brush(0)
|
||||
if Global.custom_brush_indexes[1] == custom_brush_index:
|
||||
Global.custom_brush_indexes[1] = -3
|
||||
Global.current_brush_types[1] = Global.Brush_Types.PIXEL
|
||||
# Global.right_brush_type_label.text = "Brush: Pixel"
|
||||
Global.update_custom_brush(1)
|
||||
if brush_type != Global.Brush_Types.CUSTOM:
|
||||
return
|
||||
|
||||
var project_brush_index = custom_brush_index - Global.brushes_from_files
|
||||
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:
|
||||
Global.custom_brush_indexes[0] -= 1
|
||||
if Global.custom_brush_indexes[1] == bb.custom_brush_index:
|
||||
Global.custom_brush_indexes[1] -= 1
|
||||
if Global.custom_brush_indexes[0] == custom_brush_index:
|
||||
Global.custom_brush_indexes[0] = -3
|
||||
Global.current_brush_types[0] = Global.Brush_Types.PIXEL
|
||||
Global.update_custom_brush(0)
|
||||
if Global.custom_brush_indexes[1] == custom_brush_index:
|
||||
Global.custom_brush_indexes[1] = -3
|
||||
Global.current_brush_types[1] = Global.Brush_Types.PIXEL
|
||||
Global.update_custom_brush(1)
|
||||
|
||||
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)
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Delete Custom Brush")
|
||||
for i in range(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:
|
||||
Global.custom_brush_indexes[0] -= 1
|
||||
if Global.custom_brush_indexes[1] == bb.custom_brush_index:
|
||||
Global.custom_brush_indexes[1] -= 1
|
||||
|
||||
var custom_brushes: Array = Global.current_project.brushes.duplicate()
|
||||
custom_brushes.remove(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)
|
||||
|
||||
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()
|
||||
var custom_brushes: Array = Global.current_project.brushes.duplicate()
|
||||
custom_brushes.remove(custom_brush_index)
|
||||
|
||||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue