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

Scans Steam installations to discover games. More...

#include <steam_integration.h>

Classes

struct  SteamPlaytimeData
 Steam playtime and usage statistics from localconfig.vdf. More...

Public Member Functions

 SteamLibraryScanner ()
 Constructor - auto-detects Steam installation.
std::vector< std::filesystem::path > getLibraryPaths () const
 Get list of detected Steam library paths.
bool isSteamInstalled () const
 Check if Steam is installed on this system.
std::vector< SteamGame > scanAllLibraries ()
 Scan all Steam libraries for installed games.
std::vector< SteamGame > scanAllOwnedGames ()
 Scan for all owned Steam games (installed and not installed).

Static Public Member Functions

static std::string fetchGameNameFromCache (uint32_t appId)
 Get game name from pre-loaded cache (instant).
static std::string fetchGameNameFromSteamAPI (uint32_t appId)
 Fetch game name from Steam Web API.
static bool fetchSteamMetadata (uint32_t appId, std::string &outName, std::string &outType, std::vector< std::string > &outGenres, std::vector< std::string > &outCategories)
 Fetch all Steam metadata in a single API call (OPTIMIZED).
static bool fetchSteamMetadata (uint32_t appId, std::string &outType, std::vector< std::string > &outGenres, std::vector< std::string > &outCategories)
 Fetch enhanced metadata from Steam Web API (type, genres, categories).
static bool forceUninstallGame (uint32_t appId)
 Force uninstall a Steam game by directly removing files.
static bool getGameInstallInfo (uint32_t appId, std::string &installDir, std::filesystem::path &libraryPath)
 Get installation info for a Steam game.
static bool isAppNameCacheLoaded ()
 Check if app name cache is loaded.
static bool isSteamRunning ()
 Check if Steam is currently running.
static bool loadAppNameCache ()
 Load Steam app name cache from GetAppList API.
static std::string normalizeProtonName (const std::string &display)
 Strip launcher-side display annotations from a Proton name.
static void populateDirectLaunchInfo (SteamGame &game)
 Populate a SteamGame with direct-launch information.
static std::map< uint32_t, CloudSaveInfo > readAllCloudSaveInfo ()
 Read all cloud save info for all games at once (batch operation).
static std::map< uint32_t, std::vector< std::string > > readAllUserCategories ()
 Read all user categories for all games at once (batch operation).
static std::vector< DLCInfo > readDLCFromACF (const std::filesystem::path &acfFilePath, const std::filesystem::path &libraryPath)
 Read DLC information from appmanifest ACF file.
static CloudSaveInfo readSteamCloudSaveInfo (uint32_t appId)
 Read Steam Cloud save information for a game from localconfig.vdf.
static std::string readSteamLaunchOptions (uint32_t appId)
 Read Steam launch options for a game from localconfig.vdf.
static std::map< uint32_t, SteamPlaytimeData > readSteamPlaytimeData ()
 Read Steam playtime statistics for all games from localconfig.vdf.
static std::string readSteamProtonVersion (uint32_t appId)
 Read Proton compatibility tool mapping for a game from config.vdf.
static std::vector< std::string > readSteamUserCategories (uint32_t appId)
 Read user-defined categories (tags) for a game from localconfig.vdf.
static bool requestUninstallGame (uint32_t appId)
 Request Steam to uninstall a game via steam:// protocol.
static std::filesystem::path resolveProtonPath (uint32_t appId, std::string &outCompatToolName)
 Resolve Proton executable path for a game.
static bool restartSteam ()
 Attempt to gracefully restart Steam (blocking).
static std::future< bool > restartSteamAsync ()
 Attempt to gracefully restart Steam asynchronously.
static std::vector< std::pair< std::string, std::filesystem::path > > scanProtonVersions ()
 Scan for all installed Proton versions.
static bool writeSteamLaunchOptions (uint32_t appId, const std::string &launchOptions)
 Write Steam launch options for a game to localconfig.vdf.
static bool writeSteamProtonVersion (uint32_t appId, const std::string &protonName)
 Write Proton compatibility tool mapping for a game to config.vdf.

