mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-17 03:24:43 -05:00
Created ColorAndToolOptions script and scene
Removed the tool option signals from Main.gd and put them to ColorAndToolOptions.gd. Instead of having 2 methods for left and right, they are now in one method, using a boolean to differentiate between left and right.
This commit is contained in:
parent
c1db72865f
commit
1e114d6f4f
8 changed files with 1201 additions and 1277 deletions
207
src/Main.gd
207
src/Main.gd
|
|
@ -7,8 +7,6 @@ var tools := []
|
|||
var redone := false
|
||||
var unsaved_canvas_state := 0
|
||||
var is_quitting_on_save := false
|
||||
var previous_left_color := Color.black
|
||||
var previous_right_color := Color.white
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
|
@ -534,10 +532,6 @@ func _can_draw_true() -> void:
|
|||
Global.dialog_open(false)
|
||||
|
||||
|
||||
func _can_draw_false() -> void:
|
||||
Global.can_draw = false
|
||||
|
||||
|
||||
func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_left := true) -> void:
|
||||
var current_action := tool_pressed.name
|
||||
if (mouse_press and Input.is_action_just_released("left_mouse")) or (!mouse_press and key_for_left):
|
||||
|
|
@ -628,203 +622,10 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
|
|||
Global.right_cursor_tool_texture.create_from_image(load("res://assets/graphics/cursor_icons/%s_cursor.png" % Global.current_right_tool.to_lower()), 0)
|
||||
|
||||
|
||||
func _on_LeftBrushTypeButton_pressed() -> void:
|
||||
Global.brushes_popup.popup(Rect2(Global.left_brush_type_button.rect_global_position, Vector2(226, 72)))
|
||||
Global.brush_type_window_position = "left"
|
||||
|
||||
|
||||
func _on_RightBrushTypeButton_pressed() -> void:
|
||||
Global.brushes_popup.popup(Rect2(Global.right_brush_type_button.rect_global_position, Vector2(226, 72)))
|
||||
Global.brush_type_window_position = "right"
|
||||
|
||||
|
||||
func _on_LeftBrushSizeEdit_value_changed(value) -> void:
|
||||
Global.left_brush_size_edit.value = value
|
||||
Global.left_brush_size_slider.value = value
|
||||
var new_size = int(value)
|
||||
Global.left_brush_size = new_size
|
||||
update_left_custom_brush()
|
||||
|
||||
|
||||
func _on_RightBrushSizeEdit_value_changed(value) -> void:
|
||||
Global.right_brush_size_edit.value = value
|
||||
Global.right_brush_size_slider.value = value
|
||||
var new_size = int(value)
|
||||
Global.right_brush_size = new_size
|
||||
update_right_custom_brush()
|
||||
|
||||
|
||||
func _on_Brush_Selected() -> void:
|
||||
$BrushesPopup.hide()
|
||||
|
||||
|
||||
func _on_ColorSwitch_pressed() -> void:
|
||||
var temp: Color = Global.left_color_picker.color
|
||||
Global.left_color_picker.color = Global.right_color_picker.color
|
||||
Global.right_color_picker.color = temp
|
||||
update_left_custom_brush()
|
||||
update_right_custom_brush()
|
||||
|
||||
|
||||
func _on_ColorDefaults_pressed() -> void:
|
||||
Global.left_color_picker.color = Color.black
|
||||
Global.right_color_picker.color = Color.white
|
||||
update_left_custom_brush()
|
||||
update_right_custom_brush()
|
||||
|
||||
|
||||
func _on_LeftColorPickerButton_color_changed(color : Color) -> void:
|
||||
# If the color changed while it's on full transparency, make it opaque (GH issue #54)
|
||||
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.left_color_picker.color.a = 1
|
||||
update_left_custom_brush()
|
||||
previous_left_color = color
|
||||
|
||||
|
||||
func _on_RightColorPickerButton_color_changed(color : Color) -> void:
|
||||
# If the color changed while it's on full transparency, make it opaque (GH issue #54)
|
||||
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.right_color_picker.color.a = 1
|
||||
update_right_custom_brush()
|
||||
previous_right_color = color
|
||||
|
||||
|
||||
func _on_LeftInterpolateFactor_value_changed(value : float) -> void:
|
||||
Global.left_interpolate_spinbox.value = value
|
||||
Global.left_interpolate_slider.value = value
|
||||
update_left_custom_brush()
|
||||
|
||||
|
||||
func _on_RightInterpolateFactor_value_changed(value : float) -> void:
|
||||
Global.right_interpolate_spinbox.value = value
|
||||
Global.right_interpolate_slider.value = value
|
||||
update_right_custom_brush()
|
||||
|
||||
|
||||
func update_left_custom_brush() -> void:
|
||||
Global.update_left_custom_brush()
|
||||
|
||||
|
||||
func update_right_custom_brush() -> void:
|
||||
Global.update_right_custom_brush()
|
||||
|
||||
|
||||
func _on_LeftFillAreaOptions_item_selected(ID : int) -> void:
|
||||
Global.left_fill_area = ID
|
||||
|
||||
|
||||
func _on_LeftFillWithOptions_item_selected(ID : int) -> void:
|
||||
Global.left_fill_with = ID
|
||||
if ID == 1:
|
||||
Global.left_fill_pattern_container.visible = true
|
||||
else:
|
||||
Global.left_fill_pattern_container.visible = false
|
||||
|
||||
|
||||
func _on_LeftPatternTypeButton_pressed() -> void:
|
||||
Global.pattern_window_position = "left"
|
||||
Global.patterns_popup.popup(Rect2(Global.left_brush_type_button.rect_global_position, Vector2(226, 72)))
|
||||
|
||||
|
||||
func _on_LeftPatternOffsetX_value_changed(value : float) -> void:
|
||||
Global.left_fill_pattern_offset.x = value
|
||||
|
||||
|
||||
func _on_LeftPatternOffsetY_value_changed(value : float) -> void:
|
||||
Global.left_fill_pattern_offset.y = value
|
||||
|
||||
|
||||
func _on_RightPatternOffsetX_value_changed(value : float) -> void:
|
||||
Global.right_fill_pattern_offset.x = value
|
||||
|
||||
|
||||
func _on_RightPatternOffsetY_value_changed(value : float) -> void:
|
||||
Global.right_fill_pattern_offset.y = value
|
||||
|
||||
|
||||
func _on_RightFillAreaOptions_item_selected(ID : int) -> void:
|
||||
Global.right_fill_area = ID
|
||||
|
||||
|
||||
func _on_RightFillWithOptions_item_selected(ID : int) -> void:
|
||||
Global.right_fill_with = ID
|
||||
if ID == 1:
|
||||
Global.right_fill_pattern_container.visible = true
|
||||
else:
|
||||
Global.right_fill_pattern_container.visible = false
|
||||
|
||||
|
||||
func _on_RightPatternTypeButton_pressed() -> void:
|
||||
Global.pattern_window_position = "right"
|
||||
Global.patterns_popup.popup(Rect2(Global.right_brush_type_button.rect_global_position, Vector2(226, 72)))
|
||||
|
||||
|
||||
func _on_LeftLightenDarken_item_selected(ID : int) -> void:
|
||||
Global.left_ld = ID
|
||||
|
||||
|
||||
func _on_LeftLDAmountSpinbox_value_changed(value : float) -> void:
|
||||
Global.left_ld_amount = value / 100
|
||||
Global.left_ld_amount_slider.value = value
|
||||
Global.left_ld_amount_spinbox.value = value
|
||||
|
||||
|
||||
func _on_RightLightenDarken_item_selected(ID : int) -> void:
|
||||
Global.right_ld = ID
|
||||
|
||||
|
||||
func _on_RightLDAmountSpinbox_value_changed(value : float) -> void:
|
||||
Global.right_ld_amount = value / 100
|
||||
Global.right_ld_amount_slider.value = value
|
||||
Global.right_ld_amount_spinbox.value = value
|
||||
|
||||
|
||||
func _on_LeftForColorOptions_item_selected(ID : int) -> void:
|
||||
Global.left_color_picker_for = ID
|
||||
|
||||
|
||||
func _on_RightForColorOptions_item_selected(ID : int) -> void:
|
||||
Global.right_color_picker_for = ID
|
||||
|
||||
|
||||
func _on_LeftZoomModeOptions_item_selected(ID : int) -> void:
|
||||
Global.left_zoom_mode = ID
|
||||
|
||||
|
||||
func _on_RightZoomModeOptions_item_selected(ID : int) -> void:
|
||||
Global.right_zoom_mode = ID
|
||||
|
||||
|
||||
func _on_FitToFrameButton_pressed() -> void:
|
||||
Global.camera.fit_to_frame(Global.canvas.size)
|
||||
|
||||
|
||||
func _on_100ZoomButton_pressed() -> void:
|
||||
Global.camera.zoom = Vector2.ONE
|
||||
Global.camera.offset = Global.canvas.size / 2
|
||||
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
||||
Global.horizontal_ruler.update()
|
||||
Global.vertical_ruler.update()
|
||||
|
||||
|
||||
func _on_LeftHorizontalMirroring_toggled(button_pressed) -> void:
|
||||
Global.left_horizontal_mirror = button_pressed
|
||||
|
||||
|
||||
func _on_LeftVerticalMirroring_toggled(button_pressed) -> void:
|
||||
Global.left_vertical_mirror = button_pressed
|
||||
|
||||
|
||||
func _on_RightHorizontalMirroring_toggled(button_pressed) -> void:
|
||||
Global.right_horizontal_mirror = button_pressed
|
||||
|
||||
|
||||
func _on_RightVerticalMirroring_toggled(button_pressed) -> void:
|
||||
Global.right_vertical_mirror = button_pressed
|
||||
|
||||
|
||||
func show_quit_dialog() -> void:
|
||||
if !$QuitDialog.visible:
|
||||
if !Global.project_has_changed:
|
||||
|
|
@ -868,11 +669,3 @@ func _on_BackupConfirmation_delete(project_path : String, backup_path : String)
|
|||
# Reopen last project
|
||||
if Global.open_last_project:
|
||||
load_last_project()
|
||||
|
||||
|
||||
func _on_LeftPixelPerfectMode_toggled(button_pressed : bool) -> void:
|
||||
Global.left_pixel_perfect = button_pressed
|
||||
|
||||
|
||||
func _on_RightPixelPerfectMode_toggled(button_pressed : bool) -> void:
|
||||
Global.right_pixel_perfect = button_pressed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue