Fix template select scene
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
export (PackedScene) var template = load("res://scenes/levels/Template.tscn")
|
||||||
|
|
||||||
onready var levels = Array()
|
onready var levels = Array()
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@@ -33,7 +35,10 @@ func _apply_scenes():
|
|||||||
if resource == null:
|
if resource == null:
|
||||||
resource = _get_resource(index, table, datas)
|
resource = _get_resource(index, table, datas)
|
||||||
|
|
||||||
_apply_scene(name, thumb, resource)
|
_apply_scene(_load_scene(name),
|
||||||
|
_load_texture(thumb),
|
||||||
|
_build_path(name),
|
||||||
|
_build_method(name))
|
||||||
name = null
|
name = null
|
||||||
thumb = null
|
thumb = null
|
||||||
resource = null
|
resource = null
|
||||||
@@ -50,41 +55,24 @@ func _get_resource(index, table, datas):
|
|||||||
if table.get_prop_at(index).get_prop_name() == "resource":
|
if table.get_prop_at(index).get_prop_name() == "resource":
|
||||||
return datas[index].get_data()
|
return datas[index].get_data()
|
||||||
|
|
||||||
func _apply_scene(name, thumb, resource):
|
func _build_path(name):
|
||||||
$MarginContainer/HBoxContainer.add_child(_configure_margin_container())
|
return "MarginContainer/HBoxContainer/"+name+"/TextureRect"
|
||||||
_configure_button(thumb, $MarginContainer/HBoxContainer/MarginContainer, name)
|
|
||||||
$MarginContainer/HBoxContainer/MarginContainer.add_child(_configure_vbox())
|
|
||||||
$MarginContainer/HBoxContainer/MarginContainer/VBoxContainer.add_child(_configure_hbox())
|
|
||||||
$MarginContainer/HBoxContainer/MarginContainer/VBoxContainer/HBoxContainer.add_child(_configure_label("reset"))
|
|
||||||
$MarginContainer/HBoxContainer/MarginContainer/VBoxContainer/HBoxContainer.add_child(_configure_label("0 / 10"))
|
|
||||||
|
|
||||||
func _configure_margin_container():
|
func _build_method(name):
|
||||||
var margin = MarginContainer.new()
|
return "_on_"+name.to_lower()+"_pressed"
|
||||||
margin.set_name("MarginContainer")
|
|
||||||
|
|
||||||
return margin
|
func _load_scene(name):
|
||||||
|
var template_instance = template.instance()
|
||||||
|
template_instance.set_name(name)
|
||||||
|
|
||||||
func _configure_hbox():
|
return template_instance
|
||||||
var hbox = HBoxContainer.new()
|
|
||||||
hbox.set_name("HBoxContainer")
|
|
||||||
|
|
||||||
return hbox
|
func _load_texture(thumbnail):
|
||||||
|
return load(thumbnail)
|
||||||
|
|
||||||
func _configure_vbox():
|
func _apply_scene(instance, thumb, node, method):
|
||||||
var vbox = VBoxContainer.new()
|
$MarginContainer/HBoxContainer.add_child(instance)
|
||||||
vbox.set_name("VBoxContainer")
|
var button = get_node(node+"/TextureButton")
|
||||||
|
button.set_normal_texture(thumb)
|
||||||
|
button.connect("pressed", self, method)
|
||||||
|
|
||||||
return vbox
|
|
||||||
|
|
||||||
func _configure_label(name):
|
|
||||||
var label = Label.new()
|
|
||||||
label.set_text(name)
|
|
||||||
|
|
||||||
return label
|
|
||||||
|
|
||||||
func _configure_button(thumb, parent, name):
|
|
||||||
var thumbnail = TextureButton.new()
|
|
||||||
parent.add_child(thumbnail)
|
|
||||||
# $MarginContainer/HBoxContainer/VBoxContainer.add_child(thumbnail)
|
|
||||||
thumbnail.set_normal_texture(load(thumb))
|
|
||||||
thumbnail.connect("pressed", self, "_on_"+name.to_lower()+"_pressed")
|
|
||||||
|
|||||||
@@ -1,31 +1,45 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[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://scenes/UI/choose_scenes/ChooseScene.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://scenes/levels/Template.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
[node name="ChooseScene" type="CenterContainer"]
|
[node name="ChooseScene" type="CenterContainer"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
margin_left = 73.7365
|
||||||
|
margin_top = -67.0147
|
||||||
|
margin_right = 73.7366
|
||||||
|
margin_bottom = -67.0146
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
margin_left = 712.0
|
margin_left = 705.0
|
||||||
margin_top = 435.0
|
margin_top = 435.0
|
||||||
margin_right = 727.0
|
margin_right = 735.0
|
||||||
margin_bottom = 465.0
|
margin_bottom = 465.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
custom_constants/margin_right = 15
|
custom_constants/margin_right = 15
|
||||||
custom_constants/margin_top = 15
|
custom_constants/margin_top = 15
|
||||||
|
custom_constants/margin_left = 15
|
||||||
custom_constants/margin_bottom = 15
|
custom_constants/margin_bottom = 15
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
|
||||||
|
margin_left = 15.0
|
||||||
margin_top = 15.0
|
margin_top = 15.0
|
||||||
|
margin_right = 15.0
|
||||||
margin_bottom = 15.0
|
margin_bottom = 15.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
custom_constants/separation = 120
|
||||||
|
|
||||||
|
[node name="example" parent="MarginContainer/HBoxContainer" instance=ExtResource( 2 )]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[editable path="MarginContainer/HBoxContainer/example"]
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/levels/warcraft.jpg" type="Texture" id=1]
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer"]
|
||||||
|
margin_right = 150.0
|
||||||
|
margin_bottom = 174.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
|
margin_right = 150.0
|
||||||
|
margin_bottom = 150.0
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="TextureButton" type="TextureButton" parent="TextureRect"]
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="HBoxContainer" parent="."]
|
||||||
|
margin_top = 154.0
|
||||||
|
margin_right = 150.0
|
||||||
|
margin_bottom = 174.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
custom_constants/separation = 25
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="ButtonReset" type="Button" parent="VBoxContainer"]
|
||||||
|
margin_right = 62.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/ButtonReset"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 7
|
||||||
|
text = "Reset"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ButtonCount" type="Button" parent="VBoxContainer"]
|
||||||
|
margin_left = 87.0
|
||||||
|
margin_right = 150.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/ButtonCount"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 7
|
||||||
|
text = "X / 10"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user