@@ -7,7 +7,6 @@ signal advance_section
7
7
@onready var n_emulator_info_tab := % EmulatorInfoTab
8
8
9
9
var icon_cache := {}
10
- var emulator_cache := {}
11
10
12
11
func _ready ():
13
12
n_systems .get_popup ().max_size .y = RetroHubUI .max_popupmenu_height + 50
@@ -39,7 +38,6 @@ func set_systems():
39
38
else :
40
39
n_systems .add_icon_item (preload ("res://assets/icons/failure.svg" ), system ["fullname" ])
41
40
n_systems .set_item_metadata (n_systems .get_item_count ()- 1 , false )
42
- emulator_cache .clear ()
43
41
44
42
func handle_emulator_info (system_raw : Dictionary ) -> bool :
45
43
var system_emulators : Array = system_raw ["emulator" ]
@@ -52,38 +50,18 @@ func handle_emulator_info(system_raw: Dictionary) -> bool:
52
50
var emulator : Dictionary = emulators ["retroarch" ]
53
51
parent .add_child (retroarch_info )
54
52
55
- if not emulator_cache .has ("retroarch" ):
56
- emulator_cache ["retroarch" ] = {}
57
-
58
53
# Test for binpath first
59
- var binpaths
60
- if emulator_cache ["retroarch" ].has ("binpaths" ):
61
- binpaths = emulator_cache ["retroarch" ]["binpaths" ]
62
- else :
63
- binpaths = emulator ["binpath" ]
64
- emulator_cache ["retroarch" ]["binpaths" ] = binpaths
65
- var binpath : String
66
- if emulator_cache ["retroarch" ].has ("binpath" ):
67
- binpath = emulator_cache ["retroarch" ]["binpath" ]
68
- else :
69
- binpath = FileUtils .test_for_valid_path (binpaths )
70
- emulator_cache ["retroarch" ]["binpath" ] = binpath
54
+ var binpath := RetroHubRetroArchEmulator .find_path (emulator , "binpath" , {})
71
55
if not binpath .is_empty ():
72
56
retroarch_info .set_path_found (true , binpath )
73
57
# Then test for cores
74
58
var required_cores : Array = system_emulator ["retroarch" ]
75
- var corespath : String
76
- if emulator_cache ["retroarch" ].has ("corespath" ):
77
- corespath = emulator_cache ["retroarch" ]["corespath" ]
78
- else :
79
- corespath = RetroHubRetroArchEmulator .get_custom_core_path ()
80
- if corespath .is_empty ():
81
- corespath = JSONUtils .format_string_with_substitutes (FileUtils .test_for_valid_path (emulator ["corepath" ]) , {"binpath" : binpath })
82
- if corespath .is_empty ():
83
- retroarch_info .set_core_found (false , "Could not find any cores inside:\n " + convert_list_to_string (emulator ["corepath" ]))
84
- emulator_cache ["retroarch" ]["corespath" ] = corespath
85
- continue
86
- emulator_cache ["retroarch" ]["corespath" ] = corespath
59
+ var corespath := RetroHubRetroArchEmulator .get_custom_core_path ()
60
+ if corespath .is_empty ():
61
+ corespath = JSONUtils .format_string_with_substitutes (FileUtils .test_for_valid_path (emulator ["corepath" ]) , {"binpath" : binpath })
62
+ if corespath .is_empty ():
63
+ retroarch_info .set_core_found (false , "Could not find any cores inside:\n " + convert_list_to_string (emulator ["corepath" ]))
64
+ continue
87
65
var cores : Array = emulator ["cores" ]
88
66
var avail_cores := []
89
67
for req_core in required_cores :
@@ -94,9 +72,12 @@ func handle_emulator_info(system_raw: Dictionary) -> bool:
94
72
retroarch_info .set_core_found (false , "No default config for cores:\n " + convert_list_to_string (required_cores ))
95
73
continue
96
74
var corepaths := []
75
+ var corepath := ""
97
76
for core in avail_cores :
77
+ corepath = RetroHubRetroArchEmulator .find_core_path (core ["name" ], emulator , corespath )
78
+ if not corepath .is_empty ():
79
+ break
98
80
corepaths .push_back (corespath .path_join (core ["file" ]))
99
- var corepath := FileUtils .test_for_valid_path (corepaths )
100
81
if not corepath .is_empty ():
101
82
for core in avail_cores :
102
83
if core ["file" ] == corepath .get_file ():
@@ -106,7 +87,7 @@ func handle_emulator_info(system_raw: Dictionary) -> bool:
106
87
retroarch_info .set_core_found (false , convert_list_to_string (corepaths ))
107
88
continue
108
89
else :
109
- retroarch_info .set_path_found (false , convert_list_to_string (binpaths ))
90
+ retroarch_info .set_path_found (false , convert_list_to_string (emulator [ "binpath" ] ))
110
91
continue
111
92
112
93
elif emulators .has (system_emulator ):
@@ -115,36 +96,19 @@ func handle_emulator_info(system_raw: Dictionary) -> bool:
115
96
var emulator : Dictionary = emulators [system_emulator ]
116
97
parent .add_child (generic_info )
117
98
118
- if not emulator_cache .has (emulator ["name" ]):
119
- emulator_cache [emulator ["name" ]] = {}
120
-
121
99
generic_info .set_name (emulator ["fullname" ])
122
100
if not icon_cache .has (system_emulator ):
123
101
icon_cache [system_emulator ] = load ("res://assets/emulators/%s .png" % system_emulator )
124
102
generic_info .set_logo (icon_cache [system_emulator ])
125
103
126
104
# Test for binpath first
127
- var binpaths
128
- if emulator_cache [emulator ["name" ]].has ("binpaths" ):
129
- binpaths = emulator_cache [emulator ["name" ]]["binpaths" ]
130
- else :
131
- binpaths = emulator ["binpath" ]
132
- emulator_cache [emulator ["name" ]]["binpaths" ] = binpaths
133
- var binpath : String
134
- if emulator_cache [emulator ["name" ]].has ("binpath" ):
135
- binpath = emulator_cache [emulator ["name" ]]["binpath" ]
136
- else :
137
- binpath = FileUtils .test_for_valid_path (binpaths )
138
- emulator_cache [emulator ["name" ]]["binpath" ] = binpath
105
+ var binpath := RetroHubGenericEmulator .find_path (emulator , "binpath" , {})
139
106
if not binpath .is_empty ():
140
107
found = true
141
108
generic_info .set_found (true , binpath )
142
109
continue
143
- elif binpaths is Array :
144
- generic_info .set_found (false , convert_list_to_string (binpaths ))
145
- continue
146
110
else :
147
- generic_info .set_found (false , binpaths )
111
+ generic_info .set_found (false , convert_list_to_string ( emulator [ "binpath" ]) )
148
112
continue
149
113
return found
150
114
0 commit comments