2021-05-08 13:44:51 +02:00
|
|
|
extends Control
|
|
|
|
|
|
2021-05-13 23:15:05 +02:00
|
|
|
onready var levels = Array()
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
print("[choose_scene#_ready]")
|
|
|
|
|
_apply_scenes()
|
|
|
|
|
|
2021-05-09 17:10:40 +02:00
|
|
|
# Load scene warcraft
|
2021-05-08 13:44:51 +02:00
|
|
|
func _on_WarCraft_pressed():
|
2021-05-12 13:10:56 +02:00
|
|
|
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
|
2021-05-10 14:18:45 +02:00
|
|
|
|
|
|
|
|
func _on_Lightmap_pressed():
|
|
|
|
|
Global.goto_scene("res://developers/aurelien/CheckLightmap.tscn")
|
|
|
|
|
|
2021-05-13 23:15:05 +02:00
|
|
|
func _on_warcraft_pressed():
|
2021-05-14 18:46:57 +02:00
|
|
|
Global.current_scene_int = 0
|
2021-05-13 23:15:05 +02:00
|
|
|
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
|
|
|
|
|
|
|
|
|
|
func _on_develop_pressed():
|
2021-05-14 18:46:57 +02:00
|
|
|
Global.current_scene_int = 1
|
2021-05-13 23:15:05 +02:00
|
|
|
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")
|