Detailed Description

Scans Steam installations to discover games.

Detects Steam library folders and parses all appmanifest files to build a list of installed games.

Definition at line 376 of file steam_integration.h.

Constructor & Destructor Documentation

◆ SteamLibraryScanner()

SteamLibraryScanner::SteamLibraryScanner ( )

Constructor - auto-detects Steam installation.

Definition at line 1039 of file steam_integration.cpp.

Referenced by getGameInstallInfo().

Member Function Documentation

◆ fetchGameNameFromCache()

std::string SteamLibraryScanner::fetchGameNameFromCache ( uint32_t appId)
static

Get game name from pre-loaded cache (instant).

Parameters
appIdSteam App ID
Returns
Game name if in cache, empty string otherwise

Definition at line 2605 of file steam_integration.cpp.

References s_appNameCache, and s_appNameCacheMutex.

Referenced by fetchGameNameFromSteamAPI(), and scanAllOwnedGames().

◆ fetchGameNameFromSteamAPI()

std::string SteamLibraryScanner::fetchGameNameFromSteamAPI ( uint32_t appId)
static

Fetch game name from Steam Web API.

Parameters
appIdSteam App ID
Returns
Game name if found, empty string otherwise

Definition at line 2627 of file steam_integration.cpp.

References Logger::debug(), Logger::error(), fetchGameNameFromCache(), PipeHandle::get(), Logger::info(), and Logger::warn().

◆ fetchSteamMetadata() [1/2]

bool SteamLibraryScanner::fetchSteamMetadata ( uint32_t appId,
std::string & outName,
std::string & outType,
std::vector< std::string > & outGenres,
std::vector< std::string > & outCategories )
static

Fetch all Steam metadata in a single API call (OPTIMIZED).

Fetches name, type, genres, and categories in one network request. Use this instead of separate fetchGameNameFromSteamAPI + fetchSteamMetadata calls.

Parameters
appIdSteam App ID
outNameOutput for game name
outTypeOutput for app type (game/dlc/demo/tool/etc)
outGenresOutput for genres list
outCategoriesOutput for categories list
Returns
true if metadata was successfully fetched

Definition at line 2737 of file steam_integration.cpp.

References PipeHandle::get(), and Logger::warn().

◆ fetchSteamMetadata() [2/2]

bool SteamLibraryScanner::fetchSteamMetadata ( uint32_t appId,
std::string & outType,
std::vector< std::string > & outGenres,
std::vector< std::string > & outCategories )
static

Fetch enhanced metadata from Steam Web API (type, genres, categories).

Parameters
appIdSteam App ID
outTypeOutput for app type (game/dlc/demo/tool/etc)
outGenresOutput for genres list
outCategoriesOutput for categories list
Returns
true if metadata was successfully fetched

Definition at line 2729 of file steam_integration.cpp.

References fetchSteamMetadata().

Referenced by fetchSteamMetadata().

◆ forceUninstallGame()

bool SteamLibraryScanner::forceUninstallGame ( uint32_t appId)
static

Force uninstall a Steam game by directly removing files.

Parameters
appIdSteam App ID to uninstall
Returns
true if files were successfully removed

This bypasses Steam's confirmation dialog by:

  1. Removing the game directory from steamapps/common/
  2. Removing the Proton prefix from steamapps/compatdata/ (if exists)
  3. Removing the appmanifest_{appId}.acf file

Steam will detect the missing files on next refresh and update its state. Use requestUninstallGame() for the preferred Steam-native uninstall.

Definition at line 4439 of file steam_integration.cpp.

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

Referenced by ContextMenuManager::install().

◆ getGameInstallInfo()

bool SteamLibraryScanner::getGameInstallInfo ( uint32_t appId,
std::string & installDir,
std::filesystem::path & libraryPath )
static

Get installation info for a Steam game.

Parameters
appIdSteam App ID
[out]installDirGame installation directory name
[out]libraryPathLibrary path containing the game
Returns
true if game info was found

Definition at line 4347 of file steam_integration.cpp.

