diff --git a/assets/env/base_env.tres b/assets/env/base_env.tres new file mode 100644 index 0000000..e78bbbc --- /dev/null +++ b/assets/env/base_env.tres @@ -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 diff --git a/assets/ui/themes/icon-reset.png b/assets/ui/themes/icon-reset.png new file mode 100644 index 0000000..161bd52 Binary files /dev/null and b/assets/ui/themes/icon-reset.png differ diff --git a/assets/ui/themes/icon-reset.png.import b/assets/ui/themes/icon-reset.png.import new file mode 100644 index 0000000..8e4a318 --- /dev/null +++ b/assets/ui/themes/icon-reset.png.import @@ -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 diff --git a/assets/ui/themes/level-btn.png b/assets/ui/themes/level-btn.png new file mode 100644 index 0000000..9081994 Binary files /dev/null and b/assets/ui/themes/level-btn.png differ diff --git a/assets/ui/themes/level-btn.png.import b/assets/ui/themes/level-btn.png.import new file mode 100644 index 0000000..9a35803 --- /dev/null +++ b/assets/ui/themes/level-btn.png.import @@ -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 diff --git a/db/MLevel.gd b/db/MLevel.gd new file mode 100644 index 0000000..68b73f9 --- /dev/null +++ b/db/MLevel.gd @@ -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 diff --git a/db/MScene.gd b/db/MScene.gd index 7fc2ac9..ebdbaee 100644 --- a/db/MScene.gd +++ b/db/MScene.gd @@ -1,6 +1,5 @@ extends "res://db/MBase.gd" -var m_id = null var m_value = { "id": null, "value": null } var m_lock = { "id": null, "value": null } var m_label = null @@ -10,7 +9,6 @@ var m_level = null var m_mesh = null func _init(row_index): - print("scene#_init") table = Global.database.get_table_by_name("scenes") var datas = table.get_data_at_row_idx(row_index) @@ -34,15 +32,6 @@ func search_keys(): if m_tick_reference["id"] == null: 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(): return m_key diff --git a/db/ahog.json b/db/ahog.json index 2e57850..298edf8 100644 --- a/db/ahog.json +++ b/db/ahog.json @@ -14,10 +14,9 @@ "table_name":"levels", "props":[ {"name":"name","type":"3","auto_increment":"0"}, - {"name":"thumb","type":"4","auto_increment":"0"}, - {"name":"resource","type":"4","auto_increment":"0"} + {"name":"thumb","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", @@ -30,7 +29,7 @@ {"name":"level","type":"table","table_name":"levels","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"] } ] -} +} \ No newline at end of file diff --git a/scenes/UI/choose_scenes/ChooseScene.gd b/scenes/UI/choose_scenes/ChooseScene.gd index 8fbcdff..dbc7c94 100644 --- a/scenes/UI/choose_scenes/ChooseScene.gd +++ b/scenes/UI/choose_scenes/ChooseScene.gd @@ -3,6 +3,8 @@ 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() @@ -12,51 +14,16 @@ func _on_warcraft_pressed(): Global.current_scene_int = 0 Global.goto_scene("res://scenes/levels/warcraft/WarCraft.tscn") -func _on_develop_pressed(): - Global.current_scene_int = 1 - Global.goto_scene("res://developers/aurelien/CheckLightmap.tscn") +func _on_reset_level(): + print("Reset level ...") ## 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(_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() + _apply_scene(mlevel.new(row_index)) func _build_path(name): - return "MarginContainer/HBoxContainer/"+name+"/TextureRect" + return "MarginContainer/HBoxContainer/"+name func _build_method(name): return "_on_"+name.to_lower()+"_pressed" @@ -70,9 +37,28 @@ func _load_scene(name): func _load_texture(thumbnail): return load(thumbnail) -func _apply_scene(instance, thumb, node, method): - $MarginContainer/HBoxContainer.add_child(instance) - var button = get_node(node+"/TextureButton") - button.set_normal_texture(thumb) - button.connect("pressed", self, method) +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") + + 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()) diff --git a/scenes/UI/settings/Settings.gd b/scenes/UI/settings/Settings.gd index 66df407..ec623d9 100644 --- a/scenes/UI/settings/Settings.gd +++ b/scenes/UI/settings/Settings.gd @@ -20,8 +20,8 @@ func _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) + $VBoxContainer/Langue/HBoxContainer/data.set_text(lang) + $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()): diff --git a/scenes/levels/Template.tscn b/scenes/levels/Template.tscn index 0ad350d..ec2c14a 100644 --- a/scenes/levels/Template.tscn +++ b/scenes/levels/Template.tscn @@ -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"] margin_right = 150.0 @@ -10,35 +11,40 @@ __meta__ = { } [node name="TextureRect" type="TextureRect" parent="."] -margin_right = 150.0 -margin_bottom = 150.0 +margin_right = 217.0 +margin_bottom = 200.0 texture = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } [node name="TextureButton" type="TextureButton" parent="TextureRect"] +margin_left = 25.0 +margin_top = 25.0 margin_right = 40.0 margin_bottom = 40.0 mouse_default_cursor_shape = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 __meta__ = { "_edit_use_anchors_": false } [node name="VBoxContainer" type="HBoxContainer" parent="."] -margin_top = 154.0 -margin_right = 150.0 -margin_bottom = 174.0 +margin_top = 204.0 +margin_right = 217.0 +margin_bottom = 332.0 size_flags_horizontal = 3 size_flags_vertical = 3 custom_constants/separation = 25 alignment = 1 -[node name="ButtonReset" type="Button" parent="VBoxContainer"] -margin_right = 62.0 -margin_bottom = 20.0 +[node name="ButtonReset" type="TextureButton" parent="VBoxContainer"] +margin_right = 64.0 +margin_bottom = 128.0 mouse_default_cursor_shape = 2 size_flags_horizontal = 3 +texture_normal = ExtResource( 2 ) [node name="Label" type="Label" parent="VBoxContainer/ButtonReset"] anchor_right = 1.0 @@ -52,15 +58,13 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ButtonCount" type="Button" parent="VBoxContainer"] -margin_left = 87.0 -margin_right = 150.0 -margin_bottom = 20.0 +[node name="ButtonCount" type="TextureButton" parent="VBoxContainer"] +margin_left = 89.0 +margin_right = 217.0 +margin_bottom = 128.0 mouse_default_cursor_shape = 2 size_flags_horizontal = 3 -__meta__ = { -"_edit_use_anchors_": false -} +texture_normal = ExtResource( 2 ) [node name="Label" type="Label" parent="VBoxContainer/ButtonCount"] anchor_right = 1.0 diff --git a/scenes/levels/levels.gd b/scenes/levels/levels.gd index 8cb17ec..3035d9d 100644 --- a/scenes/levels/levels.gd +++ b/scenes/levels/levels.gd @@ -9,11 +9,9 @@ const RAY_LENGTH = 1000 onready var gyroscope_value_old = Vector3(0, 0, 0) onready var table = Global.database.get_table_by_name("scenes") onready var meshes = {} -onready var meshes2 = null onready var from = null onready var to = null - -var mscene = load("res://db/MScene.gd") +onready var mscene = load("res://db/MScene.gd") func _ready(): _load_translations() @@ -159,6 +157,7 @@ func _physics_process(_delta): var result = space_state.intersect_ray(from, to, [], 1, false, true) from = null to = null - var node = result["collider"].get_parent() - if node != null: - _start_dissolve(node.name) + if result.has("collider"): + var node = result["collider"].get_parent() + if node != null: + _start_dissolve(node.name) diff --git a/scenes/main.gd b/scenes/main.gd index 5234596..64d32cf 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -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") onready var current_scene = "title" -onready var scene_instance = $MarginContainer/HBoxContainer/MarginContainer/scene_instance func _ready(): _translation()