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:
darknight
2021-05-29 21:09:10 +02:00
parent 80890cbdce
commit ed20465f39
22 changed files with 475 additions and 165 deletions
+42 -3
View File
@@ -13,17 +13,41 @@ var msetting = preload("res://db/MSetting.gd")
var setting = null
func _ready():
print("[global#_ready]")
_initialize_database()
_initialize_setting()
_initialize_current_scene()
func _initialize_setting():
print("global#_initialize_setting")
setting = msetting.new()
apply_language(translate_int_to_locale(get_setting_language()))
apply_resolution()
apply_fullscreen()
func translate_int_to_locale(id):
var lang = "en_GB"
if id == 0:
lang = "en_GB"
if id == 1:
lang = "fr_FR"
return lang
func apply_language(local):
TranslationServer.set_locale(local)
func apply_resolution():
var screen_size = Vector2(get_setting_resolution()[0], get_setting_resolution()[1])
var margin_size = Vector2(0, 0)
get_viewport().set_size_override(true, screen_size, margin_size)
func apply_fullscreen():
OS.set_window_fullscreen(get_setting_fullscreen())
func goto_scene(path):
print("[global#goto_scene]")
print("[global#goto_scene] : "+String(path))
loader = ResourceLoader.load_interactive(path)
if loader == null:
print("Error loading ....")
@@ -39,6 +63,7 @@ func get_setting_language():
func set_setting_language(value):
setting.set_langue(value)
apply_language(translate_int_to_locale(value))
func get_setting_gyrosocpe():
return setting.get_gyroscope()
@@ -52,6 +77,20 @@ func get_setting_ambient_sound():
func set_setting_ambient_sound(value):
setting.set_ambient_sound(value)
func get_setting_resolution():
return setting.get_resolution()
func set_setting_resolution(value):
setting.set_resolution(value)
apply_resolution()
func get_setting_fullscreen():
return setting.get_fullscreen()
func set_setting_fullscreen(value):
setting.set_fullscreen(value)
apply_fullscreen()
func _process(_delta):
print("[global#_process]")
if loader == null:
+16 -11
View File
@@ -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")
+7 -4
View File
@@ -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"]
+9
View File
@@ -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")
+63
View File
@@ -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"]
+35 -7
View File
@@ -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))
+79 -21
View File
@@ -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"]
+26 -13
View File
@@ -11,20 +11,31 @@ onready var table = Global.database.get_table_by_name("scenes")
onready var meshes = {}
onready var from = null
onready var to = null
onready var mlevel = load("res://db/MLevel.gd")
onready var mscene = load("res://db/MScene.gd")
onready var victory_condition = 0
onready var victory_progress = 0
func _ready():
_load_translations()
_load_meshes()
_prepare_victory_condition()
func _prepare_victory_condition():
var level = mlevel.new(Global.current_scene_int)
victory_condition = level.object_to_find()
victory_progress = level.object_finding()
func _process(_delta):
_check_dissolve_mesh()
_check_change_angle_camera()
_check_victory_condition()
func _check_dissolve_mesh():
# Event dissolve in object searched by gamer
for key in meshes:
if meshes[key].lock() == true and meshes[key].mesh() != null:
if bool(meshes[key].lock()) == true and meshes[key].mesh() != null:
if meshes[key].tick_reference() == 0:
meshes[key].set_tick_reference(OS.get_ticks_msec())
@@ -32,15 +43,10 @@ func _check_dissolve_mesh():
meshes[key].set_value(meshes[key].value() + 0.01)
_node_to_mesh(key).get_surface_material(0).set("shader_param/dissolve_amount", meshes[key].value())
else:
victory_progress = mlevel.new(Global.current_scene_int).object_finding()
_node_to_mesh(key).call_deferred("free")
meshes[key].set_mesh(null)
func _node_to_mesh(key):
return get_node(meshes[key].mesh())
func _node_to_area(key):
return get_node(meshes[key].mesh()+"/Area")
func _check_change_angle_camera():
var camera = $"Main Camera"
var gyroscope = Input.get_gyroscope()
@@ -104,12 +110,22 @@ func _gyroscope_changed_up(gyroscope):
gyroscope.x < gyroscope_value_old.x
func _start_dissolve(key):
if meshes[key].lock() == false:
meshes[key].set_lock(true)
if bool(meshes[key].lock()) == false:
meshes[key].set_lock(int(true))
$ObjectFind.stream = meshes[key].audio_sound()
$ObjectFind.play()
## PRIVATE
func _check_victory_condition():
if victory_condition == victory_progress:
print("[levels#_check_victory_condition] \\o/")
Global.goto_scene("res://scenes/UI/ending.tscn")
func _node_to_mesh(key):
return get_node(meshes[key].mesh())
func _node_to_area(key):
return get_node(meshes[key].mesh()+"/Area")
func _load_translations():
pass
@@ -122,9 +138,6 @@ func _load_meshes():
if scene_detail.key() != null:
meshes[scene_detail.key()] = scene_detail
for key in meshes:
meshes[key].search_keys()
func _input(event):
if event is InputEventMouseButton or event is InputEventScreenTouch:
var camera = $"Main Camera"
+7 -10
View File
@@ -13,33 +13,30 @@ func _ready():
func _display_hud_menu():
var counter = 0
var scene = null
var label_id = null
var label_counter = null
for key in meshes:
scene = meshes[key]
_create_button_info(scene, counter, label_id)
label_id = scene.label_id()
counter = +1
_create_button_info(scene, counter, label_counter)
label_counter = scene.label_counter()
counter = counter + 1
# Back to main scene
func _on_TextureButton_pressed():
Global.goto_scene("res://scenes/main.tscn")
func _create_button_info(scene, counter, label_id):
func _create_button_info(scene, counter, label_counter):
var btn = null
if counter == 0:
btn = object_first.instance()
#print("[warCraft#_create_button_info] ["+String(counter)+"] use first")
elif counter == meshes.size() - 1:
btn = object_last.instance()
#print("[warCraft#_create_button_info] ["+String(counter)+"] use last")
else:
btn = object_std.instance()
#print("[warCraft#_create_button_info] ["+String(counter)+"] use standar")
if label_id != null and label_id == scene.label_id():
last_btn.get_node("Label").set_text(last_btn.get_node("Label").text + " X")
if label_counter != null and label_counter == scene.label_counter():
last_btn.get_node("Label").set_text(last_btn.get_node("Label").text + " " + String(scene.counter()))
else:
$ListObjects/ListContainer.add_child(btn)
btn.get_node("Label").set_text(scene.label())
+1 -1
View File
@@ -270,7 +270,7 @@ cell_center_y = false
cell_center_z = false
baked_meshes = [ SubResource( 4 ) ]
data = {
"cells": PoolIntArray( 0, 0, 0, 65531, 0, 3, 65532, 0, 0, 65533, 0, 0, 65534, 0, 0, 65535, 0, 0, 0, 1, 0, 65531, 1, 3, 65532, 1, 0, 65533, 1, 0, 65534, 1, 0, 65535, 1, 0, 0, 2, 0, 65531, 2, 3, 65532, 2, 0, 65533, 2, 0, 65534, 2, 0, 65535, 2, 0, 0, 65533, 0, 65532, 65533, 0, 65533, 65533, 0, 65534, 65533, 0, 65535, 65533, 0, 0, 65534, 0, 65531, 65534, 3, 65532, 65534, 0, 65533, 65534, 0, 65534, 65534, 0, 65535, 65534, 0, 0, 65535, 0, 65531, 65535, 3, 65532, 65535, 0, 65533, 65535, 0, 65534, 65535, 0, 65535, 65535, 0 )
"cells": PoolIntArray( 0, 0, 0, 65531, 0, -1610612733, 65532, 0, 0, 65533, 0, -1610612736, 65534, 0, 0, 65535, 0, 0, 0, 1, 0, 65531, 1, 3, 65532, 1, 0, 65533, 1, 0, 65534, 1, 0, 65535, 1, 0, 0, 2, 0, 65531, 2, 3, 65532, 2, 0, 65533, 2, 0, 65534, 2, 0, 65535, 2, 0, 0, 65533, 0, 65532, 65533, 0, 65533, 65533, 0, 65534, 65533, 0, 65535, 65533, 0, 0, 65534, 0, 65531, 65534, 3, 65532, 65534, 0, 65533, 65534, 0, 65534, 65534, 0, 65535, 65534, 0, 0, 65535, 0, 65531, 65535, 1073741827, 65532, 65535, 0, 65533, 65535, 0, 65534, 65535, 0, 65535, 65535, 0 )
}
__meta__ = {
"_editor_clip_": 0,