References SteamLibraryScanner(), getLibraryPaths(), and readVdfContent().

Referenced by forceUninstallGame().

◆ getLibraryPaths()

std::vector< std::filesystem::path > SteamLibraryScanner::getLibraryPaths ( ) const

Get list of detected Steam library paths.

Returns
Vector of library folder paths

Definition at line 1279 of file steam_integration.cpp.

Referenced by SteamDownloadMonitor::getDownloadingGames(), getGameInstallInfo(), SteamDownloadMonitor::readGameState(), and SteamUpdateMonitor::Impl::scanForUpdates().

◆ isAppNameCacheLoaded()

bool SteamLibraryScanner::isAppNameCacheLoaded ( )
static

Check if app name cache is loaded.

Definition at line 2617 of file steam_integration.cpp.

References s_appNameCacheLoaded, and s_appNameCacheMutex.

◆ isSteamInstalled()

bool SteamLibraryScanner::isSteamInstalled ( ) const

Check if Steam is installed on this system.

Returns
True if Steam installation detected

Definition at line 1284 of file steam_integration.cpp.

Referenced by GameImportDialog::GameImportDialog(), and SteamUpdateMonitor::Impl::scanForUpdates().

◆ isSteamRunning()

bool SteamLibraryScanner::isSteamRunning ( )
static

Check if Steam is currently running.

Returns
true if Steam process is detected

Definition at line 2872 of file steam_integration.cpp.

References ProcessExecutor::isProcessRunning().

Referenced by restartSteam().

◆ loadAppNameCache()

bool SteamLibraryScanner::loadAppNameCache ( )
static

Load Steam app name cache from GetAppList API.

Fetches the complete list of Steam app names in ONE request and caches it. Subsequent calls to fetchGameNameFromCache() will be instant.

Returns
true if cache was loaded successfully

Definition at line 2464 of file steam_integration.cpp.

References Logger::error(), PipeHandle::get(), SteamPaths::getPrimarySteamRoot(), Logger::info(), loadAppNamesFromLocalCache(), s_appNameCache, s_appNameCacheLoaded, s_appNameCacheMutex, and Logger::warn().

Referenced by MainWindow::MainWindow().

◆ normalizeProtonName()

std::string SteamLibraryScanner::normalizeProtonName ( const std::string & display)
static

Strip launcher-side display annotations from a Proton name.

Converts "proton-cachyos-slr (system)" -> "proton-cachyos-slr" so the value can be compared against / written to Steam's CompatToolMapping (which uses bare tool directory names). Returns empty string for Steam-managed sentinels ("Native Linux", "Proton (Steam-managed)", "Proton") — caller should treat empty as "leave Steam's mapping alone".

Definition at line 3517 of file steam_integration.cpp.

Referenced by writeSteamProtonVersion().

◆ populateDirectLaunchInfo()

void SteamLibraryScanner::populateDirectLaunchInfo ( SteamGame & game)
static

Populate a SteamGame with direct-launch information.

Reads appinfo.vdf to find the game executable and resolves the Proton path. This enables direct Proton launching instead of steam -applaunch.

Parameters
gameSteamGame to populate (modified in place)

Definition at line 3424 of file steam_integration.cpp.

References SteamGame::appId, SteamGame::compatToolName, SteamGame::gameArguments, SteamGame::gameExecutable, SteamPaths::getPrimarySteamRoot(), SteamGame::isProtonGame, SteamAppInfoParser::load(), SteamGame::protonPath, resolveProtonPath(), SteamGame::steamType, and Logger::warn().

◆ readAllCloudSaveInfo()

std::map< uint32_t, CloudSaveInfo > SteamLibraryScanner::readAllCloudSaveInfo ( )
static

Read all cloud save info for all games at once (batch operation).

Returns
Map of App ID to CloudSaveInfo

More efficient than calling readSteamCloudSaveInfo() for each game individually. Parses localconfig.vdf once and extracts all cloud save data.

Definition at line 4187 of file steam_integration.cpp.

