Refacto open scene UI

This commit is contained in:
VAILLANT Jeremy
2021-05-08 15:54:58 +02:00
parent ae75a91632
commit 9fcbe5a516
7 changed files with 44 additions and 40 deletions
-9
View File
@@ -1,9 +0,0 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _on_Return_pressed():
get_tree().change_scene("res://scenes/main.tscn")
+12 -12
View File
@@ -1,9 +1,19 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scenes/UI/About.gd" type="Script" id=1]
[sub_resource type="GDScript" id=1]
script/source = "extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _on_Return_pressed():
get_tree().change_scene(\"res://scenes/main.tscn\")
"
[node name="About" type="Node"]
script = ExtResource( 1 )
script = SubResource( 1 )
[node name="GRem" type="Label" parent="."]
margin_left = 350.0
@@ -25,13 +35,3 @@ text = "Lead Artist : Stilobique -- VAILLANT Aurelien"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Return" type="LinkButton" parent="."]
margin_right = 40.0
margin_bottom = 14.0
text = "back"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Return" to="." method="_on_Return_pressed"]
-3
View File
@@ -1,7 +1,4 @@
extends Control
func _on_Return_pressed():
get_tree().change_scene("res://scenes/main.tscn")
func _on_WarCraft_pressed():
get_tree().change_scene("res://scenes/levels/WarCraft.tscn")
+12 -14
View File
@@ -1,32 +1,30 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/UI/ChooseScene.gd" type="Script" id=1]
[ext_resource path="res://assets/levels/warcraft.jpg" type="Texture" id=2]
[node name="ChooseScene" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 200.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer" type="GridContainer" parent="."]
margin_right = 1024.0
margin_bottom = 600.0
margin_left = 25.0
margin_top = 26.2599
margin_right = 824.0
margin_bottom = 601.26
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Return" type="LinkButton" parent="GridContainer"]
margin_right = 54.0
margin_bottom = 14.0
text = "back"
[node name="WarCraft" type="TextureButton" parent="GridContainer"]
margin_right = 150.0
margin_bottom = 150.0
mouse_default_cursor_shape = 2
texture_normal = ExtResource( 2 )
[node name="WarCraft" type="LinkButton" parent="GridContainer"]
margin_top = 18.0
margin_right = 54.0
margin_bottom = 32.0
text = "WarCraft"
[connection signal="pressed" from="GridContainer/Return" to="." method="_on_Return_pressed"]
[connection signal="pressed" from="GridContainer/WarCraft" to="." method="_on_WarCraft_pressed"]
+17 -2
View File
@@ -1,13 +1,28 @@
extends Node
export (PackedScene) var about = load("res://scenes/UI/About.tscn")
export (PackedScene) var scenes = load("res://scenes/UI/ChooseScene.tscn")
var scene
# Quit the game
func _on_Quit_pressed():
get_tree().quit(0)
# Load scene about
func _on_About_pressed():
get_tree().change_scene("res://scenes/UI/About.tscn")
_prepare_change_scene()
scene = about.instance()
add_child(scene)
# Load scene for select game
func _on_New_pressed():
get_tree().change_scene("res://scenes/UI/ChooseScene.tscn")
_prepare_change_scene()
scene = scenes.instance()
add_child(scene)
## PRIVATE
func _prepare_change_scene():
if (scene != null):
remove_child(scene)
scene.call_deferred("free")
+3
View File
@@ -102,6 +102,9 @@ margin_right = 151.0
margin_bottom = 98.0
text = "Quitter"
script = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Grid/Menu/Action/New" to="." method="_on_New_pressed"]
[connection signal="pressed" from="Grid/Menu/Action/About" to="." method="_on_About_pressed"]