More Global left/right variables became Arrays

Global.update_left_custom_brush() and its right counterpart have also now become Global.update_custom_brush(mouse_button : int)
This commit is contained in:
OverloadedOrama 2020-05-31 18:40:47 +03:00
parent c538140de2
commit 4cc0ccb97b
9 changed files with 102 additions and 159 deletions

View file

@ -12,76 +12,52 @@ func _on_BrushButton_pressed() -> void:
_on_DeleteButton_pressed()
return
# Change left brush
if Global.brush_type_window_position == "left":
Global.current_brush_type[0] = brush_type
Global.custom_left_brush_index = custom_brush_index
if custom_brush_index > -1: # Custom brush
if Global.current_left_tool == Global.Tools.PENCIL:
Global.color_interpolation_containers[0].visible = true
# 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 Global.current_left_tool == 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
Global.color_interpolation_containers[0].visible = false
elif custom_brush_index == -3: # Pixel brush
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[0].visible = false
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[0].visible = false
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_left_custom_brush()
Global.brushes_popup.hide()
else: # Change right brush
Global.current_brush_type[1] = brush_type
Global.custom_right_brush_index = custom_brush_index
if custom_brush_index > -1:
if Global.current_right_tool == Global.Tools.PENCIL:
Global.color_interpolation_containers[1].visible = true
# if hint_tooltip == "":
# Global.right_brush_type_label.text = tr("Custom brush")
# else:
# Global.right_brush_type_label.text = tr("Brush:") + " %s" % hint_tooltip
elif custom_brush_index == -3: # Pixel brush
Global.color_interpolation_containers[1].visible = false
# Global.right_brush_type_label.text = tr("Brush: Pixel")
elif custom_brush_index == -2: # Circle brush
Global.color_interpolation_containers[1].visible = false
# Global.right_brush_type_label.text = tr("Brush: Circle")
elif custom_brush_index == -1: # Filled Circle brush
Global.color_interpolation_containers[1].visible = false
# Global.right_brush_type_label.text = tr("Brush: Filled Circle")
Global.update_right_custom_brush()
Global.brushes_popup.hide()
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_left_brush_index == custom_brush_index:
Global.custom_left_brush_index = -3
Global.current_brush_type[0] = Global.Brush_Types.PIXEL
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_left_custom_brush()
if Global.custom_right_brush_index == custom_brush_index:
Global.custom_right_brush_index = -3
Global.current_brush_type[1] = 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.right_brush_type_label.text = "Brush: Pixel"
Global.update_right_custom_brush()
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")
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_left_brush_index == bb.custom_brush_index:
Global.custom_left_brush_index -= 1
if Global.custom_right_brush_index == bb.custom_brush_index:
Global.custom_right_brush_index -= 1
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
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)