feature/list-object-counter (#60)
Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com> Reviewed-on: Athena/game-source#60 Co-authored-by: darknight <vaillant.jeremy@dev-crea.com> Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
This commit is contained in:
@@ -2,9 +2,7 @@ extends Control
|
||||
|
||||
export (PackedScene) var template = load("res://scenes/levels/Template.tscn")
|
||||
|
||||
onready var levels = Array()
|
||||
onready var mlevel = load("res://db/MLevel.gd")
|
||||
onready var table = Global.table_levels
|
||||
|
||||
func _ready():
|
||||
_apply_scenes()
|
||||
@@ -14,13 +12,17 @@ func _on_warcraft_pressed():
|
||||
Global.current_scene_int = 0
|
||||
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
|
||||
|
||||
func _on_reset_level():
|
||||
print("Reset level ...")
|
||||
func _on_reset_level(level, node, index):
|
||||
Global.current_scene_int = index
|
||||
level.reset()
|
||||
_configure_reset(level, node, index)
|
||||
_configure_counter(level, node)
|
||||
Global.current_scene_int = null
|
||||
|
||||
## PRIVATE
|
||||
func _apply_scenes():
|
||||
for row_index in range(0, Global.table_levels.m_rows_count):
|
||||
_apply_scene(mlevel.new(row_index))
|
||||
_apply_scene(mlevel.new(row_index), 0)
|
||||
|
||||
func _build_path(name):
|
||||
return "MarginContainer/HBoxContainer/"+name
|
||||
@@ -37,12 +39,12 @@ func _load_scene(name):
|
||||
func _load_texture(thumbnail):
|
||||
return load(thumbnail)
|
||||
|
||||
func _apply_scene(level):
|
||||
func _apply_scene(level, index):
|
||||
$MarginContainer/HBoxContainer.add_child(_load_scene(level.name()))
|
||||
var node = _build_path(level.name())
|
||||
|
||||
_configure_select(level, node)
|
||||
_configure_reset(level, node)
|
||||
_configure_reset(level, node, index)
|
||||
_configure_counter(level, node)
|
||||
|
||||
func _configure_select(level, node):
|
||||
@@ -51,12 +53,15 @@ func _configure_select(level, node):
|
||||
select.set_normal_texture(_load_texture(level.thumbnail()))
|
||||
select.connect("pressed", self, _build_method(level.name()))
|
||||
|
||||
func _configure_reset(level, node):
|
||||
func _configure_reset(level, node, index):
|
||||
var reset = get_node(node+"/VBoxContainer/MarginContainer/ButtonReset")
|
||||
|
||||
if int(level.object_finding()) != 0:
|
||||
|
||||
if int(level.object_finding()) == 0:
|
||||
reset.set_disabled(true)
|
||||
reset.connect("pressed", self, "_on_reset_level")
|
||||
reset.disconnect("pressed", self, "_on_reset_level")
|
||||
else:
|
||||
reset.set_disabled(false)
|
||||
reset.connect("pressed", self, "_on_reset_level", [level, node, index])
|
||||
|
||||
func _configure_counter(level, node):
|
||||
var count = get_node(node+"/VBoxContainer/MarginContainer2/ButtonCount/Label")
|
||||
|
||||
@@ -16,10 +16,10 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
margin_left = 705.0
|
||||
margin_top = 435.0
|
||||
margin_right = 735.0
|
||||
margin_bottom = 465.0
|
||||
margin_left = 625.0
|
||||
margin_top = 345.0
|
||||
margin_right = 655.0
|
||||
margin_bottom = 375.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/margin_right = 15
|
||||
@@ -44,4 +44,7 @@ visible = false
|
||||
margin_right = 200.0
|
||||
margin_bottom = 284.0
|
||||
|
||||
[node name="ButtonReset" parent="MarginContainer/HBoxContainer/example/VBoxContainer/MarginContainer" index="0"]
|
||||
enabled_focus_mode = 0
|
||||
|
||||
[editable path="MarginContainer/HBoxContainer/example"]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
extends CenterContainer
|
||||
|
||||
func _ready():
|
||||
print("[ending_#ready]")
|
||||
$AudioStreamPlayer.play()
|
||||
|
||||
func _on_Timer_timeout():
|
||||
print("[ending#_on_Timer_timeout]")
|
||||
Global.goto_scene("res://scenes/main.tscn")
|
||||
@@ -0,0 +1,63 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/UI/ending.gd" type="Script" id=1]
|
||||
[ext_resource path="res://assets/sounds/victory.ogg" type="AudioStream" id=2]
|
||||
[ext_resource path="res://assets/fonts/MKX Title.ttf" type="DynamicFontData" id=3]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 35
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
margin_left = 640.0
|
||||
margin_top = 360.0
|
||||
margin_right = 640.0
|
||||
margin_bottom = 360.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="ColorRect"]
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 360.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="ColorRect/VBoxContainer"]
|
||||
margin_top = 95.0
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 264.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "aHog !!!
|
||||
|
||||
|
||||
bravo vous avez gagné."
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 4.31
|
||||
autostart = true
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 2 )
|
||||
volume_db = -29.411
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
@@ -1,19 +1,25 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
print("[Settings#_ready]")
|
||||
_translation()
|
||||
_apply_translation()
|
||||
_apply_settings_language()
|
||||
_apply_settings_gyroscope()
|
||||
_apply_settings_sound_ambient()
|
||||
_apply_settings_resolution()
|
||||
_apply_settings_fullscreen()
|
||||
|
||||
## PRIVATE
|
||||
func _translation():
|
||||
$VBoxContainer/Langue/HBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
|
||||
func _apply_translation():
|
||||
$VBoxContainer/langue/VBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
|
||||
$VBoxContainer/gyroscope/HBoxContainer/Label.text = tr("SETTINGS_LABEL_GYROSCOPE")
|
||||
|
||||
func _apply_settings_language():
|
||||
$VBoxContainer/Langue/HBoxContainer/data.set_text(Global.get_setting_language())
|
||||
var data = $VBoxContainer/langue/VBoxContainer/data
|
||||
|
||||
data.add_item("English", load("res://assets/ui/flags/english.png"), true) # id : 0
|
||||
data.add_item("Français", load("res://assets/ui/flags/french.png"), true) # id : 1
|
||||
|
||||
data.select(Global.get_setting_language())
|
||||
|
||||
func _apply_settings_gyroscope():
|
||||
$VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(Global.get_setting_gyrosocpe())
|
||||
@@ -21,10 +27,32 @@ func _apply_settings_gyroscope():
|
||||
func _apply_settings_sound_ambient():
|
||||
$VBoxContainer/ambient_sound/HBoxContainer/data.set_pressed(Global.get_setting_ambient_sound())
|
||||
|
||||
func _apply_settings_resolution():
|
||||
var data = $VBoxContainer/resolution/VBoxContainer/data
|
||||
|
||||
data.add_item("2560 x 1440", null, true) # id : 0
|
||||
data.add_item("1920 x 1080", null, true) # id : 1
|
||||
data.add_item("1280 x 720", null, true) # id : 2
|
||||
data.add_item("854 x 576", null, true) # id : 3
|
||||
|
||||
for index in range(4):
|
||||
if data.get_item_text(index).split(' x ') == Global.get_setting_resolution():
|
||||
data.select(index)
|
||||
|
||||
func _apply_settings_fullscreen():
|
||||
$VBoxContainer/fullscreen/HBoxContainer/data.set_pressed(Global.get_setting_fullscreen())
|
||||
|
||||
func _on_gyroscope_pressed():
|
||||
print("[Settings#_on_gyroscope_pressed] change value to database ...........")
|
||||
Global.set_setting_gyroscope(int($VBoxContainer/gyroscope/HBoxContainer/data.pressed))
|
||||
|
||||
func _on_ambient_sound_pressed():
|
||||
print("[Settings#_on_ambient_sound_pressed] change value to database ...........")
|
||||
Global.set_setting_ambient_sound(int($VBoxContainer/ambient_sound/HBoxContainer/data.pressed))
|
||||
|
||||
func _on_langue_item_selected(index):
|
||||
Global.set_setting_language(index)
|
||||
|
||||
func _on_resolution_item_selected(index):
|
||||
Global.set_setting_resolution($VBoxContainer/resolution/VBoxContainer/data.get_item_text(index))
|
||||
|
||||
func _on_fullscreen_item_selected():
|
||||
Global.set_setting_fullscreen(int($VBoxContainer/fullscreen/HBoxContainer/data.pressed))
|
||||
|
||||
@@ -14,38 +14,48 @@ __meta__ = {
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_left = 547.0
|
||||
margin_top = 309.0
|
||||
margin_top = 265.0
|
||||
margin_right = 732.0
|
||||
margin_bottom = 411.0
|
||||
margin_bottom = 455.0
|
||||
alignment = 1
|
||||
|
||||
[node name="Langue" type="CenterContainer" parent="VBoxContainer"]
|
||||
[node name="langue" type="CenterContainer" parent="VBoxContainer"]
|
||||
margin_right = 185.0
|
||||
margin_bottom = 14.0
|
||||
margin_bottom = 27.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Langue"]
|
||||
margin_left = 58.0
|
||||
margin_right = 127.0
|
||||
margin_bottom = 14.0
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/langue"]
|
||||
margin_left = 67.0
|
||||
margin_right = 117.0
|
||||
margin_bottom = 27.0
|
||||
__meta__ = {
|
||||
"_editor_description_": ""
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/Langue/HBoxContainer"]
|
||||
[node name="Label" type="Label" parent="VBoxContainer/langue/VBoxContainer"]
|
||||
margin_right = 50.0
|
||||
margin_bottom = 14.0
|
||||
text = "langue :"
|
||||
align = 1
|
||||
|
||||
[node name="data" type="Label" parent="VBoxContainer/Langue/HBoxContainer"]
|
||||
margin_left = 54.0
|
||||
margin_right = 69.0
|
||||
margin_bottom = 14.0
|
||||
text = "FR"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[node name="data" type="ItemList" parent="VBoxContainer/langue/VBoxContainer"]
|
||||
margin_top = 18.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 27.0
|
||||
auto_height = true
|
||||
max_columns = 2
|
||||
same_column_width = true
|
||||
fixed_icon_size = Vector2( 32, 32 )
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/langue"]
|
||||
margin_left = 92.0
|
||||
margin_top = 13.0
|
||||
margin_right = 92.0
|
||||
margin_bottom = 13.0
|
||||
|
||||
[node name="gyroscope" type="CenterContainer" parent="VBoxContainer"]
|
||||
margin_top = 18.0
|
||||
margin_top = 31.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 58.0
|
||||
margin_bottom = 71.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/gyroscope"]
|
||||
margin_left = 16.0
|
||||
@@ -65,9 +75,9 @@ margin_bottom = 40.0
|
||||
align = 1
|
||||
|
||||
[node name="ambient_sound" type="CenterContainer" parent="VBoxContainer"]
|
||||
margin_top = 62.0
|
||||
margin_top = 75.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 102.0
|
||||
margin_bottom = 115.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/ambient_sound"]
|
||||
margin_right = 185.0
|
||||
@@ -84,5 +94,53 @@ margin_left = 109.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="resolution" type="CenterContainer" parent="VBoxContainer"]
|
||||
margin_top = 119.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 146.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/resolution"]
|
||||
margin_left = 54.0
|
||||
margin_right = 130.0
|
||||
margin_bottom = 27.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/resolution/VBoxContainer"]
|
||||
margin_right = 76.0
|
||||
margin_bottom = 14.0
|
||||
text = "Resolution :"
|
||||
|
||||
[node name="data" type="ItemList" parent="VBoxContainer/resolution/VBoxContainer"]
|
||||
margin_top = 18.0
|
||||
margin_right = 76.0
|
||||
margin_bottom = 27.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
auto_height = true
|
||||
same_column_width = true
|
||||
|
||||
[node name="fullscreen" type="CenterContainer" parent="VBoxContainer"]
|
||||
margin_top = 150.0
|
||||
margin_right = 185.0
|
||||
margin_bottom = 190.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/fullscreen"]
|
||||
margin_left = 15.0
|
||||
margin_right = 169.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/fullscreen/HBoxContainer"]
|
||||
margin_top = 13.0
|
||||
margin_right = 74.0
|
||||
margin_bottom = 27.0
|
||||
text = "Fullscreen :"
|
||||
|
||||
[node name="data" type="CheckButton" parent="VBoxContainer/fullscreen/HBoxContainer"]
|
||||
margin_left = 78.0
|
||||
margin_right = 154.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[connection signal="item_selected" from="VBoxContainer/langue/VBoxContainer/data" to="." method="_on_langue_item_selected"]
|
||||
[connection signal="pressed" from="VBoxContainer/gyroscope/HBoxContainer/data" to="." method="_on_gyroscope_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/ambient_sound/HBoxContainer/data" to="." method="_on_ambient_sound_pressed"]
|
||||
[connection signal="item_selected" from="VBoxContainer/resolution/VBoxContainer/data" to="." method="_on_resolution_item_selected"]
|
||||
[connection signal="pressed" from="VBoxContainer/fullscreen/HBoxContainer/data" to="." method="_on_fullscreen_item_selected"]
|
||||
|
||||
Reference in New Issue
Block a user