remove migration system

This commit is contained in:
Nitwel 2024-01-23 11:25:54 +01:00
parent 7c5f549462
commit 83ee764b45
3 changed files with 9 additions and 68 deletions

View File

@ -42,7 +42,7 @@ transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0,
shape = SubResource("CapsuleShape3D_dopke")
[node name="ThumbTip" type="BoneAttachment3D" parent="XRHandLeft"]
transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928488, 0.0498668, 0.0560917, -0.112777)
transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928487, 0.0498668, 0.0560917, -0.112777)
bone_name = "Thumb_Tip_L"
bone_idx = 4
use_external_skeleton = true
@ -52,7 +52,7 @@ external_skeleton = NodePath("../left_hand/Armature_001/Skeleton3D")
gizmo_extents = 0.02
[node name="MiddleTip" type="BoneAttachment3D" parent="XRHandLeft"]
transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996577, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653568, 0.032112, 0.00654224, -0.171612)
transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996576, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653567, 0.032112, 0.00654224, -0.171612)
bone_name = "Middle_Tip_L"
bone_idx = 14
use_external_skeleton = true
@ -94,7 +94,7 @@ hand_skeleton = NodePath("right_hand/Armature/Skeleton3D")
transform = Transform3D(1, 0, 4.7579e-13, 0, 1, 0, -1.34149e-12, 1.77636e-15, 1, 0, 0, 0)
[node name="IndexTip" type="BoneAttachment3D" parent="XRHandRight"]
transform = Transform3D(0.19221, 0.669966, 0.717079, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345977, -0.164767, -0.0355401)
transform = Transform3D(0.19221, 0.669966, 0.717078, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345978, -0.164767, -0.0355401)
bone_name = "Index_Tip_R"
bone_idx = 9
use_external_skeleton = true

View File

@ -28,13 +28,13 @@ func save():
var save_tree = _generate_save_tree(get_tree().root.get_node("Main"))
var json_text = JSON.stringify({
"version": "1.0.0",
"version": get_version(),
"tree": save_tree
})
save_file.store_line(json_text)
func load():
await clear()
await clear()
if HomeApi.has_connected() == false:
return
@ -49,17 +49,15 @@ func load():
var json_text = save_file.get_line()
var save_data = JSON.parse_string(json_text)
save_data = migrate(save_data)
if save_data == null:
save()
return
var save_tree = save_data["tree"]
if save_tree == null:
return
if save_tree.has("version") == false:
save()
return
if save_tree is Array:
for tree in save_tree:
_build_save_tree(tree)
@ -69,59 +67,6 @@ func load():
loaded.emit()
is_loaded = true
func migrate(data: Dictionary):
var migration_version = data["migration"]
var migrations = load_migrations()
if migration_version == null || migrations == {}:
return null
var migration_keys = migrations.keys().sort()
for key in migration_keys:
if is_migration_newer(migration_version, key):
var migration = migrations[key]
data = migration.migrate(data)
data["migration"] = key
return data
func is_migration_newer(version, new_version):
var version_split = version.split(".")
var new_version_split = new_version.split(".")
for i in range(0, 3):
if int(version_split[i]) > int(new_version_split[i]):
return false
elif int(version_split[i]) < int(new_version_split[i]):
return true
return false
func load_migrations():
var migrations = {}
var migrations_dir := DirAccess.open("res://lib/migrations")
if migrations == null:
return {}
migrations_dir.list_dir_begin()
var file_name = migrations_dir.get_next()
while file_name != "":
if file_name.ends_with(".gd"):
var version = file_name.substr(0, -3)
migrations[version] = load("res://lib/migrations/%s" % file_name)
file_name = migrations_dir.get_next()
migrations_dir.list_dir_end()
return migrations
func get_version():
var config_error = export_config.load(export_config_path)

View File

@ -1,4 +0,0 @@
extends Object
static func migrate(data: Dictionary):
return data