From 8c9545e18313a5c09d5e166d6ec0cdf9b2b500ab Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 25 Nov 2021 17:42:35 +0200 Subject: [PATCH] Preload tool scenes The app now opens just a bit faster --- src/Autoload/Tools.gd | 36 ++++++++++++++++++------------------ src/Tools/BaseTool.gd | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index 7c2aa6a35..7997f3131 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -8,23 +8,23 @@ var shift := false var alt := false var _tools = { - "RectSelect": "res://src/Tools/SelectionTools/RectSelect.tscn", - "EllipseSelect": "res://src/Tools/SelectionTools/EllipseSelect.tscn", - "PolygonSelect": "res://src/Tools/SelectionTools/PolygonSelect.tscn", - "ColorSelect": "res://src/Tools/SelectionTools/ColorSelect.tscn", - "MagicWand": "res://src/Tools/SelectionTools/MagicWand.tscn", - "Lasso": "res://src/Tools/SelectionTools/Lasso.tscn", - "Move": "res://src/Tools/Move.tscn", - "Zoom": "res://src/Tools/Zoom.tscn", - "Pan": "res://src/Tools/Pan.tscn", - "ColorPicker": "res://src/Tools/ColorPicker.tscn", - "Pencil": "res://src/Tools/Pencil.tscn", - "Eraser": "res://src/Tools/Eraser.tscn", - "Bucket": "res://src/Tools/Bucket.tscn", - "Shading": "res://src/Tools/Shading.tscn", - "LineTool": "res://src/Tools/LineTool.tscn", - "RectangleTool": "res://src/Tools/RectangleTool.tscn", - "EllipseTool": "res://src/Tools/EllipseTool.tscn", + "RectSelect": preload("res://src/Tools/SelectionTools/RectSelect.tscn"), + "EllipseSelect": preload("res://src/Tools/SelectionTools/EllipseSelect.tscn"), + "PolygonSelect": preload("res://src/Tools/SelectionTools/PolygonSelect.tscn"), + "ColorSelect": preload("res://src/Tools/SelectionTools/ColorSelect.tscn"), + "MagicWand": preload("res://src/Tools/SelectionTools/MagicWand.tscn"), + "Lasso": preload("res://src/Tools/SelectionTools/Lasso.tscn"), + "Move": preload("res://src/Tools/Move.tscn"), + "Zoom": preload("res://src/Tools/Zoom.tscn"), + "Pan": preload("res://src/Tools/Pan.tscn"), + "ColorPicker": preload("res://src/Tools/ColorPicker.tscn"), + "Pencil": preload("res://src/Tools/Pencil.tscn"), + "Eraser": preload("res://src/Tools/Eraser.tscn"), + "Bucket": preload("res://src/Tools/Bucket.tscn"), + "Shading": preload("res://src/Tools/Shading.tscn"), + "LineTool": preload("res://src/Tools/LineTool.tscn"), + "RectangleTool": preload("res://src/Tools/RectangleTool.tscn"), + "EllipseTool": preload("res://src/Tools/EllipseTool.tscn"), } var _slots = {} var _panels = {} @@ -98,7 +98,7 @@ func _ready() -> void: func set_tool(name: String, button: int) -> void: var slot = _slots[button] var panel: Node = _panels[button] - var node: Node = load(_tools[name]).instance() + var node: Node = _tools[name].instance() node.name = name node.tool_slot = slot slot.tool_node = node diff --git a/src/Tools/BaseTool.gd b/src/Tools/BaseTool.gd index c15d7533f..000ed3094 100644 --- a/src/Tools/BaseTool.gd +++ b/src/Tools/BaseTool.gd @@ -2,7 +2,7 @@ class_name BaseTool extends VBoxContainer var kname: String -var tool_slot: Tools.Slot = null +var tool_slot = null # Tools.Slot, can't have static typing due to cyclic errors var cursor_text := "" var _cursor := Vector2.INF