game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
SteamGridDBService Class Reference

Service for fetching game images from SteamGridDB. More...

#include <steamgriddb_service.h>

Static Public Member Functions

static void clearCache ()
 Clear all cached images.
static std::string downloadBestCover (const std::string &gameName)
 Download best cover art for a game by name.
static void downloadBestCoverAsync (const std::string &gameName, const std::function< void(const std::string &)> &callback)
 Download best cover art asynchronously.
static std::string downloadImage (const SteamGridDBImage &image, const std::string &gameName)
 Download an image to local cache.
static SteamGridDBImageSet getAllImages (int gameId)
 Get all images for a game.
static std::string getCachedCover (const std::string &gameName)
 Check if we have a cached cover for a game.
static std::string getCacheDirectory ()
 Get the cache directory for downloaded images.
static size_t getCacheSize ()
 Get total size of cached images in bytes.
static SteamGridDBGame getGameBySteamAppId (int steamAppId)
 Get game info by Steam App ID.
static std::vector< SteamGridDBImage > getGridImages (int gameId)
 Get grid/cover images for a game.
static std::vector< SteamGridDBImage > getHeroImages (int gameId)
 Get hero images for a game.
static std::vector< SteamGridDBImage > getIconImages (int gameId)
 Get icon images for a game.
static std::vector< SteamGridDBImage > getLogoImages (int gameId)
 Get logo images for a game.
static bool hasApiKey ()
 Check if API key is configured.
static std::vector< SteamGridDBGame > searchGames (const std::string &query)
 Search for games by name.
static void searchGamesAsync (const std::string &query, const std::function< void(const std::vector< SteamGridDBGame > &)> &callback)
 Search for games by name asynchronously.
static void setApiKey (const std::string &key)
 Set the API key for SteamGridDB.

Detailed Description

Service for fetching game images from SteamGridDB.

Provides methods to search for games and fetch images from SteamGridDB. Requires an API key for full functionality.

Usage Example

// Set API key (from user settings)
SteamGridDBService::setApiKey("your-api-key-here");
// Search for a game
auto games = SteamGridDBService::searchGames("World of Warcraft");
if (!games.empty()) {
// Fetch cover art
auto images = SteamGridDBService::getGridImages(games[0].id);
if (!images.empty()) {
// Download the best cover
std::string localPath = SteamGridDBService::downloadImage(
images[0], "World of Warcraft");
}
}
static std::vector< SteamGridDBGame > searchGames(const std::string &query)
Search for games by name.
static std::string downloadImage(const SteamGridDBImage &image, const std::string &gameName)
Download an image to local cache.
static std::vector< SteamGridDBImage > getGridImages(int gameId)
Get grid/cover images for a game.
static void setApiKey(const std::string &key)
Set the API key for SteamGridDB.

Definition at line 109 of file steamgriddb_service.h.

Member Function Documentation

◆ clearCache()

void SteamGridDBService::clearCache ( )
static

Clear all cached images.

Definition at line 838 of file steamgriddb_service.cpp.

References getCacheDirectory(), Logger::info(), and Logger::warn().

◆ downloadBestCover()

std::string SteamGridDBService::downloadBestCover ( const std::string & gameName)
static

Download best cover art for a game by name.

Parameters
gameNameName of the game to search for
Returns
Local path to downloaded cover, or empty if not found

This is a convenience method that searches for the game, finds the best rated cover, and downloads it.

Definition at line 718 of file steamgriddb_service.cpp.

References Logger::debug(), downloadImage(), getCachedCover(), getGridImages(), SteamGridDBGame::id, Logger::info(), SteamGridDBGame::name, searchGames(), and Logger::warn().

Referenced by downloadBestCoverAsync().

◆ downloadBestCoverAsync()

void SteamGridDBService::downloadBestCoverAsync ( const std::string & gameName,
const std::function< void(const std::string &)> & callback )
static

Download best cover art asynchronously.

Parameters
gameNameName of the game
callbackFunction to call with local path (empty on failure)

Definition at line 786 of file steamgriddb_service.cpp.

References downloadBestCover().

◆ downloadImage()

std::string SteamGridDBService::downloadImage ( const SteamGridDBImage & image,
const std::string & gameName )
static

Download an image to local cache.

Parameters
imageImage to download
gameNameGame name (used for filename)
Returns
Local path to downloaded image, or empty on failure

Definition at line 685 of file steamgriddb_service.cpp.

References Logger::debug(), getCacheDirectory(), SteamGridDBImage::id, Logger::info(), SteamGridDBImage::mime, and SteamGridDBImage::url.

Referenced by SteamGridDBSearchWorker::doDownloadImage(), and downloadBestCover().

◆ getAllImages()

