Merge pull request 'feature/save-state-scene' (#47) from feature/save-state-scene into dev

Reviewed-on: Athena/game-source#47
This commit is contained in:
darknight
2021-05-15 16:43:05 +02:00
13 changed files with 206 additions and 86 deletions
+28
View File
@@ -0,0 +1,28 @@
[gd_resource type="Environment" load_steps=3 format=2]
[ext_resource path="res://assets/hdri/tx_night_place.hdr" type="Texture" id=1]
[sub_resource type="PanoramaSky" id=2]
panorama = ExtResource( 1 )
[resource]
background_mode = 3
background_sky = SubResource( 2 )
background_color = Color( 0.188235, 0.133333, 0.133333, 1 )
background_energy = 0.6
ambient_light_color = Color( 0.694118, 0.168627, 0.67451, 1 )
ambient_light_energy = 1.55
ambient_light_sky_contribution = 0.5
fog_enabled = true
fog_color = Color( 0.562167, 0.29, 1, 0.941176 )
fog_depth_begin = 0.0
fog_depth_end = 60.0
fog_depth_curve = 1.10957
fog_height_enabled = true
fog_height_min = 2.0
fog_height_max = -20.0
fog_height_curve = 0.965936
tonemap_mode = 2
ss_reflections_enabled = true
dof_blur_far_distance = 2.0
glow_enabled = true
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

+34
View File
@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon-reset.png-d000c25cd26938ceb23700c305ecc4f1.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/themes/icon-reset.png"
dest_files=[ "res://.import/icon-reset.png-d000c25cd26938ceb23700c305ecc4f1.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

+34
View File
@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/level-btn.png-e139f192a132d04b829735472e4911a5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/themes/level-btn.png"
dest_files=[ "res://.import/level-btn.png-e139f192a132d04b829735472e4911a5.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
+48
View File
@@ -0,0 +1,48 @@
extends "res://db/MBase.gd"
var m_name = null
var m_thumb = null
var m_level = null
func _init(row_idx):
m_level = row_idx
table = Global.database.get_table_by_name("levels")
var datas = table.get_data_at_row_idx(m_level)
if true:
m_name = _get_name(datas)
m_thumb = _get_thumb(datas)
func object_to_find():
var count = 0
var datas = _scenes().get_data_by_prop_name_and_data("level", String(m_level))
if datas.size() != 0:
count = datas.size()
return count as String
func _scenes():
return Global.database.get_table_by_name("scenes")
func object_finding():
var count = 0
var datas = _scenes().get_data_by_prop_name_and_data("lock", String(m_level))
if datas.size() != 0:
count = datas.count(true)
return count as String
func name():
return m_name
func thumbnail():
return m_thumb
## PRIVATE
func _get_name(datas):
return _get_data(datas, 0) as String
func _get_thumb(datas):
return _get_data(datas, 1) as String
-11
View File
@@ -1,6 +1,5 @@
extends "res://db/MBase.gd" extends "res://db/MBase.gd"
var m_id = null
var m_value = { "id": null, "value": null } var m_value = { "id": null, "value": null }
var m_lock = { "id": null, "value": null } var m_lock = { "id": null, "value": null }
var m_label = null var m_label = null
@@ -10,7 +9,6 @@ var m_level = null
var m_mesh = null var m_mesh = null
func _init(row_index): func _init(row_index):
print("scene#_init")
table = Global.database.get_table_by_name("scenes") table = Global.database.get_table_by_name("scenes")
var datas = table.get_data_at_row_idx(row_index) var datas = table.get_data_at_row_idx(row_index)
@@ -34,15 +32,6 @@ func search_keys():
if m_tick_reference["id"] == null: if m_tick_reference["id"] == null:
m_tick_reference["id"] = _get_tick_reference_id(prop_index) m_tick_reference["id"] = _get_tick_reference_id(prop_index)
func object():
return {
"label": m_label,
"lock": m_lock["value"],
"value": m_value["value"],
"tick_reference": m_tick_reference["value"],
"mesh": m_mesh
}
func key(): func key():
return m_key return m_key
+3 -4
View File
@@ -14,10 +14,9 @@
"table_name":"levels", "table_name":"levels",
"props":[ "props":[
{"name":"name","type":"3","auto_increment":"0"}, {"name":"name","type":"3","auto_increment":"0"},
{"name":"thumb","type":"4","auto_increment":"0"}, {"name":"thumb","type":"4","auto_increment":"0"}
{"name":"resource","type":"4","auto_increment":"0"}
], ],
"data":["WarCraft","res://assets/levels/warcraft.jpg","res://scenes/levels/warcraft/WarCraft.tscn"] "data":["WarCraft","res://assets/levels/warcraft.jpg"]
}, },
{ {
"table_name":"scenes", "table_name":"scenes",
@@ -30,7 +29,7 @@
{"name":"level","type":"table","table_name":"levels","auto_increment":"0"}, {"name":"level","type":"table","table_name":"levels","auto_increment":"0"},
{"name":"mesh","type":"3","auto_increment":"0"} {"name":"mesh","type":"3","auto_increment":"0"}
], ],
"data":["0.0","True","Dagger","0","dagger","0","dagger","0.0","0","Fiole","7788","fiole1","0","fioles/fiole1","1.79","0","Fiole","0","fiole2","0","fioles/fiole2","0.0","0","Fiole","0","fiole3","0","fioles/fiole_socle/fiole3","0.0","0","Spyglass","0","spyglass","0","spyglass","0.0","0","Coins","0","coin1","0","golds/coin1","0.0","0","Coins","0","coin2","0","golds/coin2","0.0","0","Coins","0","coin3","0","golds/coin3","0.0","0","Weapon Gun","0","weapon","0","weapon","0.0","0","Apple","0","apple1","0","apples/apple1","0.0","0","Apple","0","apple2","0","apples/apple2","0.0","0","Apple","0","apple3","0","apples/apple3","0.0","0","Apple","0","apple4","0","apples/apple4","0.0","0","Beer","0","beer","0","beer","0.0","0","SuperDager","0","gadder","1","sm_super_dager"] "data":["0.0","True","Dagger","0","dagger","0","dagger","0.0","0","Fiole","14006","fiole1","0","fioles/fiole1","1.45","0","Fiole","0","fiole2","0","fioles/fiole2","0.0","0","Fiole","0","fiole3","0","fioles/fiole_socle/fiole3","0.0","0","Spyglass","0","spyglass","0","spyglass","0.0","0","Coins","0","coin1","0","golds/coin1","0.0","0","Coins","0","coin2","0","golds/coin2","0.0","0","Coins","0","coin3","0","golds/coin3","0.0","0","Weapon Gun","0","weapon","0","weapon","0.0","0","Apple","0","apple1","0","apples/apple1","0.0","0","Apple","0","apple2","0","apples/apple2","0.0","0","Apple","0","apple3","0","apples/apple3","0.0","0","Apple","0","apple4","0","apples/apple4","0.0","0","Beer","0","beer","0","beer","0.0","0","SuperDager","0","gadder","1","sm_super_dager"]
} }
] ]
} }
+30 -44
View File
@@ -3,6 +3,8 @@ extends Control
export (PackedScene) var template = load("res://scenes/levels/Template.tscn") export (PackedScene) var template = load("res://scenes/levels/Template.tscn")
onready var levels = Array() onready var levels = Array()
onready var mlevel = load("res://db/MLevel.gd")
onready var table = Global.table_levels
func _ready(): func _ready():
_apply_scenes() _apply_scenes()
@@ -12,51 +14,16 @@ func _on_warcraft_pressed():
Global.current_scene_int = 0 Global.current_scene_int = 0
Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn") Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn")
func _on_develop_pressed(): func _on_reset_level():
Global.current_scene_int = 1 print("Reset level ...")
Global.goto_scene("res://developers/aurelien/CheckLightmap.tscn")
## PRIVATE ## PRIVATE
func _apply_scenes(): 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): for row_index in range(0, Global.table_levels.m_rows_count):
datas = Global.table_levels.get_data_at_row_idx(row_index) _apply_scene(mlevel.new(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(_load_scene(name),
_load_texture(thumb),
_build_path(name),
_build_method(name))
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 _build_path(name): func _build_path(name):
return "MarginContainer/HBoxContainer/"+name+"/TextureRect" return "MarginContainer/HBoxContainer/"+name
func _build_method(name): func _build_method(name):
return "_on_"+name.to_lower()+"_pressed" return "_on_"+name.to_lower()+"_pressed"
@@ -70,9 +37,28 @@ func _load_scene(name):
func _load_texture(thumbnail): func _load_texture(thumbnail):
return load(thumbnail) return load(thumbnail)
func _apply_scene(instance, thumb, node, method): func _apply_scene(level):
$MarginContainer/HBoxContainer.add_child(instance) $MarginContainer/HBoxContainer.add_child(_load_scene(level.name()))
var button = get_node(node+"/TextureButton") var node = _build_path(level.name())
button.set_normal_texture(thumb)
button.connect("pressed", self, method)
_configure_select(level, node)
_configure_reset(level, node)
_configure_counter(level, node)
func _configure_select(level, node):
var select = get_node(node+"/TextureRect/TextureButton")
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())
+2 -2
View File
@@ -20,8 +20,8 @@ func _apply_settings():
var lang = _get_settings_data("langue", Global.table_settings, Global.data_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) var gyro = _get_settings_data("gyroscope", Global.table_settings, Global.data_settings)
#$CenterContainer/VBoxContainer/Langue/HBoxContainer/data.set_text(lang) $VBoxContainer/Langue/HBoxContainer/data.set_text(lang)
#$CenterContainer/VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(int(gyro) as bool) $VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(int(gyro) as bool)
func _get_settings_data(name, table, datas): func _get_settings_data(name, table, datas):
for index in range(0, Global.table_settings.get_props_count()): for index in range(0, Global.table_settings.get_props_count()):
+21 -17
View File
@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://assets/levels/warcraft.jpg" type="Texture" id=1] [ext_resource path="res://assets/ui/themes/level-btn.png" type="Texture" id=1]
[ext_resource path="res://assets/ui/themes/icon-reset.png" type="Texture" id=2]
[node name="VBoxContainer" type="VBoxContainer"] [node name="VBoxContainer" type="VBoxContainer"]
margin_right = 150.0 margin_right = 150.0
@@ -10,35 +11,40 @@ __meta__ = {
} }
[node name="TextureRect" type="TextureRect" parent="."] [node name="TextureRect" type="TextureRect" parent="."]
margin_right = 150.0 margin_right = 217.0
margin_bottom = 150.0 margin_bottom = 200.0
texture = ExtResource( 1 ) texture = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="TextureButton" type="TextureButton" parent="TextureRect"] [node name="TextureButton" type="TextureButton" parent="TextureRect"]
margin_left = 25.0
margin_top = 25.0
margin_right = 40.0 margin_right = 40.0
margin_bottom = 40.0 margin_bottom = 40.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="VBoxContainer" type="HBoxContainer" parent="."] [node name="VBoxContainer" type="HBoxContainer" parent="."]
margin_top = 154.0 margin_top = 204.0
margin_right = 150.0 margin_right = 217.0
margin_bottom = 174.0 margin_bottom = 332.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
custom_constants/separation = 25 custom_constants/separation = 25
alignment = 1 alignment = 1
[node name="ButtonReset" type="Button" parent="VBoxContainer"] [node name="ButtonReset" type="TextureButton" parent="VBoxContainer"]
margin_right = 62.0 margin_right = 64.0
margin_bottom = 20.0 margin_bottom = 128.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
texture_normal = ExtResource( 2 )
[node name="Label" type="Label" parent="VBoxContainer/ButtonReset"] [node name="Label" type="Label" parent="VBoxContainer/ButtonReset"]
anchor_right = 1.0 anchor_right = 1.0
@@ -52,15 +58,13 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="ButtonCount" type="Button" parent="VBoxContainer"] [node name="ButtonCount" type="TextureButton" parent="VBoxContainer"]
margin_left = 87.0 margin_left = 89.0
margin_right = 150.0 margin_right = 217.0
margin_bottom = 20.0 margin_bottom = 128.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
__meta__ = { texture_normal = ExtResource( 2 )
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="VBoxContainer/ButtonCount"] [node name="Label" type="Label" parent="VBoxContainer/ButtonCount"]
anchor_right = 1.0 anchor_right = 1.0
+5 -6
View File
@@ -9,11 +9,9 @@ const RAY_LENGTH = 1000
onready var gyroscope_value_old = Vector3(0, 0, 0) onready var gyroscope_value_old = Vector3(0, 0, 0)
onready var table = Global.database.get_table_by_name("scenes") onready var table = Global.database.get_table_by_name("scenes")
onready var meshes = {} onready var meshes = {}
onready var meshes2 = null
onready var from = null onready var from = null
onready var to = null onready var to = null
onready var mscene = load("res://db/MScene.gd")
var mscene = load("res://db/MScene.gd")
func _ready(): func _ready():
_load_translations() _load_translations()
@@ -159,6 +157,7 @@ func _physics_process(_delta):
var result = space_state.intersect_ray(from, to, [], 1, false, true) var result = space_state.intersect_ray(from, to, [], 1, false, true)
from = null from = null
to = null to = null
var node = result["collider"].get_parent() if result.has("collider"):
if node != null: var node = result["collider"].get_parent()
_start_dissolve(node.name) if node != null:
_start_dissolve(node.name)
-1
View File
@@ -4,7 +4,6 @@ export (PackedScene) var settings = load("res://scenes/UI/settings/Settings.tscn
export (PackedScene) var scenes = load("res://scenes/UI/choose_scenes/ChooseScene.tscn") export (PackedScene) var scenes = load("res://scenes/UI/choose_scenes/ChooseScene.tscn")
onready var current_scene = "title" onready var current_scene = "title"
onready var scene_instance = $MarginContainer/HBoxContainer/MarginContainer/scene_instance
func _ready(): func _ready():
_translation() _translation()