2019-08-18 09:28:38 +00:00
|
|
|
|
extends Node
|
|
|
|
|
|
2020-05-31 15:03:44 +00:00
|
|
|
|
|
2020-03-12 02:17:48 +00:00
|
|
|
|
enum Grid_Types {CARTESIAN, ISOMETRIC, ALL}
|
2020-02-14 16:26:03 +00:00
|
|
|
|
enum Pressure_Sensitivity {NONE, ALPHA, SIZE, ALPHA_AND_SIZE}
|
2020-05-31 13:04:33 +00:00
|
|
|
|
enum Direction {UP, DOWN, LEFT, RIGHT}
|
2020-06-01 00:36:07 +00:00
|
|
|
|
enum Theme_Types {DARK, BLUE, CARAMEL, LIGHT}
|
2020-04-10 21:47:06 +00:00
|
|
|
|
|
2020-04-13 07:55:01 +00:00
|
|
|
|
# Stuff for arrowkey-based canvas movements nyaa ^.^
|
|
|
|
|
const low_speed_move_rate := 150.0
|
|
|
|
|
const medium_speed_move_rate := 750.0
|
|
|
|
|
const high_speed_move_rate := 3750.0
|
|
|
|
|
|
2020-05-31 13:04:33 +00:00
|
|
|
|
var root_directory := "."
|
|
|
|
|
var window_title := "" setget title_changed # Why doesn't Godot have get_window_title()?
|
|
|
|
|
var config_cache := ConfigFile.new()
|
|
|
|
|
var XDGDataPaths = preload("res://src/XDGDataPaths.gd")
|
|
|
|
|
var directory_module : Reference
|
2020-04-13 07:55:01 +00:00
|
|
|
|
|
2020-06-04 18:05:36 +00:00
|
|
|
|
var projects := [] # Array of Projects
|
|
|
|
|
var current_project : Project
|
|
|
|
|
var current_project_index := 0 setget project_changed
|
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
var recent_projects := []
|
|
|
|
|
|
2020-04-13 07:55:01 +00:00
|
|
|
|
# Indices are as in the Direction enum
|
2020-04-13 13:39:18 +00:00
|
|
|
|
# This is the total time the key for
|
2020-04-13 07:55:01 +00:00
|
|
|
|
# that direction has been pressed.
|
|
|
|
|
var key_move_press_time := [0.0, 0.0, 0.0, 0.0]
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Canvas related stuff
|
2020-04-06 15:35:54 +00:00
|
|
|
|
var layers_changed_skip := false
|
2019-08-18 09:28:38 +00:00
|
|
|
|
var can_draw := false
|
2019-10-03 16:37:31 +00:00
|
|
|
|
var has_focus := false
|
2020-05-05 00:53:58 +00:00
|
|
|
|
var cursor_image = preload("res://assets/graphics/cursor_icons/cursor.png")
|
2020-07-09 12:22:17 +00:00
|
|
|
|
var left_cursor_tool_texture := ImageTexture.new()
|
|
|
|
|
var right_cursor_tool_texture := ImageTexture.new()
|
2020-04-24 21:42:02 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var image_clipboard : Image
|
2020-04-11 17:10:07 +00:00
|
|
|
|
var play_only_tags := true
|
2020-07-16 02:05:40 +00:00
|
|
|
|
var show_x_symmetry_axis := false
|
|
|
|
|
var show_y_symmetry_axis := false
|
2020-08-18 14:03:49 +00:00
|
|
|
|
var default_clear_color := Color.gray
|
2020-02-11 22:38:35 +00:00
|
|
|
|
|
2020-06-04 20:20:20 +00:00
|
|
|
|
# Preferences
|
2020-07-28 22:54:15 +00:00
|
|
|
|
var pressure_sensitivity_mode = Pressure_Sensitivity.NONE
|
|
|
|
|
var open_last_project := false
|
|
|
|
|
var smooth_zoom := true
|
2020-06-01 00:36:07 +00:00
|
|
|
|
var theme_type : int = Theme_Types.DARK
|
2020-01-10 22:29:29 +00:00
|
|
|
|
var default_image_width := 64
|
|
|
|
|
var default_image_height := 64
|
2020-01-10 19:24:07 +00:00
|
|
|
|
var default_fill_color := Color(0, 0, 0, 0)
|
2020-03-12 02:17:48 +00:00
|
|
|
|
var grid_type = Grid_Types.CARTESIAN
|
2019-12-07 17:34:54 +00:00
|
|
|
|
var grid_width := 1
|
|
|
|
|
var grid_height := 1
|
2020-08-19 21:12:07 +00:00
|
|
|
|
var grid_isometric_cell_size := 2
|
2019-12-07 17:34:54 +00:00
|
|
|
|
var grid_color := Color.black
|
2019-12-27 00:28:36 +00:00
|
|
|
|
var guide_color := Color.purple
|
2020-04-18 07:03:18 +00:00
|
|
|
|
var checker_size := 10
|
2020-05-03 00:42:44 +00:00
|
|
|
|
var checker_color_1 := Color(0.47, 0.47, 0.47, 1)
|
|
|
|
|
var checker_color_2 := Color(0.34, 0.35, 0.34, 1)
|
2020-08-17 19:30:58 +00:00
|
|
|
|
var checker_follow_movement := false
|
|
|
|
|
var checker_follow_scale := false
|
2020-10-25 23:10:14 +00:00
|
|
|
|
var tilemode_opacity := 1.0
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-07-29 00:16:02 +00:00
|
|
|
|
var autosave_interval := 1.0
|
2020-05-31 20:04:59 +00:00
|
|
|
|
var enable_autosave := true
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Tools & options
|
2020-01-13 11:26:06 +00:00
|
|
|
|
var show_left_tool_icon := true
|
|
|
|
|
var show_right_tool_icon := true
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var left_square_indicator_visible := true
|
|
|
|
|
var right_square_indicator_visible := false
|
2020-04-24 21:42:02 +00:00
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# View menu options
|
2019-09-18 14:47:28 +00:00
|
|
|
|
var tile_mode := false
|
2019-09-09 22:57:46 +00:00
|
|
|
|
var draw_grid := false
|
2019-12-03 00:30:38 +00:00
|
|
|
|
var show_rulers := true
|
|
|
|
|
var show_guides := true
|
2020-02-15 01:30:40 +00:00
|
|
|
|
var show_animation_timeline := true
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Onion skinning options
|
2020-03-26 18:56:30 +00:00
|
|
|
|
var onion_skinning := false
|
2020-05-01 17:47:10 +00:00
|
|
|
|
var onion_skinning_past_rate := 1.0
|
|
|
|
|
var onion_skinning_future_rate := 1.0
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var onion_skinning_blue_red := false
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Palettes
|
2019-12-15 03:11:32 +00:00
|
|
|
|
var palettes := {}
|
|
|
|
|
|
2019-12-25 19:42:01 +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
|
2020-06-04 23:48:38 +00:00
|
|
|
|
var tabs : Tabs
|
2019-11-19 21:23:43 +00:00
|
|
|
|
var main_viewport : ViewportContainer
|
2019-09-25 19:59:48 +00:00
|
|
|
|
var second_viewport : ViewportContainer
|
2020-06-11 23:27:21 +00:00
|
|
|
|
var small_preview_viewport : ViewportContainer
|
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
|
2020-04-20 16:12:22 +00:00
|
|
|
|
var transparent_checker : ColorRect
|
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
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
var recent_projects_submenu : PopupMenu
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
var new_image_dialog : ConfirmationDialog
|
2020-06-09 17:19:55 +00:00
|
|
|
|
var open_sprites_dialog : FileDialog
|
|
|
|
|
var save_sprites_dialog : FileDialog
|
2020-06-30 17:25:43 +00:00
|
|
|
|
var save_sprites_html5_dialog : ConfirmationDialog
|
2020-05-03 15:47:13 +00:00
|
|
|
|
var export_dialog : AcceptDialog
|
2020-05-28 00:41:28 +00:00
|
|
|
|
var preferences_dialog : AcceptDialog
|
2020-06-05 14:50:52 +00:00
|
|
|
|
var unsaved_changes_dialog : ConfirmationDialog
|
2019-12-28 16:35:53 +00:00
|
|
|
|
|
2020-04-25 19:24:20 +00:00
|
|
|
|
var color_switch_button : BaseButton
|
2020-04-15 18:52:20 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var brushes_popup : Popup
|
2020-04-24 21:42:02 +00:00
|
|
|
|
var patterns_popup : Popup
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2020-01-15 20:01:43 +00:00
|
|
|
|
var animation_timeline : Panel
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-01-15 20:01:43 +00:00
|
|
|
|
var animation_timer : Timer
|
2020-10-19 14:57:40 +00:00
|
|
|
|
var frame_properties : ConfirmationDialog
|
2020-01-18 19:06:47 +00:00
|
|
|
|
var frame_ids : HBoxContainer
|
2020-05-23 21:22:06 +00:00
|
|
|
|
var current_frame_mark_label : Label
|
2020-04-03 12:34:16 +00:00
|
|
|
|
var onion_skinning_button : BaseButton
|
2019-11-19 21:23:43 +00:00
|
|
|
|
var loop_animation_button : BaseButton
|
|
|
|
|
var play_forward : BaseButton
|
|
|
|
|
var play_backwards : BaseButton
|
2020-01-18 22:56:30 +00:00
|
|
|
|
var layers_container : VBoxContainer
|
|
|
|
|
var frames_container : VBoxContainer
|
2020-04-02 00:29:14 +00:00
|
|
|
|
var tag_container : Control
|
2020-04-05 22:07:28 +00:00
|
|
|
|
var tag_dialog : AcceptDialog
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-05-03 15:17:12 +00:00
|
|
|
|
var remove_frame_button : BaseButton
|
2020-10-04 23:37:55 +00:00
|
|
|
|
var move_left_frame_button : BaseButton
|
|
|
|
|
var move_right_frame_button : BaseButton
|
2020-05-03 15:17:12 +00:00
|
|
|
|
|
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-12-24 21:51:08 +00:00
|
|
|
|
var layer_opacity_slider : HSlider
|
2019-12-24 22:23:45 +00:00
|
|
|
|
var layer_opacity_spinbox : SpinBox
|
2019-09-25 19:59:48 +00:00
|
|
|
|
|
2020-08-01 21:59:00 +00:00
|
|
|
|
var preview_zoom_slider : VSlider
|
|
|
|
|
|
2020-04-25 19:24:20 +00:00
|
|
|
|
var add_palette_button : BaseButton
|
2019-12-15 03:11:32 +00:00
|
|
|
|
var edit_palette_button : BaseButton
|
2019-12-30 18:29:46 +00:00
|
|
|
|
var palette_option_button : OptionButton
|
2019-12-15 03:11:32 +00:00
|
|
|
|
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
|
2020-08-01 21:59:00 +00:00
|
|
|
|
|
2019-12-17 01:23:18 +00:00
|
|
|
|
var error_dialog : AcceptDialog
|
2020-06-13 14:59:57 +00:00
|
|
|
|
var quit_dialog : ConfirmationDialog
|
|
|
|
|
var quit_and_save_dialog : ConfirmationDialog
|
2019-12-15 03:11:32 +00:00
|
|
|
|
|
2020-05-03 21:04:00 +00:00
|
|
|
|
onready var current_version : String = ProjectSettings.get_setting("application/config/Version")
|
|
|
|
|
|
2020-04-24 21:42:02 +00:00
|
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
|
func _ready() -> void:
|
2019-12-26 19:36:56 +00:00
|
|
|
|
randomize()
|
2020-02-09 23:23:33 +00:00
|
|
|
|
if OS.has_feature("standalone"):
|
|
|
|
|
root_directory = OS.get_executable_path().get_base_dir()
|
2019-12-20 14:36:23 +00:00
|
|
|
|
# Load settings from the config file
|
|
|
|
|
config_cache.load("user://cache.ini")
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
recent_projects = config_cache.get_value("data", "recent_projects", [])
|
2020-04-12 22:40:26 +00:00
|
|
|
|
|
2020-04-11 06:58:58 +00:00
|
|
|
|
# The fact that root_dir is set earlier than this is important
|
|
|
|
|
# XDGDataDirs depends on it nyaa
|
|
|
|
|
directory_module = XDGDataPaths.new()
|
2019-12-05 23:48:29 +00:00
|
|
|
|
image_clipboard = Image.new()
|
2020-06-13 15:09:46 +00:00
|
|
|
|
Input.set_custom_mouse_cursor(Global.cursor_image, Input.CURSOR_CROSS, Vector2(15, 15))
|
2020-04-12 22:40:26 +00:00
|
|
|
|
|
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")
|
2020-06-25 15:18:20 +00:00
|
|
|
|
|
2020-06-04 23:48:38 +00:00
|
|
|
|
tabs = find_node_by_name(root, "Tabs")
|
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")
|
2020-06-11 23:27:21 +00:00
|
|
|
|
small_preview_viewport = find_node_by_name(root, "PreviewViewportContainer")
|
2020-06-02 23:14:24 +00:00
|
|
|
|
camera = find_node_by_name(main_viewport, "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")
|
2020-04-20 16:12:22 +00:00
|
|
|
|
transparent_checker = find_node_by_name(root, "TransparentChecker")
|
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")
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
|
|
|
|
recent_projects_submenu = PopupMenu.new()
|
2020-10-26 20:51:55 +00:00
|
|
|
|
recent_projects_submenu.set_name("recent_projects_submenu")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
new_image_dialog = find_node_by_name(root, "CreateNewImage")
|
2020-06-09 17:19:55 +00:00
|
|
|
|
open_sprites_dialog = find_node_by_name(root, "OpenSprite")
|
|
|
|
|
save_sprites_dialog = find_node_by_name(root, "SaveSprite")
|
2020-06-30 17:25:43 +00:00
|
|
|
|
save_sprites_html5_dialog = find_node_by_name(root, "SaveSpriteHTML5")
|
2020-05-03 15:47:13 +00:00
|
|
|
|
export_dialog = find_node_by_name(root, "ExportDialog")
|
2020-05-28 00:41:28 +00:00
|
|
|
|
preferences_dialog = find_node_by_name(root, "PreferencesDialog")
|
2020-06-05 14:50:52 +00:00
|
|
|
|
unsaved_changes_dialog = find_node_by_name(root, "UnsavedCanvasDialog")
|
2019-12-28 16:35:53 +00:00
|
|
|
|
|
2020-04-15 18:52:20 +00:00
|
|
|
|
color_switch_button = find_node_by_name(root, "ColorSwitch")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
brushes_popup = find_node_by_name(root, "BrushesPopup")
|
2020-04-24 21:42:02 +00:00
|
|
|
|
patterns_popup = find_node_by_name(root, "PatternsPopup")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2020-01-15 20:01:43 +00:00
|
|
|
|
animation_timeline = find_node_by_name(root, "AnimationTimeline")
|
2020-10-20 00:27:38 +00:00
|
|
|
|
frame_properties = find_node_by_name(root, "FrameProperties")
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-01-18 22:56:30 +00:00
|
|
|
|
layers_container = find_node_by_name(animation_timeline, "LayersContainer")
|
|
|
|
|
frames_container = find_node_by_name(animation_timeline, "FramesContainer")
|
2020-01-15 20:01:43 +00:00
|
|
|
|
animation_timer = find_node_by_name(animation_timeline, "AnimationTimer")
|
2020-01-18 19:06:47 +00:00
|
|
|
|
frame_ids = find_node_by_name(animation_timeline, "FrameIDs")
|
2020-05-23 21:22:06 +00:00
|
|
|
|
current_frame_mark_label = find_node_by_name(control, "CurrentFrameMark")
|
2020-04-03 12:34:16 +00:00
|
|
|
|
onion_skinning_button = find_node_by_name(animation_timeline, "OnionSkinning")
|
2020-01-15 20:01:43 +00:00
|
|
|
|
loop_animation_button = find_node_by_name(animation_timeline, "LoopAnim")
|
|
|
|
|
play_forward = find_node_by_name(animation_timeline, "PlayForward")
|
|
|
|
|
play_backwards = find_node_by_name(animation_timeline, "PlayBackwards")
|
2020-04-02 00:29:14 +00:00
|
|
|
|
tag_container = find_node_by_name(animation_timeline, "TagContainer")
|
2020-04-05 21:51:46 +00:00
|
|
|
|
tag_dialog = find_node_by_name(animation_timeline, "FrameTagDialog")
|
2019-11-29 22:41:34 +00:00
|
|
|
|
|
2020-05-03 15:17:12 +00:00
|
|
|
|
remove_frame_button = find_node_by_name(animation_timeline, "DeleteFrame")
|
2020-10-04 23:37:55 +00:00
|
|
|
|
move_left_frame_button = find_node_by_name(animation_timeline, "MoveLeft")
|
|
|
|
|
move_right_frame_button = find_node_by_name(animation_timeline, "MoveRight")
|
2020-05-03 15:17:12 +00:00
|
|
|
|
|
2020-01-18 19:06:47 +00:00
|
|
|
|
remove_layer_button = find_node_by_name(animation_timeline, "RemoveLayer")
|
|
|
|
|
move_up_layer_button = find_node_by_name(animation_timeline, "MoveUpLayer")
|
2020-03-26 01:24:25 +00:00
|
|
|
|
move_down_layer_button = find_node_by_name(animation_timeline, "MoveDownLayer")
|
2020-01-18 19:06:47 +00:00
|
|
|
|
merge_down_layer_button = find_node_by_name(animation_timeline, "MergeDownLayer")
|
|
|
|
|
|
|
|
|
|
layer_opacity_slider = find_node_by_name(animation_timeline, "OpacitySlider")
|
|
|
|
|
layer_opacity_spinbox = find_node_by_name(animation_timeline, "OpacitySpinBox")
|
2019-12-15 11:44:53 +00:00
|
|
|
|
|
2020-08-01 21:59:00 +00:00
|
|
|
|
preview_zoom_slider = find_node_by_name(root, "PreviewZoomSlider")
|
|
|
|
|
|
2019-12-15 03:11:32 +00:00
|
|
|
|
add_palette_button = find_node_by_name(root, "AddPalette")
|
|
|
|
|
edit_palette_button = find_node_by_name(root, "EditPalette")
|
2019-12-30 18:29:46 +00:00
|
|
|
|
palette_option_button = find_node_by_name(root, "PaletteOptionButton")
|
2019-12-15 03:11:32 +00:00
|
|
|
|
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")
|
2020-06-13 14:59:57 +00:00
|
|
|
|
quit_dialog = find_node_by_name(root, "QuitDialog")
|
|
|
|
|
quit_and_save_dialog = find_node_by_name(root, "QuitAndSaveDialog")
|
2019-08-18 09:28:38 +00:00
|
|
|
|
|
2020-06-04 23:48:38 +00:00
|
|
|
|
projects.append(Project.new())
|
2020-06-05 15:54:11 +00:00
|
|
|
|
projects[0].layers.append(Layer.new())
|
2020-06-04 23:48:38 +00:00
|
|
|
|
current_project = projects[0]
|
|
|
|
|
|
2020-04-02 00:29:14 +00:00
|
|
|
|
|
2019-12-28 01:07:48 +00:00
|
|
|
|
# Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name
|
2020-06-01 13:42:53 +00:00
|
|
|
|
func find_node_by_name(root : Node, node_name : String) -> 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
|
|
|
|
|
|
2020-04-19 21:09:48 +00:00
|
|
|
|
|
2019-11-13 13:45:55 +00:00
|
|
|
|
func notification_label(text : String) -> void:
|
2020-05-01 22:19:01 +00:00
|
|
|
|
var notification : Label = load("res://src/UI/NotificationLabel.tscn").instance()
|
2019-12-08 01:12:34 +00:00
|
|
|
|
notification.text = tr(text)
|
2020-03-09 14:59:17 +00:00
|
|
|
|
notification.rect_position = Vector2(240, OS.window_size.y - animation_timeline.rect_size.y - 20)
|
2020-03-01 15:56:34 +00:00
|
|
|
|
notification.theme = control.theme
|
2019-11-13 13:45:55 +00:00
|
|
|
|
get_tree().get_root().add_child(notification)
|
|
|
|
|
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func general_undo(project : Project = current_project) -> void:
|
|
|
|
|
project.undos -= 1
|
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
2020-04-19 18:17:33 +00:00
|
|
|
|
notification_label("Undo: %s" % action_name)
|
|
|
|
|
|
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func general_redo(project : Project = current_project) -> void:
|
|
|
|
|
if project.undos < project.undo_redo.get_version(): # If we did undo and then redo
|
|
|
|
|
project.undos = project.undo_redo.get_version()
|
2020-04-19 18:17:33 +00:00
|
|
|
|
if control.redone:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
2020-04-19 18:17:33 +00:00
|
|
|
|
notification_label("Redo: %s" % action_name)
|
|
|
|
|
|
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func undo(_frame_index := -1, _layer_index := -1, project : Project = current_project) -> void:
|
|
|
|
|
general_undo(project)
|
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
2020-04-22 16:01:33 +00:00
|
|
|
|
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
|
2020-06-02 23:14:24 +00:00
|
|
|
|
if _layer_index > -1 and _frame_index > -1:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
canvas.update_texture(_layer_index, _frame_index, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
else:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
for i in project.frames.size():
|
|
|
|
|
for j in project.layers.size():
|
|
|
|
|
canvas.update_texture(j, i, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
if action_name == "Scale":
|
|
|
|
|
canvas.camera_zoom()
|
2020-08-17 19:54:33 +00:00
|
|
|
|
Global.canvas.grid.isometric_polylines.clear()
|
|
|
|
|
Global.canvas.grid.update()
|
2020-09-14 14:51:35 +00:00
|
|
|
|
Global.cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
elif "Frame" in action_name:
|
|
|
|
|
# This actually means that frames.size is one, but it hasn't been updated yet
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if project.frames.size() == 2: # Stop animating
|
2019-11-23 22:52:17 +00:00
|
|
|
|
play_forward.pressed = false
|
|
|
|
|
play_backwards.pressed = false
|
|
|
|
|
animation_timer.stop()
|
2019-11-10 01:25:25 +00:00
|
|
|
|
|
2019-12-27 22:57:28 +00:00
|
|
|
|
canvas.update()
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if !project.has_changed:
|
|
|
|
|
project.has_changed = true
|
|
|
|
|
if project == current_project:
|
|
|
|
|
self.window_title = window_title + "(*)"
|
2019-11-13 13:45:55 +00:00
|
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func redo(_frame_index := -1, _layer_index := -1, project : Project = current_project) -> void:
|
|
|
|
|
general_redo(project)
|
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
2020-04-22 16:01:33 +00:00
|
|
|
|
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
|
2020-06-02 23:14:24 +00:00
|
|
|
|
if _layer_index > -1 and _frame_index > -1:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
canvas.update_texture(_layer_index, _frame_index, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
else:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
for i in project.frames.size():
|
|
|
|
|
for j in project.layers.size():
|
|
|
|
|
canvas.update_texture(j, i, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
if action_name == "Scale":
|
|
|
|
|
canvas.camera_zoom()
|
2020-08-17 19:54:33 +00:00
|
|
|
|
Global.canvas.grid.isometric_polylines.clear()
|
|
|
|
|
Global.canvas.grid.update()
|
2020-09-14 14:51:35 +00:00
|
|
|
|
Global.cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
elif "Frame" in action_name:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if project.frames.size() == 1: # Stop animating
|
2019-11-23 22:52:17 +00:00
|
|
|
|
play_forward.pressed = false
|
|
|
|
|
play_backwards.pressed = false
|
|
|
|
|
animation_timer.stop()
|
2019-11-10 01:25:25 +00:00
|
|
|
|
|
2019-12-27 22:57:28 +00:00
|
|
|
|
canvas.update()
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if !project.has_changed:
|
|
|
|
|
project.has_changed = true
|
|
|
|
|
if project == current_project:
|
|
|
|
|
self.window_title = window_title + "(*)"
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
|
|
2020-02-22 15:21:52 +00:00
|
|
|
|
func title_changed(value : String) -> void:
|
|
|
|
|
window_title = value
|
|
|
|
|
OS.set_window_title(value)
|
|
|
|
|
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2020-06-04 18:05:36 +00:00
|
|
|
|
func project_changed(value : int) -> void:
|
|
|
|
|
current_project_index = value
|
|
|
|
|
current_project = projects[value]
|
2020-06-05 01:30:31 +00:00
|
|
|
|
current_project.change_project()
|
2020-04-19 17:39:08 +00:00
|
|
|
|
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2020-05-08 15:37:45 +00:00
|
|
|
|
func dialog_open(open : bool) -> void:
|
|
|
|
|
if open:
|
|
|
|
|
can_draw = false
|
|
|
|
|
control.get_node("ModulateTween").interpolate_property(control, "modulate", control.modulate, Color(0.5, 0.5, 0.5), 0.1, Tween.TRANS_LINEAR, Tween.EASE_OUT)
|
|
|
|
|
else:
|
|
|
|
|
can_draw = true
|
|
|
|
|
control.get_node("ModulateTween").interpolate_property(control, "modulate", control.modulate, Color.white, 0.1, Tween.TRANS_LINEAR, Tween.EASE_OUT)
|
|
|
|
|
|
|
|
|
|
control.get_node("ModulateTween").start()
|
|
|
|
|
|
|
|
|
|
|
2020-05-03 00:13:08 +00:00
|
|
|
|
func disable_button(button : BaseButton, disable : bool) -> void:
|
|
|
|
|
button.disabled = disable
|
|
|
|
|
if disable:
|
|
|
|
|
button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
|
|
|
|
else:
|
|
|
|
|
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
|
|
|
|
|
|
|
|
|
if button is Button:
|
|
|
|
|
var theme := theme_type
|
2020-06-01 00:36:07 +00:00
|
|
|
|
if theme == Theme_Types.CARAMEL:
|
|
|
|
|
theme = Theme_Types.DARK
|
2020-05-03 00:13:08 +00:00
|
|
|
|
for c in button.get_children():
|
|
|
|
|
if c is TextureRect:
|
|
|
|
|
var normal_file_name = c.texture.resource_path.get_file().trim_suffix(".png").replace("_disabled", "")
|
|
|
|
|
if disable:
|
2020-05-06 12:56:44 +00:00
|
|
|
|
change_button_texturerect(c, "%s_disabled.png" % normal_file_name)
|
2020-05-03 00:13:08 +00:00
|
|
|
|
else:
|
2020-05-06 12:56:44 +00:00
|
|
|
|
change_button_texturerect(c, "%s.png" % normal_file_name)
|
2020-05-03 00:13:08 +00:00
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
2020-05-06 12:19:53 +00:00
|
|
|
|
func change_button_texturerect(texture_button : TextureRect, new_file_name : String) -> void:
|
|
|
|
|
var file_name := texture_button.texture.resource_path.get_basename().get_file()
|
|
|
|
|
var directory_path := texture_button.texture.resource_path.get_basename().replace(file_name, "")
|
|
|
|
|
texture_button.texture = load(directory_path.plus_file(new_file_name))
|
|
|
|
|
|
|
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
|
func update_hint_tooltips() -> void:
|
|
|
|
|
var root = get_tree().get_root()
|
|
|
|
|
|
|
|
|
|
var rect_select : BaseButton = find_node_by_name(root, "RectSelect")
|
|
|
|
|
rect_select.hint_tooltip = tr("""Rectangular Selection
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Press %s to move the content""") % [InputMap.get_action_list("left_rectangle_select_tool")[0].as_text(), InputMap.get_action_list("right_rectangle_select_tool")[0].as_text(), "Shift"]
|
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
var zoom_tool : BaseButton = find_node_by_name(root, "Zoom")
|
|
|
|
|
zoom_tool.hint_tooltip = tr("""Zoom
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_zoom_tool")[0].as_text(), InputMap.get_action_list("right_zoom_tool")[0].as_text()]
|
|
|
|
|
|
|
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
|
var color_picker : BaseButton = find_node_by_name(root, "ColorPicker")
|
|
|
|
|
color_picker.hint_tooltip = tr("""Color Picker
|
|
|
|
|
Select a color from a pixel of the sprite
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_colorpicker_tool")[0].as_text(), InputMap.get_action_list("right_colorpicker_tool")[0].as_text()]
|
|
|
|
|
|
|
|
|
|
var pencil : BaseButton = find_node_by_name(root, "Pencil")
|
|
|
|
|
pencil.hint_tooltip = tr("""Pencil
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Hold %s to make a line""") % [InputMap.get_action_list("left_pencil_tool")[0].as_text(), InputMap.get_action_list("right_pencil_tool")[0].as_text(), "Shift"]
|
|
|
|
|
|
|
|
|
|
var eraser : BaseButton = find_node_by_name(root, "Eraser")
|
|
|
|
|
eraser.hint_tooltip = tr("""Eraser
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Hold %s to make a line""") % [InputMap.get_action_list("left_eraser_tool")[0].as_text(), InputMap.get_action_list("right_eraser_tool")[0].as_text(), "Shift"]
|
|
|
|
|
|
|
|
|
|
var bucket : BaseButton = find_node_by_name(root, "Bucket")
|
|
|
|
|
bucket.hint_tooltip = tr("""Bucket
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_fill_tool")[0].as_text(), InputMap.get_action_list("right_fill_tool")[0].as_text()]
|
|
|
|
|
|
|
|
|
|
var ld : BaseButton = find_node_by_name(root, "LightenDarken")
|
|
|
|
|
ld.hint_tooltip = tr("""Lighten/Darken
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_lightdark_tool")[0].as_text(), InputMap.get_action_list("right_lightdark_tool")[0].as_text()]
|
|
|
|
|
|
2020-04-12 16:50:14 +00:00
|
|
|
|
var color_switch : BaseButton = find_node_by_name(root, "ColorSwitch")
|
|
|
|
|
color_switch.hint_tooltip = tr("""Switch left and right colors
|
2020-04-15 18:52:20 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("switch_colors")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var first_frame : BaseButton = find_node_by_name(root, "FirstFrame")
|
|
|
|
|
first_frame.hint_tooltip = tr("""Jump to the first frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_first_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var previous_frame : BaseButton = find_node_by_name(root, "PreviousFrame")
|
|
|
|
|
previous_frame.hint_tooltip = tr("""Go to the previous frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_previous_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
play_backwards.hint_tooltip = tr("""Play the animation backwards (from end to beginning)
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("play_backwards")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
play_forward.hint_tooltip = tr("""Play the animation forward (from beginning to end)
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("play_forward")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var next_frame : BaseButton = find_node_by_name(root, "NextFrame")
|
|
|
|
|
next_frame.hint_tooltip = tr("""Go to the next frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_next_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var last_frame : BaseButton = find_node_by_name(root, "LastFrame")
|
|
|
|
|
last_frame.hint_tooltip = tr("""Jump to the last frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_last_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
|
|
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")
|
|
|
|
|
|
2020-06-05 23:16:53 +00:00
|
|
|
|
var i := 0
|
2020-06-04 18:05:36 +00:00
|
|
|
|
for project in projects:
|
|
|
|
|
project.undo_redo.free()
|
2020-06-05 23:16:53 +00:00
|
|
|
|
OpenSave.remove_backup(i)
|
|
|
|
|
i += 1
|
2020-10-26 20:51:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func save_project_to_recent_list(path : String) -> void:
|
|
|
|
|
if path.get_file().substr(0, 7) == "backup-" or path == "":
|
|
|
|
|
return
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
if recent_projects.has(path):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if recent_projects.size() >= 5:
|
|
|
|
|
recent_projects.pop_front()
|
|
|
|
|
recent_projects.push_back(path)
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
config_cache.set_value("data", "recent_projects", recent_projects)
|
|
|
|
|
|
|
|
|
|
recent_projects_submenu.clear()
|
|
|
|
|
update_recent_projects_submenu()
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
func update_recent_projects_submenu() -> void:
|
|
|
|
|
for project in Global.recent_projects:
|
|
|
|
|
recent_projects_submenu.add_item(project.get_file())
|