|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Complete representation of a game in the library. More...
#include <game.h>
Public Member Functions | |
| Game () | |
| Default constructor. | |
| void | deserializeMetadata (const std::string &json) |
| Deserialize metadata from JSON. | |
| void | deserializeRunnerConfig (const std::string &json) |
| Deserialize runner configuration from JSON. | |
| double | getAverageSessionDuration () const |
| Get average session duration for this game. | |
| double | getCompletionPercentage (int targetStyle=0) const |
| Get completion percentage based on HLTB estimate. | |
| std::string | getCompletionStatusName () const |
| Get human-readable completion status name. | |
| const std::string & | getDescriptionLower () const |
| Get lowercase description (cached for performance). | |
| const std::string & | getDeveloperLower () const |
| Get lowercase developer (cached for performance). | |
| std::string | getFormattedInstallSize () const |
| Format install size as human-readable string. | |
| std::string | getFormattedPlayTime () const |
| Format total play time as human-readable string. | |
| std::string | getImagePath (ImageType type) const |
| Get path for a specific image type. | |
| const std::string & | getNameLower () const |
| Get lowercase name (cached for performance). | |
| std::string | getPlatformName () const |
| Get human-readable platform name. | |
| const std::string & | getPublisherLower () const |
| Get lowercase publisher (cached for performance). | |
| double | getRemainingPlaytime (int targetStyle=0) const |
| Get estimated remaining playtime based on HLTB data. | |
| std::string | getRunnerName () const |
| Get human-readable runner name. | |
| std::string | getSourceName () const |
| Get human-readable source name. | |
| std::string | getStatusName () const |
| Get human-readable status name. | |
| void | invalidateCache () const |
| Invalidate lowercase caches (call when name/metadata changes). | |
| bool | isInstalled () const |
| Check if game is currently installed. | |
| bool | isRunning () const |
| Check if game is currently running. | |
| std::string | serializeMetadata () const |
| Serialize metadata to JSON. | |
| std::string | serializeRunnerConfig () const |
| Serialize runner configuration to JSON. | |
| void | syncPlatformFromRunner () |
| Sync the deprecated platform field from the current runner and source. | |
Public Attributes | |
| std::string | activeTemplateName |
| Currently active template name (empty = using runnerConfig directly). | |
| bool | cacheInitialized_ = false |
| True if caches have been computed. | |
| std::vector< std::string > | collections |
| Collections this game belongs to. | |
| CompletionStatus | completionStatus = CompletionStatus::NotPlayed |
| User's completion status. | |
| std::map< std::string, GameRunnerConfig > | configTemplates |
| Named configuration templates (presets) that can be switched between Key is template name (e.g., "Performance", "Quality", "Compatibility"). | |
| std::string | descriptionLowerCache_ |
| Cached lowercase description for case-insensitive search (computed on first access). | |
| std::string | developerLowerCache_ |
| Cached lowercase developer for case-insensitive search (computed on first access). | |
| HowLongToBeatInfo | hltbInfo |
| Time-to-beat estimates. | |
| std::string | id |
| Unique identifier (auto-generated or user-specified). | |
| std::string | installPath |
| Installation directory path. | |
| uint64_t | installSizeBytes |
| Installation size in bytes. | |
| bool | isFavorite |
| Is this marked as a favorite game? | |
| GameMetadata | metadata |
| Descriptive information and media. | |
| std::string | name |
| Display name shown in UI. | |
| std::string | nameLowerCache_ |
| Cached lowercase name for case-insensitive search (computed on first access). | |
| GamePlatform | platform |
| std::string | publisherLowerCache_ |
| Cached lowercase publisher for case-insensitive search (computed on first access). | |
| std::vector< PlaySession > | recentSessions |
| Recent play sessions (last 20 kept in memory). | |
| GameRunner | runner |
| Runner/compatibility layer to use (Native, Proton, Wine, etc.). | |
| GameRunnerConfig | runnerConfig |
| How to launch and run the game. | |
| GameSource | source |
| Where the game was acquired from (Steam, GOG, Local, etc.). | |
| GameStatistics | statistics |
| Play statistics and usage tracking. | |
| GameStatus | status |
| Current installation and execution status. | |
| std::string | userNotes |
| User's personal notes about the game. | |
Complete representation of a game in the library.
The Game class stores all information about a game, including:
Games are persisted in the SQLite-backed GameLibrary. Per-field JSON serialization is used for nested structs (runner config, metadata).
This class is NOT thread-safe. External synchronization is required if a Game object is accessed from multiple threads.
|
inline |
Default constructor.
Creates a new Game with default values:
Definition at line 852 of file game.h.
References installSizeBytes, isFavorite, runner, source, and status.
| void Game::deserializeMetadata | ( | const std::string & | json | ) |
Deserialize metadata from JSON.
| json | JSON string to parse |
Definition at line 888 of file game.cpp.
References DLCInfo::appId, DLCInfo::installed, metadata, DLCInfo::name, DLCInfo::sizeBytes, and Logger::warn().
| void Game::deserializeRunnerConfig | ( | const std::string & | json | ) |
Deserialize runner configuration from JSON.
| json | JSON string to parse |
Definition at line 724 of file game.cpp.
References runnerConfig, and Logger::warn().
| double Game::getAverageSessionDuration | ( | ) | const |
Get average session duration for this game.
Definition at line 367 of file game.cpp.
References recentSessions.
| double Game::getCompletionPercentage | ( | int | targetStyle = 0 | ) | const |
Get completion percentage based on HLTB estimate.
| targetStyle | Target playstyle (0=main, 1=main+extras, 2=completionist) |
Definition at line 338 of file game.cpp.
References hltbInfo, and statistics.
| std::string Game::getCompletionStatusName | ( | ) | const |
| const std::string & Game::getDescriptionLower | ( | ) | const |
Get lowercase description (cached for performance).
Definition at line 208 of file game.cpp.
References cacheInitialized_, descriptionLowerCache_, and getNameLower().
| const std::string & Game::getDeveloperLower | ( | ) | const |
Get lowercase developer (cached for performance).
Definition at line 190 of file game.cpp.
References cacheInitialized_, developerLowerCache_, and getNameLower().
| std::string Game::getFormattedInstallSize | ( | ) | const |
Format install size as human-readable string.
Definition at line 144 of file game.cpp.
References installSizeBytes.
| std::string Game::getFormattedPlayTime | ( | ) | const |
Format total play time as human-readable string.
Definition at line 114 of file game.cpp.
References statistics.
Referenced by DetailsPanelManager::Impl::update().
| std::string Game::getImagePath | ( | ImageType | type | ) | const |
Get path for a specific image type.
| type | Type of image |
Returns the path for the requested image type, checking both new imagePaths and legacy coverArtPath/bannerPath fields for backwards compatibility.
Definition at line 221 of file game.cpp.
References Capsule, Header, HeroImage, Icon, Logo, metadata, and VerticalCover.
Referenced by GameThumbnailCache::findBestImage(), and DetailsPanelManager::Impl::update().
| const std::string & Game::getNameLower | ( | ) | const |
Get lowercase name (cached for performance).
This method computes lowercase strings on first access and caches them to avoid 15M+ string transformations per second during search/filtering.
Definition at line 176 of file game.cpp.
References cacheInitialized_, descriptionLowerCache_, developerLowerCache_, metadata, name, nameLowerCache_, publisherLowerCache_, and toLower().
Referenced by getDescriptionLower(), getDeveloperLower(), and getPublisherLower().
| std::string Game::getPlatformName | ( | ) | const |
Get human-readable platform name.
Definition at line 68 of file game.cpp.
References DOSBox, Epic, GOG, Native, Proton, RetroArch, ScummVM, Steam, and Wine.
| const std::string & Game::getPublisherLower | ( | ) | const |
Get lowercase publisher (cached for performance).
Definition at line 199 of file game.cpp.
References cacheInitialized_, getNameLower(), and publisherLowerCache_.
| double Game::getRemainingPlaytime | ( | int | targetStyle = 0 | ) | const |
Get estimated remaining playtime based on HLTB data.
| targetStyle | Target playstyle (0=main, 1=main+extras, 2=completionist) |
Definition at line 309 of file game.cpp.
References hltbInfo, and statistics.
| std::string Game::getRunnerName | ( | ) | const |
| std::string Game::getSourceName | ( | ) | const |
| std::string Game::getStatusName | ( | ) | const |
Get human-readable status name.
Definition at line 95 of file game.cpp.
References Installed, Installing, NotInstalled, Running, status, and Updating.
|
inline |
Invalidate lowercase caches (call when name/metadata changes).
Call this method after modifying name, developer, publisher, or description to ensure cached lowercase versions are recomputed on next access.
Definition at line 1027 of file game.h.
References cacheInitialized_.
|
inline |
Check if game is currently installed.
For Steam games, the steamInstalled metadata flag takes precedence since it's synced from Steam's actual state.
Definition at line 944 of file game.h.
References Installed, metadata, Running, source, status, and Steam.
Referenced by GameActionFactory::addLaunchActions(), GameActionFactory::addOpenFolderAction(), GameActionFactory::addSteamActions(), DetailsPanelManager::Impl::update(), and DetailsPanelManager::Impl::updateLaunchButton().
|
inline |
| std::string Game::serializeMetadata | ( | ) | const |
| std::string Game::serializeRunnerConfig | ( | ) | const |
Serialize runner configuration to JSON.
Definition at line 647 of file game.cpp.
References runnerConfig.
Referenced by GameDatabase::insertGame().
|
inline |
Sync the deprecated platform field from the current runner and source.
Call this after setting runner/source to keep platform consistent. This exists for backward compatibility with code that still reads platform.
Definition at line 912 of file game.h.
References DOSBox, Native, Proton, runner, ScummVM, source, Steam, and Wine.
Referenced by ScannedGame::toGame(), and SteamGame::toGame().
| std::string Game::activeTemplateName |
Currently active template name (empty = using runnerConfig directly).
Definition at line 797 of file game.h.
Referenced by GameDatabase::insertGame(), and DetailsPanelManager::Impl::update().
|
mutable |
True if caches have been computed.
Definition at line 835 of file game.h.
Referenced by getDescriptionLower(), getDeveloperLower(), getNameLower(), getPublisherLower(), and invalidateCache().
| std::vector<std::string> Game::collections |
Collections this game belongs to.
Definition at line 804 of file game.h.
Referenced by GameActionFactory::addCollectionsSubmenu(), core::GameLibraryController::addGameToCollection(), GameLibrary::addGameToCollection(), GameListProxyModel::filterAcceptsRow(), core::GameLibraryController::Impl::passesFilter(), core::GameLibraryController::removeGameFromCollection(), GameLibrary::removeGameFromCollection(), and DetailsPanelManager::Impl::update().
| CompletionStatus Game::completionStatus = CompletionStatus::NotPlayed |
User's completion status.
Definition at line 810 of file game.h.
Referenced by getCompletionStatusName(), and DetailsPanelManager::Impl::update().
| std::map<std::string, GameRunnerConfig> Game::configTemplates |
Named configuration templates (presets) that can be switched between Key is template name (e.g., "Performance", "Quality", "Compatibility").
Definition at line 794 of file game.h.
Referenced by GameDatabase::insertGame(), and DetailsPanelManager::Impl::update().
|
mutable |
Cached lowercase description for case-insensitive search (computed on first access).
Definition at line 833 of file game.h.
Referenced by getDescriptionLower(), and getNameLower().
|
mutable |
Cached lowercase developer for case-insensitive search (computed on first access).
Definition at line 829 of file game.h.
Referenced by getDeveloperLower(), and getNameLower().
| HowLongToBeatInfo Game::hltbInfo |
Time-to-beat estimates.
Definition at line 812 of file game.h.
Referenced by getCompletionPercentage(), getRemainingPlaytime(), and DetailsPanelManager::Impl::update().
| std::string Game::id |
Unique identifier (auto-generated or user-specified).
Definition at line 773 of file game.h.
Referenced by GameLibrary::addGame(), core::GameLibraryController::duplicateGame(), GameThumbnailCache::findBestImage(), GameThumbnailCache::getGameThumbnail(), GameThumbnailCache::getHeroImage(), GameDatabase::insertGame(), GameLaunchManager::requestLaunch(), GameProcessManager::scanForRunningGames(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), core::GameLibraryController::toggleFavorite(), GameLibrary::updateGame(), and GameDatabase::updateGameImages().
| std::string Game::installPath |
Installation directory path.
Definition at line 819 of file game.h.
Referenced by GameDatabase::insertGame(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), ScannedGame::toGame(), SteamGame::toGame(), and DetailsPanelManager::Impl::update().
| uint64_t Game::installSizeBytes |
Installation size in bytes.
Definition at line 820 of file game.h.
Referenced by Game(), getFormattedInstallSize(), GameDatabase::insertGame(), ScannedGame::toGame(), SteamGame::toGame(), and DetailsPanelManager::Impl::update().
| bool Game::isFavorite |
Is this marked as a favorite game?
Definition at line 803 of file game.h.
Referenced by Game(), GameActionFactory::addFavoriteAction(), GameDatabase::insertGame(), core::GameLibraryController::Impl::passesFilter(), and core::GameLibraryController::toggleFavorite().
| GameMetadata Game::metadata |
Descriptive information and media.
Definition at line 785 of file game.h.
Referenced by GameActionFactory::addChangeArtworkAction(), GameLibrary::addGame(), GameActionFactory::addLaunchActions(), GameActionFactory::addProtonDBAction(), GameActionFactory::addSteamActions(), SteamLaunchBuilder::buildLaunchCommand(), deserializeMetadata(), GameLibrary::discoverImagesForGame(), getImagePath(), GameSuggestionService::getLocalSuggestions(), getNameLower(), GameSuggestionService::getSuggestions(), GameSuggestionService::getSuggestionsAsync(), GameDatabase::insertGame(), isInstalled(), GameProcessManager::launchGame(), core::GameLibraryController::Impl::passesFilter(), ShortcutsController::registerPaletteCommands(), GameProcessManager::scanForRunningGames(), serializeMetadata(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), ScannedGame::toGame(), SteamGame::toGame(), DetailsPanelManager::Impl::update(), and DetailsPanelManager::Impl::updateLaunchButton().
| std::string Game::name |
Display name shown in UI.
Definition at line 774 of file game.h.
Referenced by GameConfigDialog::GameConfigDialog(), PerformanceProfileDialog::PerformanceProfileDialog(), anonymous_namespace{game_process.cpp}::addApplicationSpecificFixes(), GameActionFactory::addChangeArtworkAction(), core::GameLibraryController::addGame(), GameLibrary::addGame(), GameDatabase::beginTransaction(), GameLibrary::discoverImagesForGame(), MainWindow::dropEvent(), core::GameLibraryController::duplicateGame(), DetailsPanelManager::Impl::eventFilter(), GameSuggestionService::getLocalSuggestions(), getNameLower(), GameSuggestionService::getSuggestions(), GameSuggestionService::getSuggestionsAsync(), GameDatabase::insertGame(), GameProcessManager::launchGame(), core::GameLibraryController::Impl::passesFilter(), GameLaunchManager::requestLaunch(), core::GameLibraryController::Impl::sortGames(), GameProcessManager::stopGame(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), ScannedGame::toGame(), SteamGame::toGame(), DetailsPanelManager::Impl::update(), and GameProcessManager::update().
|
mutable |
Cached lowercase name for case-insensitive search (computed on first access).
Definition at line 827 of file game.h.
Referenced by getNameLower().
| GamePlatform Game::platform |
Definition at line 776 of file game.h.
Referenced by core::GameLibraryController::Impl::passesFilter().
|
mutable |
Cached lowercase publisher for case-insensitive search (computed on first access).
Definition at line 831 of file game.h.
Referenced by getNameLower(), and getPublisherLower().
| std::vector<PlaySession> Game::recentSessions |
Recent play sessions (last 20 kept in memory).
Definition at line 811 of file game.h.
Referenced by getAverageSessionDuration(), and DetailsPanelManager::Impl::update().
| GameRunner Game::runner |
Runner/compatibility layer to use (Native, Proton, Wine, etc.).
Definition at line 777 of file game.h.
Referenced by Game(), GameSuggestionService::applySuggestions(), MainWindow::dropEvent(), getRunnerName(), GameDatabase::insertGame(), GameProcessManager::launchGame(), core::GameLibraryController::Impl::passesFilter(), syncPlatformFromRunner(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), ScannedGame::toGame(), and SteamGame::toGame().
| GameRunnerConfig Game::runnerConfig |
How to launch and run the game.
Definition at line 784 of file game.h.
Referenced by anonymous_namespace{game_process.cpp}::addApplicationSpecificFixes(), GameLibrary::addGame(), GameActionFactory::addOpenFolderAction(), GameActionFactory::addQuickSettingsSubmenu(), GameSuggestionService::applySuggestions(), SteamLaunchBuilder::buildLaunchCommand(), deserializeRunnerConfig(), MainWindow::dropEvent(), GameDatabase::insertGame(), GameProcessManager::launchGame(), ShortcutsController::registerPaletteCommands(), serializeRunnerConfig(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), ScannedGame::toGame(), SteamGame::toGame(), GameActionFactory::Impl::toggleRunnerConfigFlag(), DetailsPanelManager::Impl::update(), and DetailsPanelManager::Impl::updateRunningInfo().
| GameSource Game::source |
Where the game was acquired from (Steam, GOG, Local, etc.).
Definition at line 775 of file game.h.
Referenced by Game(), GameLibrary::addGame(), GameActionFactory::addLaunchActions(), GameActionFactory::addSteamActions(), MainWindow::dropEvent(), getSourceName(), GameDatabase::insertGame(), ContextMenuManager::install(), isInstalled(), core::GameLibraryController::Impl::passesFilter(), syncPlatformFromRunner(), GOGIntegration::toGame(), LegendaryIntegration::toGame(), ScannedGame::toGame(), SteamGame::toGame(), DetailsPanelManager::Impl::update(), and DetailsPanelManager::Impl::updateLaunchButton().
| GameStatistics Game::statistics |
Play statistics and usage tracking.
Definition at line 786 of file game.h.
Referenced by GameLibrary::addGame(), core::GameLibraryController::duplicateGame(), getCompletionPercentage(), getFormattedPlayTime(), getRemainingPlaytime(), GameDatabase::getSchemaVersion(), GameDatabase::insertGame(), GameProcessManager::launchGame(), core::GameLibraryController::Impl::sortGames(), GameProcessManager::stopGame(), SteamGame::toGame(), DetailsPanelManager::Impl::update(), and GameProcessManager::update().
| GameStatus Game::status |
Current installation and execution status.
Definition at line 778 of file game.h.
Referenced by Game(), getStatusName(), GameDatabase::insertGame(), isInstalled(), isRunning(), core::GameLibraryController::Impl::passesFilter(), core::GameLibraryController::Impl::sortGames(), ScannedGame::toGame(), SteamGame::toGame(), DetailsPanelManager::Impl::update(), and DetailsPanelManager::Impl::updateLaunchButton().
| std::string Game::userNotes |
User's personal notes about the game.
Definition at line 813 of file game.h.
Referenced by DetailsPanelManager::Impl::eventFilter(), and DetailsPanelManager::Impl::update().