LibraryManager
Inherits: Resource
Unified interface to manage games from multiple sources
Description
The LibraryManager is responsible for managing any number of Library providers and offers a unified interface to manage games from multiple sources. New game library sources can be created in the core code base or in plugins by implementing/extending the Library class and registering the provider with the library manager.
With registered library providers, other systems can request library items from the LibraryManager, and it will use all available sources to return a unified library item:
const LibraryManager := preload("res://core/global/library_manager.tres")
...
# Return a dictionary of all installed games from every library provider
var installed_games := LibraryManager.get_installed()
Games in the LibraryManager are stored as LibraryItem resources, which contains information about each game. Each LibraryItem has a list of LibraryLaunchItems which contains the data for how to launch that game through a specific Library provider.
Properties
| Type | Name | Default |
|---|---|---|
| SettingsManager | settings_manager | |
| CustomLogger | logger |
Methods
| Returns | Signature |
|---|---|
| LibraryItem[] | get_library_items(modifiers: Callable[] = [...]) |
| LibraryItem[] | sort_by_name(apps: LibraryItem[]) |
| LibraryItem[] | filter_installed(apps: LibraryItem[]) |
| LibraryItem[] | filter_by_library(apps: LibraryItem[], library_id: String) |
| LibraryItem[] | filter_by_hidden(apps: LibraryItem[]) |
| Dictionary | get_available() |
| void | reload_library() |
| void | add_library_launch_item(library_id: String, item: LibraryLaunchItem) |
| void | remove_library_launch_item(library_id: String, name: String) |
| void | load_library(library_id: String) |
| bool | has_app(name: String) |
| LibraryItem | get_app_by_name(name: String) |
| bool | has_library(id: String) |
| Library | get_library_by_id(id: String) |
| Library[] | get_libraries() |
| void | register_library(library: Library) |
| void | unregister_library(library: Library) |
Property Descriptions
settings_manager
SettingsManager settings_manager
Note
There is currently no description for this property. Please help us by contributing one!
logger
CustomLogger logger
Note
There is currently no description for this property. Please help us by contributing one!
Method Descriptions
get_library_items()
LibraryItem[] get_library_items(modifiers: Callable[] = [...])
Returns library items based on the given modifiers. A modifier is a Callable that takes an array of LibraryItem objects and returns an array of those items that may be sorted or filtered out.
const LibraryManager := preload("res://core/global/library_manager.tres")
...
var filter := func(apps: Array[LibraryItem]) -> Array[LibraryItem]:
return apps.filter(func(item: LibraryItem): not item.is_installed())
# Return non-installed games
var not_installed := LibraryManager.get_library_items([filter])
sort_by_name()
LibraryItem[] sort_by_name(apps: LibraryItem[])
Sorts the given array of apps by name
filter_installed()
LibraryItem[] filter_installed(apps: LibraryItem[])
Filters the given array of apps by installed status
filter_by_library()
LibraryItem[] filter_by_library(apps: LibraryItem[], library_id: String)
Filter the given array of apps by library provider
filter_by_hidden()
LibraryItem[] filter_by_hidden(apps: LibraryItem[])
Filters the given array of apps by hidden
get_available()
Dictionary get_available()
Returns an dictionary of all available apps
reload_library()
void reload_library()
Loads all library items from each provider and sorts them. This can take a while, so should be called asyncronously
add_library_launch_item()
void add_library_launch_item(library_id: String, item: LibraryLaunchItem)
Add the given library launch item to the list of available apps.
remove_library_launch_item()
void remove_library_launch_item(library_id: String, name: String)
Remove the given library launch item from the list of available apps.
load_library()
void load_library(library_id: String)
Loads the launch items from the given library
has_app()
Returns true if the app with the given name exists in the library.
get_app_by_name()
LibraryItem get_app_by_name(name: String)
Returns the library item for the given app for all library providers
has_library()
Returns true if the library with the given id is registered
get_library_by_id()
Library get_library_by_id(id: String)
Returns the given library implementation by id
get_libraries()
Library[] get_libraries()
Returns a list of all registered libraries
register_library()
void register_library(library: Library)
Registers the given library with the library manager.
unregister_library()
void unregister_library(library: Library)
Unregisters the given library with the library manager