Merge branch 'dev' into feature/props-ho

This commit is contained in:
stilobique
2021-05-14 11:03:28 +02:00
79 changed files with 5300 additions and 154 deletions
+69 -21
View File
@@ -1,16 +1,22 @@
extends Control
var current_scene = null
var loader = null
var wait_frames = 1
var time_max = 100 # msec
const TICKS_TIME_MAX = 100 # msec
onready var current_scene = null
onready var loader = null
onready var wait_frames = 1
onready var database = null
onready var table_settings = null
onready var data_settings = null
onready var table_levels = null
onready var data_levels = null
onready var table_scenes = null
onready var data_scenes = null
func _ready():
print("[global#_ready] get root scene")
var root = get_tree().get_root()
current_scene = root.get_child(root.get_child_count() - 1)
if current_scene.name != "Main":
get_node("/root/Loading").hide()
print("[global#_ready]")
_initialize_current_scene()
_initialize_database()
func goto_scene(path):
print("[global#goto_scene]")
@@ -25,7 +31,7 @@ func goto_scene(path):
Loading.get_node("ColorRect/CenterContainer/VBoxContainer/ProgressBar").set_max(loader.get_stage_count())
func gyroscope_enabled():
if Input.get_gyroscope():
if _gyroscope_enabled():
return true
else:
return false
@@ -41,29 +47,71 @@ func _process(_delta):
var tick = OS.get_ticks_msec()
# Use "time_max" to control for how long we block this thread
while OS.get_ticks_msec() < tick + time_max:
# Use "TICKS_TIME_MAX" to control for how long we block this thread
while OS.get_ticks_msec() < tick + TICKS_TIME_MAX:
var err = loader.poll()
if err == ERR_FILE_EOF: # Finished loading.
var resource = loader.get_resource()
loader = null
set_new_scene(resource)
get_node("/root/Loading").hide()
_set_new_scene()
break
elif err == OK:
update_progress()
_update_progress()
else:
print("[global#_process] Error loading")
loader = null
break
func update_progress():
## PRIVATE
func _initialize_current_scene():
print("[global#_initialize_current_scene]")
var root = get_tree().get_root()
current_scene = root.get_child(root.get_child_count() - 1)
if current_scene.name != "Main":
get_node("/root/Loading").hide()
func _initialize_database():
print("[global#_initialize_database]")
var database_manager = load(gddb_constants.c_addon_main_path + "core/db_man.gd").new()
var db_id = database_manager.load_database("res://db/ahog.json")
if db_id == gddb_types.e_db_invalid_file:
print("[global#_initialize_database] Error invalid database file !")
OS.set_exit_code(1)
if db_id == gddb_types.e_db_invalid_ver:
print("[global#_initialize_database] Error invalid database version !")
OS.set_exit_code(1)
database = database_manager.get_db_by_id(db_id)
table_settings = database.get_table_by_name("settings")
data_settings = table_settings.get_data_at_row_idx(0)
table_levels = database.get_table_by_name("levels")
func _get_settings_data(name, index, table, datas):
print("[global#_get_settings_data] name : "+String(name))
var data = null
if table.get_prop_at(index).get_prop_name() == name:
data = datas[index].get_data()
return data
func _gyroscope_enabled():
print("[global#_gyroscope_enabled]")
for index in range(0, table_settings.get_props_count()):
_get_settings_data("gyroscope", index, table_settings, data_settings)
func _update_progress():
print("[global#update_progress]")
Loading.visible = true
Loading.get_node("ColorRect/CenterContainer/VBoxContainer/ProgressBar").set_value(loader.get_stage())
func set_new_scene(scene_resource):
func _set_new_scene():
print("[global#set_new_scene]")
current_scene = scene_resource.instance()
var resource = loader.get_resource()
loader = null
current_scene = resource.instance()
get_node("/root").add_child(current_scene)
get_node("/root/Loading").hide()
-57
View File
@@ -1,57 +0,0 @@
[gd_scene load_steps=2 format=2]
[sub_resource type="GDScript" id=1]
script/source = "extends Node
func _ready():
$CenterContainer/VBoxContainer/LeadDev.text = tr(\"ABOUT_LEAD_DEV\")
$CenterContainer/VBoxContainer/LeadArtist.text = tr(\"ABOUT_LEAD_ARTIST\")
$CenterContainer/VBoxContainer/Sources.text = tr(\"ABOUT_SOURCE_GAME\")
"
[node name="About" type="Node"]
script = SubResource( 1 )
[node name="CenterContainer" type="CenterContainer" parent="."]
margin_left = 150.0
margin_right = 1024.0
margin_bottom = 600.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 210.0
margin_top = 275.0
margin_right = 663.0
margin_bottom = 325.0
alignment = 1
[node name="LeadDev" type="Label" parent="CenterContainer/VBoxContainer"]
margin_right = 453.0
margin_bottom = 14.0
text = "Lead Develop : GRem -- VAILLANT Jérémy"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LeadArtist" type="Label" parent="CenterContainer/VBoxContainer"]
margin_top = 18.0
margin_right = 453.0
margin_bottom = 32.0
text = "Lead Artist : Stilobique -- VAILLANT Aurelien"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sources" type="Label" parent="CenterContainer/VBoxContainer"]
margin_top = 36.0
margin_right = 453.0
margin_bottom = 50.0
text = "Source code of game : https://dev.stilobique.com/Athena/game-source"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
+70 -3
View File
@@ -1,13 +1,80 @@
extends Control
onready var levels = Array()
func _ready():
print("[choose_scene#_ready]")
_apply_scenes()
# Load scene warcraft
func _on_WarCraft_pressed():
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
func _on_Lightmap_pressed():
Global.goto_scene("res://developers/aurelien/CheckLightmap.tscn")
func _on_warcraft_pressed():
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
func _on_develop_pressed():
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")
func _on_Dagger_pressed():
Global.goto_scene("res://developers/jeremy/Dagger.tscn")
+10 -20
View File
@@ -20,10 +20,10 @@ __meta__ = {
}
[node name="GridContainer" type="GridContainer" parent="games"]
margin_left = 25.0
margin_top = 26.2599
margin_right = 824.0
margin_bottom = 601.26
margin_left = 503.586
margin_top = 300.0
margin_right = 1302.59
margin_bottom = 604.0
__meta__ = {
"_edit_use_anchors_": false
}
@@ -49,23 +49,13 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Dagger" type="TextureButton" parent="games/GridContainer"]
margin_top = 308.0
margin_right = 150.0
margin_bottom = 458.0
mouse_default_cursor_shape = 2
texture_normal = ExtResource( 2 )
[node name="Container" type="Control" parent="games"]
margin_right = 824.0
margin_bottom = 300.0
[node name="Label" type="Label" parent="games/GridContainer/Dagger"]
margin_right = 44.0
margin_bottom = 14.0
text = "Dagger"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="VBoxContainer" parent="games/Container"]
margin_right = 824.0
margin_bottom = 300.0
[connection signal="pressed" from="games/GridContainer/WarCraft" to="." method="_on_WarCraft_pressed"]
[connection signal="pressed" from="games/GridContainer/Lightmap" to="." method="_on_Lightmap_pressed"]
[connection signal="pressed" from="games/GridContainer/Dagger" to="." method="_on_Dagger_pressed"]
+43
View File
@@ -0,0 +1,43 @@
extends Node
onready var language_id = null
onready var gyroscope_id = null
func _ready():
print("[Settings#_ready]")
_translation()
_apply_settings()
## PRIVATE
func _translation():
print("[Settings#_translation]")
$CenterContainer/VBoxContainer/Langue/HBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
$CenterContainer/VBoxContainer/gyroscope/HBoxContainer/Label.text = tr("SETTINGS_LABEL_GYROSCOPE")
func _apply_settings():
print("[Settings#_apply_settings]")
var lang = _get_settings_data("langue", Global.table_settings, Global.data_settings)
var gyro = _get_settings_data("gyroscope", Global.table_settings, Global.data_settings)
$CenterContainer/VBoxContainer/Langue/HBoxContainer/data.set_text(lang)
$CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(int(gyro) as bool)
func _get_settings_data(name, table, datas):
for index in range(0, Global.table_settings.get_props_count()):
if table.get_prop_at(index).get_prop_name() == name:
_save_id(name, table.get_prop_at(index).get_prop_id())
return datas[index].get_data()
func _save_id(name, id):
if name == "langue":
language_id = id
if name == "gyroscope":
gyroscope_id = id
func _on_gyroscope_pressed():
print("[Settings#_on_gyroscop_toggled] change value to database ...........")
Global.table_settings.edit_data(gyroscope_id,
gddb_types.e_prop_type_bool,
int($CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data.pressed) as String)
Global.database.save_db()
+70
View File
@@ -0,0 +1,70 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scenes/UI/Settings.gd" type="Script" id=1]
[node name="Settings" type="Control"]
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CenterContainer" type="CenterContainer" parent="."]
margin_left = 150.0
margin_right = 1024.0
margin_bottom = 600.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 360.0
margin_top = 271.0
margin_right = 513.0
margin_bottom = 329.0
alignment = 1
[node name="Langue" type="CenterContainer" parent="CenterContainer/VBoxContainer"]
margin_right = 153.0
margin_bottom = 14.0
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/Langue"]
margin_left = 42.0
margin_right = 111.0
margin_bottom = 14.0
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/Langue/HBoxContainer"]
margin_right = 50.0
margin_bottom = 14.0
text = "langue :"
[node name="data" type="Label" parent="CenterContainer/VBoxContainer/Langue/HBoxContainer"]
margin_left = 54.0
margin_right = 69.0
margin_bottom = 14.0
text = "FR"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="gyroscope" type="CenterContainer" parent="CenterContainer/VBoxContainer"]
margin_top = 18.0
margin_right = 153.0
margin_bottom = 58.0
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/gyroscope"]
margin_right = 153.0
margin_bottom = 40.0
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/gyroscope/HBoxContainer"]
margin_top = 13.0
margin_right = 73.0
margin_bottom = 27.0
text = "gyroscope :"
[node name="data" type="CheckButton" parent="CenterContainer/VBoxContainer/gyroscope/HBoxContainer"]
margin_left = 77.0
margin_right = 153.0
margin_bottom = 40.0
align = 1
[connection signal="pressed" from="CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data" to="." method="_on_gyroscope_pressed"]
+10 -9
View File
@@ -1,6 +1,6 @@
extends Node
export (PackedScene) var about = load("res://scenes/UI/About.tscn")
export (PackedScene) var settings = load("res://scenes/UI/Settings.tscn")
export (PackedScene) var scenes = load("res://scenes/UI/ChooseScene.tscn")
const max_diff = 0.08
@@ -9,20 +9,16 @@ var current_scene = null
var value_old = Vector2(0, 0)
func _ready():
print(tr("MESSAGE_READY"))
$Grid/Menu/Action/New.text = tr("MAIN_BUTTON_NEW")
$Grid/Menu/Action/Continue.text = tr("MAIN_BUTTON_CONTINUE")
$Grid/Menu/Action/About.text = tr("MAIN_BUTTON_ABOUT")
$Grid/Menu/Action/Quit.text = tr("MAIN_BUTTON_QUIT")
_translation()
# Quit the game
func _on_Quit_pressed():
get_tree().quit(0)
# Load scene about
func _on_About_pressed():
# Load scene settings
func _on_Settings_pressed():
_prepare_change_scene()
current_scene = about.instance()
current_scene = settings.instance()
add_child(current_scene)
# Load scene for select game
@@ -32,6 +28,11 @@ func _on_New_pressed():
add_child(current_scene)
## PRIVATE
func _translation():
$Grid/Menu/Action/Puzzles.text = tr("MAIN_BUTTON_PUZZLES")
$Grid/Menu/Action/Settings.text = tr("MAIN_BUTTON_SETTINGS")
$Grid/Menu/Action/Quit.text = tr("MAIN_BUTTON_QUIT")
func _prepare_change_scene():
if (current_scene != null):
remove_child(current_scene)
+7 -19
View File
@@ -76,36 +76,24 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="New" type="LinkButton" parent="Grid/Menu/Action"]
[node name="Puzzles" type="LinkButton" parent="Grid/Menu/Action"]
margin_left = 10.0
margin_top = 30.0
margin_right = 130.0
margin_bottom = 64.0
custom_fonts/font = ExtResource( 3 )
text = "new"
text = "Puzzles"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Continue" type="LinkButton" parent="Grid/Menu/Action"]
margin_left = 10.0
margin_top = 80.0
margin_right = 136.0
margin_bottom = 114.0
custom_fonts/font = ExtResource( 3 )
disabled = true
text = "Reprendre"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="About" type="LinkButton" parent="Grid/Menu/Action"]
[node name="Settings" type="LinkButton" parent="Grid/Menu/Action"]
margin_left = 10.0
margin_top = 130.0
margin_right = 86.0
margin_right = 114.0
margin_bottom = 164.0
custom_fonts/font = ExtResource( 3 )
text = "Credit"
text = "Settings"
__meta__ = {
"_edit_use_anchors_": false
}
@@ -122,6 +110,6 @@ __meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Grid/Menu/Action/New" to="." method="_on_New_pressed"]
[connection signal="pressed" from="Grid/Menu/Action/About" to="." method="_on_About_pressed"]
[connection signal="pressed" from="Grid/Menu/Action/Puzzles" to="." method="_on_New_pressed"]
[connection signal="pressed" from="Grid/Menu/Action/Settings" to="." method="_on_Settings_pressed"]
[connection signal="pressed" from="Grid/Menu/Action/Quit" to="." method="_on_Quit_pressed"]