References findVdfSectionEnd(), getActiveUserId(), SteamPaths::getPrimarySteamRoot(), readSteamCloudSaveInfo(), readVdfContent(), and CloudSaveInfo::supported.

Referenced by scanAllLibraries().

◆ readAllUserCategories()

std::map< uint32_t, std::vector< std::string > > SteamLibraryScanner::readAllUserCategories ( )
static

Read all user categories for all games at once (batch operation).

Returns
Map of App ID to vector of category names

More efficient than calling readSteamUserCategories() for each game individually.

Definition at line 4265 of file steam_integration.cpp.

References findVdfSectionEnd(), getActiveUserId(), SteamPaths::getPrimarySteamRoot(), readSteamUserCategories(), and readVdfContent().

Referenced by scanAllLibraries().

◆ readDLCFromACF()

std::vector< DLCInfo > SteamLibraryScanner::readDLCFromACF ( const std::filesystem::path & acfFilePath,
const std::filesystem::path & libraryPath )
static

Read DLC information from appmanifest ACF file.

Parameters
acfFilePathPath to appmanifest_*.acf file
libraryPathSteam library root path
Returns
Vector of DLC information

Parses InstalledDepots section to detect DLC: "InstalledDepots" -> "[DepotID]" -> "manifest", "size", etc.

Definition at line 4069 of file steam_integration.cpp.

References DLCInfo::appId, Logger::error(), DLCInfo::installed, DLCInfo::name, readVdfContent(), and DLCInfo::sizeBytes.

◆ readSteamCloudSaveInfo()

CloudSaveInfo SteamLibraryScanner::readSteamCloudSaveInfo ( uint32_t appId)
static

Read Steam Cloud save information for a game from localconfig.vdf.

Parameters
appIdSteam App ID
Returns
CloudSaveInfo struct with cloud save status

Parses the Cloud section from localconfig.vdf: "Apps" -> "[AppID]" -> "Cloud" -> "cloud", "cloudenabled", "lastsyncstate", etc.

Definition at line 3794 of file steam_integration.cpp.

References Logger::debug(), CloudSaveInfo::enabled, Logger::error(), findVdfSectionEnd(), getActiveUserId(), SteamPaths::getPrimarySteamRoot(), CloudSaveInfo::lastSyncState, CloudSaveInfo::lastSyncTime, readVdfContent(), CloudSaveInfo::storageBytes, CloudSaveInfo::supported, and Logger::warn().

Referenced by readAllCloudSaveInfo().

◆ readSteamLaunchOptions()

std::string SteamLibraryScanner::readSteamLaunchOptions ( uint32_t appId)
static

Read Steam launch options for a game from localconfig.vdf.

Parameters
appIdSteam App ID
Returns
Launch options string, or empty string if not found

Definition at line 1517 of file steam_integration.cpp.

References Logger::error(), and SteamPaths::getPrimarySteamRoot().

Referenced by SteamGame::toGame().

◆ readSteamPlaytimeData()

◆ readSteamProtonVersion()

std::string SteamLibraryScanner::readSteamProtonVersion ( uint32_t appId)
static

Read Proton compatibility tool mapping for a game from config.vdf.

Parameters
appIdSteam App ID
Returns
Proton version name, or empty string if not found/using default

Definition at line 3162 of file steam_integration.cpp.

References Logger::error(), and SteamPaths::getPrimarySteamRoot().

Referenced by resolveProtonPath().

◆ readSteamUserCategories()

std::vector< std::string > SteamLibraryScanner::readSteamUserCategories ( uint32_t appId)
static

Read user-defined categories (tags) for a game from localconfig.vdf.

Parameters
appIdSteam App ID
Returns
Vector of category/tag names

Parses the tags section from localconfig.vdf: "Apps" -> "[AppID]" -> "tags" -> "0" "Category1", "1" "Category2", etc.

Definition at line 3964 of file steam_integration.cpp.

References findVdfSectionEnd(), getActiveUserId(), SteamPaths::getPrimarySteamRoot(), and readVdfContent().

Referenced by readAllUserCategories().

