Removal of the DrawGD/Global singleton part 1.

This commit is contained in:
Relintai 2020-11-29 16:34:17 +01:00
parent 140a687d6b
commit 431d2e5488
48 changed files with 159 additions and 77 deletions

View File

@ -190,53 +190,54 @@ func _ready() -> void:
# XDGDataDirs depends on it nyaa
directory_module = XDGDataPaths.new()
image_clipboard = Image.new()
Input.set_custom_mouse_cursor(DrawGD.cursor_image, Input.CURSOR_CROSS, Vector2(15, 15))
Input.set_custom_mouse_cursor(cursor_image, Input.CURSOR_CROSS, Vector2(15, 15))
refresh_nodes()
func refresh_nodes():
var root = get_tree().get_root()
control = find_node_by_name(root, "DrawGDControl")
#var root = get_tree().get_root()
# control = find_node_by_name(root, "DrawGDControl")
control = get_parent()
top_menu_container = find_node_by_name(control, "TopMenuContainer")
left_cursor = find_node_by_name(root, "LeftCursor")
right_cursor = find_node_by_name(root, "RightCursor")
canvas = find_node_by_name(root, "Canvas")
left_cursor = find_node_by_name(control, "LeftCursor")
right_cursor = find_node_by_name(control, "RightCursor")
canvas = find_node_by_name(control, "Canvas")
tabs = find_node_by_name(root, "Tabs")
main_viewport = find_node_by_name(root, "ViewportContainer")
second_viewport = find_node_by_name(root, "ViewportContainer2")
small_preview_viewport = find_node_by_name(root, "PreviewViewportContainer")
tabs = find_node_by_name(control, "Tabs")
main_viewport = find_node_by_name(control, "ViewportContainer")
second_viewport = find_node_by_name(control, "ViewportContainer2")
small_preview_viewport = find_node_by_name(control, "PreviewViewportContainer")
camera = find_node_by_name(main_viewport, "Camera2D")
camera2 = find_node_by_name(root, "Camera2D2")
camera_preview = find_node_by_name(root, "CameraPreview")
selection_rectangle = find_node_by_name(root, "SelectionRectangle")
horizontal_ruler = find_node_by_name(root, "HorizontalRuler")
vertical_ruler = find_node_by_name(root, "VerticalRuler")
transparent_checker = find_node_by_name(root, "TransparentChecker")
camera2 = find_node_by_name(control, "Camera2D2")
camera_preview = find_node_by_name(control, "CameraPreview")
selection_rectangle = find_node_by_name(control, "SelectionRectangle")
horizontal_ruler = find_node_by_name(control, "HorizontalRuler")
vertical_ruler = find_node_by_name(control, "VerticalRuler")
transparent_checker = find_node_by_name(control, "TransparentChecker")
file_menu = find_node_by_name(root, "FileMenu")
edit_menu = find_node_by_name(root, "EditMenu")
view_menu = find_node_by_name(root, "ViewMenu")
image_menu = find_node_by_name(root, "ImageMenu")
help_menu = find_node_by_name(root, "HelpMenu")
cursor_position_label = find_node_by_name(root, "CursorPosition")
zoom_level_label = find_node_by_name(root, "ZoomLevel")
file_menu = find_node_by_name(control, "FileMenu")
edit_menu = find_node_by_name(control, "EditMenu")
view_menu = find_node_by_name(control, "ViewMenu")
image_menu = find_node_by_name(control, "ImageMenu")
help_menu = find_node_by_name(control, "HelpMenu")
cursor_position_label = find_node_by_name(control, "CursorPosition")
zoom_level_label = find_node_by_name(control, "ZoomLevel")
new_image_dialog = find_node_by_name(root, "CreateNewImage")
open_sprites_dialog = find_node_by_name(root, "OpenSprite")
save_sprites_dialog = find_node_by_name(root, "SaveSprite")
save_sprites_html5_dialog = find_node_by_name(root, "SaveSpriteHTML5")
export_dialog = find_node_by_name(root, "ExportDialog")
preferences_dialog = find_node_by_name(root, "PreferencesDialog")
unsaved_changes_dialog = find_node_by_name(root, "UnsavedCanvasDialog")
new_image_dialog = find_node_by_name(control, "CreateNewImage")
open_sprites_dialog = find_node_by_name(control, "OpenSprite")
save_sprites_dialog = find_node_by_name(control, "SaveSprite")
save_sprites_html5_dialog = find_node_by_name(control, "SaveSpriteHTML5")
export_dialog = find_node_by_name(control, "ExportDialog")
preferences_dialog = find_node_by_name(control, "PreferencesDialog")
unsaved_changes_dialog = find_node_by_name(control, "UnsavedCanvasDialog")
color_switch_button = find_node_by_name(root, "ColorSwitch")
color_switch_button = find_node_by_name(control, "ColorSwitch")
brushes_popup = find_node_by_name(root, "BrushesPopup")
patterns_popup = find_node_by_name(root, "PatternsPopup")
brushes_popup = find_node_by_name(control, "BrushesPopup")
patterns_popup = find_node_by_name(control, "PatternsPopup")
animation_timeline = find_node_by_name(root, "AnimationTimeline")
animation_timeline = find_node_by_name(control, "AnimationTimeline")
layers_container = find_node_by_name(animation_timeline, "LayersContainer")
frames_container = find_node_by_name(animation_timeline, "FramesContainer")
@ -262,20 +263,20 @@ func refresh_nodes():
layer_opacity_slider = find_node_by_name(animation_timeline, "OpacitySlider")
layer_opacity_spinbox = find_node_by_name(animation_timeline, "OpacitySpinBox")
preview_zoom_slider = find_node_by_name(root, "PreviewZoomSlider")
preview_zoom_slider = find_node_by_name(control, "PreviewZoomSlider")
add_palette_button = find_node_by_name(root, "AddPalette")
edit_palette_button = find_node_by_name(root, "EditPalette")
palette_option_button = find_node_by_name(root, "PaletteOptionButton")
palette_container = find_node_by_name(root, "PaletteContainer")
edit_palette_popup = find_node_by_name(root, "EditPalettePopup")
new_palette_dialog = find_node_by_name(root, "NewPaletteDialog")
add_palette_button = find_node_by_name(control, "AddPalette")
edit_palette_button = find_node_by_name(control, "EditPalette")
palette_option_button = find_node_by_name(control, "PaletteOptionButton")
palette_container = find_node_by_name(control, "PaletteContainer")
edit_palette_popup = find_node_by_name(control, "EditPalettePopup")
new_palette_dialog = find_node_by_name(control, "NewPaletteDialog")
new_palette_name_line_edit = find_node_by_name(new_palette_dialog, "NewPaletteNameLineEdit")
palette_import_file_dialog = find_node_by_name(root, "PaletteImportFileDialog")
palette_import_file_dialog = find_node_by_name(control, "PaletteImportFileDialog")
error_dialog = find_node_by_name(root, "ErrorDialog")
quit_dialog = find_node_by_name(root, "QuitDialog")
quit_and_save_dialog = find_node_by_name(root, "QuitAndSaveDialog")
error_dialog = find_node_by_name(control, "ErrorDialog")
quit_dialog = find_node_by_name(control, "QuitDialog")
quit_and_save_dialog = find_node_by_name(control, "QuitAndSaveDialog")
projects.append(Project.new())
projects[0].layers.append(Layer.new())
@ -330,9 +331,9 @@ func undo(_frame_index := -1, _layer_index := -1, project : Project = current_pr
if action_name == "Scale":
canvas.camera_zoom()
DrawGD.canvas.grid.isometric_polylines.clear()
DrawGD.canvas.grid.update()
DrawGD.cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
canvas.grid.isometric_polylines.clear()
canvas.grid.update()
cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
elif "Frame" in action_name:
# This actually means that frames.size is one, but it hasn't been updated yet
@ -361,9 +362,9 @@ func redo(_frame_index := -1, _layer_index := -1, project : Project = current_pr
if action_name == "Scale":
canvas.camera_zoom()
DrawGD.canvas.grid.isometric_polylines.clear()
DrawGD.canvas.grid.update()
DrawGD.cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
canvas.grid.isometric_polylines.clear()
canvas.grid.update()
cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
elif "Frame" in action_name:
if project.frames.size() == 1: # Stop animating
@ -517,5 +518,5 @@ func _exit_tree() -> void:
var i := 0
for project in projects:
project.undo_redo.free()
DrawGD.opensave.remove_backup(i)
opensave.remove_backup(i)
i += 1

View File

@ -1,6 +1,7 @@
tool
extends Reference
var DrawGD : Node = null
enum GradientDirection {TOP, BOTTOM, LEFT, RIGHT}

View File

@ -1,6 +1,7 @@
tool
extends Node
var DrawGD : Node = null
enum ExportTab { FRAME = 0, SPRITESHEET = 1, ANIMATION = 2 }
var current_tab : int = ExportTab.FRAME

View File

@ -1,6 +1,7 @@
tool
extends Reference
var DrawGD : Node = null
# Get hold of the brushes, including random brushes (subdirectories and % files
# in them, non % files get loaded independently.) nyaaa

View File

@ -9,6 +9,7 @@ var backup_save_paths := [] # Array of strings
onready var autosave_timer : Timer
var DrawGD : Node = null
func _ready() -> void:
autosave_timer = Timer.new()

View File

@ -13,6 +13,8 @@ class Slot:
var pixel_perfect := false
var horizontal_mirror := false
var vertical_mirror := false
var DrawGD : Node = null
func _init(slot_name : String) -> void:
@ -59,6 +61,7 @@ var control := false
var shift := false
var alt := false
var DrawGD : Node = null
func _ready():
yield(get_tree(), "idle_frame")

View File

@ -17,6 +17,7 @@ var preview : TextureRect
var selection_checkbox : CheckBox
var affect_option_button : OptionButton
var DrawGD : Node = null
func _ready() -> void:
set_nodes()

View File

@ -4,6 +4,8 @@ class_name Project extends Reference
var Export = preload("res://addons/draw_gd/src/Autoload/Export.gd")
var DrawGD : Node = null
var name := "" setget name_changed
var size : Vector2 setget size_changed
var undo_redo : UndoRedo

View File

@ -9,6 +9,7 @@ var opensprite_file_selected := false
var redone := false
var is_quitting_on_save := false
onready var DrawGD : Node = $DrawGDSingleton
# Called when the node enters the scene tree for the first time.
func _ready() -> void:

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://addons/draw_gd/src/Main.gd" type="Script" id=1]
[ext_resource path="res://addons/draw_gd/src/UI/Dialogs/ImageEffects/ImageEffects.tscn" type="PackedScene" id=2]
@ -12,8 +12,9 @@
[ext_resource path="res://addons/draw_gd/src/UI/Dialogs/SaveSpriteHTML5.tscn" type="PackedScene" id=10]
[ext_resource path="res://addons/draw_gd/src/UI/TopMenuContainer.tscn" type="PackedScene" id=11]
[ext_resource path="res://addons/draw_gd/src/UI/Dialogs/SaveSprite.tscn" type="PackedScene" id=12]
[ext_resource path="res://addons/draw_gd/src/Autoload/DrawGD.gd" type="Script" id=13]
[sub_resource type="Image" id=1]
[sub_resource type="Image" id=5]
data = {
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 0, 255, 175, 255, 175, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 0, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 0, 255, 132, 255, 132, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 0, 255, 132, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 48, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 48, 255, 48, 255, 48, 255, 175, 255, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 48, 255, 48, 255, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"format": "LumAlpha8",
@ -25,10 +26,10 @@ data = {
[sub_resource type="ImageTexture" id=2]
flags = 0
flags = 0
image = SubResource( 1 )
image = SubResource( 5 )
size = Vector2( 22, 22 )
[sub_resource type="Image" id=3]
[sub_resource type="Image" id=6]
data = {
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 0, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 0, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 132, 255, 132, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 132, 255, 132, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 132, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 175, 255, 175, 255, 175, 255, 175, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"format": "LumAlpha8",
@ -40,7 +41,7 @@ data = {
[sub_resource type="ImageTexture" id=4]
flags = 0
flags = 0
image = SubResource( 3 )
image = SubResource( 6 )
size = Vector2( 22, 22 )
[node name="DrawGDControl" type="Control"]
@ -149,6 +150,9 @@ texture = SubResource( 4 )
[node name="ModulateTween" type="Tween" parent="."]
[node name="DrawGDSingleton" type="Node" parent="."]
script = ExtResource( 13 )
[connection signal="popup_hide" from="Dialogs/CreateNewImage" to="." method="_can_draw_true"]
[connection signal="file_selected" from="Dialogs/OpenSprite" to="." method="_on_OpenSprite_file_selected"]
[connection signal="popup_hide" from="Dialogs/OpenSprite" to="." method="_on_OpenSprite_popup_hide"]

View File

@ -15,6 +15,7 @@ onready var left_color_button = $VBoxContainer/HBoxContainer/VBoxContainer/Cente
onready var right_color_button = $VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/RightColor/NinePatchRect
onready var dummyBtn = $DummyBtn
var DrawGD : Node = null
func _ready() -> void:
$VBoxContainer/HBoxContainer/EditPaletteColorPicker.presets_visible = false

View File

@ -14,6 +14,7 @@ onready var remove_palette_warning = $"../../../../RemovePaletteWarning"
var Import = preload("res://addons/draw_gd/src/Autoload/Import.gd")
var DrawGD : Node = null
func _ready() -> void:
_load_palettes()

View File

@ -27,8 +27,17 @@ const languages_dict := {
var loaded_locales : Array
onready var cjk_font = preload("res://addons/draw_gd/assets/fonts/CJK/NotoSansCJKtc-Regular.tres")
var DrawGD : Node = null
func _ready() -> void:
var n : Node = get_parent()
while n:
if n.has_method("DrawGD"):
print("ddddddddddddddddd")
DrawGD = n.DrawGD
n = n.get_parent()
loaded_locales = TranslationServer.get_loaded_locales()
# Make sure locales are always sorted, in the same order

View File

@ -8,6 +8,8 @@ var shortcut_already_assigned = false
var old_input_event : InputEventKey
var new_input_event : InputEventKey
var DrawGD : Node = null
onready var shortcut_selector_popup = DrawGD.preferences_dialog.get_node("Popups/ShortcutSelector")
onready var theme_font_color : Color = DrawGD.preferences_dialog.get_node("Popups/ShortcutSelector/EnteredShortcut").get_color("font_color")

View File

@ -1,6 +1,8 @@
tool
extends AcceptDialog
var DrawGD : Node = null
# Preferences table: [Prop name in DrawGD, relative node path, value type, default value]
var preferences = [
["open_last_project", "Startup/StartupContainer/OpenLastProject", "pressed", DrawGD.open_last_project],

View File

@ -7,6 +7,8 @@ var value_type : String
var default_value
var node : Node
var DrawGD : Node = null
func _ready() -> void:
# Handle themes

View File

@ -11,6 +11,7 @@ var _move_pixel := false
var _clipboard := Image.new()
var _undo_data := {}
var DrawGD : Node = null
func _ready() -> void:
_clear_image.create(1, 1, false, Image.FORMAT_RGBA8)
@ -69,7 +70,7 @@ func move_start(move_pixel : bool) -> void:
return
_undo_data = _get_undo_data(true)
var project := DrawGD.current_project
var project = DrawGD.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var rect = Rect2(Vector2.ZERO, project.size)
@ -91,7 +92,7 @@ func move_end() -> void:
var undo_data = _undo_data if _move_pixel else _get_undo_data(false)
if _move_pixel:
var project := DrawGD.current_project
var project = DrawGD.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var size := _clipped_rect.size
var rect = Rect2(Vector2.ZERO, size)
@ -108,7 +109,7 @@ func copy() -> void:
if _selected_rect.has_no_area():
return
var project := DrawGD.current_project
var project = DrawGD.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
_clipboard = image.get_rect(_selected_rect)
if _clipboard.is_invisible():
@ -122,7 +123,7 @@ func cut() -> void: # This is basically the same as copy + delete
return
var undo_data = _get_undo_data(true)
var project := DrawGD.current_project
var project = DrawGD.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var size := _selected_rect.size
var rect = Rect2(Vector2.ZERO, size)
@ -143,7 +144,7 @@ func paste() -> void:
return
var undo_data = _get_undo_data(true)
var project := DrawGD.current_project
var project = DrawGD.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var size := _selected_rect.size
var rect = Rect2(Vector2.ZERO, size)
@ -154,7 +155,7 @@ func paste() -> void:
func delete() -> void:
var undo_data = _get_undo_data(true)
var project := DrawGD.current_project
var project = DrawGD.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var size := _selected_rect.size
var rect = Rect2(Vector2.ZERO, size)
@ -166,7 +167,7 @@ func delete() -> void:
func commit_undo(action : String, undo_data : Dictionary) -> void:
var redo_data = _get_undo_data("image_data" in undo_data)
var project := DrawGD.current_project
var project = DrawGD.current_project
project.undos += 1
project.undo_redo.create_action(action)
@ -183,7 +184,7 @@ func commit_undo(action : String, undo_data : Dictionary) -> void:
func _get_undo_data(undo_image : bool) -> Dictionary:
var data = {}
var project := DrawGD.current_project
var project = DrawGD.current_project
data["selected_rect"] = DrawGD.current_project.selected_rect
if undo_image:
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image

View File

@ -14,6 +14,8 @@ signal brush_selected(brush)
signal brush_removed(brush)
enum {PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM}
var DrawGD : Node = null
var pixel_image = preload("res://addons/draw_gd/assets/graphics/pixel_image.png")
var circle_image = preload("res://addons/draw_gd/assets/graphics/circle_9x9.png")
var circle_filled_image = preload("res://addons/draw_gd/assets/graphics/circle_filled_9x9.png")
@ -62,6 +64,8 @@ static func create_button(image : Image) -> Node:
static func add_file_brush(images : Array, hint := "") -> void:
var DrawGD : Node = null
var button = create_button(images[0])
button.brush.type = FILE if images.size() == 1 else RANDOM_FILE
button.brush.image = images[0]
@ -73,6 +77,8 @@ static func add_file_brush(images : Array, hint := "") -> void:
static func add_project_brush(image : Image, hint := "") -> void:
var DrawGD : Node = null
var button = create_button(image)
button.brush.type = CUSTOM
button.brush.image = image
@ -83,6 +89,8 @@ static func add_project_brush(image : Image, hint := "") -> void:
static func clear_project_brush() -> void:
var DrawGD : Node = null
var container = DrawGD.brushes_popup.get_node("TabContainer/Project/ProjectBrushContainer")
for child in container.get_children():
child.queue_free()

View File

@ -10,6 +10,7 @@ var transparent_checker : ColorRect
var mouse_pos := Vector2.ZERO
var drag := false
var DrawGD : Node = null
func _ready() -> void:
viewport_container = get_parent().get_parent()

View File

@ -14,6 +14,8 @@ onready var grid = $Grid
onready var tile_mode = $TileMode
onready var indicators = $Indicators
var DrawGD : Node = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:

View File

@ -5,6 +5,8 @@ extends Node2D
var frame : int = 0
onready var animation_timer : Timer = $AnimationTimer
var DrawGD : Node = null
func _draw() -> void:
var current_project : Project = DrawGD.current_project
if frame >= current_project.frames.size():

View File

@ -5,6 +5,7 @@ extends Node2D
var location := Vector2.ZERO
var isometric_polylines := [] # An array of PoolVector2Arrays
var DrawGD : Node = null
func _draw() -> void:
if DrawGD.draw_grid:

View File

@ -1,6 +1,7 @@
tool
extends Node2D
var DrawGD : Node = null
func _input(event : InputEvent) -> void:
if DrawGD.has_focus and event is InputEventMouseMotion:

View File

@ -3,17 +3,20 @@ class_name Guide extends Line2D
enum Types {HORIZONTAL, VERTICAL}
var DrawGD : Node = null
var font := preload("res://addons/draw_gd/assets/fonts/Roboto-Regular.tres")
var has_focus := true
var mouse_pos := Vector2.ZERO
var type = Types.HORIZONTAL
var project = DrawGD.current_project
var project = null
func _ready() -> void:
width = DrawGD.camera.zoom.x
default_color = DrawGD.guide_color
project.guides.append(self)
project = DrawGD.current_project
func _input(_event : InputEvent):

View File

@ -10,6 +10,7 @@ var minor_subdivision := 4
var first : Vector2
var last : Vector2
var DrawGD : Node = null
func _ready() -> void:
DrawGD.main_viewport.connect("item_rect_changed", self, "update")

View File

@ -1,7 +1,6 @@
tool
class_name SymmetryGuide extends Guide
var _texture = preload("res://addons/draw_gd/assets/graphics/dotted_line.png")

View File

@ -10,6 +10,7 @@ var minor_subdivision := 4
var first : Vector2
var last : Vector2
var DrawGD : Node = null
func _ready() -> void:
DrawGD.main_viewport.connect("item_rect_changed", self, "update")

View File

@ -4,6 +4,7 @@ extends Node2D
var location := Vector2.ZERO
var DrawGD : Node = null
func _draw() -> void:
var current_cels : Array = DrawGD.current_project.frames[DrawGD.current_project.current_frame].cels

View File

@ -6,6 +6,7 @@ onready var canvas_preview = $HBoxContainer/PreviewViewportContainer/Viewport/Ca
onready var camera : Camera2D = $HBoxContainer/PreviewViewportContainer/Viewport/CameraPreview
onready var play_button : Button = $HBoxContainer/VBoxContainer/PlayButton
var DrawGD : Node = null
func _on_PreviewZoomSlider_value_changed(value : float) -> void:
camera.zoom = -Vector2(value, value)

View File

@ -5,6 +5,7 @@ extends VBoxContainer
onready var left_picker := $ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton
onready var right_picker := $ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/RightColorPickerButton
var DrawGD : Node = null
func _ready() -> void:
DrawGD.tools.connect("color_changed", self, "update_color")

View File

@ -9,6 +9,8 @@ onready var fill_color_node = $VBoxContainer/OptionsContainer/FillColor
onready var size_value = Vector2()
var DrawGD : Node = null
# Template Id identifier
enum Templates {
TDefault = 0,

View File

@ -44,6 +44,7 @@ onready var path_line_edit = $VBoxContainer/Path/PathLineEdit
onready var file_line_edit = $VBoxContainer/File/FileLineEdit
onready var file_file_format = $VBoxContainer/File/FileFormat
var DrawGD : Node = null
func _ready() -> void:
tabs.add_tab("Frame")

View File

@ -16,6 +16,7 @@ onready var x_spinbox : SpinBox = $VBoxContainer/OptionsContainer/XSpinBox
onready var y_spinbox : SpinBox = $VBoxContainer/OptionsContainer/YSpinBox
onready var preview_rect : TextureRect = $VBoxContainer/Preview
var DrawGD : Node = null
func _on_ResizeCanvas_about_to_show() -> void:
if first_time:

View File

@ -1,6 +1,8 @@
tool
extends ConfirmationDialog
var DrawGD : Node = null
var DrawingAlgos = preload("res://addons/draw_gd/src/Autoload/DrawingAlgos.gd")
func _on_ScaleImage_confirmed() -> void:

View File

@ -1,6 +1,7 @@
tool
extends ConfirmationDialog
var DrawGD : Node = null
var current_cel : Image
var shader : Shader

View File

@ -21,6 +21,7 @@ onready var new_layer_options = $VBoxContainer/HBoxContainer/NewLayerOptions
onready var new_brush_options = $VBoxContainer/HBoxContainer/NewBrushOptions
onready var new_brush_name = $VBoxContainer/HBoxContainer/NewBrushOptions/BrushName
var DrawGD : Node = null
func _on_PreviewDialog_about_to_show() -> void:
var img_texture := ImageTexture.new()

View File

@ -4,6 +4,7 @@ extends BaseButton
var pattern := Patterns.Pattern.new()
var DrawGD : Node = null
func _on_PatternButton_pressed() -> void:
DrawGD.patterns_popup.select_pattern(pattern)

View File

@ -11,6 +11,7 @@ signal pattern_selected(pattern)
var default_pattern : Pattern = null
var DrawGD : Node = null
func select_pattern(pattern : Pattern) -> void:
emit_signal("pattern_selected", pattern)
@ -27,6 +28,8 @@ static func create_button(image : Image) -> Node:
static func add(image : Image, hint := "") -> void:
var DrawGD : Node = null
var button = create_button(image)
button.pattern.image = image
button.hint_tooltip = hint

View File

@ -1,6 +1,7 @@
tool
extends Tabs
var DrawGD : Node = null
func _on_Tabs_tab_changed(tab : int) -> void:
DrawGD.current_project_index = tab

View File

@ -10,6 +10,7 @@ var last_frame := 0
var timeline_scroll : ScrollContainer
var tag_scroll_container : ScrollContainer
var DrawGD : Node = null
func _ready() -> void:
timeline_scroll = DrawGD.find_node_by_name(self, "TimelineScroll")
@ -65,11 +66,14 @@ func _on_DeleteFrame_pressed(frame := -1) -> void:
var frame_to_delete : Frame = DrawGD.current_project.frames[frame]
var new_frames : Array = DrawGD.current_project.frames.duplicate()
new_frames.erase(frame_to_delete)
var current_frame := DrawGD.current_project.current_frame
var DrawGD : Node = null
var current_frame = DrawGD.current_project.current_frame
if current_frame > 0 && current_frame == new_frames.size(): # If it's the last frame
current_frame -= 1
var new_animation_tags := DrawGD.current_project.animation_tags.duplicate()
var new_animation_tags = DrawGD.current_project.animation_tags.duplicate()
# Loop through the tags to create new classes for them, so that they won't be the same
# as DrawGD.current_project.animation_tags's classes. Needed for undo/redo to work properly.
for i in new_animation_tags.size():
@ -125,7 +129,7 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
var new_frame := Frame.new()
var new_frames := DrawGD.current_project.frames.duplicate()
var new_frames = DrawGD.current_project.frames.duplicate()
new_frames.insert(frame + 1, new_frame)
for cel in DrawGD.current_project.frames[frame].cels: # Copy every cel
@ -134,7 +138,7 @@ func _on_CopyFrame_pressed(frame := -1) -> void:
sprite.lock()
new_frame.cels.append(Cel.new(sprite, cel.opacity))
var new_animation_tags := DrawGD.current_project.animation_tags.duplicate()
var new_animation_tags = DrawGD.current_project.animation_tags.duplicate()
# Loop through the tags to create new classes for them, so that they won't be the same
# as DrawGD.current_project.animation_tags's classes. Needed for undo/redo to work properly.
for i in new_animation_tags.size():

View File

@ -10,6 +10,7 @@ onready var main_vbox_cont : VBoxContainer = $VBoxContainer/ScrollContainer/VBox
onready var add_tag_button : Button = $VBoxContainer/ScrollContainer/VBoxTagContainer/AddTag
onready var options_dialog = $TagOptions
var DrawGD : Node = null
func _ready() -> void:
$"TagOptions/GridContainer/ColorPickerButton".get_picker().presets_visible = false
@ -93,7 +94,7 @@ func _on_TagOptions_confirmed() -> void:
if tag_from > tag_to:
tag_from = tag_to
var new_animation_tags := DrawGD.current_project.animation_tags.duplicate()
var new_animation_tags = DrawGD.current_project.animation_tags.duplicate()
# Loop through the tags to create new classes for them, so that they won't be the same
# as DrawGD.current_project.animation_tags's classes. Needed for undo/redo to work properly.
for i in new_animation_tags.size():
@ -120,7 +121,7 @@ func _on_TagOptions_confirmed() -> void:
func _on_TagOptions_custom_action(action : String) -> void:
if action == "delete_tag":
var new_animation_tags := DrawGD.current_project.animation_tags.duplicate()
var new_animation_tags = DrawGD.current_project.animation_tags.duplicate()
new_animation_tags.remove(current_tag_id)
# Handle Undo/Redo
DrawGD.current_project.undos += 1

View File

@ -9,6 +9,7 @@ var linked_button : BaseButton
var label : Label
var line_edit : LineEdit
var DrawGD : Node = null
func _ready() -> void:
visibility_button = DrawGD.find_node_by_name(self, "VisibilityButton")

View File

@ -13,6 +13,8 @@ onready var tools := [
[$LightenDarken, "lightdark"],
]
var DrawGD : Node = null
func _ready() -> void:
for t in tools:

View File

@ -10,12 +10,17 @@ var zen_mode := false
var was_exported = false
var DrawGD : Node = null
func _ready() -> void:
setup_file_menu()
setup_edit_menu()
setup_view_menu()
setup_image_menu()
# DrawGds = get_tree().root.find_node("DrawGDSingleton")
# print(DrawGds)
func setup_file_menu() -> void:

View File

@ -1,6 +1,7 @@
tool
extends ColorRect
var DrawGD : Node = null
func _ready() -> void:
rect_size = DrawGD.current_project.size

View File

@ -1,6 +1,7 @@
tool
extends ViewportContainer
var DrawGD : Node = null
func _on_ViewportContainer_mouse_entered() -> void:
DrawGD.has_focus = true

View File

@ -1,6 +1,8 @@
tool
extends Reference
var DrawGD : Node = null
# These are *with* the config subdirectory name
var xdg_data_home : String
var xdg_data_dirs : Array

View File

@ -119,10 +119,6 @@ config/Version="v0.8.1-stable"
driver="Dummy"
[autoload]
DrawGD="*res://addons/draw_gd/src/Autoload/DrawGD.gd"
[debug]
gdscript/warnings/narrowing_conversion=false