@@ -43,8 +43,8 @@ func load_manifest() -> void:
43
43
ModLoaderUtils .log_info ("Loading mod_manifest (manifest.json) for -> %s " % dir_name , LOG_NAME )
44
44
45
45
# Load meta data file
46
- var manifest_path = get_required_mod_file_path (required_mod_files .MANIFEST )
47
- var manifest_dict = _get_json_as_dict (manifest_path ) # todo get from utils
46
+ var manifest_path : = get_required_mod_file_path (required_mod_files .MANIFEST )
47
+ var manifest_dict := ModLoaderUtils . get_json_as_dict (manifest_path )
48
48
49
49
ModLoaderUtils .log_info ("%s loaded manifest data -> %s " % [dir_name , manifest_dict ], LOG_NAME )
50
50
@@ -59,8 +59,8 @@ func load_manifest() -> void:
59
59
60
60
## Validates if [member dir_name] matches [method ModManifest.get_mod_id]
61
61
func is_mod_dir_name_same_as_id () -> bool :
62
- var manifest_id = manifest .get_mod_id ()
63
- if dir_name ! = manifest_id :
62
+ var manifest_id : = manifest .get_mod_id ()
63
+ if not dir_name = = manifest_id :
64
64
ModLoaderUtils .log_fatal ('Mod directory name "%s " does not match the data in manifest.json. Expected "%s "' % [ dir_name , manifest_id ], LOG_NAME )
65
65
is_loadable = false
66
66
return false
@@ -69,10 +69,10 @@ func is_mod_dir_name_same_as_id() -> bool:
69
69
70
70
## Confirms that all files from [member required_mod_files] exist
71
71
func has_required_files () -> bool :
72
- var file_check = File .new ()
72
+ var file_check : = File .new ()
73
73
74
74
for required_file in required_mod_files :
75
- var file_path = get_required_mod_file_path (required_mod_files [required_file ])
75
+ var file_path : = get_required_mod_file_path (required_mod_files [required_file ])
76
76
77
77
if ! file_check .file_exists (file_path ):
78
78
ModLoaderUtils .log_fatal ("ERROR - %s is missing a required file: %s " % [dir_name , file_path ], LOG_NAME )
@@ -95,25 +95,6 @@ func get_required_mod_file_path(required_file: int) -> String:
95
95
return ""
96
96
97
97
98
- ## Parses JSON from a given file path and returns a dictionary.
99
- ## Returns an empty dictionary if no file exists (check with size() < 1)
100
- static func _get_json_as_dict (path :String ) -> Dictionary : # todo move to utils
101
- var file = File .new ()
102
-
103
- if ! file .file_exists (path ):
104
- file .close ()
105
- return {}
106
-
107
- file .open (path , File .READ )
108
- var content = file .get_as_text ()
109
-
110
- var parsed := JSON .parse (content )
111
- if parsed .error :
112
- # log error
113
- return {}
114
- return parsed .result
115
-
116
-
117
98
# func _to_string() -> String:
118
99
# todo if we want it pretty printed
119
100
0 commit comments