bugfix/android-database (#78)

Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com>
Reviewed-on: Athena/game-source#78
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-06-06 18:54:25 +02:00
parent 1883355678
commit fcff613a93
4 changed files with 47 additions and 17 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
"props":[
{"name":"langue","type":"1","auto_increment":"0"},
{"name":"gyroscope","type":"0","auto_increment":"0"},
{"name":"ambiant_sound","type":"0","auto_increment":"0"},
{"name":"ambient_sound","type":"0","auto_increment":"0"},
{"name":"resolution","type":"3","auto_increment":"0"},
{"name":"fullscreen","type":"0","auto_increment":"0"}
],
-1
View File
@@ -223,7 +223,6 @@ texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
+4 -5
View File
@@ -6,7 +6,7 @@
[ext_resource path="res://assets/ui/themes/UI-Button-ItemsList-last-hover.png" type="Texture" id=6]
[ext_resource path="res://assets/ui/themes/UI-Button-ItemsList-last.png" type="Texture" id=8]
[sub_resource type="Animation" id=2]
[sub_resource type="Animation" id=1]
resource_name = "ObjectFind"
tracks/0/type = "bezier"
tracks/0/path = NodePath("ListContainer/TextureButtonLast/Label:rect_position:x")
@@ -19,8 +19,7 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 0.2, 0.4, 0.6, 0.8, 1 )
}
[sub_resource type="Animation" id=1]
resource_name = "ObjectFindAll"
[sub_resource type="Animation" id=2]
tracks/0/type = "bezier"
tracks/0/path = NodePath("ListContainer/TextureButtonLast:rect_position:x")
tracks/0/interp = 1
@@ -102,5 +101,5 @@ margin_bottom = 128.0
texture_normal = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/ObjectFind = SubResource( 2 )
anims/ObjectFindAll = SubResource( 1 )
anims/ObjectFind = SubResource( 1 )
anims/ObjectFindAll = SubResource( 2 )
+40 -8
View File
@@ -2,14 +2,46 @@ extends Node
func initialize():
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")
var db_id = database_manager.load_database(save_database_in())
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)
check_invalid_type(db_id)
check_invalid_version(db_id)
return database_manager.get_db_by_id(db_id)
func check_invalid_type(db_id):
if db_id == gddb_types.e_db_invalid_file:
print("[Database#check_invalid_type] Error invalid database file !")
OS.set_exit_code(1)
func check_invalid_version(db_id):
if db_id == gddb_types.e_db_invalid_ver:
print("[Database#check_invalid_version] Error invalid database version !")
OS.set_exit_code(1)
func save_database_in():
if OS.get_name() == "Android":
copy_database()
return android_path()
else:
return normal_path()
func android_path():
return "user://database.json"
func normal_path():
return "res://db/ahog.json"
func copy_database():
var database_copy = File.new()
if !database_copy.file_exists(android_path()):
var database_file = File.new()
database_file.open(normal_path(), File.READ)
database_copy.open(android_path(), File.WRITE)
database_copy.store_string(database_file.get_as_text())
database_copy.close()
database_file.close()