Skip to content

Commit 9bec8f1

Browse files
Preload more resources
Had to remove references to Brushes and Patterns classes from BrushesButton.gd and PatternButton.gd due to GDScript's cyclic reference bug
1 parent 763a063 commit 9bec8f1

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

src/Autoload/Global.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ var palette_panel : PalettePanel
189189
var error_dialog : AcceptDialog
190190
var quit_dialog : ConfirmationDialog
191191
var quit_and_save_dialog : ConfirmationDialog
192+
var notification_label_node = preload("res://src/UI/NotificationLabel.tscn")
192193

193194
onready var current_version : String = ProjectSettings.get_setting("application/config/Version")
194195

195-
196196
func _ready() -> void:
197197
randomize()
198198
if OS.get_name() == "OSX":
@@ -327,7 +327,7 @@ func _ready() -> void:
327327

328328

329329
func notification_label(text : String) -> void:
330-
var notification : Label = load("res://src/UI/NotificationLabel.tscn").instance()
330+
var notification : Label = notification_label_node.instance()
331331
notification.text = tr(text)
332332
notification.rect_position = Vector2(70, OS.window_size.y - animation_timeline.rect_size.y - 20)
333333
notification.theme = control.theme

src/Classes/Project.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var was_exported := false
4242
var frame_button_node = preload("res://src/UI/Timeline/FrameButton.tscn")
4343
var layer_button_node = preload("res://src/UI/Timeline/LayerButton.tscn")
4444
var cel_button_node = preload("res://src/UI/Timeline/CelButton.tscn")
45+
var animation_tag_node = preload("res://src/UI/Timeline/AnimationTagUI.tscn")
4546

4647

4748
func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) -> void:
@@ -564,7 +565,7 @@ func animation_tags_changed(value : Array) -> void:
564565

565566
for tag in animation_tags:
566567
var tag_base_size = Global.animation_timeline.cel_size + 3
567-
var tag_c : Container = load("res://src/UI/Timeline/AnimationTagUI.tscn").instance()
568+
var tag_c : Container = animation_tag_node.instance()
568569
Global.tag_container.add_child(tag_c)
569570
tag_c.tag = tag
570571
var tag_position : int = Global.tag_container.get_child_count() - 1

src/Palette/PalettePanel.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var edited_swatch_index = -1
88

99
onready var palette_select := $PaletteVBoxContainer/PaletteButtons/PaletteSelect
1010
onready var add_palette_button := $PaletteVBoxContainer/PaletteButtons/AddPalette
11-
onready var palette_grid := $PaletteVBoxContainer/SwatchesContainer/PaletteScroll/HBoxContainer/CenterContainer/HBoxContainer/PaletteGrid
11+
onready var palette_grid := find_node("PaletteGrid")
1212
onready var palette_scroll := $PaletteVBoxContainer/SwatchesContainer/PaletteScroll
1313

1414
onready var add_color_button := $PaletteVBoxContainer/SwatchesContainer/ColorButtons/AddColor

src/UI/BrushButton.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extends BaseButton
22

33

4-
var brush := Brushes.Brush.new()
4+
var brush = Global.brushes_popup.Brush.new()
55

66

77
func _on_BrushButton_pressed() -> void:
@@ -13,17 +13,17 @@ func _on_BrushButton_pressed() -> void:
1313

1414

1515
func _on_DeleteButton_pressed() -> void:
16-
if brush.type != Brushes.CUSTOM:
16+
if brush.type != Global.brushes_popup.CUSTOM:
1717
return
1818

1919
Global.brushes_popup.remove_brush(self)
2020

2121

2222
func _on_BrushButton_mouse_entered() -> void:
23-
if brush.type == Brushes.CUSTOM:
23+
if brush.type == Global.brushes_popup.CUSTOM:
2424
$DeleteButton.visible = true
2525

2626

2727
func _on_BrushButton_mouse_exited() -> void:
28-
if brush.type == Brushes.CUSTOM:
28+
if brush.type == Global.brushes_popup.CUSTOM:
2929
$DeleteButton.visible = false

src/UI/BrushesPopup.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static func get_default_brush() -> Brush:
5252

5353

5454
static func create_button(image : Image) -> Node:
55-
var button : BaseButton = load("res://src/UI/BrushButton.tscn").instance()
55+
var button : BaseButton = preload("res://src/UI/BrushButton.tscn").instance()
5656
var tex := ImageTexture.new()
5757
tex.create_from_image(image, 0)
5858
button.get_child(0).texture = tex

src/UI/PatternButton.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extends BaseButton
22

33

4-
var pattern := Patterns.Pattern.new()
4+
var pattern = Global.patterns_popup.Pattern.new()
55

66

77
func _on_PatternButton_pressed() -> void:

src/UI/PatternsPopup.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func select_pattern(pattern : Pattern) -> void:
1717

1818

1919
static func create_button(image : Image) -> Node:
20-
var button : BaseButton = load("res://src/UI/PatternButton.tscn").instance()
20+
var button : BaseButton = preload("res://src/UI/PatternButton.tscn").instance()
2121
var tex := ImageTexture.new()
2222
tex.create_from_image(image, 0)
2323
button.get_child(0).texture = tex

0 commit comments

Comments
 (0)