2020-01-28 11:47:29 +01:00
|
|
|
extends Control
|
|
|
|
|
2020-02-06 21:46:49 +01:00
|
|
|
var loader
|
2020-01-28 11:47:29 +01:00
|
|
|
|
2020-02-08 09:37:46 +01:00
|
|
|
onready var progress_bar = $VBoxContainer/ProgressBar
|
|
|
|
|
2020-02-06 21:46:49 +01:00
|
|
|
func _ready():
|
|
|
|
var path : String
|
2020-01-28 11:47:29 +01:00
|
|
|
if Directory.new().file_exists("res://material_maker/main_window.tscn"):
|
2020-02-06 21:46:49 +01:00
|
|
|
path = "res://material_maker/main_window.tscn"
|
2020-02-19 08:31:49 +01:00
|
|
|
|
2020-01-28 11:47:29 +01:00
|
|
|
else:
|
2020-02-06 21:46:49 +01:00
|
|
|
path = "res://demo/demo.tscn"
|
|
|
|
loader = ResourceLoader.load_interactive(path)
|
|
|
|
if loader == null: # check for errors
|
|
|
|
print("error")
|
|
|
|
queue_free()
|
|
|
|
|
2020-02-08 09:37:46 +01:00
|
|
|
func _process(_delta):
|
2020-02-06 21:46:49 +01:00
|
|
|
var err = loader.poll()
|
|
|
|
if err == ERR_FILE_EOF:
|
|
|
|
var resource = loader.get_resource()
|
2020-02-19 08:31:49 +01:00
|
|
|
var scene = resource.instance()
|
|
|
|
get_node("/root").add_child(scene)
|
2020-02-06 21:46:49 +01:00
|
|
|
queue_free()
|
|
|
|
elif err == OK:
|
|
|
|
var progress = float(loader.get_stage()) / loader.get_stage_count()
|
2020-02-08 09:37:46 +01:00
|
|
|
progress_bar.value = 100.0*progress
|
2020-02-06 21:46:49 +01:00
|
|
|
else: # error during loading
|
|
|
|
print("error")
|
|
|
|
queue_free()
|