◆ requestUninstallGame()

bool SteamLibraryScanner::requestUninstallGame ( uint32_t appId)
static

Request Steam to uninstall a game via steam:// protocol.

Parameters
appIdSteam App ID to uninstall
Returns
true if the uninstall request was sent to Steam

This opens Steam's uninstall dialog for the game, allowing the user to confirm the uninstall through Steam's native interface. Steam will handle removing game files and updating its internal state.

Definition at line 4393 of file steam_integration.cpp.

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

◆ resolveProtonPath()

std::filesystem::path SteamLibraryScanner::resolveProtonPath ( uint32_t appId,
std::string & outCompatToolName )
static

Resolve Proton executable path for a game.

Checks the user's CompatToolMapping for explicit per-game Proton config, then falls back to the best available installed Proton version.

Parameters
appIdSteam App ID
[out]outCompatToolNameRaw compat tool name from config (e.g., "proton_experimental")
Returns
Filesystem path to the proton executable, or empty if none found

Definition at line 3263 of file steam_integration.cpp.

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

Referenced by populateDirectLaunchInfo().

◆ restartSteam()

bool SteamLibraryScanner::restartSteam ( )
static

Attempt to gracefully restart Steam (blocking).

Returns
true if restart was successful

Definition at line 2877 of file steam_integration.cpp.

References Logger::error(), ProcessExecutor::execute(), ProcessExecutor::executeBackground(), Logger::info(), isSteamRunning(), and ProcessResult::success.

Referenced by restartSteamAsync().

◆ restartSteamAsync()

std::future< bool > SteamLibraryScanner::restartSteamAsync ( )
static

Attempt to gracefully restart Steam asynchronously.

Returns
future that will contain true if restart was successful

Definition at line 2918 of file steam_integration.cpp.

References restartSteam().

◆ scanAllLibraries()

◆ scanAllOwnedGames()

◆ scanProtonVersions()

std::vector< std::pair< std::string, std::filesystem::path > > SteamLibraryScanner::scanProtonVersions ( )
static

Scan for all installed Proton versions.

Returns
Vector of Proton installation paths with display names

Definition at line 2928 of file steam_integration.cpp.

References SteamConstants::COMMON_DIR, SteamConstants::COMPAT_TOOLS_DIR, SteamConstants::CONFIG_DIR, SteamPaths::getAllSteamRoots(), SteamPaths::getPrimarySteamRoot(), Logger::info(), SteamConstants::LIBRARY_FOLDERS_VDF, and SteamConstants::STEAMAPPS_DIR.

Referenced by resolveProtonPath().

◆ writeSteamLaunchOptions()

bool SteamLibraryScanner::writeSteamLaunchOptions ( uint32_t appId,
const std::string & launchOptions )
static

Write Steam launch options for a game to localconfig.vdf.

Parameters
appIdSteam App ID
launchOptionsLaunch options string to write
Returns
True if successfully written, false otherwise

Definition at line 1918 of file steam_integration.cpp.

References Logger::error(), SteamPaths::getPrimarySteamRoot(), Logger::info(), vdfEscapeValue(), and Logger::warn().

◆ writeSteamProtonVersion()

bool SteamLibraryScanner::writeSteamProtonVersion ( uint32_t appId,
const std::string & protonName )
static

Write Proton compatibility tool mapping for a game to config.vdf.

Parameters
appIdSteam App ID
protonNameName of the Proton version (e.g., "proton-cachyos-10.0-20251120-slr-x86_64")
Returns
True if successfully written, false otherwise

The name is normalised via normalizeProtonName() before writing — the launcher's runner picker stores display strings (with " (system)", " (Steam-managed)", etc. annotations) but Steam looks up tools by bare directory name. Writing an annotated string causes Steam to silently fall back to no compat tool.

Definition at line 3559 of file steam_integration.cpp.

References Logger::error(), SteamPaths::getPrimarySteamRoot(), Logger::info(), normalizeProtonName(), SteamConstants::VDF_BACKUP_SUFFIX, vdfEscapeValue(), and Logger::warn().


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