@@ -14,6 +14,8 @@ var folder_size : int = -1
14
14
15
15
var game_datas := {}
16
16
17
+ var known_systems : Array [String ] = []
18
+
17
19
const ES_MEDIA_NAMES := [
18
20
"3dboxes" , "marquees" , "screenshots" ,
19
21
"titlescreens" , "videos"
@@ -164,6 +166,19 @@ func inspect_theme_xml(path: String) -> int:
164
166
# to copy previous data and, therefore, not affect the other game library
165
167
# platform. This will be run in a thread, so avoid any unsafe-thread API
166
168
func begin_import (copy : bool ):
169
+ # We don't have information on systems yet, so workaround and load system.json to get it
170
+ # Our systems names come from ES, so we can use them directly
171
+ var _raw_systems = JSONUtils .load_json_file (RetroHubConfig ._get_systems_file ())
172
+ if not _raw_systems is Array :
173
+ push_error ("Failed loading system.json" )
174
+ return
175
+ for system in _raw_systems :
176
+ if system .has ("name" ):
177
+ known_systems .append (system ["name" ])
178
+ else :
179
+ push_error ("Failed loading system.json" )
180
+ return
181
+
167
182
reset_major (4 )
168
183
progress_major ("Importing configuration" )
169
184
import_config ()
@@ -210,6 +225,7 @@ func import_metadata():
210
225
next_folder = dir .get_next ()
211
226
reset_minor (total_games )
212
227
for system in gamelists .keys ():
228
+ if not system in known_systems : continue
213
229
var base_path := RetroHubConfig ._get_gamelists_dir ().path_join (system as String )
214
230
FileUtils .ensure_path (base_path )
215
231
var data = gamelists [system ]
@@ -253,8 +269,6 @@ func process_metadata(system: String, dict: Dictionary):
253
269
if dict .has ("favorite" ):
254
270
game_data .favorite = bool (dict ["favorite" ])
255
271
var short_path := system .path_join (game_data .path .get_file ().get_basename ())
256
- if (RetroHubConfig .systems .has (system )):
257
- game_data .system = RetroHubConfig .systems [system ]
258
272
game_data .system_path = system
259
273
game_datas [short_path ] = game_data
260
274
@@ -313,9 +327,10 @@ func save_game_data():
313
327
reset_minor (game_datas .size ())
314
328
for game_data in game_datas .values ():
315
329
progress_minor ("Saving \" %s \" metadata" % game_data .name )
316
- if not RetroHubConfig ._save_game_data (game_data ):
330
+ if not RetroHubConfig ._save_game_data (game_data , game_data . system_path , false ):
317
331
push_error ("Failed to save game data for \" %s \" " % game_data .name )
318
332
319
333
320
334
func cleanup ():
321
335
game_datas .clear ()
336
+ known_systems .clear ()
0 commit comments