mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Changes to better follow GDScript style guide
Nothing new is being added in this commit, just code re-ordering & re-naming to better follow the recommended GDScript style guide. http://docs.godotengine.org/en/3.2/getting_started/scripting/gdscript/gdscript_styleguide.html And https://www.gdquest.com/docs/guidelines/best-practices/godot-gdscript/
This commit is contained in:
parent
5fe4b74a39
commit
8ff917111c
|
@ -1,6 +1,6 @@
|
||||||
extends BaseButton
|
extends BaseButton
|
||||||
|
|
||||||
export var brush_type = 0 # Global.BRUSH_TYPES.PIXEL
|
export var brush_type = 0 # Global.Brush_Types.PIXEL
|
||||||
export var custom_brush_index := -3
|
export var custom_brush_index := -3
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var random_brushes := []
|
var random_brushes := []
|
||||||
|
@ -56,15 +56,15 @@ func _on_BrushButton_pressed() -> void:
|
||||||
Global.update_right_custom_brush()
|
Global.update_right_custom_brush()
|
||||||
|
|
||||||
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_left_brush_index == custom_brush_index:
|
||||||
Global.custom_left_brush_index = -3
|
Global.custom_left_brush_index = -3
|
||||||
Global.current_left_brush_type = Global.BRUSH_TYPES.PIXEL
|
Global.current_left_brush_type = 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_left_custom_brush()
|
||||||
if Global.custom_right_brush_index == custom_brush_index:
|
if Global.custom_right_brush_index == custom_brush_index:
|
||||||
Global.custom_right_brush_index = -3
|
Global.custom_right_brush_index = -3
|
||||||
Global.current_right_brush_type = Global.BRUSH_TYPES.PIXEL
|
Global.current_right_brush_type = 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_right_custom_brush()
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ func _on_DeleteButton_pressed() -> void:
|
||||||
Global.undo_redo.commit_action()
|
Global.undo_redo.commit_action()
|
||||||
|
|
||||||
func _on_BrushButton_mouse_entered() -> void:
|
func _on_BrushButton_mouse_entered() -> void:
|
||||||
if brush_type == Global.BRUSH_TYPES.CUSTOM:
|
if brush_type == Global.Brush_Types.CUSTOM:
|
||||||
$DeleteButton.visible = true
|
$DeleteButton.visible = true
|
||||||
|
|
||||||
func _on_BrushButton_mouse_exited() -> void:
|
func _on_BrushButton_mouse_exited() -> void:
|
||||||
if brush_type == Global.BRUSH_TYPES.CUSTOM:
|
if brush_type == Global.Brush_Types.CUSTOM:
|
||||||
$DeleteButton.visible = false
|
$DeleteButton.visible = false
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extends Node2D
|
|
||||||
class_name Canvas
|
class_name Canvas
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
var layers := []
|
var layers := []
|
||||||
var current_layer_index := 0
|
var current_layer_index := 0
|
||||||
|
@ -77,28 +77,98 @@ func _ready() -> void:
|
||||||
line_2d.add_point(previous_mouse_pos_for_lines)
|
line_2d.add_point(previous_mouse_pos_for_lines)
|
||||||
add_child(line_2d)
|
add_child(line_2d)
|
||||||
|
|
||||||
func camera_zoom() -> void:
|
func _draw() -> void:
|
||||||
# Set camera zoom based on the sprite size
|
draw_texture_rect(Global.transparent_background, Rect2(location, size), true) #Draw transparent background
|
||||||
var bigger = max(size.x, size.y)
|
#Onion Skinning
|
||||||
var zoom_max := Vector2(bigger, bigger) * 0.01
|
#Past
|
||||||
if zoom_max > Vector2.ONE:
|
if Global.onion_skinning_past_rate > 0:
|
||||||
Global.camera.zoom_max = zoom_max
|
var color : Color
|
||||||
Global.camera2.zoom_max = zoom_max
|
if Global.onion_skinning_blue_red:
|
||||||
Global.camera_preview.zoom_max = zoom_max
|
color = Color.blue
|
||||||
else:
|
else:
|
||||||
Global.camera.zoom_max = Vector2.ONE
|
color = Color.white
|
||||||
Global.camera2.zoom_max = Vector2.ONE
|
for i in range(1, Global.onion_skinning_past_rate + 1):
|
||||||
Global.camera_preview.zoom_max = Vector2.ONE
|
if Global.current_frame >= i:
|
||||||
|
for texture in Global.canvases[Global.current_frame - i].layers:
|
||||||
|
color.a = 0.6/i
|
||||||
|
draw_texture(texture[1], location, color)
|
||||||
|
|
||||||
Global.camera.zoom = Vector2(bigger, bigger) * 0.002
|
#Future
|
||||||
Global.camera2.zoom = Vector2(bigger, bigger) * 0.002
|
if Global.onion_skinning_future_rate > 0:
|
||||||
Global.camera_preview.zoom = Vector2(bigger, bigger) * 0.007
|
var color : Color
|
||||||
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
if Global.onion_skinning_blue_red:
|
||||||
|
color = Color.red
|
||||||
|
else:
|
||||||
|
color = Color.white
|
||||||
|
for i in range(1, Global.onion_skinning_future_rate + 1):
|
||||||
|
if Global.current_frame < Global.canvases.size() - i:
|
||||||
|
for texture in Global.canvases[Global.current_frame + i].layers:
|
||||||
|
color.a = 0.6/i
|
||||||
|
draw_texture(texture[1], location, color)
|
||||||
|
|
||||||
|
#Draw current frame layers
|
||||||
|
for texture in layers:
|
||||||
|
var modulate_color := Color(1, 1, 1, texture[4])
|
||||||
|
if texture[3]: #if it's visible
|
||||||
|
draw_texture(texture[1], location, modulate_color)
|
||||||
|
|
||||||
|
if Global.tile_mode:
|
||||||
|
draw_texture(texture[1], Vector2(location.x, location.y + size.y), modulate_color) #Down
|
||||||
|
draw_texture(texture[1], Vector2(location.x - size.x, location.y + size.y), modulate_color) #Down Left
|
||||||
|
draw_texture(texture[1], Vector2(location.x - size.x, location.y), modulate_color) #Left
|
||||||
|
draw_texture(texture[1], location - size, modulate_color) #Up left
|
||||||
|
draw_texture(texture[1], Vector2(location.x, location.y - size.y), modulate_color) #Up
|
||||||
|
draw_texture(texture[1], Vector2(location.x + size.x, location.y - size.y), modulate_color) #Up right
|
||||||
|
draw_texture(texture[1], Vector2(location.x + size.x, location.y), modulate_color) #Right
|
||||||
|
draw_texture(texture[1], location + size, modulate_color) #Down right
|
||||||
|
|
||||||
|
#Idea taken from flurick (on GitHub)
|
||||||
|
if Global.draw_grid:
|
||||||
|
for x in range(0, size.x, Global.grid_width):
|
||||||
|
draw_line(Vector2(x, location.y), Vector2(x, size.y), Global.grid_color, true)
|
||||||
|
for y in range(0, size.y, Global.grid_height):
|
||||||
|
draw_line(Vector2(location.x, y), Vector2(size.x, y), Global.grid_color, true)
|
||||||
|
|
||||||
|
#Draw rectangle to indicate the pixel currently being hovered on
|
||||||
|
var mouse_pos := current_pixel
|
||||||
|
if point_in_rectangle(mouse_pos, location, location + size):
|
||||||
|
mouse_pos = mouse_pos.floor()
|
||||||
|
if Global.left_square_indicator_visible && Global.can_draw:
|
||||||
|
if Global.current_left_brush_type == Global.Brush_Types.PIXEL || Global.current_left_tool == "LightenDarken":
|
||||||
|
if Global.current_left_tool == "Pencil" || Global.current_left_tool == "Eraser" || Global.current_left_tool == "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)
|
||||||
|
elif Global.current_left_brush_type == Global.Brush_Types.CIRCLE || Global.current_left_brush_type == Global.Brush_Types.FILLED_CIRCLE:
|
||||||
|
if Global.current_left_tool == "Pencil" || Global.current_left_tool == "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 == "Pencil" || Global.current_left_tool == "Eraser":
|
||||||
|
var custom_brush_size = Global.custom_left_brush_image.get_size() - Vector2.ONE
|
||||||
|
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
||||||
|
draw_texture(Global.custom_left_brush_texture, dst)
|
||||||
|
|
||||||
|
if Global.right_square_indicator_visible && Global.can_draw:
|
||||||
|
if Global.current_right_brush_type == Global.Brush_Types.PIXEL || Global.current_right_tool == "LightenDarken":
|
||||||
|
if Global.current_right_tool == "Pencil" || Global.current_right_tool == "Eraser" || Global.current_right_tool == "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)
|
||||||
|
elif Global.current_right_brush_type == Global.Brush_Types.CIRCLE || Global.current_right_brush_type == Global.Brush_Types.FILLED_CIRCLE:
|
||||||
|
if Global.current_right_tool == "Pencil" || Global.current_right_tool == "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 == "Pencil" || Global.current_right_tool == "Eraser":
|
||||||
|
var custom_brush_size = Global.custom_right_brush_image.get_size() - Vector2.ONE
|
||||||
|
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
||||||
|
draw_texture(Global.custom_right_brush_texture, dst)
|
||||||
|
|
||||||
# Set camera offset to the center of canvas
|
|
||||||
Global.camera.offset = size / 2
|
|
||||||
Global.camera2.offset = size / 2
|
|
||||||
Global.camera_preview.offset = size / 2
|
|
||||||
|
|
||||||
func _input(event : InputEvent) -> void:
|
func _input(event : InputEvent) -> void:
|
||||||
# Don't process anything below if the input isn't a mouse event, or Shift/Ctrl.
|
# Don't process anything below if the input isn't a mouse event, or Shift/Ctrl.
|
||||||
|
@ -350,6 +420,29 @@ func _input(event : InputEvent) -> void:
|
||||||
if sprite_changed_this_frame:
|
if sprite_changed_this_frame:
|
||||||
update_texture(current_layer_index, (Input.is_action_just_released("left_mouse") || Input.is_action_just_released("right_mouse")))
|
update_texture(current_layer_index, (Input.is_action_just_released("left_mouse") || Input.is_action_just_released("right_mouse")))
|
||||||
|
|
||||||
|
func camera_zoom() -> void:
|
||||||
|
# Set camera zoom based on the sprite size
|
||||||
|
var bigger = max(size.x, size.y)
|
||||||
|
var zoom_max := Vector2(bigger, bigger) * 0.01
|
||||||
|
if zoom_max > Vector2.ONE:
|
||||||
|
Global.camera.zoom_max = zoom_max
|
||||||
|
Global.camera2.zoom_max = zoom_max
|
||||||
|
Global.camera_preview.zoom_max = zoom_max
|
||||||
|
else:
|
||||||
|
Global.camera.zoom_max = Vector2.ONE
|
||||||
|
Global.camera2.zoom_max = Vector2.ONE
|
||||||
|
Global.camera_preview.zoom_max = Vector2.ONE
|
||||||
|
|
||||||
|
Global.camera.zoom = Vector2(bigger, bigger) * 0.002
|
||||||
|
Global.camera2.zoom = Vector2(bigger, bigger) * 0.002
|
||||||
|
Global.camera_preview.zoom = Vector2(bigger, bigger) * 0.007
|
||||||
|
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
||||||
|
|
||||||
|
# Set camera offset to the center of canvas
|
||||||
|
Global.camera.offset = size / 2
|
||||||
|
Global.camera2.offset = size / 2
|
||||||
|
Global.camera_preview.offset = size / 2
|
||||||
|
|
||||||
func handle_undo(action : String) -> void:
|
func handle_undo(action : String) -> void:
|
||||||
if !can_undo:
|
if !can_undo:
|
||||||
return
|
return
|
||||||
|
@ -427,98 +520,6 @@ func get_layer_container(layer_index : int) -> LayerContainer:
|
||||||
return container
|
return container
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func _draw() -> void:
|
|
||||||
draw_texture_rect(Global.transparent_background, Rect2(location, size), true) #Draw transparent background
|
|
||||||
#Onion Skinning
|
|
||||||
#Past
|
|
||||||
if Global.onion_skinning_past_rate > 0:
|
|
||||||
var color : Color
|
|
||||||
if Global.onion_skinning_blue_red:
|
|
||||||
color = Color.blue
|
|
||||||
else:
|
|
||||||
color = Color.white
|
|
||||||
for i in range(1, Global.onion_skinning_past_rate + 1):
|
|
||||||
if Global.current_frame >= i:
|
|
||||||
for texture in Global.canvases[Global.current_frame - i].layers:
|
|
||||||
color.a = 0.6/i
|
|
||||||
draw_texture(texture[1], location, color)
|
|
||||||
|
|
||||||
#Future
|
|
||||||
if Global.onion_skinning_future_rate > 0:
|
|
||||||
var color : Color
|
|
||||||
if Global.onion_skinning_blue_red:
|
|
||||||
color = Color.red
|
|
||||||
else:
|
|
||||||
color = Color.white
|
|
||||||
for i in range(1, Global.onion_skinning_future_rate + 1):
|
|
||||||
if Global.current_frame < Global.canvases.size() - i:
|
|
||||||
for texture in Global.canvases[Global.current_frame + i].layers:
|
|
||||||
color.a = 0.6/i
|
|
||||||
draw_texture(texture[1], location, color)
|
|
||||||
|
|
||||||
#Draw current frame layers
|
|
||||||
for texture in layers:
|
|
||||||
var modulate_color := Color(1, 1, 1, texture[4])
|
|
||||||
if texture[3]: #if it's visible
|
|
||||||
draw_texture(texture[1], location, modulate_color)
|
|
||||||
|
|
||||||
if Global.tile_mode:
|
|
||||||
draw_texture(texture[1], Vector2(location.x, location.y + size.y), modulate_color) #Down
|
|
||||||
draw_texture(texture[1], Vector2(location.x - size.x, location.y + size.y), modulate_color) #Down Left
|
|
||||||
draw_texture(texture[1], Vector2(location.x - size.x, location.y), modulate_color) #Left
|
|
||||||
draw_texture(texture[1], location - size, modulate_color) #Up left
|
|
||||||
draw_texture(texture[1], Vector2(location.x, location.y - size.y), modulate_color) #Up
|
|
||||||
draw_texture(texture[1], Vector2(location.x + size.x, location.y - size.y), modulate_color) #Up right
|
|
||||||
draw_texture(texture[1], Vector2(location.x + size.x, location.y), modulate_color) #Right
|
|
||||||
draw_texture(texture[1], location + size, modulate_color) #Down right
|
|
||||||
|
|
||||||
#Idea taken from flurick (on GitHub)
|
|
||||||
if Global.draw_grid:
|
|
||||||
for x in range(0, size.x, Global.grid_width):
|
|
||||||
draw_line(Vector2(x, location.y), Vector2(x, size.y), Global.grid_color, true)
|
|
||||||
for y in range(0, size.y, Global.grid_height):
|
|
||||||
draw_line(Vector2(location.x, y), Vector2(size.x, y), Global.grid_color, true)
|
|
||||||
|
|
||||||
#Draw rectangle to indicate the pixel currently being hovered on
|
|
||||||
var mouse_pos := current_pixel
|
|
||||||
if point_in_rectangle(mouse_pos, location, location + size):
|
|
||||||
mouse_pos = mouse_pos.floor()
|
|
||||||
if Global.left_square_indicator_visible && Global.can_draw:
|
|
||||||
if Global.current_left_brush_type == Global.BRUSH_TYPES.PIXEL || Global.current_left_tool == "LightenDarken":
|
|
||||||
if Global.current_left_tool == "Pencil" || Global.current_left_tool == "Eraser" || Global.current_left_tool == "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)
|
|
||||||
elif Global.current_left_brush_type == Global.BRUSH_TYPES.CIRCLE || Global.current_left_brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE:
|
|
||||||
if Global.current_left_tool == "Pencil" || Global.current_left_tool == "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 == "Pencil" || Global.current_left_tool == "Eraser":
|
|
||||||
var custom_brush_size = Global.custom_left_brush_image.get_size() - Vector2.ONE
|
|
||||||
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
|
||||||
draw_texture(Global.custom_left_brush_texture, dst)
|
|
||||||
|
|
||||||
if Global.right_square_indicator_visible && Global.can_draw:
|
|
||||||
if Global.current_right_brush_type == Global.BRUSH_TYPES.PIXEL || Global.current_right_tool == "LightenDarken":
|
|
||||||
if Global.current_right_tool == "Pencil" || Global.current_right_tool == "Eraser" || Global.current_right_tool == "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)
|
|
||||||
elif Global.current_right_brush_type == Global.BRUSH_TYPES.CIRCLE || Global.current_right_brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE:
|
|
||||||
if Global.current_right_tool == "Pencil" || Global.current_right_tool == "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 == "Pencil" || Global.current_right_tool == "Eraser":
|
|
||||||
var custom_brush_size = Global.custom_right_brush_image.get_size() - Vector2.ONE
|
|
||||||
var dst := rectangle_center(mouse_pos, custom_brush_size)
|
|
||||||
draw_texture(Global.custom_right_brush_texture, dst)
|
|
||||||
|
|
||||||
func generate_layer_panels() -> void:
|
func generate_layer_panels() -> void:
|
||||||
for child in Global.vbox_layer_container.get_children():
|
for child in Global.vbox_layer_container.get_children():
|
||||||
if child is LayerContainer:
|
if child is LayerContainer:
|
||||||
|
@ -562,14 +563,14 @@ func pencil_and_eraser(mouse_pos : Vector2, color : Color, current_mouse_button
|
||||||
func draw_brush(pos : Vector2, color : Color, current_mouse_button : String, current_action := "None") -> void:
|
func draw_brush(pos : Vector2, color : Color, current_mouse_button : String, current_action := "None") -> void:
|
||||||
if Global.can_draw && Global.has_focus:
|
if Global.can_draw && Global.has_focus:
|
||||||
var brush_size := 1
|
var brush_size := 1
|
||||||
var brush_type = Global.BRUSH_TYPES.PIXEL
|
var brush_type = Global.Brush_Types.PIXEL
|
||||||
var brush_index := -1
|
var brush_index := -1
|
||||||
var custom_brush_image : Image
|
var custom_brush_image : Image
|
||||||
var horizontal_mirror := false
|
var horizontal_mirror := false
|
||||||
var vertical_mirror := false
|
var vertical_mirror := false
|
||||||
var ld := 0
|
var ld := 0
|
||||||
var ld_amount := 0.1
|
var ld_amount := 0.1
|
||||||
if Global.pressure_sensitivity_mode == Global.PRESSURE_SENSITIVITY.ALPHA:
|
if Global.pressure_sensitivity_mode == Global.Pressure_Sensitivity.ALPHA:
|
||||||
if current_action == "Pencil":
|
if current_action == "Pencil":
|
||||||
color.a *= pen_pressure
|
color.a *= pen_pressure
|
||||||
elif current_action == "Eraser":
|
elif current_action == "Eraser":
|
||||||
|
@ -578,7 +579,7 @@ func draw_brush(pos : Vector2, color : Color, current_mouse_button : String, cur
|
||||||
brush_size = Global.left_brush_size
|
brush_size = Global.left_brush_size
|
||||||
brush_type = Global.current_left_brush_type
|
brush_type = Global.current_left_brush_type
|
||||||
brush_index = Global.custom_left_brush_index
|
brush_index = Global.custom_left_brush_index
|
||||||
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_left_brush_image
|
||||||
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)
|
||||||
|
@ -598,7 +599,7 @@ func draw_brush(pos : Vector2, color : Color, current_mouse_button : String, cur
|
||||||
brush_size = Global.right_brush_size
|
brush_size = Global.right_brush_size
|
||||||
brush_type = Global.current_right_brush_type
|
brush_type = Global.current_right_brush_type
|
||||||
brush_index = Global.custom_right_brush_index
|
brush_index = Global.custom_right_brush_index
|
||||||
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_right_brush_image
|
||||||
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)
|
||||||
|
@ -620,7 +621,7 @@ func draw_brush(pos : Vector2, color : Color, current_mouse_button : String, cur
|
||||||
var end_pos_x
|
var end_pos_x
|
||||||
var end_pos_y
|
var end_pos_y
|
||||||
|
|
||||||
if brush_type == Global.BRUSH_TYPES.PIXEL || current_action == "LightenDarken":
|
if brush_type == Global.Brush_Types.PIXEL || current_action == "LightenDarken":
|
||||||
start_pos_x = pos.x - (brush_size >> 1)
|
start_pos_x = pos.x - (brush_size >> 1)
|
||||||
start_pos_y = pos.y - (brush_size >> 1)
|
start_pos_y = pos.y - (brush_size >> 1)
|
||||||
end_pos_x = start_pos_x + brush_size
|
end_pos_x = start_pos_x + brush_size
|
||||||
|
@ -689,18 +690,18 @@ func draw_brush(pos : Vector2, color : Color, current_mouse_button : String, cur
|
||||||
layers[current_layer_index][0].set_pixel(mirror_x, mirror_y, _c)
|
layers[current_layer_index][0].set_pixel(mirror_x, mirror_y, _c)
|
||||||
sprite_changed_this_frame = true
|
sprite_changed_this_frame = true
|
||||||
|
|
||||||
elif brush_type == Global.BRUSH_TYPES.CIRCLE || brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE:
|
elif brush_type == Global.Brush_Types.CIRCLE || brush_type == Global.Brush_Types.FILLED_CIRCLE:
|
||||||
plot_circle(layers[current_layer_index][0], pos.x, pos.y, brush_size, color, brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE)
|
plot_circle(layers[current_layer_index][0], pos.x, pos.y, brush_size, color, brush_type == Global.Brush_Types.FILLED_CIRCLE)
|
||||||
|
|
||||||
# Handle mirroring
|
# Handle mirroring
|
||||||
var mirror_x := east_limit + west_limit - pos.x
|
var mirror_x := east_limit + west_limit - pos.x
|
||||||
var mirror_y := south_limit + north_limit - pos.y
|
var mirror_y := south_limit + north_limit - pos.y
|
||||||
if horizontal_mirror:
|
if horizontal_mirror:
|
||||||
plot_circle(layers[current_layer_index][0], mirror_x, pos.y, brush_size, color, brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE)
|
plot_circle(layers[current_layer_index][0], mirror_x, pos.y, brush_size, color, brush_type == Global.Brush_Types.FILLED_CIRCLE)
|
||||||
if vertical_mirror:
|
if vertical_mirror:
|
||||||
plot_circle(layers[current_layer_index][0], pos.x, mirror_y, brush_size, color, brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE)
|
plot_circle(layers[current_layer_index][0], pos.x, mirror_y, brush_size, color, brush_type == Global.Brush_Types.FILLED_CIRCLE)
|
||||||
if horizontal_mirror && vertical_mirror:
|
if horizontal_mirror && vertical_mirror:
|
||||||
plot_circle(layers[current_layer_index][0], mirror_x, mirror_y, brush_size, color, brush_type == Global.BRUSH_TYPES.FILLED_CIRCLE)
|
plot_circle(layers[current_layer_index][0], mirror_x, mirror_y, brush_size, color, brush_type == Global.Brush_Types.FILLED_CIRCLE)
|
||||||
|
|
||||||
sprite_changed_this_frame = true
|
sprite_changed_this_frame = true
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ func _on_AboutDialog_about_to_show() -> void:
|
||||||
translators.create_item(translators_root).set_text(0, " Michael Alexsander (YeldhamDev) - " + tr("Brazilian Portuguese"))
|
translators.create_item(translators_root).set_text(0, " Michael Alexsander (YeldhamDev) - " + tr("Brazilian Portuguese"))
|
||||||
translators.create_item(translators_root).set_text(0, " Andreev Andrei - " + tr("Russian"))
|
translators.create_item(translators_root).set_text(0, " Andreev Andrei - " + tr("Russian"))
|
||||||
translators.create_item(translators_root).set_text(0, " ax trifonov (ax34) - " + tr("Russian"))
|
translators.create_item(translators_root).set_text(0, " ax trifonov (ax34) - " + tr("Russian"))
|
||||||
|
translators.create_item(translators_root).set_text(0, " Artem (blinovartem) - " + tr("Russian"))
|
||||||
translators.create_item(translators_root).set_text(0, " JunYouIntrovert - " + tr("Chinese Traditional"))
|
translators.create_item(translators_root).set_text(0, " JunYouIntrovert - " + tr("Chinese Traditional"))
|
||||||
translators.create_item(translators_root).set_text(0, " Chenxu Wang - " + tr("Chinese Simplified"))
|
translators.create_item(translators_root).set_text(0, " Chenxu Wang - " + tr("Chinese Simplified"))
|
||||||
translators.create_item(translators_root).set_text(0, " Marco Galli (Gaarco) - " + tr("Italian"))
|
translators.create_item(translators_root).set_text(0, " Marco Galli (Gaarco) - " + tr("Italian"))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
var frame := 0
|
var frame := 0
|
||||||
|
|
||||||
onready var popup_menu := $PopupMenu
|
onready var popup_menu := $PopupMenu
|
||||||
|
|
||||||
func _on_FrameButton_pressed() -> void:
|
func _on_FrameButton_pressed() -> void:
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
enum Pressure_Sensitivity {NONE, ALPHA, SIZE}
|
||||||
|
enum Brush_Types {PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM}
|
||||||
|
|
||||||
var root_directory := "."
|
var root_directory := "."
|
||||||
var config_cache := ConfigFile.new()
|
var config_cache := ConfigFile.new()
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
|
@ -16,8 +19,8 @@ var has_focus := false
|
||||||
var canvases := []
|
var canvases := []
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var hidden_canvases := []
|
var hidden_canvases := []
|
||||||
enum PRESSURE_SENSITIVITY {NONE, ALPHA, SIZE}
|
|
||||||
var pressure_sensitivity_mode = PRESSURE_SENSITIVITY.ALPHA
|
var pressure_sensitivity_mode = Pressure_Sensitivity.ALPHA
|
||||||
var smooth_zoom := true
|
var smooth_zoom := true
|
||||||
var left_cursor_tool_texture : ImageTexture
|
var left_cursor_tool_texture : ImageTexture
|
||||||
var right_cursor_tool_texture : ImageTexture
|
var right_cursor_tool_texture : ImageTexture
|
||||||
|
@ -107,15 +110,14 @@ var onion_skinning_future_rate := 0
|
||||||
var onion_skinning_blue_red := false
|
var onion_skinning_blue_red := false
|
||||||
|
|
||||||
# Brushes
|
# Brushes
|
||||||
enum BRUSH_TYPES {PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM}
|
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var left_brush_size := 1
|
var left_brush_size := 1
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var right_brush_size := 1
|
var right_brush_size := 1
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var current_left_brush_type = BRUSH_TYPES.PIXEL
|
var current_left_brush_type = Brush_Types.PIXEL
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var current_right_brush_type = BRUSH_TYPES.PIXEL
|
var current_right_brush_type = Brush_Types.PIXEL
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var brush_type_window_position := "left"
|
var brush_type_window_position := "left"
|
||||||
var left_circle_points := []
|
var left_circle_points := []
|
||||||
|
@ -486,12 +488,12 @@ func frame_changed(value : int) -> void:
|
||||||
canvas.frame_button.get_node("FrameID").add_color_override("font_color", Color("#3c5d75"))
|
canvas.frame_button.get_node("FrameID").add_color_override("font_color", Color("#3c5d75"))
|
||||||
|
|
||||||
|
|
||||||
func create_brush_button(brush_img : Image, brush_type := BRUSH_TYPES.CUSTOM, hint_tooltip := "") -> void:
|
func create_brush_button(brush_img : Image, brush_type := Brush_Types.CUSTOM, hint_tooltip := "") -> void:
|
||||||
var brush_container
|
var brush_container
|
||||||
var brush_button = load("res://Prefabs/BrushButton.tscn").instance()
|
var brush_button = load("res://Prefabs/BrushButton.tscn").instance()
|
||||||
brush_button.brush_type = brush_type
|
brush_button.brush_type = brush_type
|
||||||
brush_button.custom_brush_index = custom_brushes.size() - 1
|
brush_button.custom_brush_index = custom_brushes.size() - 1
|
||||||
if brush_type == BRUSH_TYPES.FILE || brush_type == BRUSH_TYPES.RANDOM_FILE:
|
if brush_type == Brush_Types.FILE || brush_type == Brush_Types.RANDOM_FILE:
|
||||||
brush_container = file_brush_container
|
brush_container = file_brush_container
|
||||||
else:
|
else:
|
||||||
brush_container = project_brush_container
|
brush_container = project_brush_container
|
||||||
|
@ -499,13 +501,13 @@ func create_brush_button(brush_img : Image, brush_type := BRUSH_TYPES.CUSTOM, hi
|
||||||
brush_tex.create_from_image(brush_img, 0)
|
brush_tex.create_from_image(brush_img, 0)
|
||||||
brush_button.get_child(0).texture = brush_tex
|
brush_button.get_child(0).texture = brush_tex
|
||||||
brush_button.hint_tooltip = hint_tooltip
|
brush_button.hint_tooltip = hint_tooltip
|
||||||
if brush_type == BRUSH_TYPES.RANDOM_FILE:
|
if brush_type == Brush_Types.RANDOM_FILE:
|
||||||
brush_button.random_brushes.append(brush_img)
|
brush_button.random_brushes.append(brush_img)
|
||||||
brush_container.add_child(brush_button)
|
brush_container.add_child(brush_button)
|
||||||
|
|
||||||
func remove_brush_buttons() -> void:
|
func remove_brush_buttons() -> void:
|
||||||
current_left_brush_type = BRUSH_TYPES.PIXEL
|
current_left_brush_type = Brush_Types.PIXEL
|
||||||
current_right_brush_type = BRUSH_TYPES.PIXEL
|
current_right_brush_type = 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()
|
||||||
|
|
||||||
|
@ -528,16 +530,16 @@ func redo_custom_brush(_brush_button : BaseButton = null) -> void:
|
||||||
notification_label("Redo: %s" % action_name)
|
notification_label("Redo: %s" % action_name)
|
||||||
|
|
||||||
func update_left_custom_brush() -> void:
|
func update_left_custom_brush() -> void:
|
||||||
if current_left_brush_type == BRUSH_TYPES.PIXEL:
|
if current_left_brush_type == 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")
|
||||||
left_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
left_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||||
elif current_left_brush_type == BRUSH_TYPES.CIRCLE:
|
elif current_left_brush_type == 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")
|
||||||
left_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
left_brush_type_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_left_brush_type == BRUSH_TYPES.FILLED_CIRCLE:
|
elif current_left_brush_type == 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")
|
||||||
left_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
left_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||||
|
@ -553,16 +555,16 @@ func update_left_custom_brush() -> void:
|
||||||
left_brush_type_button.get_child(0).texture = custom_left_brush_texture
|
left_brush_type_button.get_child(0).texture = custom_left_brush_texture
|
||||||
|
|
||||||
func update_right_custom_brush() -> void:
|
func update_right_custom_brush() -> void:
|
||||||
if current_right_brush_type == BRUSH_TYPES.PIXEL:
|
if current_right_brush_type == 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")
|
||||||
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||||
elif current_right_brush_type == BRUSH_TYPES.CIRCLE:
|
elif current_right_brush_type == 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")
|
||||||
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||||
right_circle_points = plot_circle(right_brush_size)
|
right_circle_points = plot_circle(right_brush_size)
|
||||||
elif current_right_brush_type == BRUSH_TYPES.FILLED_CIRCLE:
|
elif current_right_brush_type == 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")
|
||||||
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||||
|
|
|
@ -30,14 +30,14 @@ func find_brushes(brushes_dir : Directory, path : String) -> Array:
|
||||||
found_random_brush = Global.file_brush_container.get_child_count()
|
found_random_brush = Global.file_brush_container.get_child_count()
|
||||||
image.convert(Image.FORMAT_RGBA8)
|
image.convert(Image.FORMAT_RGBA8)
|
||||||
Global.custom_brushes.append(image)
|
Global.custom_brushes.append(image)
|
||||||
Global.create_brush_button(image, Global.BRUSH_TYPES.RANDOM_FILE, file.trim_suffix(".png"))
|
Global.create_brush_button(image, Global.Brush_Types.RANDOM_FILE, file.trim_suffix(".png"))
|
||||||
else:
|
else:
|
||||||
var brush_button = Global.file_brush_container.get_child(found_random_brush)
|
var brush_button = Global.file_brush_container.get_child(found_random_brush)
|
||||||
brush_button.random_brushes.append(image)
|
brush_button.random_brushes.append(image)
|
||||||
else:
|
else:
|
||||||
image.convert(Image.FORMAT_RGBA8)
|
image.convert(Image.FORMAT_RGBA8)
|
||||||
Global.custom_brushes.append(image)
|
Global.custom_brushes.append(image)
|
||||||
Global.create_brush_button(image, Global.BRUSH_TYPES.FILE, file.trim_suffix(".png"))
|
Global.create_brush_button(image, Global.Brush_Types.FILE, file.trim_suffix(".png"))
|
||||||
elif file.get_extension() == "": # Probably a directory
|
elif file.get_extension() == "": # Probably a directory
|
||||||
var subdir := "./%s" % [file]
|
var subdir := "./%s" % [file]
|
||||||
if brushes_dir.dir_exists(subdir): # If it's an actual directory
|
if brushes_dir.dir_exists(subdir): # If it's an actual directory
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extends Button
|
|
||||||
class_name LayerContainer
|
class_name LayerContainer
|
||||||
|
extends Button
|
||||||
|
|
||||||
var i
|
var i
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
|
|
|
@ -5,7 +5,6 @@ var opensprite_file_selected := false
|
||||||
var file_menu : PopupMenu
|
var file_menu : PopupMenu
|
||||||
var view_menu : PopupMenu
|
var view_menu : PopupMenu
|
||||||
var tools := []
|
var tools := []
|
||||||
|
|
||||||
var redone := false
|
var redone := false
|
||||||
var previous_left_color := Color.black
|
var previous_left_color := Color.black
|
||||||
var previous_right_color := Color.white
|
var previous_right_color := Color.white
|
||||||
|
@ -415,7 +414,7 @@ func _on_OpenSprite_file_selected(path : String) -> void:
|
||||||
var guide := Guide.new()
|
var guide := Guide.new()
|
||||||
guide.default_color = Color.purple
|
guide.default_color = Color.purple
|
||||||
guide.type = file.get_8()
|
guide.type = file.get_8()
|
||||||
if guide.type == guide.TYPE.HORIZONTAL:
|
if guide.type == guide.Types.HORIZONTAL:
|
||||||
guide.add_point(Vector2(-99999, file.get_16()))
|
guide.add_point(Vector2(-99999, file.get_16()))
|
||||||
guide.add_point(Vector2(99999, file.get_16()))
|
guide.add_point(Vector2(99999, file.get_16()))
|
||||||
else:
|
else:
|
||||||
|
@ -492,7 +491,7 @@ func _on_SaveSprite_file_selected(path : String) -> void:
|
||||||
if child is Guide:
|
if child is Guide:
|
||||||
file.store_line("|")
|
file.store_line("|")
|
||||||
file.store_8(child.type)
|
file.store_8(child.type)
|
||||||
if child.type == child.TYPE.HORIZONTAL:
|
if child.type == child.Types.HORIZONTAL:
|
||||||
file.store_16(child.points[0].y)
|
file.store_16(child.points[0].y)
|
||||||
file.store_16(child.points[1].y)
|
file.store_16(child.points[1].y)
|
||||||
else:
|
else:
|
||||||
|
@ -571,7 +570,7 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
|
||||||
Global.left_brush_type_container.visible = true
|
Global.left_brush_type_container.visible = true
|
||||||
Global.left_brush_size_container.visible = true
|
Global.left_brush_size_container.visible = true
|
||||||
Global.left_mirror_container.visible = true
|
Global.left_mirror_container.visible = true
|
||||||
if Global.current_left_brush_type == Global.BRUSH_TYPES.FILE || Global.current_left_brush_type == Global.BRUSH_TYPES.CUSTOM || Global.current_left_brush_type == Global.BRUSH_TYPES.RANDOM_FILE:
|
if Global.current_left_brush_type == Global.Brush_Types.FILE || Global.current_left_brush_type == Global.Brush_Types.CUSTOM || Global.current_left_brush_type == Global.Brush_Types.RANDOM_FILE:
|
||||||
Global.left_color_interpolation_container.visible = true
|
Global.left_color_interpolation_container.visible = true
|
||||||
elif current_action == "Eraser":
|
elif current_action == "Eraser":
|
||||||
Global.left_brush_type_container.visible = true
|
Global.left_brush_type_container.visible = true
|
||||||
|
@ -598,7 +597,7 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
|
||||||
Global.right_brush_type_container.visible = true
|
Global.right_brush_type_container.visible = true
|
||||||
Global.right_brush_size_container.visible = true
|
Global.right_brush_size_container.visible = true
|
||||||
Global.right_mirror_container.visible = true
|
Global.right_mirror_container.visible = true
|
||||||
if Global.current_right_brush_type == Global.BRUSH_TYPES.FILE || Global.current_right_brush_type == Global.BRUSH_TYPES.CUSTOM || Global.current_right_brush_type == Global.BRUSH_TYPES.RANDOM_FILE:
|
if Global.current_right_brush_type == Global.Brush_Types.FILE || Global.current_right_brush_type == Global.Brush_Types.CUSTOM || Global.current_right_brush_type == Global.Brush_Types.RANDOM_FILE:
|
||||||
Global.right_color_interpolation_container.visible = true
|
Global.right_color_interpolation_container.visible = true
|
||||||
elif current_action == "Eraser":
|
elif current_action == "Eraser":
|
||||||
Global.right_brush_type_container.visible = true
|
Global.right_brush_type_container.visible = true
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
extends WindowDialog
|
extends WindowDialog
|
||||||
|
|
||||||
onready var color_picker = $VBoxContainer/HBoxContainer/EditPaletteColorPicker
|
|
||||||
onready var palette_grid = $VBoxContainer/HBoxContainer/Panel/ScrollContainer/EditPaletteGridContainer
|
|
||||||
onready var color_name_edit = $VBoxContainer/PaletteOptions/EditPaletteColorNameLineEdit
|
|
||||||
onready var palette_name_edit = $VBoxContainer/PaletteOptions/EditPaletteNameLineEdit
|
|
||||||
|
|
||||||
var palette_button = preload("res://Prefabs/PaletteButton.tscn")
|
var palette_button = preload("res://Prefabs/PaletteButton.tscn")
|
||||||
|
|
||||||
var current_palette : String
|
var current_palette : String
|
||||||
var current_swatch := -1
|
var current_swatch := -1
|
||||||
var working_palette : Palette
|
var working_palette : Palette
|
||||||
|
|
||||||
|
onready var color_picker = $VBoxContainer/HBoxContainer/EditPaletteColorPicker
|
||||||
|
onready var palette_grid = $VBoxContainer/HBoxContainer/Panel/ScrollContainer/EditPaletteGridContainer
|
||||||
|
onready var color_name_edit = $VBoxContainer/PaletteOptions/EditPaletteColorNameLineEdit
|
||||||
|
onready var palette_name_edit = $VBoxContainer/PaletteOptions/EditPaletteNameLineEdit
|
||||||
|
|
||||||
func open(palette : String) -> void:
|
func open(palette : String) -> void:
|
||||||
current_palette = palette
|
current_palette = palette
|
||||||
palette_name_edit.text = current_palette
|
palette_name_edit.text = current_palette
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extends Reference
|
|
||||||
class_name Palette
|
class_name Palette
|
||||||
|
extends Reference
|
||||||
|
|
||||||
func get_class():
|
func get_class():
|
||||||
return "Palette"
|
return "Palette"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extends Reference
|
|
||||||
class_name PaletteColor
|
class_name PaletteColor
|
||||||
|
extends Reference
|
||||||
|
|
||||||
func get_class():
|
func get_class():
|
||||||
return "PaletteColor"
|
return "PaletteColor"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
extends Line2D
|
|
||||||
class_name Guide
|
class_name Guide
|
||||||
|
extends Line2D
|
||||||
|
|
||||||
enum TYPE {HORIZONTAL, VERTICAL}
|
enum Types {HORIZONTAL, VERTICAL}
|
||||||
|
|
||||||
var font := preload("res://Assets/Fonts/Roboto-Regular.tres")
|
var font := preload("res://Assets/Fonts/Roboto-Regular.tres")
|
||||||
var has_focus := true
|
var has_focus := true
|
||||||
var mouse_pos := Vector2.ZERO
|
var mouse_pos := Vector2.ZERO
|
||||||
var previous_points := points
|
var previous_points := points
|
||||||
var type = TYPE.HORIZONTAL
|
var type = Types.HORIZONTAL
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
width = 0.1
|
width = 0.1
|
||||||
|
@ -19,7 +19,7 @@ func _process(delta : float) -> void:
|
||||||
mouse_pos = get_local_mouse_position()
|
mouse_pos = get_local_mouse_position()
|
||||||
var point0 := points[0]
|
var point0 := points[0]
|
||||||
var point1 := points[1]
|
var point1 := points[1]
|
||||||
if type == TYPE.HORIZONTAL:
|
if type == Types.HORIZONTAL:
|
||||||
point0.y -= width * 3
|
point0.y -= width * 3
|
||||||
point1.y += width * 3
|
point1.y += width * 3
|
||||||
else:
|
else:
|
||||||
|
@ -34,7 +34,7 @@ func _process(delta : float) -> void:
|
||||||
if Input.is_action_just_pressed("left_mouse"):
|
if Input.is_action_just_pressed("left_mouse"):
|
||||||
previous_points = points
|
previous_points = points
|
||||||
if Input.is_action_pressed("left_mouse"):
|
if Input.is_action_pressed("left_mouse"):
|
||||||
if type == TYPE.HORIZONTAL:
|
if type == Types.HORIZONTAL:
|
||||||
points[0].y = round(mouse_pos.y)
|
points[0].y = round(mouse_pos.y)
|
||||||
points[1].y = round(mouse_pos.y)
|
points[1].y = round(mouse_pos.y)
|
||||||
else:
|
else:
|
||||||
|
@ -58,7 +58,7 @@ func _draw() -> void:
|
||||||
if has_focus:
|
if has_focus:
|
||||||
var viewport_size: Vector2 = Global.main_viewport.rect_size
|
var viewport_size: Vector2 = Global.main_viewport.rect_size
|
||||||
var zoom: Vector2 = Global.camera.zoom
|
var zoom: Vector2 = Global.camera.zoom
|
||||||
if type == TYPE.HORIZONTAL:
|
if type == Types.HORIZONTAL:
|
||||||
draw_set_transform(Vector2(Global.camera.offset.x - (viewport_size.x / 2) * zoom.x, points[0].y + font.get_height() * zoom.x * 2), rotation, zoom * 2)
|
draw_set_transform(Vector2(Global.camera.offset.x - (viewport_size.x / 2) * zoom.x, points[0].y + font.get_height() * zoom.x * 2), rotation, zoom * 2)
|
||||||
draw_string(font, Vector2.ZERO, "%spx" % str(round(mouse_pos.y)))
|
draw_string(font, Vector2.ZERO, "%spx" % str(round(mouse_pos.y)))
|
||||||
else:
|
else:
|
||||||
|
@ -73,7 +73,7 @@ func outside_canvas(undo := false) -> bool:
|
||||||
if Global.undos < Global.undo_redo.get_version(): #If we did undo and then redo
|
if Global.undos < Global.undo_redo.get_version(): #If we did undo and then redo
|
||||||
Global.undos = Global.undo_redo.get_version()
|
Global.undos = Global.undo_redo.get_version()
|
||||||
Global.notification_label("Move Guide")
|
Global.notification_label("Move Guide")
|
||||||
if type == TYPE.HORIZONTAL:
|
if type == Types.HORIZONTAL:
|
||||||
if points[0].y < 0 || points[0].y > Global.canvas.size.y:
|
if points[0].y < 0 || points[0].y > Global.canvas.size.y:
|
||||||
queue_free()
|
queue_free()
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -77,7 +77,7 @@ func _on_HorizontalRuler_pressed() -> void:
|
||||||
if mouse_pos.x < RULER_WIDTH: #For double guides
|
if mouse_pos.x < RULER_WIDTH: #For double guides
|
||||||
Global.vertical_ruler._on_VerticalRuler_pressed()
|
Global.vertical_ruler._on_VerticalRuler_pressed()
|
||||||
var guide := Guide.new()
|
var guide := Guide.new()
|
||||||
guide.type = guide.TYPE.HORIZONTAL
|
guide.type = guide.Types.HORIZONTAL
|
||||||
guide.add_point(Vector2(-99999, Global.canvas.current_pixel.y))
|
guide.add_point(Vector2(-99999, Global.canvas.current_pixel.y))
|
||||||
guide.add_point(Vector2(99999, Global.canvas.current_pixel.y))
|
guide.add_point(Vector2(99999, Global.canvas.current_pixel.y))
|
||||||
Global.canvas.add_child(guide)
|
Global.canvas.add_child(guide)
|
||||||
|
|
|
@ -72,7 +72,7 @@ func _on_VerticalRuler_pressed() -> void:
|
||||||
if !Global.show_guides:
|
if !Global.show_guides:
|
||||||
return
|
return
|
||||||
var guide := Guide.new()
|
var guide := Guide.new()
|
||||||
guide.type = guide.TYPE.VERTICAL
|
guide.type = guide.Types.VERTICAL
|
||||||
guide.add_point(Vector2(Global.canvas.current_pixel.x, -99999))
|
guide.add_point(Vector2(Global.canvas.current_pixel.x, -99999))
|
||||||
guide.add_point(Vector2(Global.canvas.current_pixel.x, 99999))
|
guide.add_point(Vector2(Global.canvas.current_pixel.x, 99999))
|
||||||
Global.canvas.add_child(guide)
|
Global.canvas.add_child(guide)
|
||||||
|
|
Loading…
Reference in a new issue