mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00: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
|
@ -38,7 +38,7 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
|
|||
elif current_action == Global.Tools.ERASER: # This is not working
|
||||
color.a *= (1.0 - pen_pressure)
|
||||
if current_mouse_button == Global.Mouse_Button.LEFT:
|
||||
brush_size = Global.left_brush_size
|
||||
brush_size = Global.brush_sizes[0]
|
||||
brush_type = Global.current_brush_types[0]
|
||||
brush_index = Global.custom_brush_indexes[0]
|
||||
if brush_type != Global.Brush_Types.RANDOM_FILE:
|
||||
|
@ -53,14 +53,14 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
|
|||
custom_brush_image = Global.blend_image_with_color(custom_brush_image, color, Global.interpolate_spinboxes[0].value / 100)
|
||||
custom_brush_image.lock()
|
||||
|
||||
horizontal_mirror = Global.left_horizontal_mirror
|
||||
vertical_mirror = Global.left_vertical_mirror
|
||||
pixel_perfect = Global.left_pixel_perfect
|
||||
ld = Global.left_ld
|
||||
ld_amount = Global.left_ld_amount
|
||||
horizontal_mirror = Global.horizontal_mirror[0]
|
||||
vertical_mirror = Global.vertical_mirror[0]
|
||||
pixel_perfect = Global.pixel_perfect[0]
|
||||
ld = Global.ld_modes[0]
|
||||
ld_amount = Global.ld_amounts[0]
|
||||
|
||||
elif current_mouse_button == Global.Mouse_Button.RIGHT:
|
||||
brush_size = Global.right_brush_size
|
||||
brush_size = Global.brush_sizes[1]
|
||||
brush_type = Global.current_brush_types[1]
|
||||
brush_index = Global.custom_brush_indexes[1]
|
||||
if brush_type != Global.Brush_Types.RANDOM_FILE:
|
||||
|
@ -75,11 +75,11 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
|
|||
custom_brush_image = Global.blend_image_with_color(custom_brush_image, color, Global.interpolate_spinboxes[1].value / 100)
|
||||
custom_brush_image.lock()
|
||||
|
||||
horizontal_mirror = Global.right_horizontal_mirror
|
||||
vertical_mirror = Global.right_vertical_mirror
|
||||
pixel_perfect = Global.right_pixel_perfect
|
||||
ld = Global.right_ld
|
||||
ld_amount = Global.right_ld_amount
|
||||
horizontal_mirror = Global.horizontal_mirror[1]
|
||||
vertical_mirror = Global.vertical_mirror[1]
|
||||
pixel_perfect = Global.pixel_perfect[1]
|
||||
ld = Global.ld_modes[1]
|
||||
ld_amount = Global.ld_amounts[1]
|
||||
|
||||
var start_pos_x
|
||||
var start_pos_y
|
||||
|
|
|
@ -7,6 +7,10 @@ enum Brush_Types {PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM}
|
|||
enum Direction {UP, DOWN, LEFT, RIGHT}
|
||||
enum Mouse_Button {LEFT, RIGHT}
|
||||
enum Tools {PENCIL, ERASER, BUCKET, LIGHTENDARKEN, RECTSELECT, COLORPICKER, ZOOM}
|
||||
enum Fill_Area {SAME_COLOR_AREA, SAME_COLOR_PIXELS}
|
||||
enum Fill_With {COLOR, PATTERN}
|
||||
enum Lighten_Darken_Mode {LIGHTEN, DARKEN}
|
||||
enum Zoom_Mode {ZOOM_IN, ZOOM_OUT}
|
||||
|
||||
# Stuff for arrowkey-based canvas movements nyaa ^.^
|
||||
const low_speed_move_rate := 150.0
|
||||
|
@ -69,43 +73,26 @@ var autosave_interval := 5.0
|
|||
var enable_autosave := true
|
||||
|
||||
# Tools & options
|
||||
var current_left_tool : int = Tools.PENCIL
|
||||
var current_right_tool :int = Tools.ERASER
|
||||
var current_tools := [Tools.PENCIL, Tools.ERASER]
|
||||
var show_left_tool_icon := true
|
||||
var show_right_tool_icon := true
|
||||
var left_square_indicator_visible := true
|
||||
var right_square_indicator_visible := false
|
||||
|
||||
# 0 for area of same color, 1 for all pixels of the same color
|
||||
var left_fill_area := 0
|
||||
var right_fill_area := 0
|
||||
var fill_areas := [Fill_Area.SAME_COLOR_AREA, Fill_Area.SAME_COLOR_AREA]
|
||||
var fill_with := [Fill_With.COLOR, Fill_With.COLOR]
|
||||
var fill_pattern_offsets := [Vector2.ZERO, Vector2.ZERO]
|
||||
|
||||
var left_fill_with := 0
|
||||
var right_fill_with := 0
|
||||
var ld_modes := [Lighten_Darken_Mode.LIGHTEN, Lighten_Darken_Mode.LIGHTEN]
|
||||
var ld_amounts := [0.1, 0.1]
|
||||
|
||||
var left_fill_pattern_offset := Vector2.ZERO
|
||||
var right_fill_pattern_offset := Vector2.ZERO
|
||||
var color_picker_for := [Mouse_Button.LEFT, Mouse_Button.RIGHT]
|
||||
|
||||
# 0 for lighten, 1 for darken
|
||||
var left_ld := 0
|
||||
var right_ld := 0
|
||||
var left_ld_amount := 0.1
|
||||
var right_ld_amount := 0.1
|
||||
var zoom_modes := [Zoom_Mode.ZOOM_IN, Zoom_Mode.ZOOM_OUT]
|
||||
|
||||
var left_color_picker_for : int = Mouse_Button.LEFT
|
||||
var right_color_picker_for : int = Mouse_Button.RIGHT
|
||||
|
||||
# 0 for zoom in, 1 for zoom out
|
||||
var left_zoom_mode := 0
|
||||
var right_zoom_mode := 1
|
||||
|
||||
var left_horizontal_mirror := false
|
||||
var left_vertical_mirror := false
|
||||
var right_horizontal_mirror := false
|
||||
var right_vertical_mirror := false
|
||||
|
||||
var left_pixel_perfect := false
|
||||
var right_pixel_perfect := false
|
||||
var horizontal_mirror := [false, false]
|
||||
var vertical_mirror := [false, false]
|
||||
var pixel_perfect := [false, false]
|
||||
|
||||
# View menu options
|
||||
var tile_mode := false
|
||||
|
@ -121,9 +108,8 @@ var onion_skinning_future_rate := 1.0
|
|||
var onion_skinning_blue_red := false
|
||||
|
||||
# Brushes
|
||||
var left_brush_size := 1
|
||||
var right_brush_size := 1
|
||||
var current_brush_types := []
|
||||
var brush_sizes := [1, 1]
|
||||
var current_brush_types := [Brush_Types.PIXEL, Brush_Types.PIXEL]
|
||||
|
||||
var brush_type_window_position : int = Mouse_Button.LEFT
|
||||
var left_circle_points := []
|
||||
|
@ -131,14 +117,14 @@ var right_circle_points := []
|
|||
|
||||
var brushes_from_files := 0
|
||||
var custom_brushes := []
|
||||
var custom_brush_indexes := []
|
||||
var custom_brush_images := []
|
||||
var custom_brush_textures := []
|
||||
var custom_brush_indexes := [-1, -1]
|
||||
var custom_brush_images := [Image.new(), Image.new()]
|
||||
var custom_brush_textures := [ImageTexture.new(), ImageTexture.new()]
|
||||
|
||||
# Patterns
|
||||
var patterns := []
|
||||
var pattern_window_position : int = Mouse_Button.LEFT
|
||||
var pattern_images := []
|
||||
var pattern_images := [Image.new(), Image.new()]
|
||||
|
||||
# Palettes
|
||||
var palettes := {}
|
||||
|
@ -257,16 +243,6 @@ func _ready() -> void:
|
|||
|
||||
undo_redo = UndoRedo.new()
|
||||
image_clipboard = Image.new()
|
||||
current_brush_types.append(Brush_Types.PIXEL)
|
||||
current_brush_types.append(Brush_Types.PIXEL)
|
||||
custom_brush_indexes.append(-1)
|
||||
custom_brush_indexes.append(-1)
|
||||
custom_brush_images.append(Image.new())
|
||||
custom_brush_images.append(Image.new())
|
||||
custom_brush_textures.append(ImageTexture.new())
|
||||
custom_brush_textures.append(ImageTexture.new())
|
||||
pattern_images.append(Image.new())
|
||||
pattern_images.append(Image.new())
|
||||
|
||||
var root = get_tree().get_root()
|
||||
control = find_node_by_name(root, "Control")
|
||||
|
@ -881,17 +857,19 @@ func update_custom_brush(mouse_button : int) -> void:
|
|||
var pixel := Image.new()
|
||||
pixel = preload("res://assets/graphics/circle_9x9.png")
|
||||
brush_type_buttons[mouse_button].get_child(0).texture.create_from_image(pixel, 0)
|
||||
left_circle_points = plot_circle(left_brush_size)
|
||||
left_circle_points = plot_circle(brush_sizes[0])
|
||||
right_circle_points = plot_circle(brush_sizes[1])
|
||||
elif current_brush_types[mouse_button] == Brush_Types.FILLED_CIRCLE:
|
||||
var pixel := Image.new()
|
||||
pixel = preload("res://assets/graphics/circle_filled_9x9.png")
|
||||
brush_type_buttons[mouse_button].get_child(0).texture.create_from_image(pixel, 0)
|
||||
left_circle_points = plot_circle(left_brush_size)
|
||||
left_circle_points = plot_circle(brush_sizes[0])
|
||||
right_circle_points = plot_circle(brush_sizes[1])
|
||||
else:
|
||||
var custom_brush := Image.new()
|
||||
custom_brush.copy_from(custom_brushes[custom_brush_indexes[mouse_button]])
|
||||
var custom_brush_size = custom_brush.get_size()
|
||||
custom_brush.resize(custom_brush_size.x * left_brush_size, custom_brush_size.y * left_brush_size, Image.INTERPOLATE_NEAREST)
|
||||
custom_brush.resize(custom_brush_size.x * brush_sizes[mouse_button], custom_brush_size.y * brush_sizes[mouse_button], Image.INTERPOLATE_NEAREST)
|
||||
custom_brush_images[mouse_button] = blend_image_with_color(custom_brush, color_pickers[mouse_button].color, interpolate_spinboxes[mouse_button].value / 100)
|
||||
custom_brush_textures[mouse_button].create_from_image(custom_brush_images[mouse_button], 0)
|
||||
|
||||
|
|
|
@ -128,10 +128,10 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void:
|
|||
# Load tool options
|
||||
Global.color_pickers[0].color = file.get_var()
|
||||
Global.color_pickers[1].color = file.get_var()
|
||||
Global.left_brush_size = file.get_8()
|
||||
Global.brush_size_edits[0].value = Global.left_brush_size
|
||||
Global.right_brush_size = file.get_8()
|
||||
Global.brush_size_edits[1].value = Global.right_brush_size
|
||||
Global.brush_sizes[0] = file.get_8()
|
||||
Global.brush_size_edits[0].value = Global.brush_sizes[0]
|
||||
Global.brush_sizes[1] = file.get_8()
|
||||
Global.brush_size_edits[1].value = Global.brush_sizes[1]
|
||||
if file_major_version == 0 and file_minor_version < 7:
|
||||
var left_palette = file.get_var()
|
||||
var right_palette = file.get_var()
|
||||
|
@ -224,8 +224,8 @@ func save_pxo_file(path : String, autosave : bool) -> void:
|
|||
# Save tool options
|
||||
var left_color : Color = Global.color_pickers[0].color
|
||||
var right_color : Color = Global.color_pickers[1].color
|
||||
var left_brush_size : int = Global.left_brush_size
|
||||
var right_brush_size : int = Global.right_brush_size
|
||||
var left_brush_size : int = Global.brush_sizes[0]
|
||||
var right_brush_size : int = Global.brush_sizes[1]
|
||||
file.store_var(left_color)
|
||||
file.store_var(right_color)
|
||||
file.store_8(left_brush_size)
|
||||
|
|
|
@ -171,37 +171,37 @@ func _draw() -> void:
|
|||
var mouse_pos := current_pixel
|
||||
mouse_pos = mouse_pos.floor()
|
||||
if Global.left_square_indicator_visible && Global.can_draw:
|
||||
if Global.current_brush_types[0] == Global.Brush_Types.PIXEL || Global.current_left_tool == Global.Tools.LIGHTENDARKEN:
|
||||
if Global.current_left_tool == Global.Tools.PENCIL || Global.current_left_tool == Global.Tools.ERASER || Global.current_left_tool == Global.Tools.LIGHTENDARKEN:
|
||||
var start_pos_x = mouse_pos.x - (Global.left_brush_size >> 1)
|
||||
var start_pos_y = mouse_pos.y - (Global.left_brush_size >> 1)
|
||||
draw_rect(Rect2(start_pos_x, start_pos_y, Global.left_brush_size, Global.left_brush_size), Color.blue, false)
|
||||
if Global.current_brush_types[0] == Global.Brush_Types.PIXEL || Global.current_tools[0] == Global.Tools.LIGHTENDARKEN:
|
||||
if Global.current_tools[0] == Global.Tools.PENCIL || Global.current_tools[0] == Global.Tools.ERASER || Global.current_tools[0] == Global.Tools.LIGHTENDARKEN:
|
||||
var start_pos_x = mouse_pos.x - (Global.brush_sizes[0] >> 1)
|
||||
var start_pos_y = mouse_pos.y - (Global.brush_sizes[0] >> 1)
|
||||
draw_rect(Rect2(start_pos_x, start_pos_y, Global.brush_sizes[0], Global.brush_sizes[0]), Color.blue, false)
|
||||
elif Global.current_brush_types[0] == Global.Brush_Types.CIRCLE || Global.current_brush_types[0] == Global.Brush_Types.FILLED_CIRCLE:
|
||||
if Global.current_left_tool == Global.Tools.PENCIL || Global.current_left_tool == Global.Tools.ERASER:
|
||||
if Global.current_tools[0] == Global.Tools.PENCIL || Global.current_tools[0] == Global.Tools.ERASER:
|
||||
draw_set_transform(mouse_pos, rotation, scale)
|
||||
for rect in Global.left_circle_points:
|
||||
draw_rect(Rect2(rect, Vector2.ONE), Color.blue, false)
|
||||
draw_set_transform(position, rotation, scale)
|
||||
else:
|
||||
if Global.current_left_tool == Global.Tools.PENCIL || Global.current_left_tool == Global.Tools.ERASER:
|
||||
if Global.current_tools[0] == Global.Tools.PENCIL || Global.current_tools[0] == Global.Tools.ERASER:
|
||||
var custom_brush_size = Global.custom_brush_images[0].get_size() - Vector2.ONE
|
||||
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
||||
draw_texture(Global.custom_brush_textures[0], dst)
|
||||
|
||||
if Global.right_square_indicator_visible && Global.can_draw:
|
||||
if Global.current_brush_types[1] == Global.Brush_Types.PIXEL || Global.current_right_tool == Global.Tools.LIGHTENDARKEN:
|
||||
if Global.current_right_tool == Global.Tools.PENCIL || Global.current_right_tool == Global.Tools.ERASER || Global.current_right_tool == Global.Tools.LIGHTENDARKEN:
|
||||
var start_pos_x = mouse_pos.x - (Global.right_brush_size >> 1)
|
||||
var start_pos_y = mouse_pos.y - (Global.right_brush_size >> 1)
|
||||
draw_rect(Rect2(start_pos_x, start_pos_y, Global.right_brush_size, Global.right_brush_size), Color.red, false)
|
||||
if Global.current_brush_types[1] == Global.Brush_Types.PIXEL || Global.current_tools[1] == Global.Tools.LIGHTENDARKEN:
|
||||
if Global.current_tools[1] == Global.Tools.PENCIL || Global.current_tools[1] == Global.Tools.ERASER || Global.current_tools[1] == Global.Tools.LIGHTENDARKEN:
|
||||
var start_pos_x = mouse_pos.x - (Global.brush_sizes[1] >> 1)
|
||||
var start_pos_y = mouse_pos.y - (Global.brush_sizes[1] >> 1)
|
||||
draw_rect(Rect2(start_pos_x, start_pos_y, Global.brush_sizes[1], Global.brush_sizes[1]), Color.red, false)
|
||||
elif Global.current_brush_types[1] == Global.Brush_Types.CIRCLE || Global.current_brush_types[1] == Global.Brush_Types.FILLED_CIRCLE:
|
||||
if Global.current_right_tool == Global.Tools.PENCIL || Global.current_right_tool == Global.Tools.ERASER:
|
||||
if Global.current_tools[1] == Global.Tools.PENCIL || Global.current_tools[1] == Global.Tools.ERASER:
|
||||
draw_set_transform(mouse_pos, rotation, scale)
|
||||
for rect in Global.right_circle_points:
|
||||
draw_rect(Rect2(rect, Vector2.ONE), Color.red, false)
|
||||
draw_set_transform(position, rotation, scale)
|
||||
else:
|
||||
if Global.current_right_tool == Global.Tools.PENCIL || Global.current_right_tool == Global.Tools.ERASER:
|
||||
if Global.current_tools[1] == Global.Tools.PENCIL || Global.current_tools[1] == Global.Tools.ERASER:
|
||||
var custom_brush_size = Global.custom_brush_images[1].get_size() - Vector2.ONE
|
||||
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
||||
draw_texture(Global.custom_brush_textures[1], dst)
|
||||
|
@ -273,23 +273,23 @@ func _input(event : InputEvent) -> void:
|
|||
|
||||
if Input.is_mouse_button_pressed(BUTTON_LEFT):
|
||||
current_mouse_button = Global.Mouse_Button.LEFT
|
||||
current_action = Global.current_left_tool
|
||||
current_action = Global.current_tools[0]
|
||||
current_color = Global.color_pickers[0].color
|
||||
fill_area = Global.left_fill_area
|
||||
ld = Global.left_ld
|
||||
ld_amount = Global.left_ld_amount
|
||||
color_picker_for = Global.left_color_picker_for
|
||||
zoom_mode = Global.left_zoom_mode
|
||||
fill_area = Global.fill_areas[0]
|
||||
ld = Global.ld_modes[0]
|
||||
ld_amount = Global.ld_amounts[0]
|
||||
color_picker_for = Global.color_picker_for[0]
|
||||
zoom_mode = Global.zoom_modes[0]
|
||||
|
||||
elif Input.is_mouse_button_pressed(BUTTON_RIGHT):
|
||||
current_mouse_button = Global.Mouse_Button.RIGHT
|
||||
current_action = Global.current_right_tool
|
||||
current_action = Global.current_tools[1]
|
||||
current_color = Global.color_pickers[1].color
|
||||
fill_area = Global.right_fill_area
|
||||
ld = Global.right_ld
|
||||
ld_amount = Global.right_ld_amount
|
||||
color_picker_for = Global.right_color_picker_for
|
||||
zoom_mode = Global.right_zoom_mode
|
||||
fill_area = Global.fill_areas[1]
|
||||
ld = Global.ld_modes[1]
|
||||
ld_amount = Global.ld_amounts[1]
|
||||
color_picker_for = Global.color_picker_for[1]
|
||||
zoom_mode = Global.zoom_modes[1]
|
||||
|
||||
if Global.has_focus:
|
||||
Global.cursor_position_label.text = "[%s×%s] %s, %s" % [size.x, size.y, mouse_pos_floored.x, mouse_pos_floored.y]
|
||||
|
@ -339,13 +339,13 @@ func _input(event : InputEvent) -> void:
|
|||
var pattern_image : Image
|
||||
var pattern_offset : Vector2
|
||||
if current_mouse_button == Global.Mouse_Button.LEFT:
|
||||
fill_with = Global.left_fill_with
|
||||
fill_with = Global.fill_with[0]
|
||||
pattern_image = Global.pattern_images[0]
|
||||
pattern_offset = Global.left_fill_pattern_offset
|
||||
pattern_offset = Global.fill_pattern_offsets[0]
|
||||
elif current_mouse_button == Global.Mouse_Button.RIGHT:
|
||||
fill_with = Global.right_fill_with
|
||||
fill_with = Global.fill_with[1]
|
||||
pattern_image = Global.pattern_images[1]
|
||||
pattern_offset = Global.right_fill_pattern_offset
|
||||
pattern_offset = Global.fill_pattern_offsets[1]
|
||||
|
||||
if fill_area == 0: # Paint the specific area of the same color
|
||||
var horizontal_mirror := false
|
||||
|
@ -353,11 +353,11 @@ func _input(event : InputEvent) -> void:
|
|||
var mirror_x := east_limit + west_limit - mouse_pos_floored.x - 1
|
||||
var mirror_y := south_limit + north_limit - mouse_pos_floored.y - 1
|
||||
if current_mouse_button == Global.Mouse_Button.LEFT:
|
||||
horizontal_mirror = Global.left_horizontal_mirror
|
||||
vertical_mirror = Global.left_vertical_mirror
|
||||
horizontal_mirror = Global.horizontal_mirror[0]
|
||||
vertical_mirror = Global.vertical_mirror[0]
|
||||
elif current_mouse_button == Global.Mouse_Button.RIGHT:
|
||||
horizontal_mirror = Global.right_horizontal_mirror
|
||||
vertical_mirror = Global.right_vertical_mirror
|
||||
horizontal_mirror = Global.horizontal_mirror[1]
|
||||
vertical_mirror = Global.vertical_mirror[1]
|
||||
|
||||
if fill_with == 1 && pattern_image: # Pattern fill
|
||||
DrawingAlgos.pattern_fill(sprite, mouse_pos, pattern_image, sprite.get_pixelv(mouse_pos), pattern_offset)
|
||||
|
@ -451,7 +451,7 @@ func _input(event : InputEvent) -> void:
|
|||
else:
|
||||
Global.camera.zoom_camera(1)
|
||||
|
||||
if Global.can_draw && Global.has_focus && Input.is_action_just_pressed("shift") && ([Global.Tools.PENCIL, Global.Tools.ERASER, Global.Tools.LIGHTENDARKEN].has(Global.current_left_tool) || [Global.Tools.PENCIL, Global.Tools.ERASER, Global.Tools.LIGHTENDARKEN].has(Global.current_right_tool)):
|
||||
if Global.can_draw && Global.has_focus && Input.is_action_just_pressed("shift") && ([Global.Tools.PENCIL, Global.Tools.ERASER, Global.Tools.LIGHTENDARKEN].has(Global.current_tools[0]) || [Global.Tools.PENCIL, Global.Tools.ERASER, Global.Tools.LIGHTENDARKEN].has(Global.current_tools[1])):
|
||||
is_making_line = true
|
||||
line_2d.set_point_position(0, previous_mouse_pos_for_lines)
|
||||
elif Input.is_action_just_released("shift"):
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
extends AcceptDialog
|
||||
|
||||
onready var list : ItemList = $HSplitContainer/List
|
||||
onready var right_side : VBoxContainer = $HSplitContainer/ScrollContainer/VBoxContainer
|
||||
onready var general = $HSplitContainer/ScrollContainer/VBoxContainer/General
|
||||
|
||||
# Preferences table: [Prop name in Global, relative node path, value type]
|
||||
var preferences = [
|
||||
["open_last_project", "General/OpenLastProject", "pressed"],
|
||||
|
@ -29,6 +25,11 @@ var preferences = [
|
|||
["checker_color_2", "Canvas/CheckerOptions/CheckerColor2", "color"],
|
||||
]
|
||||
|
||||
onready var list : ItemList = $HSplitContainer/List
|
||||
onready var right_side : VBoxContainer = $HSplitContainer/ScrollContainer/VBoxContainer
|
||||
onready var general = $HSplitContainer/ScrollContainer/VBoxContainer/General
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Replace OK with Close since preference changes are being applied immediately, not after OK confirmation
|
||||
get_ok().text = tr("Close")
|
||||
|
|
|
@ -34,10 +34,10 @@ func _process(_delta : float) -> void:
|
|||
else:
|
||||
visible = true
|
||||
|
||||
if Global.can_draw and Global.has_focus and point_in_rectangle(mouse_pos, polygon[0], polygon[2]) and Global.selected_pixels.size() > 0 and (Global.current_left_tool == Global.Tools.RECTSELECT or Global.current_right_tool == Global.Tools.RECTSELECT):
|
||||
if Global.can_draw and Global.has_focus and point_in_rectangle(mouse_pos, polygon[0], polygon[2]) and Global.selected_pixels.size() > 0 and (Global.current_tools[0] == Global.Tools.RECTSELECT or Global.current_tools[1] == Global.Tools.RECTSELECT):
|
||||
get_parent().get_parent().mouse_default_cursor_shape = Input.CURSOR_MOVE
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
if (Global.current_left_tool == Global.Tools.RECTSELECT && Input.is_action_just_pressed("left_mouse")) || (Global.current_right_tool == Global.Tools.RECTSELECT && Input.is_action_just_pressed("right_mouse")):
|
||||
if (Global.current_tools[0] == Global.Tools.RECTSELECT && Input.is_action_just_pressed("left_mouse")) || (Global.current_tools[1] == Global.Tools.RECTSELECT && Input.is_action_just_pressed("right_mouse")):
|
||||
# Begin dragging
|
||||
is_dragging = true
|
||||
if Input.is_key_pressed(KEY_SHIFT):
|
||||
|
@ -72,7 +72,7 @@ func _process(_delta : float) -> void:
|
|||
get_parent().get_parent().mouse_default_cursor_shape = Input.CURSOR_ARROW
|
||||
|
||||
if is_dragging:
|
||||
if (Global.current_left_tool == Global.Tools.RECTSELECT && Input.is_action_pressed("left_mouse")) || (Global.current_right_tool == Global.Tools.RECTSELECT && Input.is_action_pressed("right_mouse")):
|
||||
if (Global.current_tools[0] == Global.Tools.RECTSELECT && Input.is_action_pressed("left_mouse")) || (Global.current_tools[1] == Global.Tools.RECTSELECT && Input.is_action_pressed("right_mouse")):
|
||||
# Drag
|
||||
start_pos.x = orig_x + mouse_pos_floored.x
|
||||
end_pos.x = diff_x + mouse_pos_floored.x
|
||||
|
@ -84,7 +84,7 @@ func _process(_delta : float) -> void:
|
|||
polygon[2] = end_pos
|
||||
polygon[3] = Vector2(start_pos.x, end_pos.y)
|
||||
|
||||
if (Global.current_left_tool == Global.Tools.RECTSELECT && Input.is_action_just_released("left_mouse")) || (Global.current_right_tool == Global.Tools.RECTSELECT && Input.is_action_just_released("right_mouse")):
|
||||
if (Global.current_tools[0] == Global.Tools.RECTSELECT && Input.is_action_just_released("left_mouse")) || (Global.current_tools[1] == Global.Tools.RECTSELECT && Input.is_action_just_released("right_mouse")):
|
||||
# Release Drag
|
||||
is_dragging = false
|
||||
if move_pixels:
|
||||
|
|
|
@ -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…
Reference in a new issue