Removal of the DrawGD/Global singleton part 3.

This commit is contained in:
Relintai 2020-11-29 17:56:36 +01:00
parent f0bf996e70
commit efb6641ddc
27 changed files with 257 additions and 72 deletions

View File

@ -165,7 +165,7 @@ var error_dialog : AcceptDialog
var quit_dialog : ConfirmationDialog
var quit_and_save_dialog : ConfirmationDialog
onready var current_version : String = ProjectSettings.get_setting("application/config/Version")
var current_version : String = ""
var tools_script = preload("res://addons/draw_gd/src/Autoload/Tools.gd")
var tools = null
@ -174,6 +174,8 @@ var opensave_script = preload("res://addons/draw_gd/src/Autoload/OpenSave.gd")
var opensave = null
func _enter_tree() -> void:
current_version = ProjectSettings.get_setting("application/config/Version")
randomize()
if OS.has_feature("standalone"):
root_directory = OS.get_executable_path().get_base_dir()
@ -278,7 +280,8 @@ func refresh_nodes():
quit_dialog = find_node_by_name(control, "QuitDialog")
quit_and_save_dialog = find_node_by_name(control, "QuitAndSaveDialog")
projects.append(Project.new())
projects.append(Project.new(self))
projects[0].layers.append(Layer.new())
current_project = projects[0]
@ -435,13 +438,15 @@ func update_hint_tooltips() -> void:
%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"]
Press %s to move the content""") % ["", "", "Shift"]
#% [InputMap.get_action_list("left_rectangle_select_tool")[0].as_text(), InputMap.get_action_list("right_rectangle_select_tool")[0].as_text(), "Shift"]
var zoom_tool : BaseButton = find_node_by_name(self, "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()]
%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()]
var color_picker : BaseButton = find_node_by_name(self, "ColorPicker")
@ -449,7 +454,8 @@ Press %s to move the content""") % [InputMap.get_action_list("left_rectangle_sel
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()]
%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(self, "Pencil")
pencil.hint_tooltip = tr("""Pencil
@ -457,7 +463,8 @@ Select a color from a pixel of the sprite
%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"]
Hold %s to make a line""") % ["", "", "Shift"]
#% [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(self, "Eraser")
eraser.hint_tooltip = tr("""Eraser
@ -465,45 +472,55 @@ Hold %s to make a line""") % [InputMap.get_action_list("left_pencil_tool")[0].as
%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"]
Hold %s to make a line""") % ["", "", "Shift"]
#% [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(self, "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()]
%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(self, "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()]
%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()]
var color_switch : BaseButton = find_node_by_name(self, "ColorSwitch")
color_switch.hint_tooltip = tr("""Switch left and right colors
(%s)""") % InputMap.get_action_list("switch_colors")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("switch_colors")[0].as_text()
var first_frame : BaseButton = find_node_by_name(self, "FirstFrame")
first_frame.hint_tooltip = tr("""Jump to the first frame
(%s)""") % InputMap.get_action_list("go_to_first_frame")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("go_to_first_frame")[0].as_text()
var previous_frame : BaseButton = find_node_by_name(self, "PreviousFrame")
previous_frame.hint_tooltip = tr("""Go to the previous frame
(%s)""") % InputMap.get_action_list("go_to_previous_frame")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("go_to_previous_frame")[0].as_text()
play_backwards.hint_tooltip = tr("""Play the animation backwards (from end to beginning)
(%s)""") % InputMap.get_action_list("play_backwards")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("play_backwards")[0].as_text()
play_forward.hint_tooltip = tr("""Play the animation forward (from beginning to end)
(%s)""") % InputMap.get_action_list("play_forward")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("play_forward")[0].as_text()
var next_frame : BaseButton = find_node_by_name(self, "NextFrame")
next_frame.hint_tooltip = tr("""Go to the next frame
(%s)""") % InputMap.get_action_list("go_to_next_frame")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("go_to_next_frame")[0].as_text()
var last_frame : BaseButton = find_node_by_name(self, "LastFrame")
last_frame.hint_tooltip = tr("""Jump to the last frame
(%s)""") % InputMap.get_action_list("go_to_last_frame")[0].as_text()
(%s)""") % ""
#InputMap.get_action_list("go_to_last_frame")[0].as_text()
func _exit_tree() -> void:

View File

@ -11,7 +11,14 @@ onready var autosave_timer : Timer
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
autosave_timer = Timer.new()
autosave_timer.one_shot = false
autosave_timer.process_mode = Timer.TIMER_PROCESS_IDLE
@ -69,7 +76,7 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void:
new_project.animation_tags.clear()
new_project.name = path.get_file()
else:
new_project = Project.new([], path.get_file())
new_project = Project.new(DrawGD, [], path.get_file())
var first_line := file.get_line()
var dict := JSON.parse(first_line)
@ -325,7 +332,7 @@ func save_pxo_file(path : String, autosave : bool, use_zstd_compression := true,
func open_image_as_new_tab(path : String, image : Image) -> void:
var project = Project.new([], path.get_file(), image.get_size())
var project = Project.new(DrawGD, [], path.get_file(), image.get_size())
project.layers.append(Layer.new())
DrawGD.projects.append(project)
@ -339,7 +346,7 @@ func open_image_as_new_tab(path : String, image : Image) -> void:
func open_image_as_spritesheet(path : String, image : Image, horizontal : int, vertical : int) -> void:
var project = Project.new([], path.get_file())
var project = Project.new(DrawGD, [], path.get_file())
project.layers.append(Layer.new())
DrawGD.projects.append(project)
horizontal = min(horizontal, image.get_size().x)

View File

@ -17,7 +17,8 @@ class Slot:
var DrawGD : Node = null
func _init(slot_name : String) -> void:
func _init(pDrawGD, slot_name : String) -> void:
DrawGD = pDrawGD
name = slot_name
kname = name.replace(" ", "_").to_lower()
load_config()
@ -63,10 +64,17 @@ var alt := false
var DrawGD : Node = null
func _ready():
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
yield(get_tree(), "idle_frame")
_slots[BUTTON_LEFT] = Slot.new("Left tool")
_slots[BUTTON_RIGHT] = Slot.new("Right tool")
_slots[BUTTON_LEFT] = Slot.new(DrawGD, "Left tool")
_slots[BUTTON_RIGHT] = Slot.new(DrawGD, "Right tool")
_panels[BUTTON_LEFT] = DrawGD.find_node_by_name(DrawGD.control, "LeftPanelContainer")
_panels[BUTTON_RIGHT] = DrawGD.find_node_by_name(DrawGD.control, "RightPanelContainer")
_tool_buttons = DrawGD.find_node_by_name(DrawGD.control, "ToolButtons")

View File

@ -66,9 +66,7 @@ func set_pixel_perfect(value: bool) -> void:
else:
drawers = [simple_drawer, simple_drawer, simple_drawer, simple_drawer]
func set_pixel(image: Image, position: Vector2, color: Color) -> void:
var project : Project = DrawGD.current_project
func set_pixel(image: Image, position: Vector2, color: Color, project : Project) -> void:
drawers[0].set_pixel(image, position, color, color_op)
# Handle Mirroring

View File

@ -19,7 +19,14 @@ var affect_option_button : OptionButton
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
set_nodes()
current_cel = Image.new()
current_frame = Image.new()

View File

@ -38,7 +38,7 @@ var file_name := "untitled"
var file_format : int = Export.FileFormat.PNG
func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) -> void:
func _init(pDrawGD, _frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) -> void:
frames = _frames
name = _name
size = _size
@ -46,6 +46,7 @@ func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) ->
undo_redo = UndoRedo.new()
DrawGD = pDrawGD
DrawGD.tabs.add_tab(name)
DrawGD.opensave.current_save_paths.append("")
DrawGD.opensave.backup_save_paths.append("")
@ -392,6 +393,9 @@ func layers_changed(value : Array) -> void:
for i in range(layers.size() - 1, -1, -1):
var layer_container = load("res://addons/draw_gd/src/UI/Timeline/LayerButton.tscn").instance()
layer_container.i = i
layer_container.DrawGD = DrawGD
layer_container.init()
if layers[i].name == tr("Layer") + " 0":
layers[i].name = tr("Layer") + " %s" % i

