Skip to content

Commit

Permalink
Prevent lost resources when Godot exits
Browse files Browse the repository at this point in the history
  • Loading branch information
Portponky committed Mar 26, 2024
1 parent 4b9e6ed commit 825dd0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
8 changes: 1 addition & 7 deletions addons/better-terrain/editor/Dock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions addons/better-terrain/editor/TerrainEntry.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"):
Expand Down

0 comments on commit 825dd0e

Please sign in to comment.