1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00: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:
OverloadedOrama 2020-05-19 03:51:16 +03:00
parent c879633f4b
commit caa797e26e
7 changed files with 1197 additions and 1228 deletions

View file

@ -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

File diff suppressed because one or more lines are too long

View file

@ -11,5 +11,5 @@ resizable = true
mode = 0
access = 2
filters = PoolStringArray( "*.json ; JavaScript Object Notation" )
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
current_dir = "C:/Users"
current_path = "C:/Users/"

View file

@ -0,0 +1,188 @@
extends VBoxContainer
var previous_left_color := Color.black
var previous_right_color := Color.white
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
Global.update_left_custom_brush()
Global.update_right_custom_brush()
func _on_ColorPickerButton_color_changed(color : Color, right : bool):
# 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.right_color_picker.color.a = 1
Global.update_right_custom_brush()
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.left_color_picker.color.a = 1
Global.update_left_custom_brush()
previous_left_color = color
func _on_ColorPickerButton_pressed() -> void:
Global.can_draw = false
func _on_ColorPickerButton_popup_closed() -> void:
Global.can_draw = true
func _on_ColorDefaults_pressed() -> void:
Global.left_color_picker.color = Color.black
Global.right_color_picker.color = Color.white
Global.update_left_custom_brush()
Global.update_right_custom_brush()
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_BrushTypeButton_pressed(right : bool) -> void:
if right:
Global.brushes_popup.popup(Rect2(Global.right_brush_type_button.rect_global_position, Vector2(226, 72)))
Global.brush_type_window_position = "right"
else:
Global.brushes_popup.popup(Rect2(Global.left_brush_type_button.rect_global_position, Vector2(226, 72)))
Global.brush_type_window_position = "left"
func _on_BrushSizeEdit_value_changed(value : float, right : bool) -> void:
var new_size = int(value)
if right:
Global.right_brush_size_edit.value = value
Global.right_brush_size_slider.value = value
Global.right_brush_size = new_size
Global.update_right_custom_brush()
else:
Global.left_brush_size_edit.value = value
Global.left_brush_size_slider.value = value
Global.left_brush_size = new_size
Global.update_left_custom_brush()
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
func _on_InterpolateFactor_value_changed(value : float, right : bool) -> void:
if right:
Global.right_interpolate_spinbox.value = value
Global.right_interpolate_slider.value = value
Global.update_right_custom_brush()
else:
Global.left_interpolate_spinbox.value = value
Global.left_interpolate_slider.value = value
Global.update_left_custom_brush()
func _on_FillAreaOptions_item_selected(ID : int, right : bool) -> void:
if right:
Global.right_fill_area = ID
else:
Global.left_fill_area = ID
func _on_FillWithOptions_item_selected(ID : int, right : bool) -> void:
if right:
Global.right_fill_with = ID
if ID == 1:
Global.right_fill_pattern_container.visible = true
else:
Global.right_fill_pattern_container.visible = false
else:
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_PatternTypeButton_pressed(right : bool) -> void:
if right:
Global.pattern_window_position = "right"
Global.patterns_popup.popup(Rect2(Global.right_brush_type_button.rect_global_position, Vector2(226, 72)))
else:
Global.pattern_window_position = "left"
Global.patterns_popup.popup(Rect2(Global.left_brush_type_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
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
func _on_LightenDarken_item_selected(ID : int, right : bool) -> void:
if right:
Global.right_ld = ID
else:
Global.left_ld = ID
func _on_LDAmount_value_changed(value : float, right : bool) -> void:
if right:
Global.right_ld_amount = value / 100
Global.right_ld_amount_slider.value = value
Global.right_ld_amount_spinbox.value = value
else:
Global.left_ld_amount = value / 100
Global.left_ld_amount_slider.value = value
Global.left_ld_amount_spinbox.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
func _on_ZoomModeOptions_item_selected(ID : int, right : bool) -> void:
if right:
Global.right_zoom_mode = ID
else:
Global.left_zoom_mode = 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
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

File diff suppressed because one or more lines are too long

View file

@ -346,8 +346,8 @@ window_title = "Open a Directory"
resizable = true
mode = 2
access = 2
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
current_dir = "C:/Users"
current_path = "C:/Users/"
[node name="PathValidationAlert" type="AcceptDialog" parent="Popups"]
margin_left = 8.0

View file

@ -2,8 +2,6 @@
[ext_resource path="res://src/UI/Dialogs/ImportSprites.gd" type="Script" id=1]
[node name="ImportSprites" type="FileDialog"]
margin_right = 515.0
margin_bottom = 348.0
@ -12,8 +10,8 @@ resizable = true
mode = 1
access = 2
filters = PoolStringArray( "*.bmp ; BMP Image", "*.hdr ; Radiance HDR Image", "*.jpg,*.jpeg ; JPEG Image", "*.png ; PNG Image", "*.svg ; SVG Image", "*.tga ; TGA Image", "*.webp ; WebP Image" )
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
current_dir = "C:/Users"
current_path = "C:/Users/"
script = ExtResource( 1 )
[node name="HBoxContainer2" type="HBoxContainer" parent="."]