mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
updated the start scene to perform background loading
This commit is contained in:
parent
5db13972bd
commit
c53b4e06eb
27
start.gd
27
start.gd
@ -1,10 +1,27 @@
|
||||
extends Control
|
||||
|
||||
func _ready():
|
||||
call_deferred("change_scene")
|
||||
var loader
|
||||
|
||||
func change_scene():
|
||||
func _ready():
|
||||
var path : String
|
||||
if Directory.new().file_exists("res://material_maker/main_window.tscn"):
|
||||
get_tree().change_scene("res://material_maker/main_window.tscn")
|
||||
path = "res://material_maker/main_window.tscn"
|
||||
else:
|
||||
get_tree().change_scene("res://demo/demo.tscn")
|
||||
path = "res://demo/demo.tscn"
|
||||
loader = ResourceLoader.load_interactive(path)
|
||||
if loader == null: # check for errors
|
||||
print("error")
|
||||
queue_free()
|
||||
|
||||
func _process(delta):
|
||||
var err = loader.poll()
|
||||
if err == ERR_FILE_EOF:
|
||||
var resource = loader.get_resource()
|
||||
get_node("/root").add_child(resource.instance())
|
||||
queue_free()
|
||||
elif err == OK:
|
||||
var progress = float(loader.get_stage()) / loader.get_stage_count()
|
||||
$VBoxContainer/ProgressBar.value = 100.0*progress
|
||||
else: # error during loading
|
||||
print("error")
|
||||
queue_free()
|
||||
|
32
start.tscn
32
start.tscn
@ -1,11 +1,39 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://start.gd" type="Script" id=1]
|
||||
[ext_resource path="res://rodz_labs_logo.png" type="Texture" id=2]
|
||||
|
||||
[node name="Start" type="Control"]
|
||||
[node name="Start" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -128.0
|
||||
margin_right = 128.0
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="VBoxContainer"]
|
||||
margin_top = 214.0
|
||||
margin_right = 256.0
|
||||
margin_bottom = 470.0
|
||||
texture = ExtResource( 2 )
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||
margin_top = 474.0
|
||||
margin_right = 256.0
|
||||
margin_bottom = 488.0
|
||||
text = "Loading..."
|
||||
align = 1
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer"]
|
||||
margin_top = 492.0
|
||||
margin_right = 256.0
|
||||
margin_bottom = 506.0
|
||||
|
Loading…
Reference in New Issue
Block a user