View File

@ -9,18 +9,19 @@ var opensprite_file_selected := false
var redone := false
var is_quitting_on_save := false
onready var DrawGD : Node = get_node("..")
var DrawGD : Node = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
func _enter_tree() -> void:
DrawGD = get_node("..")
#get_tree().set_auto_accept_quit(false)
setup_application_window_size()
DrawGD.window_title = tr("untitled") + " - Pixelorama " + DrawGD.current_version
DrawGD.current_project.layers[0].name = tr("Layer") + " 0"
DrawGD.layers_container.get_child(0).label.text = DrawGD.current_project.layers[0].name
DrawGD.layers_container.get_child(0).line_edit.text = DrawGD.current_project.layers[0].name
#DrawGD.layers_container.get_child(0).label.text = DrawGD.current_project.layers[0].name
#DrawGD.layers_container.get_child(0).line_edit.text = DrawGD.current_project.layers[0].name
Import.import_brushes(DrawGD.directory_module.get_brushes_search_path_in_order())
Import.import_patterns(DrawGD.directory_module.get_patterns_search_path_in_order())
@ -49,14 +50,14 @@ func _ready() -> void:
func _input(event : InputEvent) -> void:
DrawGD.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
DrawGD.left_cursor.texture = DrawGD.left_cursor_tool_texture
DrawGD.right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
DrawGD.right_cursor.texture = DrawGD.right_cursor_tool_texture
# DrawGD.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
# DrawGD.left_cursor.texture = DrawGD.left_cursor_tool_texture
# DrawGD.right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
# DrawGD.right_cursor.texture = DrawGD.right_cursor_tool_texture
if event is InputEventKey and (event.scancode == KEY_ENTER or event.scancode == KEY_KP_ENTER):
if get_focus_owner() is LineEdit:
get_focus_owner().release_focus()
# if event is InputEventKey and (event.scancode == KEY_ENTER or event.scancode == KEY_KP_ENTER):
# if get_focus_owner() is LineEdit:
# get_focus_owner().release_focus()
#TODO TEMP
return

