aboutsummaryrefslogtreecommitdiff
path: root/scripts/load_shapes.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-17 16:22:55 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-17 16:22:55 +0100
commitbedaaf9f57d0c24e2a81c0bf3c482a07382d78c1 (patch)
tree8f5e6f77f17b76f28f31a980d447bf6c49a79b4f /scripts/load_shapes.gd
parente2b1324becf85fabfd046b3e4333b2639b9e1838 (diff)
Remove ignored files
Diffstat (limited to 'scripts/load_shapes.gd')
-rw-r--r--scripts/load_shapes.gd44
1 files changed, 29 insertions, 15 deletions
diff --git a/scripts/load_shapes.gd b/scripts/load_shapes.gd
index 308f111..32e9104 100644
--- a/scripts/load_shapes.gd
+++ b/scripts/load_shapes.gd
@@ -1,29 +1,43 @@
extends Node
var saveload : Node
+
+var info : Dictionary
var models : Dictionary
+var thumbnails : Dictionary
-var loaded = false
+var loaded : bool = false
signal done_loading
-func get_saveload():
- if saveload == null: saveload = get_tree().root.get_node("world").get_node("saveload")
-
func _ready():
get_saveload()
load_models()
+ load_info()
emit_signal("done_loading")
loaded = true
+func get_saveload():
+ if saveload == null: saveload = get_tree().root.get_node("world").get_node("saveload")
+
func load_models():
- models = {}
- var dir = Directory.new()
- dir.open("res://assets/models/shapes")
- dir.list_dir_begin(true)
- var shape = dir.get_next()
- while shape != "":
- if (shape.ends_with(".glb")):
- var model = load("res://assets/models/shapes/" + shape)
- var sname = shape.substr(0, shape.length()-4)
- models[sname] = model
- shape = dir.get_next()
+ models.clear()
+ var files = saveload.parse_dir("res://assets/models/shapes", ".glb")
+ for turr in files:
+ models[turr] = load("res://assets/models/shapes/" + turr)
+
+func load_thumbnails():
+ thumbnails.clear()
+ var files = saveload.parse_dir("res://assets/textures/thumbnails/enemies", ".png")
+ for turr in files:
+ print(turr)
+ thumbnails[turr] = load("res://assets/textures/thumbnails/enemies/" + turr)
+
+func load_info():
+ info.clear()
+ var files = saveload.parse_dir("res://assets/json", ".json")
+ for f in files:
+ if f != "enemies.json": continue
+ var parsed = saveload.load_parse_json("res://assets/json/" + f)
+ if parsed != null:
+ for tin in parsed:
+ info[tin.name] = tin