Reordering scene, and setup basic scene instance on main view
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
extends Control
|
||||
|
||||
onready var levels = Array()
|
||||
|
||||
func _ready():
|
||||
print("[choose_scene#_ready]")
|
||||
_apply_scenes()
|
||||
|
||||
# Load scene warcraft
|
||||
func _on_WarCraft_pressed():
|
||||
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
|
||||
|
||||
func _on_Lightmap_pressed():
|
||||
Global.goto_scene("res://developers/aurelien/CheckLightmap.tscn")
|
||||
|
||||
func _on_warcraft_pressed():
|
||||
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
|
||||
|
||||
func _on_develop_pressed():
|
||||
Global.goto_scene("res://developers/aurelien/CheckLightmap.tscn")
|
||||
|
||||
## PRIVATE
|
||||
func _apply_scenes():
|
||||
var table = Global.table_levels
|
||||
var datas = null
|
||||
var name = null
|
||||
var thumb = null
|
||||
var resource = null
|
||||
|
||||
for row_index in range(0, Global.table_levels.m_rows_count):
|
||||
datas = Global.table_levels.get_data_at_row_idx(row_index)
|
||||
|
||||
for index in range(0, table.get_props_count()):
|
||||
if name == null:
|
||||
name = _get_name(index, table, datas)
|
||||
if thumb == null:
|
||||
thumb = _get_thumb(index, table, datas)
|
||||
if resource == null:
|
||||
resource = _get_resource(index, table, datas)
|
||||
|
||||
_apply_scene(name, thumb, resource)
|
||||
name = null
|
||||
thumb = null
|
||||
resource = null
|
||||
|
||||
func _get_name(index, table, datas):
|
||||
if table.get_prop_at(index).get_prop_name() == "name":
|
||||
return datas[index].get_data()
|
||||
|
||||
func _get_thumb(index, table, datas):
|
||||
if table.get_prop_at(index).get_prop_name() == "thumb":
|
||||
return datas[index].get_data()
|
||||
|
||||
func _get_resource(index, table, datas):
|
||||
if table.get_prop_at(index).get_prop_name() == "resource":
|
||||
return datas[index].get_data()
|
||||
|
||||
func _apply_scene(name, thumb, resource):
|
||||
$games/Container/HBoxContainer.add_child(_configure_vbox())
|
||||
_configure_button(thumb, resource, name)
|
||||
$games/Container/HBoxContainer/VBoxContainer.add_child(_configure_label(name))
|
||||
|
||||
func _configure_vbox():
|
||||
var vbox = VBoxContainer.new()
|
||||
vbox.set_name("VBoxContainer")
|
||||
|
||||
return vbox
|
||||
|
||||
func _configure_label(name):
|
||||
var label = Label.new()
|
||||
label.set_text(name)
|
||||
|
||||
return label
|
||||
|
||||
func _configure_button(thumb, _resource, name):
|
||||
var thumbnail = TextureButton.new()
|
||||
$games/Container/HBoxContainer/VBoxContainer.add_child(thumbnail)
|
||||
thumbnail.set_normal_texture(load(thumb))
|
||||
thumbnail.connect("pressed", self, "_on_"+name.to_lower()+"_pressed")
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/UI/choose_scenes/ChooseScene.gd" type="Script" id=1]
|
||||
[ext_resource path="res://assets/levels/warcraft.jpg" type="Texture" id=2]
|
||||
|
||||
[node name="ChooseScene" type="CenterContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
margin_left = 645.0
|
||||
margin_top = 298.0
|
||||
margin_right = 795.0
|
||||
margin_bottom = 602.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[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="Lightmap" type="TextureButton" parent="GridContainer"]
|
||||
margin_top = 154.0
|
||||
margin_right = 150.0
|
||||
margin_bottom = 304.0
|
||||
mouse_default_cursor_shape = 2
|
||||
texture_normal = ExtResource( 2 )
|
||||
|
||||
[node name="Label" type="Label" parent="GridContainer/Lightmap"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 14.0
|
||||
text = "Lightmap"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Container" type="Control" parent="."]
|
||||
margin_left = 720.0
|
||||
margin_top = 450.0
|
||||
margin_right = 720.0
|
||||
margin_bottom = 450.0
|
||||
|
||||
[node name="HBoxContainer" type="VBoxContainer" parent="Container"]
|
||||
margin_right = 824.0
|
||||
margin_bottom = 300.0
|
||||
|
||||
[connection signal="pressed" from="GridContainer/WarCraft" to="." method="_on_WarCraft_pressed"]
|
||||
[connection signal="pressed" from="GridContainer/Lightmap" to="." method="_on_Lightmap_pressed"]
|
||||
Reference in New Issue
Block a user