2019-08-18 09:28:38 +00:00
|
|
|
extends Node
|
|
|
|
|
2019-12-18 16:12:44 +00:00
|
|
|
var config_cache := ConfigFile.new()
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var loaded_locales : Array
|
2019-10-29 21:22:38 +00:00
|
|
|
var undo_redo : UndoRedo
|
2019-10-31 23:41:02 +00:00
|
|
|
var undos := 0 #The number of times we added undo properties
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
|
|
#Canvas related stuff
|
2019-11-10 01:25:25 +00:00
|
|
|
var current_frame := 0 setget frame_changed
|
2019-08-18 09:28:38 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var can_draw := false
|
|
|
|
# warning-ignore:unused_class_variable
|
2019-10-03 16:37:31 +00:00
|
|
|
var has_focus := false
|
2019-12-05 23:48:29 +00:00
|
|
|
var canvases := []
|
2019-09-09 22:57:46 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-12-05 23:48:29 +00:00
|
|
|
var hidden_canvases := []
|
2019-12-10 17:56:16 +00:00
|
|
|
var left_cursor_tool_texture : ImageTexture
|
|
|
|
var right_cursor_tool_texture : ImageTexture
|
2019-12-21 02:56:48 +00:00
|
|
|
var transparent_background : ImageTexture
|
2019-09-14 19:55:33 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-12-05 23:48:29 +00:00
|
|
|
var selected_pixels := []
|
|
|
|
var image_clipboard : Image
|
2019-12-07 17:34:54 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-12-21 01:02:57 +00:00
|
|
|
var theme_type := "Dark"
|
|
|
|
# warning-ignore:unused_class_variable
|
2019-12-07 17:34:54 +00:00
|
|
|
var grid_width := 1
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var grid_height := 1
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var grid_color := Color.black
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
|
|
#Tools & options
|
2019-09-14 19:55:33 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-12-05 23:48:29 +00:00
|
|
|
var current_left_tool := "Pencil"
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var current_right_tool := "Eraser"
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var left_square_indicator_visible := true
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var right_square_indicator_visible := false
|
|
|
|
#0 for area of same color, 1 for all pixels of the same color
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var left_fill_area := 0
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var right_fill_area := 0
|
|
|
|
|
|
|
|
#0 for lighten, 1 for darken
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var left_ld := 0
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var right_ld := 0
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var left_ld_amount := 0.1
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var right_ld_amount := 0.1
|
|
|
|
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var left_horizontal_mirror := false
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var left_vertical_mirror := false
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var right_horizontal_mirror := false
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var right_vertical_mirror := false
|
|
|
|
|
|
|
|
#View menu options
|
2019-09-14 19:55:33 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-09-18 14:47:28 +00:00
|
|
|
var tile_mode := false
|
|
|
|
# warning-ignore:unused_class_variable
|
2019-09-09 22:57:46 +00:00
|
|
|
var draw_grid := false
|
2019-12-03 00:30:38 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var show_rulers := true
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var show_guides := true
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
|
|
#Onion skinning options
|
2019-11-10 01:25:25 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-12-05 23:48:29 +00:00
|
|
|
var onion_skinning_past_rate := 0
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var onion_skinning_future_rate := 0
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var onion_skinning_blue_red := false
|
|
|
|
|
|
|
|
#Brushes
|
|
|
|
enum BRUSH_TYPES {PIXEL, 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
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var current_right_brush_type = BRUSH_TYPES.PIXEL
|
2019-12-16 00:02:49 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var brush_type_window_position := "left"
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
|
|
var brushes_from_files := 0
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_brushes := []
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_left_brush_index := -1
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_right_brush_index := -1
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_left_brush_image : Image
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_right_brush_image : Image
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_left_brush_texture := ImageTexture.new()
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var custom_right_brush_texture := ImageTexture.new()
|
|
|
|
|
2019-12-15 03:11:32 +00:00
|
|
|
#Palettes
|
|
|
|
# warning-ignore:unused_class_variable
|
|
|
|
var palettes := {}
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
#Nodes
|
2019-11-13 13:45:55 +00:00
|
|
|
var control : Node
|
2019-12-18 23:18:57 +00:00
|
|
|
var top_menu_container : Panel
|
2019-12-10 17:56:16 +00:00
|
|
|
var left_cursor : Sprite
|
|
|
|
var right_cursor : Sprite
|
2019-08-18 09:28:38 +00:00
|
|
|
var canvas : Canvas
|
2019-09-09 22:57:46 +00:00
|
|
|
var canvas_parent : Node
|
2019-11-19 21:23:43 +00:00
|
|
|
var main_viewport : ViewportContainer
|
2019-09-25 19:59:48 +00:00
|
|
|
var second_viewport : ViewportContainer
|
|
|
|
var viewport_separator : VSeparator
|
2019-12-02 00:04:46 +00:00
|
|
|
var split_screen_button : BaseButton
|
2019-09-09 22:57:46 +00:00
|
|
|
var camera : Camera2D
|
2019-09-25 19:59:48 +00:00
|
|
|
var camera2 : Camera2D
|
2019-12-05 14:49:27 +00:00
|
|
|
var camera_preview : Camera2D
|
2019-09-18 14:47:28 +00:00
|
|
|
var selection_rectangle : Polygon2D
|
2019-12-03 00:30:38 +00:00
|
|
|
var horizontal_ruler : BaseButton
|
2019-11-20 22:11:21 +00:00
|
|
|
var vertical_ruler : BaseButton
|
2019-09-14 19:55:33 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
var file_menu : MenuButton
|
|
|
|
var edit_menu : MenuButton
|
2019-09-18 21:10:23 +00:00
|
|
|
var view_menu : MenuButton
|
2019-12-24 14:48:07 +00:00
|
|
|
var image_menu : MenuButton
|
2019-09-25 19:59:48 +00:00
|
|
|
var help_menu : MenuButton
|
2019-12-05 23:48:29 +00:00
|
|
|
var cursor_position_label : Label
|
|
|
|
var zoom_level_label : Label
|
2019-12-03 16:36:28 +00:00
|
|
|
|
2019-09-14 19:55:33 +00:00
|
|
|
var left_color_picker : ColorPickerButton
|
|
|
|
var right_color_picker : ColorPickerButton
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
|
|
var left_tool_options_container : Container
|
|
|
|
var right_tool_options_container : Container
|
|
|
|
|
|
|
|
var left_brush_type_container : Container
|
|
|
|
var right_brush_type_container : Container
|
2019-11-29 22:41:34 +00:00
|
|
|
var left_brush_type_button : BaseButton
|
|
|
|
var right_brush_type_button : BaseButton
|
|
|
|
var left_brush_type_label : Label
|
|
|
|
var right_brush_type_label : Label
|
2019-12-05 23:48:29 +00:00
|
|
|
var brushes_popup : Popup
|
|
|
|
var file_brush_container : GridContainer
|
|
|
|
var project_brush_container : GridContainer
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
|
|
var left_brush_size_container : Container
|
|
|
|
var right_brush_size_container : Container
|
2019-09-14 19:55:33 +00:00
|
|
|
var left_brush_size_edit : SpinBox
|
|
|
|
var right_brush_size_edit : SpinBox
|
2019-12-03 16:36:28 +00:00
|
|
|
|
2019-12-02 22:25:22 +00:00
|
|
|
var left_color_interpolation_container : Container
|
|
|
|
var right_color_interpolation_container : Container
|
2019-09-25 19:59:48 +00:00
|
|
|
var left_interpolate_slider : HSlider
|
|
|
|
var right_interpolate_slider : HSlider
|
|
|
|
|
2019-12-03 22:14:14 +00:00
|
|
|
var left_fill_area_container : Container
|
|
|
|
var right_fill_area_container : Container
|
|
|
|
|
2019-12-03 23:01:37 +00:00
|
|
|
var left_ld_container : Container
|
|
|
|
var right_ld_container : Container
|
|
|
|
|
2019-12-03 16:36:28 +00:00
|
|
|
var left_mirror_container : Container
|
|
|
|
var right_mirror_container : Container
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
var animation_timer : Timer
|
|
|
|
|
|
|
|
var current_frame_label : Label
|
2019-11-19 21:23:43 +00:00
|
|
|
var loop_animation_button : BaseButton
|
|
|
|
var play_forward : BaseButton
|
|
|
|
var play_backwards : BaseButton
|
2019-09-09 22:57:46 +00:00
|
|
|
var frame_container : HBoxContainer
|
2019-12-05 23:48:29 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
var vbox_layer_container : VBoxContainer
|
2019-11-19 21:23:43 +00:00
|
|
|
var remove_layer_button : BaseButton
|
|
|
|
var move_up_layer_button : BaseButton
|
|
|
|
var move_down_layer_button : BaseButton
|
|
|
|
var merge_down_layer_button : BaseButton
|
2019-09-25 19:59:48 +00:00
|
|
|
|
2019-12-24 02:28:45 +00:00
|
|
|
var add_palette_button : TextureButton
|
2019-12-15 03:11:32 +00:00
|
|
|
var remove_palette_button : TextureButton
|
|
|
|
var palette_option_button : OptionButton
|
|
|
|
var edit_palette_button : BaseButton
|
|
|
|
var palette_container : GridContainer
|
2019-12-17 01:23:18 +00:00
|
|
|
var edit_palette_popup : WindowDialog
|
|
|
|
var new_palette_dialog : ConfirmationDialog
|
|
|
|
var new_palette_name_line_edit : LineEdit
|
2019-12-18 14:43:11 +00:00
|
|
|
var palette_import_file_dialog : FileDialog
|
2019-12-17 01:23:18 +00:00
|
|
|
|
|
|
|
var error_dialog : AcceptDialog
|
2019-12-15 03:11:32 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
func _ready() -> void:
|
2019-12-20 14:36:23 +00:00
|
|
|
# Load settings from the config file
|
|
|
|
config_cache.load("user://cache.ini")
|
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
undo_redo = UndoRedo.new()
|
2019-12-21 02:56:48 +00:00
|
|
|
transparent_background = ImageTexture.new()
|
2019-12-21 03:03:57 +00:00
|
|
|
transparent_background.create_from_image(preload("res://Assets/Graphics/Transparent Background Dark.png"), 0)
|
2019-12-05 23:48:29 +00:00
|
|
|
image_clipboard = Image.new()
|
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
var root = get_tree().get_root()
|
2019-11-13 13:45:55 +00:00
|
|
|
control = find_node_by_name(root, "Control")
|
2019-12-18 23:18:57 +00:00
|
|
|
top_menu_container = find_node_by_name(control, "TopMenuContainer")
|
2019-12-10 17:56:16 +00:00
|
|
|
left_cursor = find_node_by_name(root, "LeftCursor")
|
|
|
|
right_cursor = find_node_by_name(root, "RightCursor")
|
2019-08-18 09:28:38 +00:00
|
|
|
canvas = find_node_by_name(root, "Canvas")
|
2019-09-09 22:57:46 +00:00
|
|
|
canvases.append(canvas)
|
2019-12-10 17:56:16 +00:00
|
|
|
left_cursor_tool_texture = ImageTexture.new()
|
2019-12-21 01:17:37 +00:00
|
|
|
left_cursor_tool_texture.create_from_image(preload("res://Assets/Graphics/Tool Cursors/Pencil_Cursor.png"))
|
2019-12-10 17:56:16 +00:00
|
|
|
right_cursor_tool_texture = ImageTexture.new()
|
2019-12-21 01:17:37 +00:00
|
|
|
right_cursor_tool_texture.create_from_image(preload("res://Assets/Graphics/Tool Cursors/Eraser_Cursor.png"))
|
2019-08-18 09:28:38 +00:00
|
|
|
canvas_parent = canvas.get_parent()
|
2019-11-19 21:23:43 +00:00
|
|
|
main_viewport = find_node_by_name(root, "ViewportContainer")
|
2019-09-25 19:59:48 +00:00
|
|
|
second_viewport = find_node_by_name(root, "ViewportContainer2")
|
|
|
|
viewport_separator = find_node_by_name(root, "ViewportSeparator")
|
|
|
|
split_screen_button = find_node_by_name(root, "SplitScreenButton")
|
2019-09-09 22:57:46 +00:00
|
|
|
camera = find_node_by_name(canvas_parent, "Camera2D")
|
2019-11-19 21:23:43 +00:00
|
|
|
camera2 = find_node_by_name(root, "Camera2D2")
|
2019-12-05 14:49:27 +00:00
|
|
|
camera_preview = find_node_by_name(root, "CameraPreview")
|
2019-09-18 14:47:28 +00:00
|
|
|
selection_rectangle = find_node_by_name(root, "SelectionRectangle")
|
2019-12-03 00:30:38 +00:00
|
|
|
horizontal_ruler = find_node_by_name(root, "HorizontalRuler")
|
2019-11-20 22:11:21 +00:00
|
|
|
vertical_ruler = find_node_by_name(root, "VerticalRuler")
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
file_menu = find_node_by_name(root, "FileMenu")
|
|
|
|
edit_menu = find_node_by_name(root, "EditMenu")
|
2019-09-18 21:10:23 +00:00
|
|
|
view_menu = find_node_by_name(root, "ViewMenu")
|
2019-12-24 14:48:07 +00:00
|
|
|
image_menu = find_node_by_name(root, "ImageMenu")
|
2019-09-25 19:59:48 +00:00
|
|
|
help_menu = find_node_by_name(root, "HelpMenu")
|
2019-12-05 23:48:29 +00:00
|
|
|
cursor_position_label = find_node_by_name(root, "CursorPosition")
|
|
|
|
zoom_level_label = find_node_by_name(root, "ZoomLevel")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
|
|
left_tool_options_container = find_node_by_name(root, "LeftToolOptions")
|
|
|
|
right_tool_options_container = find_node_by_name(root, "RightToolOptions")
|
|
|
|
|
2019-09-14 19:55:33 +00:00
|
|
|
left_color_picker = find_node_by_name(root, "LeftColorPickerButton")
|
|
|
|
right_color_picker = find_node_by_name(root, "RightColorPickerButton")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
|
|
left_brush_type_container = find_node_by_name(left_tool_options_container, "LeftBrushType")
|
|
|
|
right_brush_type_container = find_node_by_name(right_tool_options_container, "RightBrushType")
|
|
|
|
left_brush_type_button = find_node_by_name(left_brush_type_container, "LeftBrushTypeButton")
|
|
|
|
right_brush_type_button = find_node_by_name(right_brush_type_container, "RightBrushTypeButton")
|
|
|
|
left_brush_type_label = find_node_by_name(left_brush_type_container, "LeftBrushTypeLabel")
|
|
|
|
right_brush_type_label = find_node_by_name(right_brush_type_container, "RightBrushTypeLabel")
|
2019-12-05 23:48:29 +00:00
|
|
|
brushes_popup = find_node_by_name(root, "BrushesPopup")
|
|
|
|
file_brush_container = find_node_by_name(brushes_popup, "FileBrushContainer")
|
|
|
|
project_brush_container = find_node_by_name(brushes_popup, "ProjectBrushContainer")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
|
|
left_brush_size_container = find_node_by_name(left_tool_options_container, "LeftBrushSize")
|
|
|
|
right_brush_size_container = find_node_by_name(right_tool_options_container, "RightBrushSize")
|
|
|
|
left_brush_size_edit = find_node_by_name(left_brush_size_container, "LeftBrushSizeEdit")
|
|
|
|
right_brush_size_edit = find_node_by_name(right_brush_size_container, "RightBrushSizeEdit")
|
|
|
|
|
|
|
|
left_color_interpolation_container = find_node_by_name(left_tool_options_container, "LeftColorInterpolation")
|
|
|
|
right_color_interpolation_container = find_node_by_name(right_tool_options_container, "RightColorInterpolation")
|
|
|
|
left_interpolate_slider = find_node_by_name(left_color_interpolation_container, "LeftInterpolateFactor")
|
|
|
|
right_interpolate_slider = find_node_by_name(right_color_interpolation_container, "RightInterpolateFactor")
|
|
|
|
|
2019-12-03 22:14:14 +00:00
|
|
|
left_fill_area_container = find_node_by_name(left_tool_options_container, "LeftFillArea")
|
|
|
|
right_fill_area_container = find_node_by_name(right_tool_options_container, "RightFillArea")
|
|
|
|
|
2019-12-03 23:01:37 +00:00
|
|
|
left_ld_container = find_node_by_name(left_tool_options_container, "LeftLDOptions")
|
|
|
|
right_ld_container = find_node_by_name(right_tool_options_container, "RightLDOptions")
|
|
|
|
|
2019-12-03 16:36:28 +00:00
|
|
|
left_mirror_container = find_node_by_name(left_tool_options_container, "LeftMirroring")
|
|
|
|
right_mirror_container = find_node_by_name(right_tool_options_container, "RightMirroring")
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
animation_timer = find_node_by_name(root, "AnimationTimer")
|
|
|
|
|
|
|
|
current_frame_label = find_node_by_name(root, "CurrentFrame")
|
2019-09-14 19:55:33 +00:00
|
|
|
loop_animation_button = find_node_by_name(root, "LoopAnim")
|
2019-09-09 22:57:46 +00:00
|
|
|
play_forward = find_node_by_name(root, "PlayForward")
|
|
|
|
play_backwards = find_node_by_name(root, "PlayBackwards")
|
|
|
|
frame_container = find_node_by_name(root, "FrameContainer")
|
2019-11-29 22:41:34 +00:00
|
|
|
|
2019-12-21 01:02:57 +00:00
|
|
|
var layer_buttons = find_node_by_name(root, "LayerButtons")
|
2019-12-21 01:27:11 +00:00
|
|
|
remove_layer_button = find_node_by_name(layer_buttons, "RemoveLayer")
|
|
|
|
move_up_layer_button = find_node_by_name(layer_buttons, "MoveUpLayer")
|
|
|
|
move_down_layer_button = find_node_by_name(layer_buttons, "MovwDownLayer")
|
|
|
|
merge_down_layer_button = find_node_by_name(layer_buttons, "MergeDownLayer")
|
2019-08-18 09:28:38 +00:00
|
|
|
vbox_layer_container = find_node_by_name(root, "VBoxLayerContainer")
|
2019-12-15 11:44:53 +00:00
|
|
|
|
2019-12-15 03:11:32 +00:00
|
|
|
add_palette_button = find_node_by_name(root, "AddPalette")
|
|
|
|
remove_palette_button = find_node_by_name(root, "RemovePalette")
|
|
|
|
palette_option_button = find_node_by_name(root, "PaletteOptionButton")
|
|
|
|
edit_palette_button = find_node_by_name(root, "EditPalette")
|
|
|
|
palette_container = find_node_by_name(root, "PaletteContainer")
|
2019-12-17 01:23:18 +00:00
|
|
|
edit_palette_popup = find_node_by_name(root, "EditPalettePopup")
|
|
|
|
new_palette_dialog = find_node_by_name(root, "NewPaletteDialog")
|
|
|
|
new_palette_name_line_edit = find_node_by_name(new_palette_dialog, "NewPaletteNameLineEdit")
|
2019-12-18 14:43:11 +00:00
|
|
|
palette_import_file_dialog = find_node_by_name(root, "PaletteImportFileDialog")
|
2019-12-17 01:23:18 +00:00
|
|
|
|
|
|
|
error_dialog = find_node_by_name(root, "ErrorDialog")
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
#Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name
|
2019-08-18 09:28:38 +00:00
|
|
|
func find_node_by_name(root, node_name) -> Node:
|
2019-10-29 21:22:38 +00:00
|
|
|
if root.get_name() == node_name:
|
2019-08-18 09:28:38 +00:00
|
|
|
return root
|
|
|
|
for child in root.get_children():
|
|
|
|
if child.get_name() == node_name:
|
|
|
|
return child
|
|
|
|
var found = find_node_by_name(child, node_name)
|
2019-10-29 21:22:38 +00:00
|
|
|
if found:
|
2019-08-18 09:28:38 +00:00
|
|
|
return found
|
2019-09-09 22:57:46 +00:00
|
|
|
return null
|
|
|
|
|
2019-11-13 13:45:55 +00:00
|
|
|
func notification_label(text : String) -> void:
|
|
|
|
var notification : Label = load("res://Prefabs/NotificationLabel.tscn").instance()
|
2019-12-08 01:12:34 +00:00
|
|
|
notification.text = tr(text)
|
2019-11-13 13:45:55 +00:00
|
|
|
notification.rect_position = Vector2(240, OS.window_size.y - 150)
|
|
|
|
get_tree().get_root().add_child(notification)
|
|
|
|
|
2019-11-10 01:25:25 +00:00
|
|
|
func undo(_canvases : Array, layer_index : int = -1) -> void:
|
2019-10-31 23:41:02 +00:00
|
|
|
undos -= 1
|
2019-11-11 16:41:43 +00:00
|
|
|
var action_name := undo_redo.get_current_action_name()
|
2019-11-06 22:12:40 +00:00
|
|
|
if action_name == "Draw" || action_name == "Rectangle Select" || action_name == "Scale" || action_name == "Merge Layer":
|
2019-11-10 01:25:25 +00:00
|
|
|
for c in _canvases:
|
2019-11-05 16:19:41 +00:00
|
|
|
if layer_index > -1:
|
|
|
|
c.update_texture(layer_index)
|
|
|
|
else:
|
|
|
|
for i in c.layers.size():
|
|
|
|
c.update_texture(i)
|
|
|
|
|
|
|
|
if action_name == "Scale":
|
|
|
|
c.camera_zoom()
|
2019-11-06 22:12:40 +00:00
|
|
|
if "Layer" in action_name:
|
2019-11-10 01:25:25 +00:00
|
|
|
var current_layer_index : int = _canvases[0].current_layer_index
|
|
|
|
_canvases[0].generate_layer_panels()
|
2019-11-06 22:12:40 +00:00
|
|
|
if action_name == "Change Layer Order":
|
2019-11-10 01:25:25 +00:00
|
|
|
_canvases[0].current_layer_index = current_layer_index
|
|
|
|
_canvases[0].get_layer_container(current_layer_index).changed_selection()
|
|
|
|
|
|
|
|
if action_name == "Add Frame":
|
|
|
|
canvas_parent.remove_child(_canvases[0])
|
|
|
|
frame_container.remove_child(_canvases[0].frame_button)
|
2019-11-23 22:52:17 +00:00
|
|
|
#This actually means that canvases.size is one, but it hasn't been updated yet
|
|
|
|
if canvases.size() == 2: #Stop animating
|
|
|
|
play_forward.pressed = false
|
|
|
|
play_backwards.pressed = false
|
|
|
|
animation_timer.stop()
|
2019-11-10 01:25:25 +00:00
|
|
|
elif action_name == "Remove Frame":
|
|
|
|
canvas_parent.add_child(_canvases[0])
|
|
|
|
canvas_parent.move_child(_canvases[0], _canvases[0].frame)
|
|
|
|
frame_container.add_child(_canvases[0].frame_button)
|
|
|
|
frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame)
|
|
|
|
elif action_name == "Change Frame Order":
|
2019-11-19 21:23:43 +00:00
|
|
|
frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame)
|
|
|
|
canvas_parent.move_child(_canvases[0], _canvases[0].frame)
|
2019-11-10 01:25:25 +00:00
|
|
|
|
2019-11-13 13:45:55 +00:00
|
|
|
notification_label("Undo: %s" % action_name)
|
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-11-10 01:25:25 +00:00
|
|
|
func redo(_canvases : Array, layer_index : int = -1) -> void:
|
2019-10-31 23:41:02 +00:00
|
|
|
if undos < undo_redo.get_version(): #If we did undo and then redo
|
|
|
|
undos = undo_redo.get_version()
|
2019-11-11 16:41:43 +00:00
|
|
|
var action_name := undo_redo.get_current_action_name()
|
2019-11-06 22:12:40 +00:00
|
|
|
if action_name == "Draw" || action_name == "Rectangle Select" || action_name == "Scale" || action_name == "Merge Layer":
|
2019-11-10 01:25:25 +00:00
|
|
|
for c in _canvases:
|
2019-11-05 16:19:41 +00:00
|
|
|
if layer_index > -1:
|
|
|
|
c.update_texture(layer_index)
|
|
|
|
else:
|
|
|
|
for i in c.layers.size():
|
|
|
|
c.update_texture(i)
|
|
|
|
|
|
|
|
if action_name == "Scale":
|
|
|
|
c.camera_zoom()
|
2019-11-06 22:12:40 +00:00
|
|
|
if "Layer" in action_name:
|
2019-11-10 01:25:25 +00:00
|
|
|
var current_layer_index : int = _canvases[0].current_layer_index
|
|
|
|
_canvases[0].generate_layer_panels()
|
2019-11-06 22:12:40 +00:00
|
|
|
if action_name == "Change Layer Order":
|
2019-11-10 01:25:25 +00:00
|
|
|
_canvases[0].current_layer_index = current_layer_index
|
|
|
|
_canvases[0].get_layer_container(current_layer_index).changed_selection()
|
|
|
|
|
|
|
|
if action_name == "Add Frame":
|
|
|
|
canvas_parent.add_child(_canvases[0])
|
|
|
|
if !Global.frame_container.is_a_parent_of(_canvases[0].frame_button):
|
|
|
|
Global.frame_container.add_child(_canvases[0].frame_button)
|
|
|
|
elif action_name == "Remove Frame":
|
|
|
|
canvas_parent.remove_child(_canvases[0])
|
|
|
|
frame_container.remove_child(_canvases[0].frame_button)
|
2019-11-23 22:52:17 +00:00
|
|
|
if canvases.size() == 1: #Stop animating
|
|
|
|
play_forward.pressed = false
|
|
|
|
play_backwards.pressed = false
|
|
|
|
animation_timer.stop()
|
2019-11-10 01:25:25 +00:00
|
|
|
elif action_name == "Change Frame Order":
|
2019-11-19 21:23:43 +00:00
|
|
|
frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame)
|
|
|
|
canvas_parent.move_child(_canvases[0], _canvases[0].frame)
|
2019-11-10 01:25:25 +00:00
|
|
|
|
2019-11-13 13:45:55 +00:00
|
|
|
if control.redone:
|
|
|
|
notification_label("Redo: %s" % action_name)
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-11-10 01:25:25 +00:00
|
|
|
func frame_changed(value : int) -> void:
|
|
|
|
current_frame = value
|
2019-12-08 01:12:34 +00:00
|
|
|
current_frame_label.text = tr("Current frame:") + " %s/%s" % [str(current_frame + 1), canvases.size()]
|
2019-11-10 01:25:25 +00:00
|
|
|
|
2019-09-09 22:57:46 +00:00
|
|
|
for c in canvases:
|
|
|
|
c.visible = false
|
|
|
|
canvas = canvases[current_frame]
|
|
|
|
canvas.visible = true
|
|
|
|
canvas.generate_layer_panels()
|
2019-11-10 01:25:25 +00:00
|
|
|
#Make all frame buttons unpressed
|
|
|
|
for c in canvases:
|
2019-12-24 02:37:17 +00:00
|
|
|
var text_color := Color.white
|
|
|
|
if theme_type == "Gold" || theme_type == "Light":
|
|
|
|
text_color = Color.black
|
2019-11-10 01:25:25 +00:00
|
|
|
c.frame_button.get_node("FrameButton").pressed = false
|
2019-12-24 02:37:17 +00:00
|
|
|
c.frame_button.get_node("FrameID").add_color_override("font_color", text_color)
|
2019-11-10 01:25:25 +00:00
|
|
|
#Make only the current frame button pressed
|
|
|
|
canvas.frame_button.get_node("FrameButton").pressed = true
|
2019-12-17 22:53:06 +00:00
|
|
|
canvas.frame_button.get_node("FrameID").add_color_override("font_color", Color("#3c5d75"))
|
2019-09-09 22:57:46 +00:00
|
|
|
|
2019-09-25 19:59:48 +00:00
|
|
|
|
2019-11-25 16:56:53 +00:00
|
|
|
func create_brush_button(brush_img : Image, brush_type := BRUSH_TYPES.CUSTOM, hint_tooltip := "") -> void:
|
2019-11-20 12:41:02 +00:00
|
|
|
var brush_container
|
2019-09-25 19:59:48 +00:00
|
|
|
var brush_button = load("res://Prefabs/BrushButton.tscn").instance()
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
brush_button.brush_type = brush_type
|
2019-09-27 17:05:24 +00:00
|
|
|
brush_button.custom_brush_index = custom_brushes.size() - 1
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
if brush_type == BRUSH_TYPES.FILE:
|
2019-11-20 12:41:02 +00:00
|
|
|
brush_container = file_brush_container
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
else:
|
2019-11-20 12:41:02 +00:00
|
|
|
brush_container = project_brush_container
|
2019-09-25 19:59:48 +00:00
|
|
|
var brush_tex := ImageTexture.new()
|
|
|
|
brush_tex.create_from_image(brush_img, 0)
|
|
|
|
brush_button.get_child(0).texture = brush_tex
|
2019-11-25 16:56:53 +00:00
|
|
|
brush_button.hint_tooltip = hint_tooltip
|
2019-11-20 12:41:02 +00:00
|
|
|
brush_container.add_child(brush_button)
|
2019-10-02 18:58:19 +00:00
|
|
|
|
|
|
|
func remove_brush_buttons() -> void:
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
current_left_brush_type = BRUSH_TYPES.PIXEL
|
|
|
|
current_right_brush_type = BRUSH_TYPES.PIXEL
|
2019-11-20 12:41:02 +00:00
|
|
|
for child in project_brush_container.get_children():
|
2019-11-11 16:41:43 +00:00
|
|
|
child.queue_free()
|
|
|
|
|
2019-11-29 22:41:34 +00:00
|
|
|
func undo_custom_brush(_brush_button : BaseButton = null) -> void:
|
2019-11-11 16:41:43 +00:00
|
|
|
undos -= 1
|
|
|
|
var action_name := undo_redo.get_current_action_name()
|
|
|
|
if action_name == "Delete Custom Brush":
|
2019-11-20 12:41:02 +00:00
|
|
|
project_brush_container.add_child(_brush_button)
|
|
|
|
project_brush_container.move_child(_brush_button, _brush_button.custom_brush_index - brushes_from_files)
|
2019-11-11 16:41:43 +00:00
|
|
|
_brush_button.get_node("DeleteButton").visible = false
|
2019-11-13 13:45:55 +00:00
|
|
|
notification_label("Undo: %s" % action_name)
|
2019-11-11 16:41:43 +00:00
|
|
|
|
2019-11-29 22:41:34 +00:00
|
|
|
func redo_custom_brush(_brush_button : BaseButton = null) -> void:
|
2019-11-11 16:41:43 +00:00
|
|
|
if undos < undo_redo.get_version(): #If we did undo and then redo
|
|
|
|
undos = undo_redo.get_version()
|
|
|
|
var action_name := undo_redo.get_current_action_name()
|
|
|
|
if action_name == "Delete Custom Brush":
|
2019-11-20 12:41:02 +00:00
|
|
|
project_brush_container.remove_child(_brush_button)
|
2019-11-13 13:45:55 +00:00
|
|
|
if control.redone:
|
|
|
|
notification_label("Redo: %s" % action_name)
|
2019-10-02 18:58:19 +00:00
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func update_left_custom_brush() -> void:
|
2019-11-29 22:41:34 +00:00
|
|
|
if current_left_brush_type == BRUSH_TYPES.PIXEL:
|
|
|
|
var pixel := Image.new()
|
|
|
|
pixel = preload("res://Assets/Graphics/pixel_image.png")
|
|
|
|
pixel = blend_image_with_color(pixel, left_color_picker.color, 1)
|
|
|
|
left_brush_type_button.get_child(0).texture.create_from_image(pixel)
|
|
|
|
else:
|
2019-09-27 17:39:16 +00:00
|
|
|
var custom_brush := Image.new()
|
|
|
|
custom_brush.copy_from(custom_brushes[custom_left_brush_index])
|
|
|
|
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)
|
2019-12-17 02:01:38 +00:00
|
|
|
custom_left_brush_image = blend_image_with_color(custom_brush, left_color_picker.color, left_interpolate_slider.value / 100)
|
2019-09-27 17:39:16 +00:00
|
|
|
custom_left_brush_texture.create_from_image(custom_left_brush_image, 0)
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-11-29 22:41:34 +00:00
|
|
|
left_brush_type_button.get_child(0).texture = custom_left_brush_texture
|
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func update_right_custom_brush() -> void:
|
2019-11-29 22:41:34 +00:00
|
|
|
if current_right_brush_type == BRUSH_TYPES.PIXEL:
|
|
|
|
var pixel := Image.new()
|
|
|
|
pixel = preload("res://Assets/Graphics/pixel_image.png")
|
|
|
|
pixel = blend_image_with_color(pixel, right_color_picker.color, 1)
|
|
|
|
right_brush_type_button.get_child(0).texture.create_from_image(pixel)
|
|
|
|
else:
|
2019-09-27 17:39:16 +00:00
|
|
|
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)
|
2019-12-17 02:01:38 +00:00
|
|
|
custom_right_brush_image = blend_image_with_color(custom_brush, right_color_picker.color, right_interpolate_slider.value / 100)
|
2019-09-27 17:39:16 +00:00
|
|
|
custom_right_brush_texture.create_from_image(custom_right_brush_image, 0)
|
2019-09-27 17:05:24 +00:00
|
|
|
|
2019-11-29 22:41:34 +00:00
|
|
|
right_brush_type_button.get_child(0).texture = custom_right_brush_texture
|
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func blend_image_with_color(image : Image, color : Color, interpolate_factor : float) -> Image:
|
|
|
|
var blended_image := Image.new()
|
|
|
|
blended_image.copy_from(image)
|
|
|
|
var size := image.get_size()
|
|
|
|
blended_image.lock()
|
|
|
|
for xx in size.x:
|
|
|
|
for yy in size.y:
|
|
|
|
if color.a > 0: #If it's the pencil
|
|
|
|
var current_color := blended_image.get_pixel(xx, yy)
|
|
|
|
if current_color.a > 0:
|
|
|
|
var new_color := current_color.linear_interpolate(color, interpolate_factor)
|
|
|
|
blended_image.set_pixel(xx, yy, new_color)
|
|
|
|
else: #If color is transparent - if it's the eraser
|
|
|
|
blended_image.set_pixel(xx, yy, Color(0, 0, 0, 0))
|
2019-10-25 14:38:38 +00:00
|
|
|
return blended_image
|
2019-12-12 22:19:28 +00:00
|
|
|
|
|
|
|
func _exit_tree() -> void:
|
2019-12-18 16:12:44 +00:00
|
|
|
config_cache.set_value("window", "screen", OS.current_screen)
|
|
|
|
config_cache.set_value("window", "maximized", OS.window_maximized || OS.window_fullscreen)
|
|
|
|
config_cache.set_value("window", "position", OS.window_position)
|
|
|
|
config_cache.set_value("window", "size", OS.window_size)
|
|
|
|
config_cache.save("user://cache.ini")
|
|
|
|
|
2019-12-12 22:19:28 +00:00
|
|
|
# Thanks to qarmin from GitHub for pointing this out
|
2019-12-18 16:12:44 +00:00
|
|
|
undo_redo.free()
|