Skip to content

Commit 7057843

Browse files
authored
Allow live loading of library so UI updates as library is loaded (#9)
1 parent 4edc806 commit 7057843

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

core/library_steam.gd

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ func _load_library(
159159
var items := [] as Array[LibraryLaunchItem]
160160
for i in json_items:
161161
var item: Dictionary = i
162+
var launch_item := LibraryLaunchItem.from_dict(item)
162163
items.append(LibraryLaunchItem.from_dict(item))
164+
launch_item_added.emit(launch_item)
163165
return items
164166

165167
# Wait for the steam client if it's not ready
@@ -175,21 +177,29 @@ func _load_library(
175177

176178
# Get all available apps
177179
var app_ids: PackedInt64Array = await get_available_apps()
178-
var app_info: Dictionary = await get_apps_info(app_ids)
180+
181+
# Get installed apps
179182
var apps_installed: Array = await steam.get_installed_apps()
180183
var app_ids_installed := PackedStringArray()
181184
for app in apps_installed:
182185
app_ids_installed.append(app["id"])
183186

184-
# Generate launch items for each game
187+
# Get the app info for each discovered game and create a launch item for
188+
# it.
185189
var items := [] as Array[LibraryLaunchItem]
186-
for app_id in app_info.keys():
187-
var info := app_info[app_id] as Dictionary
188-
var item := _app_info_to_launch_item(info, app_id in app_ids_installed)
190+
for app_id in app_ids:
191+
var id := str(app_id)
192+
var info := await get_app_info(id, caching_flags)
193+
194+
if not id in info:
195+
continue
196+
197+
var item := _app_info_to_launch_item(info, str(app_id) in app_ids_installed)
189198
if not item:
190-
logger.debug("Unable to create launch item for: " + app_id)
199+
logger.debug("Unable to create launch item for: " + str(app_id))
191200
continue
192201
items.append(item)
202+
launch_item_added.emit(item)
193203

194204
# Cache the discovered apps
195205
if caching_flags & Cache.FLAGS.SAVE:

0 commit comments

Comments
 (0)