Create method for labels and button to template
This commit is contained in:
@@ -40,14 +40,25 @@ func _load_texture(thumbnail):
|
||||
func _apply_scene(level):
|
||||
$MarginContainer/HBoxContainer.add_child(_load_scene(level.name()))
|
||||
var node = _build_path(level.name())
|
||||
|
||||
_configure_select(level, node)
|
||||
_configure_reset(level, node)
|
||||
_configure_counter(level, node)
|
||||
|
||||
func _configure_select(level, node):
|
||||
var select = get_node(node+"/TextureRect/TextureButton")
|
||||
var reset = get_node(node+"/VBoxContainer/ButtonReset")
|
||||
var count = get_node(node+"/VBoxContainer/ButtonCount/Label")
|
||||
|
||||
select.set_normal_texture(_load_texture(level.thumbnail()))
|
||||
select.connect("pressed", self, _build_method(level.name()))
|
||||
|
||||
func _configure_reset(level, node):
|
||||
var reset = get_node(node+"/VBoxContainer/ButtonReset")
|
||||
|
||||
if int(level.object_finding()) != 0:
|
||||
reset.set_disabled(true)
|
||||
reset.connect("pressed", self, "_on_reset_level")
|
||||
|
||||
func _configure_counter(level, node):
|
||||
var count = get_node(node+"/VBoxContainer/ButtonCount/Label")
|
||||
|
||||
count.set_text(level.object_finding()+" / "+level.object_to_find())
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://assets/levels/warcraft.jpg" type="Texture" id=1]
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer"]
|
||||
margin_right = 150.0
|
||||
@@ -10,9 +8,7 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
margin_right = 150.0
|
||||
margin_bottom = 150.0
|
||||
texture = ExtResource( 1 )
|
||||
margin_right = 350.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@@ -26,8 +22,8 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="HBoxContainer" parent="."]
|
||||
margin_top = 154.0
|
||||
margin_right = 150.0
|
||||
margin_top = 4.0
|
||||
margin_right = 350.0
|
||||
margin_bottom = 174.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
@@ -35,8 +31,8 @@ custom_constants/separation = 25
|
||||
alignment = 1
|
||||
|
||||
[node name="ButtonReset" type="Button" parent="VBoxContainer"]
|
||||
margin_right = 62.0
|
||||
margin_bottom = 20.0
|
||||
margin_right = 162.0
|
||||
margin_bottom = 170.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
@@ -53,9 +49,9 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="ButtonCount" type="Button" parent="VBoxContainer"]
|
||||
margin_left = 87.0
|
||||
margin_right = 150.0
|
||||
margin_bottom = 20.0
|
||||
margin_left = 187.0
|
||||
margin_right = 350.0
|
||||
margin_bottom = 170.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
__meta__ = {
|
||||
|
||||
Reference in New Issue
Block a user