View File

@ -16,7 +16,14 @@ var Import = preload("res://addons/draw_gd/src/Autoload/Import.gd")
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
_load_palettes()
# Select default palette "Default"

View File

@ -29,14 +29,13 @@ onready var cjk_font = preload("res://addons/draw_gd/assets/fonts/CJK/NotoSansCJ
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.has_method("DrawGD"):
print("ddddddddddddddddd")
DrawGD = n.DrawGD
n = n.get_parent()
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
loaded_locales = TranslationServer.get_loaded_locales()

View File

@ -10,13 +10,24 @@ 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")
var shortcut_selector_popup = null
var theme_font_color : Color = Color()
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
# Disable input until the shortcut selector is displayed
set_process_input(false)
shortcut_selector_popup = DrawGD.preferences_dialog.get_node("Popups/ShortcutSelector")
theme_font_color = DrawGD.preferences_dialog.get_node("Popups/ShortcutSelector/EnteredShortcut").get_color("font_color")
# Get default preset for shortcuts from project input map
# Buttons in shortcuts selector should be called the same as actions
@ -25,9 +36,9 @@ func _ready() -> void:
var input_events = InputMap.get_action_list(shortcut_grid_item.name)
if input_events.size() > 1:
printerr("Every shortcut action should have just one input event assigned in input map")
shortcut_grid_item.text = (input_events[0] as InputEventKey).as_text()
#shortcut_grid_item.text = (input_events[0] as InputEventKey).as_text()
shortcut_grid_item.connect("pressed", self, "_on_Shortcut_button_pressed", [shortcut_grid_item])
default_shortcuts_preset[shortcut_grid_item.name] = input_events[0]
#default_shortcuts_preset[shortcut_grid_item.name] = input_events[0]
# Load custom shortcuts from the config file
custom_shortcuts_preset = default_shortcuts_preset.duplicate()
@ -42,6 +53,9 @@ func _ready() -> void:
func _input(event : InputEvent) -> void:
#TODO
return
if event is InputEventKey:
if event.pressed:
if event.scancode == KEY_ESCAPE:

View File

@ -10,7 +10,14 @@ var node : Node
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
# Handle themes
if DrawGD.theme_type == DrawGD.Theme_Types.LIGHT:
texture_normal = load("res://addons/draw_gd/assets/graphics/light_themes/misc/icon_reload.png")

View File

@ -7,8 +7,16 @@ var cursor_text := ""
var _cursor := Vector2.INF
var DrawGD : Node
func _ready():
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
kname = name.replace(" ", "_").to_lower()
$Label.text = tool_slot.name

View File

@ -347,7 +347,7 @@ func _set_pixel(position : Vector2) -> void:
var i := int(position.x + position.y * image.get_size().x)
if _mask[i] < DrawGD.tools.pen_pressure:
_mask[i] = DrawGD.tools.pen_pressure
_drawer.set_pixel(image, position, tool_slot.color)
_drawer.set_pixel(image, position, tool_slot.color, project)
func _draw_brush_image(_image : Image, _src_rect: Rect2, _dst: Vector2) -> void:

View File

@ -1,9 +1,17 @@
tool
extends BaseButton
var DrawGD : Node = null
var brush := Brushes.Brush.new()
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
func _on_BrushButton_pressed() -> void:
# Delete the brush on middle mouse press

View File

@ -21,7 +21,14 @@ 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")
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
var container = DrawGD.brushes_popup.get_node("TabContainer/File/FileBrushContainer")
var button = create_button(pixel_image)
button.brush.type = PIXEL

View File

@ -12,7 +12,14 @@ var drag := false
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
viewport_container = get_parent().get_parent()
transparent_checker = get_parent().get_node("TransparentChecker")
tween = Tween.new()

View File

@ -18,7 +18,14 @@ var DrawGD : Node = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
var frame : Frame = new_empty_frame(true)
DrawGD.current_project.frames.append(frame)
yield(get_tree().create_timer(0.2), "timeout")

View File

@ -7,6 +7,14 @@ onready var animation_timer : Timer = $AnimationTimer
var DrawGD : Node = null
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
func _draw() -> void:
var current_project : Project = DrawGD.current_project
if frame >= current_project.frames.size():

View File

@ -7,6 +7,14 @@ var isometric_polylines := [] # An array of PoolVector2Arrays
var DrawGD : Node = null
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
func _draw() -> void:
if DrawGD.draw_grid:
draw_grid(DrawGD.grid_type)

View File

@ -3,6 +3,14 @@ extends Node2D
var DrawGD : Node = null
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
func _input(event : InputEvent) -> void:
if DrawGD.has_focus and event is InputEventMouseMotion:
update()

View File

@ -4,7 +4,14 @@ class_name SymmetryGuide extends Guide
var _texture = preload("res://addons/draw_gd/assets/graphics/dotted_line.png")
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
has_focus = false
visible = false
texture = _texture

View File

@ -6,6 +6,14 @@ var location := Vector2.ZERO
var DrawGD : Node = null
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
func _draw() -> void:
var current_cels : Array = DrawGD.current_project.frames[DrawGD.current_project.current_frame].cels
var size : Vector2 = DrawGD.current_project.size

View File

@ -2,13 +2,24 @@ tool
extends VBoxContainer
onready var left_picker := $ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton
onready var right_picker := $ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/RightColorPickerButton
var left_picker : ColorPickerButton = null
var right_picker : ColorPickerButton = null
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
DrawGD.tools.connect("color_changed", self, "update_color")
left_picker = get_node("ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton")
right_picker = get_node("ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/RightColorPickerButton")
left_picker.get_picker().presets_visible = false
right_picker.get_picker().presets_visible = false

View File

@ -4,8 +4,6 @@
[ext_resource path="res://addons/draw_gd/assets/graphics/dark_themes/misc/color_defaults.png" type="Texture" id=2]
[ext_resource path="res://addons/draw_gd/src/UI/ColorAndToolOptions.gd" type="Script" id=8]
[sub_resource type="ShortCut" id=1]
[node name="ColorAndToolOptions" type="VBoxContainer"]
@ -110,6 +108,7 @@ margin_right = 313.0
margin_bottom = 196.0
rect_min_size = Vector2( 130, 0 )
size_flags_horizontal = 6
[connection signal="pressed" from="ColorButtonsVertical/ColorSwitchCenter/ColorSwitch" to="." method="_on_ColorSwitch_pressed"]
[connection signal="color_changed" from="ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_on_ColorPickerButton_color_changed" binds= [ false ]]
[connection signal="popup_closed" from="ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_on_ColorPickerButton_popup_closed"]

View File

@ -1,11 +1,11 @@
tool
extends ConfirmationDialog
onready var templates_options = $VBoxContainer/OptionsContainer/TemplatesOptions
onready var ratio_box = $VBoxContainer/OptionsContainer/RatioCheckBox
onready var width_value = $VBoxContainer/OptionsContainer/WidthValue
onready var height_value = $VBoxContainer/OptionsContainer/HeightValue
onready var fill_color_node = $VBoxContainer/OptionsContainer/FillColor
var templates_options = null
var ratio_box = null
var width_value = null
var height_value = null
var fill_color_node = null
onready var size_value = Vector2()
@ -55,7 +55,23 @@ var TStrings ={
}
func _ready() -> void:
func _enter_tree() -> void:
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
if !n:
return
templates_options = get_node("VBoxContainer/OptionsContainer/TemplatesOptions")
ratio_box = get_node("VBoxContainer/OptionsContainer/RatioCheckBox")
width_value = get_node("VBoxContainer/OptionsContainer/WidthValue")
height_value = get_node("VBoxContainer/OptionsContainer/HeightValue")
fill_color_node = get_node("VBoxContainer/OptionsContainer/FillColor")
width_value.value = DrawGD.default_image_width
height_value.value = DrawGD.default_image_height
fill_color_node.color = DrawGD.default_fill_color
@ -83,7 +99,7 @@ func _on_CreateNewImage_confirmed() -> void:
DrawGD.canvas.fill_color = fill_color
var frame : Frame = DrawGD.canvas.new_empty_frame(false, true, Vector2(width, height))
var new_project := Project.new([frame], tr("untitled"), Vector2(width, height).floor())
var new_project := Project.new(DrawGD, [frame], tr("untitled"), Vector2(width, height).floor())
new_project.layers.append(Layer.new())
DrawGD.projects.append(new_project)
DrawGD.tabs.current_tab = DrawGD.tabs.get_tab_count() - 1

View File

@ -11,7 +11,10 @@ var line_edit : LineEdit
var DrawGD : Node = null
func _ready() -> void:
func _enter_tree() -> void:
if DrawGD:
return
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
@ -19,6 +22,9 @@ func _ready() -> void:
break
n = n.get_parent()
init()
func init():
visibility_button = DrawGD.find_node_by_name(self, "VisibilityButton")
lock_button = DrawGD.find_node_by_name(self, "LockButton")
linked_button = DrawGD.find_node_by_name(self, "LinkButton")

View File

@ -3,6 +3,14 @@ extends ViewportContainer
var DrawGD : Node = null
func _enter_tree():
var n : Node = get_parent()
while n:
if n.name == "DrawGDSingleton":
DrawGD = n
break
n = n.get_parent()
func _on_ViewportContainer_mouse_entered() -> void:
DrawGD.has_focus = true