mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 22:54:44 -04:00
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:
parent
c538140de2
commit
4cc0ccb97b
9 changed files with 102 additions and 159 deletions
|
@ -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)
|
||||
|
|
|
@ -6,11 +6,11 @@ var previous_right_color := Color.white
|
|||
|
||||
|
||||
func _on_ColorSwitch_pressed() -> void:
|
||||
var temp: Color = Global.color_pickers[0].color
|
||||
var temp : Color = Global.color_pickers[0].color
|
||||
Global.color_pickers[0].color = Global.color_pickers[1].color
|
||||
Global.color_pickers[1].color = temp
|
||||
Global.update_left_custom_brush()
|
||||
Global.update_right_custom_brush()
|
||||
Global.update_custom_brush(0)
|
||||
Global.update_custom_brush(1)
|
||||
|
||||
|
||||
func _on_ColorPickerButton_color_changed(color : Color, right : bool):
|
||||
|
@ -19,13 +19,13 @@ func _on_ColorPickerButton_color_changed(color : Color, right : bool):
|
|||
if color.a == 0:
|
||||
if previous_right_color.r != color.r or previous_right_color.g != color.g or previous_right_color.b != color.b:
|
||||
Global.color_pickers[1].color.a = 1
|
||||
Global.update_right_custom_brush()
|
||||
Global.update_custom_brush(1)
|
||||
previous_right_color = color
|
||||
else:
|
||||
if color.a == 0:
|
||||
if previous_left_color.r != color.r or previous_left_color.g != color.g or previous_left_color.b != color.b:
|
||||
Global.color_pickers[0].color.a = 1
|
||||
Global.update_left_custom_brush()
|
||||
Global.update_custom_brush(0)
|
||||
previous_left_color = color
|
||||
|
||||
|
||||
|
@ -40,8 +40,8 @@ func _on_ColorPickerButton_popup_closed() -> void:
|
|||
func _on_ColorDefaults_pressed() -> void:
|
||||
Global.color_pickers[0].color = Color.black
|
||||
Global.color_pickers[1].color = Color.white
|
||||
Global.update_left_custom_brush()
|
||||
Global.update_right_custom_brush()
|
||||
Global.update_custom_brush(0)
|
||||
Global.update_custom_brush(1)
|
||||
|
||||
|
||||
func _on_FitToFrameButton_pressed() -> void:
|
||||
|
@ -59,10 +59,10 @@ func _on_100ZoomButton_pressed() -> void:
|
|||
func _on_BrushTypeButton_pressed(right : bool) -> void:
|
||||
if right:
|
||||
Global.brushes_popup.popup(Rect2(Global.brush_type_buttons[1].rect_global_position, Vector2(226, 72)))
|
||||
Global.brush_type_window_position = "right"
|
||||
Global.brush_type_window_position = Global.Mouse_Button.RIGHT
|
||||
else:
|
||||
Global.brushes_popup.popup(Rect2(Global.brush_type_buttons[0].rect_global_position, Vector2(226, 72)))
|
||||
Global.brush_type_window_position = "left"
|
||||
Global.brush_type_window_position = Global.Mouse_Button.LEFT
|
||||
|
||||
|
||||
func _on_BrushSizeEdit_value_changed(value : float, right : bool) -> void:
|
||||
|
@ -71,12 +71,12 @@ func _on_BrushSizeEdit_value_changed(value : float, right : bool) -> void:
|
|||
Global.brush_size_edits[1].value = value
|
||||
Global.brush_size_sliders[1].value = value
|
||||
Global.right_brush_size = new_size
|
||||
Global.update_right_custom_brush()
|
||||
Global.update_custom_brush(1)
|
||||
else:
|
||||
Global.brush_size_edits[0].value = value
|
||||
Global.brush_size_sliders[0].value = value
|
||||
Global.left_brush_size = new_size
|
||||
Global.update_left_custom_brush()
|
||||
Global.update_custom_brush(0)
|
||||
|
||||
|
||||
func _on_PixelPerfectMode_toggled(button_pressed : bool, right : bool) -> void:
|
||||
|
@ -90,11 +90,11 @@ func _on_InterpolateFactor_value_changed(value : float, right : bool) -> void:
|
|||
if right:
|
||||
Global.interpolate_spinboxes[1].value = value
|
||||
Global.interpolate_sliders[1].value = value
|
||||
Global.update_right_custom_brush()
|
||||
Global.update_custom_brush(1)
|
||||
else:
|
||||
Global.interpolate_spinboxes[0].value = value
|
||||
Global.interpolate_sliders[0].value = value
|
||||
Global.update_left_custom_brush()
|
||||
Global.update_custom_brush(0)
|
||||
|
||||
|
||||
func _on_FillAreaOptions_item_selected(ID : int, right : bool) -> void:
|
||||
|
@ -121,11 +121,11 @@ func _on_FillWithOptions_item_selected(ID : int, right : bool) -> void:
|
|||
|
||||
func _on_PatternTypeButton_pressed(right : bool) -> void:
|
||||
if right:
|
||||
Global.pattern_window_position = "right"
|
||||
Global.patterns_popup.popup(Rect2(Global.brush_type_buttons[1].rect_global_position, Vector2(226, 72)))
|
||||
Global.pattern_window_position = Global.Mouse_Button.RIGHT
|
||||
else:
|
||||
Global.pattern_window_position = "left"
|
||||
Global.patterns_popup.popup(Rect2(Global.brush_type_buttons[0].rect_global_position, Vector2(226, 72)))
|
||||
Global.pattern_window_position = Global.Mouse_Button.LEFT
|
||||
|
||||
Global.patterns_popup.popup(Rect2(Global.brush_type_buttons[Global.pattern_window_position].rect_global_position, Vector2(226, 72)))
|
||||
|
||||
|
||||
func _on_PatternOffsetX_value_changed(value : float, right : bool) -> void:
|
||||
|
|
|
@ -14,16 +14,9 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func _on_PatternButton_pressed() -> void:
|
||||
if Global.pattern_window_position == "left":
|
||||
Global.pattern_left_image = image
|
||||
Global.fill_pattern_containers[0].get_child(0).get_child(0).texture = texture
|
||||
Global.fill_pattern_containers[0].get_child(2).get_child(1).max_value = image_size.x - 1
|
||||
Global.fill_pattern_containers[0].get_child(3).get_child(1).max_value = image_size.y - 1
|
||||
|
||||
elif Global.pattern_window_position == "right":
|
||||
Global.pattern_right_image = image
|
||||
Global.fill_pattern_containers[1].get_child(0).get_child(0).texture = texture
|
||||
Global.fill_pattern_containers[1].get_child(2).get_child(1).max_value = image_size.x - 1
|
||||
Global.fill_pattern_containers[1].get_child(3).get_child(1).max_value = image_size.y - 1
|
||||
Global.pattern_images[Global.pattern_window_position] = image
|
||||
Global.fill_pattern_containers[Global.pattern_window_position].get_child(0).get_child(0).texture = texture
|
||||
Global.fill_pattern_containers[Global.pattern_window_position].get_child(2).get_child(1).max_value = image_size.x - 1
|
||||
Global.fill_pattern_containers[Global.pattern_window_position].get_child(3).get_child(1).max_value = image_size.y - 1
|
||||
|
||||
Global.patterns_popup.hide()
|
||||
|
|
|
@ -61,7 +61,7 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
|
|||
Global.brush_size_sliders[current_mouse_button].visible = true
|
||||
Global.pixel_perfect_containers[current_mouse_button].visible = true
|
||||
Global.mirror_containers[current_mouse_button].visible = true
|
||||
if Global.current_brush_type[current_mouse_button] == Global.Brush_Types.FILE or Global.current_brush_type[current_mouse_button] == Global.Brush_Types.CUSTOM or Global.current_brush_type[current_mouse_button] == Global.Brush_Types.RANDOM_FILE:
|
||||
if Global.current_brush_types[current_mouse_button] == Global.Brush_Types.FILE or Global.current_brush_types[current_mouse_button] == Global.Brush_Types.CUSTOM or Global.current_brush_types[current_mouse_button] == Global.Brush_Types.RANDOM_FILE:
|
||||
Global.color_interpolation_containers[current_mouse_button].visible = true
|
||||
elif current_tool == Global.Tools.ERASER:
|
||||
Global.brush_type_containers[current_mouse_button].visible = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue