1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Preload tool scenes

The app now opens just a bit faster
This commit is contained in:
Manolis Papadeas 2021-11-25 17:42:35 +02:00
parent 7489ae3777
commit 8c9545e183
2 changed files with 19 additions and 19 deletions

View file

@ -8,23 +8,23 @@ var shift := false
var alt := false var alt := false
var _tools = { var _tools = {
"RectSelect": "res://src/Tools/SelectionTools/RectSelect.tscn", "RectSelect": preload("res://src/Tools/SelectionTools/RectSelect.tscn"),
"EllipseSelect": "res://src/Tools/SelectionTools/EllipseSelect.tscn", "EllipseSelect": preload("res://src/Tools/SelectionTools/EllipseSelect.tscn"),
"PolygonSelect": "res://src/Tools/SelectionTools/PolygonSelect.tscn", "PolygonSelect": preload("res://src/Tools/SelectionTools/PolygonSelect.tscn"),
"ColorSelect": "res://src/Tools/SelectionTools/ColorSelect.tscn", "ColorSelect": preload("res://src/Tools/SelectionTools/ColorSelect.tscn"),
"MagicWand": "res://src/Tools/SelectionTools/MagicWand.tscn", "MagicWand": preload("res://src/Tools/SelectionTools/MagicWand.tscn"),
"Lasso": "res://src/Tools/SelectionTools/Lasso.tscn", "Lasso": preload("res://src/Tools/SelectionTools/Lasso.tscn"),
"Move": "res://src/Tools/Move.tscn", "Move": preload("res://src/Tools/Move.tscn"),
"Zoom": "res://src/Tools/Zoom.tscn", "Zoom": preload("res://src/Tools/Zoom.tscn"),
"Pan": "res://src/Tools/Pan.tscn", "Pan": preload("res://src/Tools/Pan.tscn"),
"ColorPicker": "res://src/Tools/ColorPicker.tscn", "ColorPicker": preload("res://src/Tools/ColorPicker.tscn"),
"Pencil": "res://src/Tools/Pencil.tscn", "Pencil": preload("res://src/Tools/Pencil.tscn"),
"Eraser": "res://src/Tools/Eraser.tscn", "Eraser": preload("res://src/Tools/Eraser.tscn"),
"Bucket": "res://src/Tools/Bucket.tscn", "Bucket": preload("res://src/Tools/Bucket.tscn"),
"Shading": "res://src/Tools/Shading.tscn", "Shading": preload("res://src/Tools/Shading.tscn"),
"LineTool": "res://src/Tools/LineTool.tscn", "LineTool": preload("res://src/Tools/LineTool.tscn"),
"RectangleTool": "res://src/Tools/RectangleTool.tscn", "RectangleTool": preload("res://src/Tools/RectangleTool.tscn"),
"EllipseTool": "res://src/Tools/EllipseTool.tscn", "EllipseTool": preload("res://src/Tools/EllipseTool.tscn"),
} }
var _slots = {} var _slots = {}
var _panels = {} var _panels = {}
@ -98,7 +98,7 @@ func _ready() -> void:
func set_tool(name: String, button: int) -> void: func set_tool(name: String, button: int) -> void:
var slot = _slots[button] var slot = _slots[button]
var panel: Node = _panels[button] var panel: Node = _panels[button]
var node: Node = load(_tools[name]).instance() var node: Node = _tools[name].instance()
node.name = name node.name = name
node.tool_slot = slot node.tool_slot = slot
slot.tool_node = node slot.tool_node = node

View file

@ -2,7 +2,7 @@ class_name BaseTool
extends VBoxContainer extends VBoxContainer
var kname: String 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_text := ""
var _cursor := Vector2.INF var _cursor := Vector2.INF