SteamGridDBImageSet SteamGridDBService::getAllImages ( int gameId)
static

Get all images for a game.

Parameters
gameIdSteamGridDB game ID
Returns
Complete image set

Definition at line 661 of file steamgriddb_service.cpp.

References getGridImages(), getHeroImages(), getIconImages(), getLogoImages(), SteamGridDBImageSet::grids, SteamGridDBImageSet::heroes, SteamGridDBImageSet::icons, Logger::info(), and SteamGridDBImageSet::logos.

◆ getCachedCover()

std::string SteamGridDBService::getCachedCover ( const std::string & gameName)
static

Check if we have a cached cover for a game.

Parameters
gameNameGame name
Returns
Path to cached cover, or empty if not cached

Definition at line 801 of file steamgriddb_service.cpp.

References getCacheDirectory().

Referenced by downloadBestCover().

◆ getCacheDirectory()

std::string SteamGridDBService::getCacheDirectory ( )
static

Get the cache directory for downloaded images.

Returns
Path to cache directory

Definition at line 74 of file steamgriddb_service.cpp.

References Logger::warn().

Referenced by clearCache(), downloadImage(), getCachedCover(), and getCacheSize().

◆ getCacheSize()

size_t SteamGridDBService::getCacheSize ( )
static

Get total size of cached images in bytes.

Definition at line 861 of file steamgriddb_service.cpp.

References getCacheDirectory().

◆ getGameBySteamAppId()

SteamGridDBGame SteamGridDBService::getGameBySteamAppId ( int steamAppId)
static

Get game info by Steam App ID.

Parameters
steamAppIdSteam App ID
Returns
Game info if found

Definition at line 543 of file steamgriddb_service.cpp.

References Logger::info().

◆ getGridImages()

std::vector< SteamGridDBImage > SteamGridDBService::getGridImages ( int gameId)
static

Get grid/cover images for a game.

Parameters
gameIdSteamGridDB game ID
Returns
Vector of available grid images

Definition at line 580 of file steamgriddb_service.cpp.

Referenced by SteamGridDBSearchWorker::doLoadImages(), downloadBestCover(), and getAllImages().

◆ getHeroImages()

std::vector< SteamGridDBImage > SteamGridDBService::getHeroImages ( int gameId)
static

Get hero images for a game.

Parameters
gameIdSteamGridDB game ID
Returns
Vector of available hero images

Definition at line 601 of file steamgriddb_service.cpp.

Referenced by SteamGridDBSearchWorker::doLoadImages(), and getAllImages().

◆ getIconImages()

std::vector< SteamGridDBImage > SteamGridDBService::getIconImages ( int gameId)
static

Get icon images for a game.

Parameters
gameIdSteamGridDB game ID
Returns
Vector of available icon images

Definition at line 641 of file steamgriddb_service.cpp.

Referenced by SteamGridDBSearchWorker::doLoadImages(), and getAllImages().

◆ getLogoImages()

std::vector< SteamGridDBImage > SteamGridDBService::getLogoImages ( int gameId)
static

Get logo images for a game.

Parameters
gameIdSteamGridDB game ID
Returns
Vector of available logo images

Definition at line 621 of file steamgriddb_service.cpp.

Referenced by SteamGridDBSearchWorker::doLoadImages(), and getAllImages().

◆ hasApiKey()

bool SteamGridDBService::hasApiKey ( )
static

Check if API key is configured.

Returns
True if API key is set

Definition at line 68 of file steamgriddb_service.cpp.

Referenced by SteamGridDBSelectorDialog::SteamGridDBSelectorDialog().

◆ searchGames()

std::vector< SteamGridDBGame > SteamGridDBService::searchGames ( const std::string & query)
static

Search for games by name.

Parameters
querySearch query (game name)
Returns
Vector of matching games

Definition at line 498 of file steamgriddb_service.cpp.

References Logger::info(), and Logger::warn().

Referenced by SteamGridDBSearchWorker::doSearch(), downloadBestCover(), and searchGamesAsync().

◆ searchGamesAsync()

void SteamGridDBService::searchGamesAsync ( const std::string & query,
const std::function< void(const std::vector< SteamGridDBGame > &)> & callback )
static

Search for games by name asynchronously.

Parameters
querySearch query
callbackFunction to call with results

Definition at line 528 of file steamgriddb_service.cpp.

References searchGames().

◆ setApiKey()

void SteamGridDBService::setApiKey ( const std::string & key)
static

Set the API key for SteamGridDB.

Parameters
keyAPI key from steamgriddb.com

Without an API key, only limited public endpoints are available.

Definition at line 61 of file steamgriddb_service.cpp.

References Logger::info().


The documentation for this class was generated from the following files: