mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 22:54:44 -04:00
Even more Global left/right variables became arrays
ColorAndToolOptions has now the same code for left and right tool options, with more similar refactoring coming soon to places like Canvas and DrawingAlgos
This commit is contained in:
parent
15ef00bf46
commit
9b4956b4f1
9 changed files with 141 additions and 213 deletions
|
@ -16,7 +16,7 @@ func _on_BrushButton_pressed() -> void:
|
|||
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:
|
||||
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")
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
extends VBoxContainer
|
||||
|
||||
|
||||
var previous_left_color := Color.black
|
||||
var previous_right_color := Color.white
|
||||
var previous_colors := [Color.black, Color.white]
|
||||
|
||||
|
||||
func _on_ColorSwitch_pressed() -> void:
|
||||
|
@ -14,19 +13,13 @@ func _on_ColorSwitch_pressed() -> void:
|
|||
|
||||
|
||||
func _on_ColorPickerButton_color_changed(color : Color, right : bool):
|
||||
var mouse_button := int(right)
|
||||
# If the color changed while it's on full transparency, make it opaque (GH issue #54)
|
||||
if right:
|
||||
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_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_custom_brush(0)
|
||||
previous_left_color = color
|
||||
if color.a == 0:
|
||||
if previous_colors[mouse_button].r != color.r or previous_colors[mouse_button].g != color.g or previous_colors[mouse_button].b != color.b:
|
||||
Global.color_pickers[mouse_button].color.a = 1
|
||||
Global.update_custom_brush(mouse_button)
|
||||
previous_colors[mouse_button] = color
|
||||
|
||||
|
||||
func _on_ColorPickerButton_pressed() -> void:
|
||||
|
@ -57,132 +50,89 @@ 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 = 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 = Global.Mouse_Button.LEFT
|
||||
var mouse_button := int(right)
|
||||
Global.brushes_popup.popup(Rect2(Global.brush_type_buttons[mouse_button].rect_global_position, Vector2(226, 72)))
|
||||
Global.brush_type_window_position = mouse_button
|
||||
|
||||
|
||||
func _on_BrushSizeEdit_value_changed(value : float, right : bool) -> void:
|
||||
var mouse_button := int(right)
|
||||
var new_size = int(value)
|
||||
if right:
|
||||
Global.brush_size_edits[1].value = value
|
||||
Global.brush_size_sliders[1].value = value
|
||||
Global.right_brush_size = new_size
|
||||
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_custom_brush(0)
|
||||
Global.brush_size_edits[mouse_button].value = value
|
||||
Global.brush_size_sliders[mouse_button].value = value
|
||||
Global.brush_sizes[mouse_button] = new_size
|
||||
Global.update_custom_brush(mouse_button)
|
||||
|
||||
|
||||
func _on_PixelPerfectMode_toggled(button_pressed : bool, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_pixel_perfect = button_pressed
|
||||
else:
|
||||
Global.left_pixel_perfect = button_pressed
|
||||
var mouse_button := int(right)
|
||||
Global.pixel_perfect[mouse_button] = button_pressed
|
||||
|
||||
|
||||
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_custom_brush(1)
|
||||
else:
|
||||
Global.interpolate_spinboxes[0].value = value
|
||||
Global.interpolate_sliders[0].value = value
|
||||
Global.update_custom_brush(0)
|
||||
var mouse_button := int(right)
|
||||
Global.interpolate_spinboxes[mouse_button].value = value
|
||||
Global.interpolate_sliders[mouse_button].value = value
|
||||
Global.update_custom_brush(mouse_button)
|
||||
|
||||
|
||||
func _on_FillAreaOptions_item_selected(ID : int, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_fill_area = ID
|
||||
else:
|
||||
Global.left_fill_area = ID
|
||||
var mouse_button := int(right)
|
||||
Global.fill_areas[mouse_button] = ID
|
||||
|
||||
|
||||
func _on_FillWithOptions_item_selected(ID : int, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_fill_with = ID
|
||||
if ID == 1:
|
||||
Global.fill_pattern_containers[1].visible = true
|
||||
else:
|
||||
Global.fill_pattern_containers[1].visible = false
|
||||
var mouse_button := int(right)
|
||||
Global.fill_with[mouse_button] = ID
|
||||
if ID == 1:
|
||||
Global.fill_pattern_containers[mouse_button].visible = true
|
||||
else:
|
||||
Global.left_fill_with = ID
|
||||
if ID == 1:
|
||||
Global.fill_pattern_containers[0].visible = true
|
||||
else:
|
||||
Global.fill_pattern_containers[0].visible = false
|
||||
Global.fill_pattern_containers[mouse_button].visible = false
|
||||
|
||||
|
||||
func _on_PatternTypeButton_pressed(right : bool) -> void:
|
||||
if right:
|
||||
Global.pattern_window_position = Global.Mouse_Button.RIGHT
|
||||
else:
|
||||
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)))
|
||||
var mouse_button := int(right)
|
||||
Global.pattern_window_position = mouse_button
|
||||
Global.patterns_popup.popup(Rect2(Global.brush_type_buttons[mouse_button].rect_global_position, Vector2(226, 72)))
|
||||
|
||||
|
||||
func _on_PatternOffsetX_value_changed(value : float, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_fill_pattern_offset.x = value
|
||||
else:
|
||||
Global.left_fill_pattern_offset.x = value
|
||||
var mouse_button := int(right)
|
||||
Global.fill_pattern_offsets[mouse_button].x = value
|
||||
|
||||
|
||||
func _on_PatternOffsetY_value_changed(value : float, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_fill_pattern_offset.y = value
|
||||
else:
|
||||
Global.left_fill_pattern_offset.y = value
|
||||
var mouse_button := int(right)
|
||||
Global.fill_pattern_offsets[mouse_button].y = value
|
||||
|
||||
|
||||
func _on_LightenDarken_item_selected(ID : int, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_ld = ID
|
||||
else:
|
||||
Global.left_ld = ID
|
||||
var mouse_button := int(right)
|
||||
Global.ld_modes[mouse_button] = ID
|
||||
|
||||
|
||||
func _on_LDAmount_value_changed(value : float, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_ld_amount = value / 100
|
||||
Global.ld_amount_sliders[1].value = value
|
||||
Global.ld_amount_spinboxes[1].value = value
|
||||
else:
|
||||
Global.left_ld_amount = value / 100
|
||||
Global.ld_amount_sliders[0].value = value
|
||||
Global.ld_amount_spinboxes[0].value = value
|
||||
var mouse_button := int(right)
|
||||
Global.ld_amounts[mouse_button] = value / 100
|
||||
Global.ld_amount_sliders[mouse_button].value = value
|
||||
Global.ld_amount_spinboxes[mouse_button].value = value
|
||||
|
||||
|
||||
func _on_ForColorOptions_item_selected(ID : int, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_color_picker_for = ID
|
||||
else:
|
||||
Global.left_color_picker_for = ID
|
||||
var mouse_button := int(right)
|
||||
Global.color_picker_for[mouse_button] = ID
|
||||
|
||||
|
||||
func _on_ZoomModeOptions_item_selected(ID : int, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_zoom_mode = ID
|
||||
else:
|
||||
Global.left_zoom_mode = ID
|
||||
var mouse_button := int(right)
|
||||
Global.zoom_modes[mouse_button] = ID
|
||||
|
||||
|
||||
func _on_HorizontalMirroring_toggled(button_pressed : bool, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_horizontal_mirror = button_pressed
|
||||
else:
|
||||
Global.left_horizontal_mirror = button_pressed
|
||||
var mouse_button := int(right)
|
||||
Global.horizontal_mirror[mouse_button] = button_pressed
|
||||
|
||||
|
||||
func _on_VerticalMirroring_toggled(button_pressed : bool, right : bool) -> void:
|
||||
if right:
|
||||
Global.right_vertical_mirror = button_pressed
|
||||
else:
|
||||
Global.left_vertical_mirror = button_pressed
|
||||
var mouse_button := int(right)
|
||||
Global.vertical_mirror[mouse_button] = button_pressed
|
||||
|
|
|
@ -34,21 +34,20 @@ func _input(event : InputEvent) -> void:
|
|||
func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_left := true) -> void:
|
||||
var current_action := tool_pressed.name
|
||||
var current_tool : int = Global.Tools.keys().find(current_action.to_upper())
|
||||
var left_tool_name := str(Global.Tools.keys()[Global.current_left_tool]).to_lower()
|
||||
var right_tool_name := str(Global.Tools.keys()[Global.current_right_tool]).to_lower()
|
||||
var left_tool_name := str(Global.Tools.keys()[Global.current_tools[0]]).to_lower()
|
||||
var right_tool_name := str(Global.Tools.keys()[Global.current_tools[1]]).to_lower()
|
||||
var current_mouse_button := -1
|
||||
|
||||
if (mouse_press and Input.is_action_just_released("left_mouse")) or (!mouse_press and key_for_left):
|
||||
Global.current_left_tool = current_tool
|
||||
left_tool_name = current_action.to_lower()
|
||||
current_mouse_button = Global.Mouse_Button.LEFT
|
||||
|
||||
elif (mouse_press and Input.is_action_just_released("right_mouse")) or (!mouse_press and !key_for_left):
|
||||
Global.current_right_tool = current_tool
|
||||
right_tool_name = current_action.to_lower()
|
||||
current_mouse_button = Global.Mouse_Button.RIGHT
|
||||
|
||||
if current_mouse_button != -1:
|
||||
Global.current_tools[current_mouse_button] = current_tool
|
||||
# Start from 1, so the label won't get invisible
|
||||
for i in range(1, Global.tool_options_containers[current_mouse_button].get_child_count()):
|
||||
Global.tool_options_containers[current_mouse_button].get_child(i).visible = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue