mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00: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
|
@ -39,10 +39,10 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
|
||||||
color.a *= (1.0 - pen_pressure)
|
color.a *= (1.0 - pen_pressure)
|
||||||
if current_mouse_button == "left_mouse":
|
if current_mouse_button == "left_mouse":
|
||||||
brush_size = Global.left_brush_size
|
brush_size = Global.left_brush_size
|
||||||
brush_type = Global.current_brush_type[0]
|
brush_type = Global.current_brush_types[0]
|
||||||
brush_index = Global.custom_left_brush_index
|
brush_index = Global.custom_brush_indexes[0]
|
||||||
if brush_type != Global.Brush_Types.RANDOM_FILE:
|
if brush_type != Global.Brush_Types.RANDOM_FILE:
|
||||||
custom_brush_image = Global.custom_left_brush_image
|
custom_brush_image = Global.custom_brush_images[0]
|
||||||
else: # Handle random brush
|
else: # Handle random brush
|
||||||
var brush_button = Global.file_brush_container.get_child(brush_index + 3)
|
var brush_button = Global.file_brush_container.get_child(brush_index + 3)
|
||||||
var random_index = randi() % brush_button.random_brushes.size()
|
var random_index = randi() % brush_button.random_brushes.size()
|
||||||
|
@ -61,10 +61,10 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
|
||||||
|
|
||||||
elif current_mouse_button == "right_mouse":
|
elif current_mouse_button == "right_mouse":
|
||||||
brush_size = Global.right_brush_size
|
brush_size = Global.right_brush_size
|
||||||
brush_type = Global.current_brush_type[1]
|
brush_type = Global.current_brush_types[1]
|
||||||
brush_index = Global.custom_right_brush_index
|
brush_index = Global.custom_brush_indexes[1]
|
||||||
if brush_type != Global.Brush_Types.RANDOM_FILE:
|
if brush_type != Global.Brush_Types.RANDOM_FILE:
|
||||||
custom_brush_image = Global.custom_right_brush_image
|
custom_brush_image = Global.custom_brush_images[1]
|
||||||
else: # Handle random brush
|
else: # Handle random brush
|
||||||
var brush_button = Global.file_brush_container.get_child(brush_index + 3)
|
var brush_button = Global.file_brush_container.get_child(brush_index + 3)
|
||||||
var random_index = randi() % brush_button.random_brushes.size()
|
var random_index = randi() % brush_button.random_brushes.size()
|
||||||
|
|
|
@ -120,26 +120,22 @@ var onion_skinning_blue_red := false
|
||||||
# Brushes
|
# Brushes
|
||||||
var left_brush_size := 1
|
var left_brush_size := 1
|
||||||
var right_brush_size := 1
|
var right_brush_size := 1
|
||||||
var current_brush_type := []
|
var current_brush_types := []
|
||||||
|
|
||||||
var brush_type_window_position := "left"
|
var brush_type_window_position : int = Mouse_Button.LEFT
|
||||||
var left_circle_points := []
|
var left_circle_points := []
|
||||||
var right_circle_points := []
|
var right_circle_points := []
|
||||||
|
|
||||||
var brushes_from_files := 0
|
var brushes_from_files := 0
|
||||||
var custom_brushes := []
|
var custom_brushes := []
|
||||||
var custom_left_brush_index := -1
|
var custom_brush_indexes := []
|
||||||
var custom_right_brush_index := -1
|
var custom_brush_images := []
|
||||||
var custom_left_brush_image : Image
|
var custom_brush_textures := []
|
||||||
var custom_right_brush_image : Image
|
|
||||||
var custom_left_brush_texture := ImageTexture.new()
|
|
||||||
var custom_right_brush_texture := ImageTexture.new()
|
|
||||||
|
|
||||||
# Patterns
|
# Patterns
|
||||||
var patterns := []
|
var patterns := []
|
||||||
var pattern_window_position := "left"
|
var pattern_window_position : int = Mouse_Button.LEFT
|
||||||
var pattern_left_image : Image
|
var pattern_images := []
|
||||||
var pattern_right_image : Image
|
|
||||||
|
|
||||||
# Palettes
|
# Palettes
|
||||||
var palettes := {}
|
var palettes := {}
|
||||||
|
@ -258,8 +254,16 @@ func _ready() -> void:
|
||||||
|
|
||||||
undo_redo = UndoRedo.new()
|
undo_redo = UndoRedo.new()
|
||||||
image_clipboard = Image.new()
|
image_clipboard = Image.new()
|
||||||
current_brush_type.append(Brush_Types.PIXEL)
|
current_brush_types.append(Brush_Types.PIXEL)
|
||||||
current_brush_type.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()
|
var root = get_tree().get_root()
|
||||||
control = find_node_by_name(root, "Control")
|
control = find_node_by_name(root, "Control")
|
||||||
|
@ -843,8 +847,8 @@ func create_brush_button(brush_img : Image, brush_type := Brush_Types.CUSTOM, hi
|
||||||
|
|
||||||
|
|
||||||
func remove_brush_buttons() -> void:
|
func remove_brush_buttons() -> void:
|
||||||
current_brush_type[0] = Brush_Types.PIXEL
|
current_brush_types[0] = Brush_Types.PIXEL
|
||||||
current_brush_type[1] = Brush_Types.PIXEL
|
current_brush_types[1] = Brush_Types.PIXEL
|
||||||
for child in project_brush_container.get_children():
|
for child in project_brush_container.get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
|
||||||
|
@ -865,56 +869,30 @@ func redo_custom_brush(_brush_button : BaseButton = null) -> void:
|
||||||
project_brush_container.remove_child(_brush_button)
|
project_brush_container.remove_child(_brush_button)
|
||||||
|
|
||||||
|
|
||||||
func update_left_custom_brush() -> void:
|
func update_custom_brush(mouse_button : int) -> void:
|
||||||
if current_brush_type[0] == Brush_Types.PIXEL:
|
if current_brush_types[mouse_button] == Brush_Types.PIXEL:
|
||||||
var pixel := Image.new()
|
var pixel := Image.new()
|
||||||
pixel = preload("res://assets/graphics/pixel_image.png")
|
pixel = preload("res://assets/graphics/pixel_image.png")
|
||||||
brush_type_buttons[0].get_child(0).texture.create_from_image(pixel, 0)
|
brush_type_buttons[mouse_button].get_child(0).texture.create_from_image(pixel, 0)
|
||||||
elif current_brush_type[0] == Brush_Types.CIRCLE:
|
elif current_brush_types[mouse_button] == Brush_Types.CIRCLE:
|
||||||
var pixel := Image.new()
|
var pixel := Image.new()
|
||||||
pixel = preload("res://assets/graphics/circle_9x9.png")
|
pixel = preload("res://assets/graphics/circle_9x9.png")
|
||||||
brush_type_buttons[0].get_child(0).texture.create_from_image(pixel, 0)
|
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(left_brush_size)
|
||||||
elif current_brush_type[0] == Brush_Types.FILLED_CIRCLE:
|
elif current_brush_types[mouse_button] == Brush_Types.FILLED_CIRCLE:
|
||||||
var pixel := Image.new()
|
var pixel := Image.new()
|
||||||
pixel = preload("res://assets/graphics/circle_filled_9x9.png")
|
pixel = preload("res://assets/graphics/circle_filled_9x9.png")
|
||||||
brush_type_buttons[0].get_child(0).texture.create_from_image(pixel, 0)
|
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(left_brush_size)
|
||||||
else:
|
else:
|
||||||
var custom_brush := Image.new()
|
var custom_brush := Image.new()
|
||||||
custom_brush.copy_from(custom_brushes[custom_left_brush_index])
|
custom_brush.copy_from(custom_brushes[custom_brush_indexes[mouse_button]])
|
||||||
var custom_brush_size = custom_brush.get_size()
|
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 * left_brush_size, custom_brush_size.y * left_brush_size, Image.INTERPOLATE_NEAREST)
|
||||||
custom_left_brush_image = blend_image_with_color(custom_brush, color_pickers[0].color, interpolate_spinboxes[0].value / 100)
|
custom_brush_images[mouse_button] = blend_image_with_color(custom_brush, color_pickers[mouse_button].color, interpolate_spinboxes[mouse_button].value / 100)
|
||||||
custom_left_brush_texture.create_from_image(custom_left_brush_image, 0)
|
custom_brush_textures[mouse_button].create_from_image(custom_brush_images[mouse_button], 0)
|
||||||
|
|
||||||
brush_type_buttons[0].get_child(0).texture = custom_left_brush_texture
|
brush_type_buttons[mouse_button].get_child(0).texture = custom_brush_textures[mouse_button]
|
||||||
|
|
||||||
|
|
||||||
func update_right_custom_brush() -> void:
|
|
||||||
if current_brush_type[1] == Brush_Types.PIXEL:
|
|
||||||
var pixel := Image.new()
|
|
||||||
pixel = preload("res://assets/graphics/pixel_image.png")
|
|
||||||
brush_type_buttons[1].get_child(0).texture.create_from_image(pixel, 0)
|
|
||||||
elif current_brush_type[1] == Brush_Types.CIRCLE:
|
|
||||||
var pixel := Image.new()
|
|
||||||
pixel = preload("res://assets/graphics/circle_9x9.png")
|
|
||||||
brush_type_buttons[1].get_child(0).texture.create_from_image(pixel, 0)
|
|
||||||
right_circle_points = plot_circle(right_brush_size)
|
|
||||||
elif current_brush_type[1] == Brush_Types.FILLED_CIRCLE:
|
|
||||||
var pixel := Image.new()
|
|
||||||
pixel = preload("res://assets/graphics/circle_filled_9x9.png")
|
|
||||||
brush_type_buttons[1].get_child(0).texture.create_from_image(pixel, 0)
|
|
||||||
right_circle_points = plot_circle(right_brush_size)
|
|
||||||
else:
|
|
||||||
var custom_brush := Image.new()
|
|
||||||
custom_brush.copy_from(custom_brushes[custom_right_brush_index])
|
|
||||||
var custom_brush_size = custom_brush.get_size()
|
|
||||||
custom_brush.resize(custom_brush_size.x * right_brush_size, custom_brush_size.y * right_brush_size, Image.INTERPOLATE_NEAREST)
|
|
||||||
custom_right_brush_image = blend_image_with_color(custom_brush, color_pickers[1].color, interpolate_spinboxes[1].value / 100)
|
|
||||||
custom_right_brush_texture.create_from_image(custom_right_brush_image, 0)
|
|
||||||
|
|
||||||
brush_type_buttons[1].get_child(0).texture = custom_right_brush_texture
|
|
||||||
|
|
||||||
|
|
||||||
func blend_image_with_color(image : Image, color : Color, interpolate_factor : float) -> Image:
|
func blend_image_with_color(image : Image, color : Color, interpolate_factor : float) -> Image:
|
||||||
|
|
|
@ -249,16 +249,16 @@ func import_patterns(priority_ordered_search_path: Array) -> void:
|
||||||
if Global.patterns.size() > 0:
|
if Global.patterns.size() > 0:
|
||||||
var image_size = Global.patterns[0].get_size()
|
var image_size = Global.patterns[0].get_size()
|
||||||
|
|
||||||
Global.pattern_left_image = Global.patterns[0]
|
Global.pattern_images[0] = Global.patterns[0]
|
||||||
var pattern_left_tex := ImageTexture.new()
|
var pattern_left_tex := ImageTexture.new()
|
||||||
pattern_left_tex.create_from_image(Global.pattern_left_image, 0)
|
pattern_left_tex.create_from_image(Global.pattern_images[0], 0)
|
||||||
Global.fill_pattern_containers[0].get_child(0).get_child(0).texture = pattern_left_tex
|
Global.fill_pattern_containers[0].get_child(0).get_child(0).texture = pattern_left_tex
|
||||||
Global.fill_pattern_containers[0].get_child(2).get_child(1).max_value = image_size.x - 1
|
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
|
Global.fill_pattern_containers[0].get_child(3).get_child(1).max_value = image_size.y - 1
|
||||||
|
|
||||||
Global.pattern_right_image = Global.patterns[0]
|
Global.pattern_images[1] = Global.patterns[0]
|
||||||
var pattern_right_tex := ImageTexture.new()
|
var pattern_right_tex := ImageTexture.new()
|
||||||
pattern_right_tex.create_from_image(Global.pattern_right_image, 0)
|
pattern_right_tex.create_from_image(Global.pattern_images[1], 0)
|
||||||
Global.fill_pattern_containers[1].get_child(0).get_child(0).texture = pattern_right_tex
|
Global.fill_pattern_containers[1].get_child(0).get_child(0).texture = pattern_right_tex
|
||||||
Global.fill_pattern_containers[1].get_child(2).get_child(1).max_value = image_size.x - 1
|
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.fill_pattern_containers[1].get_child(3).get_child(1).max_value = image_size.y - 1
|
||||||
|
|
|
@ -171,12 +171,12 @@ func _draw() -> void:
|
||||||
var mouse_pos := current_pixel
|
var mouse_pos := current_pixel
|
||||||
mouse_pos = mouse_pos.floor()
|
mouse_pos = mouse_pos.floor()
|
||||||
if Global.left_square_indicator_visible && Global.can_draw:
|
if Global.left_square_indicator_visible && Global.can_draw:
|
||||||
if Global.current_brush_type[0] == Global.Brush_Types.PIXEL || Global.current_left_tool == Global.Tools.LIGHTENDARKEN:
|
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:
|
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_x = mouse_pos.x - (Global.left_brush_size >> 1)
|
||||||
var start_pos_y = mouse_pos.y - (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)
|
draw_rect(Rect2(start_pos_x, start_pos_y, Global.left_brush_size, Global.left_brush_size), Color.blue, false)
|
||||||
elif Global.current_brush_type[0] == Global.Brush_Types.CIRCLE || Global.current_brush_type[0] == Global.Brush_Types.FILLED_CIRCLE:
|
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_left_tool == Global.Tools.PENCIL || Global.current_left_tool == Global.Tools.ERASER:
|
||||||
draw_set_transform(mouse_pos, rotation, scale)
|
draw_set_transform(mouse_pos, rotation, scale)
|
||||||
for rect in Global.left_circle_points:
|
for rect in Global.left_circle_points:
|
||||||
|
@ -184,17 +184,17 @@ func _draw() -> void:
|
||||||
draw_set_transform(position, rotation, scale)
|
draw_set_transform(position, rotation, scale)
|
||||||
else:
|
else:
|
||||||
if Global.current_left_tool == Global.Tools.PENCIL || Global.current_left_tool == Global.Tools.ERASER:
|
if Global.current_left_tool == Global.Tools.PENCIL || Global.current_left_tool == Global.Tools.ERASER:
|
||||||
var custom_brush_size = Global.custom_left_brush_image.get_size() - Vector2.ONE
|
var custom_brush_size = Global.custom_brush_images[0].get_size() - Vector2.ONE
|
||||||
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
||||||
draw_texture(Global.custom_left_brush_texture, dst)
|
draw_texture(Global.custom_brush_textures[0], dst)
|
||||||
|
|
||||||
if Global.right_square_indicator_visible && Global.can_draw:
|
if Global.right_square_indicator_visible && Global.can_draw:
|
||||||
if Global.current_brush_type[1] == Global.Brush_Types.PIXEL || Global.current_right_tool == Global.Tools.LIGHTENDARKEN:
|
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:
|
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_x = mouse_pos.x - (Global.right_brush_size >> 1)
|
||||||
var start_pos_y = mouse_pos.y - (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)
|
draw_rect(Rect2(start_pos_x, start_pos_y, Global.right_brush_size, Global.right_brush_size), Color.red, false)
|
||||||
elif Global.current_brush_type[1] == Global.Brush_Types.CIRCLE || Global.current_brush_type[1] == Global.Brush_Types.FILLED_CIRCLE:
|
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_right_tool == Global.Tools.PENCIL || Global.current_right_tool == Global.Tools.ERASER:
|
||||||
draw_set_transform(mouse_pos, rotation, scale)
|
draw_set_transform(mouse_pos, rotation, scale)
|
||||||
for rect in Global.right_circle_points:
|
for rect in Global.right_circle_points:
|
||||||
|
@ -202,9 +202,9 @@ func _draw() -> void:
|
||||||
draw_set_transform(position, rotation, scale)
|
draw_set_transform(position, rotation, scale)
|
||||||
else:
|
else:
|
||||||
if Global.current_right_tool == Global.Tools.PENCIL || Global.current_right_tool == Global.Tools.ERASER:
|
if Global.current_right_tool == Global.Tools.PENCIL || Global.current_right_tool == Global.Tools.ERASER:
|
||||||
var custom_brush_size = Global.custom_right_brush_image.get_size() - Vector2.ONE
|
var custom_brush_size = Global.custom_brush_images[1].get_size() - Vector2.ONE
|
||||||
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
||||||
draw_texture(Global.custom_right_brush_texture, dst)
|
draw_texture(Global.custom_brush_textures[1], dst)
|
||||||
|
|
||||||
|
|
||||||
func _input(event : InputEvent) -> void:
|
func _input(event : InputEvent) -> void:
|
||||||
|
@ -340,11 +340,11 @@ func _input(event : InputEvent) -> void:
|
||||||
var pattern_offset : Vector2
|
var pattern_offset : Vector2
|
||||||
if current_mouse_button == "left_mouse":
|
if current_mouse_button == "left_mouse":
|
||||||
fill_with = Global.left_fill_with
|
fill_with = Global.left_fill_with
|
||||||
pattern_image = Global.pattern_left_image
|
pattern_image = Global.pattern_images[0]
|
||||||
pattern_offset = Global.left_fill_pattern_offset
|
pattern_offset = Global.left_fill_pattern_offset
|
||||||
elif current_mouse_button == "right_mouse":
|
elif current_mouse_button == "right_mouse":
|
||||||
fill_with = Global.right_fill_with
|
fill_with = Global.right_fill_with
|
||||||
pattern_image = Global.pattern_right_image
|
pattern_image = Global.pattern_images[1]
|
||||||
pattern_offset = Global.right_fill_pattern_offset
|
pattern_offset = Global.right_fill_pattern_offset
|
||||||
|
|
||||||
if fill_area == 0: # Paint the specific area of the same color
|
if fill_area == 0: # Paint the specific area of the same color
|
||||||
|
@ -439,12 +439,8 @@ func _input(event : InputEvent) -> void:
|
||||||
image_data.copy_from(sprite)
|
image_data.copy_from(sprite)
|
||||||
image_data.lock()
|
image_data.lock()
|
||||||
var pixel_color : Color = image_data.get_pixelv(mouse_pos)
|
var pixel_color : Color = image_data.get_pixelv(mouse_pos)
|
||||||
if color_picker_for == 0: # Pick for the left color
|
Global.color_pickers[color_picker_for].color = pixel_color
|
||||||
Global.color_pickers[0].color = pixel_color
|
Global.update_custom_brush(color_picker_for)
|
||||||
Global.update_left_custom_brush()
|
|
||||||
elif color_picker_for == 1: # Pick for the left color
|
|
||||||
Global.color_pickers[1].color = pixel_color
|
|
||||||
Global.update_right_custom_brush()
|
|
||||||
Global.Tools.ZOOM:
|
Global.Tools.ZOOM:
|
||||||
if can_handle:
|
if can_handle:
|
||||||
if zoom_mode == 0:
|
if zoom_mode == 0:
|
||||||
|
|
|
@ -166,10 +166,10 @@ func on_color_select(index : int) -> void:
|
||||||
|
|
||||||
if Input.is_action_just_pressed("left_mouse"):
|
if Input.is_action_just_pressed("left_mouse"):
|
||||||
Global.color_pickers[0].color = color
|
Global.color_pickers[0].color = color
|
||||||
Global.update_left_custom_brush()
|
Global.update_custom_brush(0)
|
||||||
elif Input.is_action_just_pressed("right_mouse"):
|
elif Input.is_action_just_pressed("right_mouse"):
|
||||||
Global.color_pickers[1].color = color
|
Global.color_pickers[1].color = color
|
||||||
Global.update_right_custom_brush()
|
Global.update_custom_brush(1)
|
||||||
|
|
||||||
|
|
||||||
func _load_palettes() -> void:
|
func _load_palettes() -> void:
|
||||||
|
|
|
@ -12,76 +12,52 @@ func _on_BrushButton_pressed() -> void:
|
||||||
_on_DeleteButton_pressed()
|
_on_DeleteButton_pressed()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Change left brush
|
# Change brush
|
||||||
if Global.brush_type_window_position == "left":
|
Global.current_brush_types[Global.brush_type_window_position] = brush_type
|
||||||
Global.current_brush_type[0] = brush_type
|
Global.custom_brush_indexes[Global.brush_type_window_position] = custom_brush_index
|
||||||
Global.custom_left_brush_index = custom_brush_index
|
if custom_brush_index > -1: # Custom brush
|
||||||
if custom_brush_index > -1: # Custom brush
|
if Global.current_left_tool == Global.Tools.PENCIL:
|
||||||
if Global.current_left_tool == Global.Tools.PENCIL:
|
Global.color_interpolation_containers[Global.brush_type_window_position].visible = true
|
||||||
Global.color_interpolation_containers[0].visible = true
|
|
||||||
# if hint_tooltip == "":
|
# if hint_tooltip == "":
|
||||||
# Global.left_brush_type_label.text = tr("Custom brush")
|
# Global.left_brush_type_label.text = tr("Custom brush")
|
||||||
# else:
|
# else:
|
||||||
# Global.left_brush_type_label.text = tr("Brush:") + " %s" % hint_tooltip
|
# Global.left_brush_type_label.text = tr("Brush:") + " %s" % hint_tooltip
|
||||||
elif custom_brush_index == -3: # Pixel brush
|
elif custom_brush_index == -3: # Pixel brush
|
||||||
Global.color_interpolation_containers[0].visible = false
|
Global.color_interpolation_containers[Global.brush_type_window_position].visible = false
|
||||||
# Global.left_brush_type_label.text = tr("Brush: Pixel")
|
# Global.left_brush_type_label.text = tr("Brush: Pixel")
|
||||||
elif custom_brush_index == -2: # Circle brush
|
elif custom_brush_index == -2: # Circle brush
|
||||||
Global.color_interpolation_containers[0].visible = false
|
Global.color_interpolation_containers[Global.brush_type_window_position].visible = false
|
||||||
# Global.left_brush_type_label.text = tr("Brush: Circle")
|
# Global.left_brush_type_label.text = tr("Brush: Circle")
|
||||||
elif custom_brush_index == -1: # Filled Circle brush
|
elif custom_brush_index == -1: # Filled Circle brush
|
||||||
Global.color_interpolation_containers[0].visible = false
|
Global.color_interpolation_containers[Global.brush_type_window_position].visible = false
|
||||||
# Global.left_brush_type_label.text = tr("Brush: Filled Circle")
|
# Global.left_brush_type_label.text = tr("Brush: Filled Circle")
|
||||||
|
|
||||||
Global.update_left_custom_brush()
|
Global.update_custom_brush(Global.brush_type_window_position)
|
||||||
Global.brushes_popup.hide()
|
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()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_DeleteButton_pressed() -> void:
|
func _on_DeleteButton_pressed() -> void:
|
||||||
if brush_type == Global.Brush_Types.CUSTOM:
|
if brush_type == Global.Brush_Types.CUSTOM:
|
||||||
if Global.custom_left_brush_index == custom_brush_index:
|
if Global.custom_brush_indexes[0] == custom_brush_index:
|
||||||
Global.custom_left_brush_index = -3
|
Global.custom_brush_indexes[0] = -3
|
||||||
Global.current_brush_type[0] = Global.Brush_Types.PIXEL
|
Global.current_brush_types[0] = Global.Brush_Types.PIXEL
|
||||||
# Global.left_brush_type_label.text = "Brush: Pixel"
|
# Global.left_brush_type_label.text = "Brush: Pixel"
|
||||||
Global.update_left_custom_brush()
|
Global.update_custom_brush(0)
|
||||||
if Global.custom_right_brush_index == custom_brush_index:
|
if Global.custom_brush_indexes[1] == custom_brush_index:
|
||||||
Global.custom_right_brush_index = -3
|
Global.custom_brush_indexes[1] = -3
|
||||||
Global.current_brush_type[1] = Global.Brush_Types.PIXEL
|
Global.current_brush_types[1] = Global.Brush_Types.PIXEL
|
||||||
# Global.right_brush_type_label.text = "Brush: 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
|
var project_brush_index = custom_brush_index - Global.brushes_from_files
|
||||||
Global.undos += 1
|
Global.undos += 1
|
||||||
Global.undo_redo.create_action("Delete Custom Brush")
|
Global.undo_redo.create_action("Delete Custom Brush")
|
||||||
for i in range(project_brush_index, Global.project_brush_container.get_child_count()):
|
for i in range(project_brush_index, Global.project_brush_container.get_child_count()):
|
||||||
var bb = Global.project_brush_container.get_child(i)
|
var bb = Global.project_brush_container.get_child(i)
|
||||||
if Global.custom_left_brush_index == bb.custom_brush_index:
|
if Global.custom_brush_indexes[0] == bb.custom_brush_index:
|
||||||
Global.custom_left_brush_index -= 1
|
Global.custom_brush_indexes[0] -= 1
|
||||||
if Global.custom_right_brush_index == bb.custom_brush_index:
|
if Global.custom_brush_indexes[1] == bb.custom_brush_index:
|
||||||
Global.custom_right_brush_index -= 1
|
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_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)
|
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:
|
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[0].color = Global.color_pickers[1].color
|
||||||
Global.color_pickers[1].color = temp
|
Global.color_pickers[1].color = temp
|
||||||
Global.update_left_custom_brush()
|
Global.update_custom_brush(0)
|
||||||
Global.update_right_custom_brush()
|
Global.update_custom_brush(1)
|
||||||
|
|
||||||
|
|
||||||
func _on_ColorPickerButton_color_changed(color : Color, right : bool):
|
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 color.a == 0:
|
||||||
if previous_right_color.r != color.r or previous_right_color.g != color.g or previous_right_color.b != color.b:
|
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.color_pickers[1].color.a = 1
|
||||||
Global.update_right_custom_brush()
|
Global.update_custom_brush(1)
|
||||||
previous_right_color = color
|
previous_right_color = color
|
||||||
else:
|
else:
|
||||||
if color.a == 0:
|
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:
|
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.color_pickers[0].color.a = 1
|
||||||
Global.update_left_custom_brush()
|
Global.update_custom_brush(0)
|
||||||
previous_left_color = color
|
previous_left_color = color
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ func _on_ColorPickerButton_popup_closed() -> void:
|
||||||
func _on_ColorDefaults_pressed() -> void:
|
func _on_ColorDefaults_pressed() -> void:
|
||||||
Global.color_pickers[0].color = Color.black
|
Global.color_pickers[0].color = Color.black
|
||||||
Global.color_pickers[1].color = Color.white
|
Global.color_pickers[1].color = Color.white
|
||||||
Global.update_left_custom_brush()
|
Global.update_custom_brush(0)
|
||||||
Global.update_right_custom_brush()
|
Global.update_custom_brush(1)
|
||||||
|
|
||||||
|
|
||||||
func _on_FitToFrameButton_pressed() -> void:
|
func _on_FitToFrameButton_pressed() -> void:
|
||||||
|
@ -59,10 +59,10 @@ func _on_100ZoomButton_pressed() -> void:
|
||||||
func _on_BrushTypeButton_pressed(right : bool) -> void:
|
func _on_BrushTypeButton_pressed(right : bool) -> void:
|
||||||
if right:
|
if right:
|
||||||
Global.brushes_popup.popup(Rect2(Global.brush_type_buttons[1].rect_global_position, Vector2(226, 72)))
|
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:
|
else:
|
||||||
Global.brushes_popup.popup(Rect2(Global.brush_type_buttons[0].rect_global_position, Vector2(226, 72)))
|
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:
|
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_edits[1].value = value
|
||||||
Global.brush_size_sliders[1].value = value
|
Global.brush_size_sliders[1].value = value
|
||||||
Global.right_brush_size = new_size
|
Global.right_brush_size = new_size
|
||||||
Global.update_right_custom_brush()
|
Global.update_custom_brush(1)
|
||||||
else:
|
else:
|
||||||
Global.brush_size_edits[0].value = value
|
Global.brush_size_edits[0].value = value
|
||||||
Global.brush_size_sliders[0].value = value
|
Global.brush_size_sliders[0].value = value
|
||||||
Global.left_brush_size = new_size
|
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:
|
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:
|
if right:
|
||||||
Global.interpolate_spinboxes[1].value = value
|
Global.interpolate_spinboxes[1].value = value
|
||||||
Global.interpolate_sliders[1].value = value
|
Global.interpolate_sliders[1].value = value
|
||||||
Global.update_right_custom_brush()
|
Global.update_custom_brush(1)
|
||||||
else:
|
else:
|
||||||
Global.interpolate_spinboxes[0].value = value
|
Global.interpolate_spinboxes[0].value = value
|
||||||
Global.interpolate_sliders[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:
|
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:
|
func _on_PatternTypeButton_pressed(right : bool) -> void:
|
||||||
if right:
|
if right:
|
||||||
Global.pattern_window_position = "right"
|
Global.pattern_window_position = Global.Mouse_Button.RIGHT
|
||||||
Global.patterns_popup.popup(Rect2(Global.brush_type_buttons[1].rect_global_position, Vector2(226, 72)))
|
|
||||||
else:
|
else:
|
||||||
Global.pattern_window_position = "left"
|
Global.pattern_window_position = Global.Mouse_Button.LEFT
|
||||||
Global.patterns_popup.popup(Rect2(Global.brush_type_buttons[0].rect_global_position, Vector2(226, 72)))
|
|
||||||
|
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:
|
func _on_PatternOffsetX_value_changed(value : float, right : bool) -> void:
|
||||||
|
|
|
@ -14,16 +14,9 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_PatternButton_pressed() -> void:
|
func _on_PatternButton_pressed() -> void:
|
||||||
if Global.pattern_window_position == "left":
|
Global.pattern_images[Global.pattern_window_position] = image
|
||||||
Global.pattern_left_image = image
|
Global.fill_pattern_containers[Global.pattern_window_position].get_child(0).get_child(0).texture = texture
|
||||||
Global.fill_pattern_containers[0].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[0].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.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.patterns_popup.hide()
|
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.brush_size_sliders[current_mouse_button].visible = true
|
||||||
Global.pixel_perfect_containers[current_mouse_button].visible = true
|
Global.pixel_perfect_containers[current_mouse_button].visible = true
|
||||||
Global.mirror_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
|
Global.color_interpolation_containers[current_mouse_button].visible = true
|
||||||
elif current_tool == Global.Tools.ERASER:
|
elif current_tool == Global.Tools.ERASER:
|
||||||
Global.brush_type_containers[current_mouse_button].visible = true
|
Global.brush_type_containers[current_mouse_button].visible = true
|
||||||
|
|
Loading…
Reference in a new issue