From 825dd0ebf5ea5f867b29d3f9ed39fb569cb93118 Mon Sep 17 00:00:00 2001 From: Portponky Date: Tue, 26 Mar 2024 11:40:21 +0000 Subject: [PATCH] Prevent lost resources when Godot exits --- addons/better-terrain/editor/Dock.gd | 8 +------- addons/better-terrain/editor/TerrainEntry.gd | 16 +++++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/addons/better-terrain/editor/Dock.gd b/addons/better-terrain/editor/Dock.gd index 3f54efa..307c702 100644 --- a/addons/better-terrain/editor/Dock.gd +++ b/addons/better-terrain/editor/Dock.gd @@ -46,13 +46,6 @@ const TERRAIN_ENTRY_SCENE := preload("res://addons/better-terrain/editor/Terrain var selected_entry := -2 -@onready var terrain_icons := [ - load("res://addons/better-terrain/icons/MatchTiles.svg"), - load("res://addons/better-terrain/icons/MatchVertices.svg"), - load("res://addons/better-terrain/icons/NonModifying.svg"), - load("res://addons/better-terrain/icons/Decoration.svg"), -] - var tilemap : TileMap var tileset : TileSet @@ -157,6 +150,7 @@ func tiles_changed() -> void: # clear terrains for c in terrain_list.get_children(): terrain_list.remove_child(c) + c.queue_free() # load terrains from tileset var terrain_count := BetterTerrain.terrain_count(tileset) diff --git a/addons/better-terrain/editor/TerrainEntry.gd b/addons/better-terrain/editor/TerrainEntry.gd index 78af543..a937f95 100644 --- a/addons/better-terrain/editor/TerrainEntry.gd +++ b/addons/better-terrain/editor/TerrainEntry.gd @@ -25,12 +25,6 @@ var _terrain_texture:Texture2D var _terrain_texture_rect:Rect2i var _icon_draw_connected := false -@onready var terrain_icons := [ - load("res://addons/better-terrain/icons/MatchTiles.svg"), - load("res://addons/better-terrain/icons/MatchVertices.svg"), - load("res://addons/better-terrain/icons/NonModifying.svg"), - load("res://addons/better-terrain/icons/Decoration.svg"), -] func _ready(): update() @@ -84,7 +78,15 @@ func update(): color_style_decoration.border_width_top = 4 color_style_decoration.border_width_bottom = 4 - type_icon_slot.texture = terrain_icons[terrain.type] + match terrain.type: + BetterTerrain.TerrainType.MATCH_TILES: + type_icon_slot.texture = load("res://addons/better-terrain/icons/MatchTiles.svg") + BetterTerrain.TerrainType.MATCH_VERTICES: + type_icon_slot.texture = load("res://addons/better-terrain/icons/MatchVertices.svg") + BetterTerrain.TerrainType.CATEGORY: + type_icon_slot.texture = load("res://addons/better-terrain/icons/NonModifying.svg") + BetterTerrain.TerrainType.DECORATION: + type_icon_slot.texture = load("res://addons/better-terrain/icons/Decoration.svg") var has_icon = false if terrain.has("icon"):