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
|
||||
|
||||
export var brush_type = 0 # Global.BRUSH_TYPES.PIXEL
|
||||
export var brush_type = 0 # Global.Brush_Types.PIXEL
|
||||
export var custom_brush_index := -3
|
||||
# warning-ignore:unused_class_variable
|
||||
var random_brushes := []
|
||||
|
@ -56,15 +56,15 @@ func _on_BrushButton_pressed() -> void:
|
|||
Global.update_right_custom_brush()
|
||||
|
||||
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:
|
||||
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.update_left_custom_brush()
|
||||
if Global.custom_right_brush_index == custom_brush_index:
|
||||
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.update_right_custom_brush()
|
||||
|
||||
|
@ -91,9 +91,9 @@ func _on_DeleteButton_pressed() -> void:
|
|||
Global.undo_redo.commit_action()
|
||||
|
||||
func _on_BrushButton_mouse_entered() -> void:
|
||||
if brush_type == Global.BRUSH_TYPES.CUSTOM:
|
||||
if brush_type == Global.Brush_Types.CUSTOM:
|
||||
$DeleteButton.visible = true
|
||||
|
||||
func _on_BrushButton_mouse_exited() -> void:
|
||||
if brush_type == Global.BRUSH_TYPES.CUSTOM:
|
||||
if brush_type == Global.Brush_Types.CUSTOM:
|
||||
$DeleteButton.visible = false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extends Node2D
|
||||
class_name Canvas
|
||||
extends Node2D
|
||||
|
||||
var layers := []
|
||||
var current_layer_index := 0
|
||||
|
@ -77,28 +77,98 @@ func _ready() -> void:
|
|||
line_2d.add_point(previous_mouse_pos_for_lines)
|
||||
add_child(line_2d)
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
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)) + " %"
|
||||
#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)
|
||||
|
||||
# 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:
|
||||
# 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:
|
||||
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:
|
||||
if !can_undo:
|
||||
return
|
||||
|
@ -427,98 +520,6 @@ func get_layer_container(layer_index : int) -> LayerContainer:
|
|||
return container
|
||||
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:
|
||||
for child in Global.vbox_layer_container.get_children():
|
||||
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:
|
||||
if Global.can_draw && Global.has_focus:
|
||||
var brush_size := 1
|
||||
var brush_type = Global.BRUSH_TYPES.PIXEL
|
||||
var brush_type = Global.Brush_Types.PIXEL
|
||||
var brush_index := -1
|
||||
var custom_brush_image : Image
|
||||
var horizontal_mirror := false
|
||||
var vertical_mirror := false
|
||||
var ld := 0
|
||||
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":
|
||||
color.a *= pen_pressure
|
||||
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_type = Global.current_left_brush_type
|
||||
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
|
||||
else: # Handle random brush
|
||||
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_type = Global.current_right_brush_type
|
||||
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
|
||||
else: # Handle random brush
|
||||
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_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_y = pos.y - (brush_size >> 1)
|
||||
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)
|
||||
sprite_changed_this_frame = true
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
# Handle mirroring
|
||||
var mirror_x := east_limit + west_limit - pos.x
|
||||
var mirror_y := south_limit + north_limit - pos.y
|
||||
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:
|
||||
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:
|
||||
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
|
||||
|
||||
|
|
|
@ -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, " 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, " Artem (blinovartem) - " + tr("Russian"))
|
||||
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, " Marco Galli (Gaarco) - " + tr("Italian"))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
extends Button
|
||||
|
||||
var frame := 0
|
||||
|
||||
onready var popup_menu := $PopupMenu
|
||||
|
||||
func _on_FrameButton_pressed() -> void:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
extends Node
|
||||
|
||||
enum Pressure_Sensitivity {NONE, ALPHA, SIZE}
|
||||
enum Brush_Types {PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM}
|
||||
|
||||
var root_directory := "."
|
||||
var config_cache := ConfigFile.new()
|
||||
# warning-ignore:unused_class_variable
|
||||
|
@ -16,8 +19,8 @@ var has_focus := false
|
|||
var canvases := []
|
||||
# warning-ignore:unused_class_variable
|
||||
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 left_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
|
||||
|
||||
# Brushes
|
||||
enum BRUSH_TYPES {PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM}
|
||||
# warning-ignore:unused_class_variable
|
||||
var left_brush_size := 1
|
||||
# warning-ignore:unused_class_variable
|
||||
var right_brush_size := 1
|
||||
# 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
|
||||
var current_right_brush_type = BRUSH_TYPES.PIXEL
|
||||
var current_right_brush_type = Brush_Types.PIXEL
|
||||
# warning-ignore:unused_class_variable
|
||||
var brush_type_window_position := "left"
|
||||
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"))
|
||||
|
||||
|
||||
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_button = load("res://Prefabs/BrushButton.tscn").instance()
|
||||
brush_button.brush_type = brush_type
|
||||
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
|
||||
else:
|
||||
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_button.get_child(0).texture = brush_tex
|
||||
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_container.add_child(brush_button)
|
||||
|
||||
func remove_brush_buttons() -> void:
|
||||
current_left_brush_type = BRUSH_TYPES.PIXEL
|
||||
current_right_brush_type = BRUSH_TYPES.PIXEL
|
||||
current_left_brush_type = Brush_Types.PIXEL
|
||||
current_right_brush_type = Brush_Types.PIXEL
|
||||
for child in project_brush_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
|
@ -528,16 +530,16 @@ func redo_custom_brush(_brush_button : BaseButton = null) -> void:
|
|||
notification_label("Redo: %s" % action_name)
|
||||
|
||||
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()
|
||||
pixel = preload("res://Assets/Graphics/pixel_image.png")
|
||||
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()
|
||||
pixel = preload("res://Assets/Graphics/circle_9x9.png")
|
||||
left_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||
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()
|
||||
pixel = preload("res://Assets/Graphics/circle_filled_9x9.png")
|
||||
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
|
||||
|
||||
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()
|
||||
pixel = preload("res://Assets/Graphics/pixel_image.png")
|
||||
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()
|
||||
pixel = preload("res://Assets/Graphics/circle_9x9.png")
|
||||
right_brush_type_button.get_child(0).texture.create_from_image(pixel, 0)
|
||||
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()
|
||||
pixel = preload("res://Assets/Graphics/circle_filled_9x9.png")
|
||||
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()
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
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:
|
||||
var brush_button = Global.file_brush_container.get_child(found_random_brush)
|
||||
brush_button.random_brushes.append(image)
|
||||
else:
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
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
|
||||
var subdir := "./%s" % [file]
|
||||
if brushes_dir.dir_exists(subdir): # If it's an actual directory
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extends Button
|
||||
class_name LayerContainer
|
||||
extends Button
|
||||
|
||||
var i
|
||||
# warning-ignore:unused_class_variable
|
||||
|
|
|
@ -5,7 +5,6 @@ var opensprite_file_selected := false
|
|||
var file_menu : PopupMenu
|
||||
var view_menu : PopupMenu
|
||||
var tools := []
|
||||
|
||||
var redone := false
|
||||
var previous_left_color := Color.black
|
||||
var previous_right_color := Color.white
|
||||
|
@ -415,7 +414,7 @@ func _on_OpenSprite_file_selected(path : String) -> void:
|
|||
var guide := Guide.new()
|
||||
guide.default_color = Color.purple
|
||||
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()))
|
||||
else:
|
||||
|
@ -492,7 +491,7 @@ func _on_SaveSprite_file_selected(path : String) -> void:
|
|||
if child is Guide:
|
||||
file.store_line("|")
|
||||
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[1].y)
|
||||
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_size_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
|
||||
elif current_action == "Eraser":
|
||||
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_size_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
|
||||
elif current_action == "Eraser":
|
||||
Global.right_brush_type_container.visible = true
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
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 current_palette : String
|
||||
var current_swatch := -1
|
||||
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:
|
||||
current_palette = palette
|
||||
palette_name_edit.text = current_palette
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extends Reference
|
||||
class_name Palette
|
||||
extends Reference
|
||||
|
||||
func get_class():
|
||||
return "Palette"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extends Reference
|
||||
class_name PaletteColor
|
||||
extends Reference
|
||||
|
||||
func get_class():
|
||||
return "PaletteColor"
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
extends Line2D
|
||||
class_name Guide
|
||||
extends Line2D
|
||||
|
||||
enum TYPE {HORIZONTAL, VERTICAL}
|
||||
enum Types {HORIZONTAL, VERTICAL}
|
||||
|
||||
var font := preload("res://Assets/Fonts/Roboto-Regular.tres")
|
||||
var has_focus := true
|
||||
var mouse_pos := Vector2.ZERO
|
||||
var previous_points := points
|
||||
var type = TYPE.HORIZONTAL
|
||||
var type = Types.HORIZONTAL
|
||||
|
||||
func _ready() -> void:
|
||||
width = 0.1
|
||||
|
@ -19,7 +19,7 @@ func _process(delta : float) -> void:
|
|||
mouse_pos = get_local_mouse_position()
|
||||
var point0 := points[0]
|
||||
var point1 := points[1]
|
||||
if type == TYPE.HORIZONTAL:
|
||||
if type == Types.HORIZONTAL:
|
||||
point0.y -= width * 3
|
||||
point1.y += width * 3
|
||||
else:
|
||||
|
@ -34,7 +34,7 @@ func _process(delta : float) -> void:
|
|||
if Input.is_action_just_pressed("left_mouse"):
|
||||
previous_points = points
|
||||
if Input.is_action_pressed("left_mouse"):
|
||||
if type == TYPE.HORIZONTAL:
|
||||
if type == Types.HORIZONTAL:
|
||||
points[0].y = round(mouse_pos.y)
|
||||
points[1].y = round(mouse_pos.y)
|
||||
else:
|
||||
|
@ -58,7 +58,7 @@ func _draw() -> void:
|
|||
if has_focus:
|
||||
var viewport_size: Vector2 = Global.main_viewport.rect_size
|
||||
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_string(font, Vector2.ZERO, "%spx" % str(round(mouse_pos.y)))
|
||||
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
|
||||
Global.undos = Global.undo_redo.get_version()
|
||||
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:
|
||||
queue_free()
|
||||
return true
|
||||
|
|
|
@ -77,7 +77,7 @@ func _on_HorizontalRuler_pressed() -> void:
|
|||
if mouse_pos.x < RULER_WIDTH: #For double guides
|
||||
Global.vertical_ruler._on_VerticalRuler_pressed()
|
||||
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))
|
||||
Global.canvas.add_child(guide)
|
||||
|
|
|
@ -72,7 +72,7 @@ func _on_VerticalRuler_pressed() -> void:
|
|||
if !Global.show_guides:
|
||||
return
|
||||
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))
|
||||
Global.canvas.add_child(guide)
|
||||
|
|
Loading…
Reference in a new issue