game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
steam_integration.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// steam_integration.h
4// ==============================================================================
5// Steam library integration for game detection and CachyOS-optimized launching
6// ==============================================================================
7// This module provides:
8// - Steam library folder detection
9// - ACF manifest parsing for game metadata
10// - Proton version management
11// - CachyOS-specific environment variable configuration
12// - Steam launch options building with game-performance wrapper
13//
14// ## Steam Library Structure
15// Steam libraries contain:
16// - steamapps/common/ - Game installation directories
17// - steamapps/appmanifest_{AppID}.acf - Game metadata in KeyValues format
18// - compatdata/ - Proton prefixes for Windows games
19//
20// ## CachyOS Gaming Optimizations
21// Key environment variables for optimal performance:
22// - PROTON_DLSS_UPGRADE, PROTON_FSR4_UPGRADE - Upscaling
23// - PROTON_USE_NTSYNC - NTSync (GE-Proton auto-enables)
24// - __GL_SHADER_DISK_CACHE_SIZE - Nvidia shader cache
25// - MESA_SHADER_CACHE_MAX_SIZE - AMD shader cache
26//
27// ## Usage Example
28// @code
29// SteamLibraryScanner scanner;
30// std::vector<SteamGame> games = scanner.scanAllLibraries();
31//
32// for (const auto& steamGame : games) {
33// Game game = steamGame.toGame();
34// library.addGame(game);
35// }
36// @endcode
37// ==============================================================================
38
39#pragma once
40
41#include "game.h"
42#include <chrono>
43#include <filesystem>
44#include <future>
45#include <map>
46#include <optional>
47#include <string>
48#include <vector>
49
50// ==============================================================================
51// Steam CDN Image Helper
52// ==============================================================================
53
54/**
55 * @class SteamCDN
56 * @brief Helper class for discovering and accessing Steam game images
57 *
58 * Provides utilities to find game images in Steam's local cache or download
59 * from Steam's CDN. Prioritizes local cache to avoid unnecessary downloads.
60 */
62{
63 public:
64 /**
65 * @brief Find all available images for a Steam game
66 * @param appId Steam App ID
67 * @param steamRoot Primary Steam root path (e.g., ~/.steam/steam)
68 * @return GameImagePaths with all discovered image paths
69 *
70 * IMPORTANT: Steam stores ALL game images in the PRIMARY Steam root's cache,
71 * not in individual library folders. Pass getPrimarySteamRoot(), not the
72 * library path where the game is installed.
73 *
74 * Searches Steam's local cache (appcache/librarycache/) for all available
75 * image types. Returns paths to existing files, leaving empty strings for
76 * unavailable images.
77 */
78 static GameImagePaths discoverImages(uint32_t appId, const std::filesystem::path& steamRoot);
79
80 /**
81 * @brief Get path to Steam's library cache directory
82 * @param steamRoot Primary Steam root path
83 * @return Path to librarycache directory (steamRoot/appcache/librarycache)
84 */
85 static std::filesystem::path getLibraryCachePath(const std::filesystem::path& steamRoot);
86
87 /**
88 * @brief Build CDN URL for a specific image type
89 * @param appId Steam App ID
90 * @param type Image type
91 * @return HTTPS URL to Steam CDN image
92 */
93 static std::string getCDNUrl(uint32_t appId, ImageType type);
94
95 /**
96 * @brief Download image from Steam CDN (fallback only)
97 * @param appId Steam App ID
98 * @param type Image type
99 * @param outputPath Where to save the downloaded image
100 * @return True if download succeeded
101 *
102 * This is a fallback for when images are not in local cache.
103 * Tries multiple CDN hosts with timeout and error handling.
104 */
105 static bool downloadImage(uint32_t appId, ImageType type, const std::string& outputPath);
106
107 private:
108 /// CDN hostnames (primary and fallback). Returned by accessor (Meyer's
109 /// singleton) so the std::string vector allocations happen on first
110 /// use rather than during static initialization, where any allocation
111 /// failure would be uncatchable
112 /// (bugprone-throwing-static-initialization, CERT ERR58-CPP).
113 static const std::vector<std::string>& cdnHosts();
114
115 /// Filename patterns for each image type in Steam's cache
116 static std::string getCacheFilename(ImageType type);
117};
118
119// ==============================================================================
120// Proton Version Information
121// ==============================================================================
122
123/**
124 * @enum ProtonVersion
125 * @brief Available Proton compatibility layer versions
126 */
128{
129 ProtonCachyOSSLR, ///< proton-cachyos-slr (recommended for anti-cheat)
130 ProtonCachyOS, ///< proton-cachyos (native, no SLR)
131 ProtonExperimental, ///< Official Proton Experimental
132 Proton9, ///< Official Proton 9.0
133 Proton8, ///< Official Proton 8.0
134 ProtonGE, ///< Proton GE (community)
135 SystemDefault, ///< Use Steam's default selection
136 NativeLinux ///< Native Linux build (no Proton)
137};
138
139/**
140 * @brief Get human-readable name for Proton version
141 */
142const char* getProtonVersionName(ProtonVersion version);
143
144/**
145 * @brief Get command/path for Proton version
146 */
147std::string getProtonVersionCommand(ProtonVersion version);
148
149// ==============================================================================
150// CachyOS Environment Variables Configuration
151// ==============================================================================
152
153/**
154 * @struct CachyOSGameConfig
155 * @brief CachyOS-specific gaming configuration options
156 */
158{
159 // Performance optimizations
160 bool useGamePerformanceWrapper = true; ///< Use game-performance CPU governor wrapper
161 bool useNTSync = false; ///< PROTON_USE_NTSYNC=1 (GE-Proton auto-enables)
162 bool useDXVKAsync = false; ///< DXVK_ASYNC=1 (async shader compilation)
163 bool useLocalShaderCache = false; ///< __GL_SHADER_DISK_CACHE=1 (NVIDIA shader cache)
164 bool skipShaderCacheCleanup = false; ///< __GL_SHADER_DISK_CACHE_SKIP_CLEANUP (NVIDIA)
165
166 // Graphics/Upscaling
167 bool enableFSR = false; ///< WINE_FULLSCREEN_FSR=1 (AMD upscaling)
168 bool enableDLSSUpgrade = false; ///< PROTON_DLSS_UPGRADE (auto-upgrade DLSS)
169 bool enableDLSSIndicator = false; ///< PROTON_DLSS_INDICATOR (show DLSS status)
170 bool enableFSR4Upgrade = false; ///< PROTON_FSR4_UPGRADE (AMD upscaling v4)
172 false; ///< PROTON_FSR4_RDNA3_UPGRADE (AMD RDNA3 optimized upscaling)
173 bool enableXeSSUpgrade = false; ///< PROTON_XESS_UPGRADE (Intel Arc upscaling)
174 bool enableNvidiaLibs = false; ///< PROTON_NVIDIA_LIBS (PhysX/CUDA support)
175 bool nvidia4000Fix = false; ///< PROTON_NVIDIA_LIBS_NO_32BIT (RTX 4000+)
176
177 // Display
178 bool enableGamescope = false; ///< ENABLE_GAMESCOPE (microcompositor)
179 bool enableHDR = false; ///< PROTON_ENABLE_HDR (requires Gamescope/Wayland)
180 bool enableDXVKHDR = false; ///< DXVK_HDR=1 (DXVK HDR support)
181 bool enableWayland = false; ///< PROTON_ENABLE_WAYLAND (experimental, breaks overlay)
182
183 // Input
184 bool preferSDL = false; ///< PROTON_PREFER_SDL (controller detection workaround)
185 bool disableSteamInput = false; ///< PROTON_NO_STEAMINPUT (disable Steam Input)
186
187 // Debugging
188 bool enableProtonLog = false; ///< PROTON_LOG=1 (verbose logging)
189 bool enableMangoHud = false; ///< MANGOHUD=1 (performance overlay)
190 bool enableDXVKHud = false; ///< DXVK_HUD=compiler (show shader compilation)
191 bool fixStuttering = false; ///< LD_PRELOAD="" (disables Steam overlay)
192
193 // Advanced options
194 std::string protonVerb; ///< PROTON_VERB (e.g., "waitforexitandrun")
195 std::string radvPerftest; ///< RADV_PERFTEST (comma-separated, e.g., "rt,nggc,sam")
196
197 /**
198 * @brief Build environment variable string for launch
199 * @return Space-separated environment variables
200 */
201 std::string buildEnvVars() const;
202};
203
204// ==============================================================================
205// Steam Game Metadata
206// ==============================================================================
207
208/**
209 * @struct SteamGame
210 * @brief Metadata for a Steam game parsed from appmanifest ACF file
211 */
213{
214 uint32_t appId; ///< Steam App ID
215 std::string name; ///< Game name
216 std::string installDir; ///< Installation directory name
217 std::filesystem::path libraryPath; ///< Steam library root path
218 std::filesystem::path gamePath; ///< Full path to game directory
219
221 true; ///< True if game is installed (has appmanifest), false if owned but not installed
222 uint64_t sizeOnDisk = 0; ///< Installation size in bytes
223 time_t lastUpdated = 0; ///< Last update timestamp
224 bool isProtonGame = false; ///< Requires Proton (Windows game)
225 std::string protonVersion; ///< Detected Proton/compatibility tool version from Steam
226
227 // Installation/Update progress tracking
228 uint32_t stateFlags = 0; ///< Steam StateFlags from appmanifest
229 uint64_t bytesDownloaded = 0; ///< Bytes downloaded so far
230 uint64_t bytesToDownload = 0; ///< Total bytes to download
231 uint64_t bytesStaged = 0; ///< Bytes staged for installation
232 uint64_t bytesToStage = 0; ///< Total bytes to stage
233 bool isDownloading = false; ///< Currently downloading/updating
234 bool isUpdatePending = false; ///< Update available but not yet started
235
236 // Steam playtime and usage data from localconfig.vdf
237 uint32_t steamPlaytimeMinutes = 0; ///< Total playtime from Steam (in minutes)
238 time_t steamLastPlayed = 0; ///< Last played timestamp from Steam
239 uint32_t steamPlaytime2Weeks = 0; ///< Playtime in last 2 weeks (in minutes)
240 time_t steamLastLaunch = 0; ///< Last launch timestamp from Steam autocloud
241 time_t steamLastExit = 0; ///< Last exit timestamp from Steam autocloud
242 std::string steamBuildId; ///< Steam build ID from appmanifest
243
244 // Steam Store metadata from API
245 std::string steamType; ///< App type: "game", "dlc", "demo", "tool", "music", etc.
246 std::vector<std::string> genres; ///< Game genres from Steam API
247 std::vector<std::string> categories; ///< Steam categories (Single-player, Multi-player, etc.)
248 bool metadataFetched = false; ///< Whether API metadata has been fetched
249
250 // Direct launch configuration (from appinfo.vdf + Proton resolution)
251 std::string gameExecutable; ///< Game exe relative to install dir (e.g., "FSD.exe")
252 std::string gameArguments; ///< Default launch arguments from Steam (e.g., "-nohmd")
253 std::filesystem::path protonPath; ///< Resolved path to proton executable
254 std::string
255 compatToolName; ///< Raw compat tool name from Steam config (e.g., "proton_experimental")
256
257 // Phase 5: Additional Steam integration data
258 std::vector<std::string> steamUserCategories; ///< User-defined categories/tags from Steam
259 CloudSaveInfo cloudSave; ///< Steam Cloud save information
260 std::vector<DLCInfo> dlc; ///< Installed DLC for this game
261
262 /**
263 * @brief Convert SteamGame to Game object for library
264 * @return Game object with Steam-specific configuration
265 */
266 Game toGame() const;
267
268 /**
269 * @brief Download cover art from Steam CDN
270 * @param coverArtDir Directory to save cover art images
271 * @return Path to downloaded cover art, or empty string if failed
272 */
273 std::string downloadCoverArt(const std::string& coverArtDir) const;
274};
275
276// ==============================================================================
277// Steam Launch Options Parser
278// ==============================================================================
279
280/**
281 * @struct ParsedSteamLaunchOptions
282 * @brief Parsed components from Steam launch options string
283 */
285{
286 std::map<std::string, std::string> environmentVariables; ///< Environment variables (KEY=VALUE)
287 std::vector<std::string> wrappers; ///< Wrapper commands (e.g., game-performance, mangohud)
288 std::vector<std::string> gameArguments; ///< Arguments after %command%
289 std::string rawString; ///< Original launch options string
290
291 /**
292 * @brief Parse Steam launch options string
293 * @param launchOptions Raw launch options from Steam
294 * @return Parsed components
295 *
296 * Example input: "DXVK_HDR=1 PROTON_ENABLE_HDR=1 game-performance %command% -dx11"
297 * - environmentVariables: {"DXVK_HDR": "1", "PROTON_ENABLE_HDR": "1"}
298 * - wrappers: {"game-performance"}
299 * - gameArguments: {"-dx11"}
300 */
301 static ParsedSteamLaunchOptions parse(const std::string& launchOptions);
302
303 /**
304 * @brief Check if launch options string is empty or only whitespace
305 */
306 bool isEmpty() const;
307};
308
309// ==============================================================================
310// ACF (App Configuration File) Parser
311// ==============================================================================
312
313/**
314 * @class ACFParser
315 * @brief Parser for Steam's KeyValues format ACF manifest files
316 *
317 * ACF files use a simple key-value format:
318 * @code
319 * "AppState"
320 * {
321 * "appid" "440"
322 * "name" "Team Fortress 2"
323 * "installdir" "Team Fortress 2"
324 * }
325 * @endcode
326 */
328{
329 public:
330 /**
331 * @brief Parse ACF file to extract game metadata.
332 * @param acfFilePath Path to `appmanifest_<AppID>.acf`.
333 * @param libraryPath Path to the parent `steamapps` directory; used
334 * to resolve the `installdir` field into an
335 * absolute install path on the returned SteamGame.
336 * @return Optional SteamGame if parsing succeeds, `nullopt` on error.
337 */
338 static std::optional<SteamGame> parseManifest(const std::filesystem::path& acfFilePath,
339 const std::filesystem::path& libraryPath);
340
341 /**
342 * @brief Detect Proton version for a Steam game from appmanifest UserConfig
343 * @param appId Steam App ID
344 * @param libraryPath Steam library root path
345 * @return Proton version string (e.g., "proton_8", "experimental"), or empty if not
346 * found/native
347 */
348 static std::string detectProtonVersion(uint32_t appId,
349 const std::filesystem::path& libraryPath);
350
351 private:
352 /**
353 * @brief Parse KeyValues format into key-value map
354 * @param content File content string
355 * @return Map of keys to values
356 */
357 static std::map<std::string, std::string> parseKeyValues(const std::string& content);
358
359 /**
360 * @brief Extract value from quoted string
361 */
362 static std::string extractQuotedValue(const std::string& line);
363};
364
365// ==============================================================================
366// Steam Library Scanner
367// ==============================================================================
368
369/**
370 * @class SteamLibraryScanner
371 * @brief Scans Steam installations to discover games
372 *
373 * Detects Steam library folders and parses all appmanifest files
374 * to build a list of installed games.
375 */
377{
378 public:
379 /**
380 * @brief Constructor - auto-detects Steam installation
381 */
383
384 /**
385 * @brief Scan all Steam libraries for installed games
386 * @return Vector of detected Steam games
387 */
388 std::vector<SteamGame> scanAllLibraries();
389
390 /**
391 * @brief Scan for all owned Steam games (installed and not installed)
392 * @return Vector of all owned games with isInstalled flag set appropriately
393 *
394 * This method:
395 * 1. Parses localconfig.vdf to get all owned App IDs
396 * 2. Scans appmanifest files to get installed games with full metadata
397 * 3. Creates minimal SteamGame entries for owned but not installed games
398 */
399 std::vector<SteamGame> scanAllOwnedGames();
400
401 /**
402 * @brief Get list of detected Steam library paths
403 * @return Vector of library folder paths
404 */
405 std::vector<std::filesystem::path> getLibraryPaths() const;
406
407 /**
408 * @brief Check if Steam is installed on this system
409 * @return True if Steam installation detected
410 */
411 bool isSteamInstalled() const;
412
413 /**
414 * @brief Read Steam launch options for a game from localconfig.vdf
415 * @param appId Steam App ID
416 * @return Launch options string, or empty string if not found
417 */
418 static std::string readSteamLaunchOptions(uint32_t appId);
419
420 /**
421 * @brief Write Steam launch options for a game to localconfig.vdf
422 * @param appId Steam App ID
423 * @param launchOptions Launch options string to write
424 * @return True if successfully written, false otherwise
425 */
426 static bool writeSteamLaunchOptions(uint32_t appId, const std::string& launchOptions);
427
428 /**
429 * @brief Steam playtime and usage statistics from localconfig.vdf
430 */
432 {
433 uint32_t playtimeMinutes = 0;
434 time_t lastPlayed = 0;
435 uint32_t playtime2Weeks = 0;
436 time_t lastLaunch = 0;
437 time_t lastExit = 0;
438 };
439
440 /**
441 * @brief Scan for all installed Proton versions
442 * @return Vector of Proton installation paths with display names
443 */
444 static std::vector<std::pair<std::string, std::filesystem::path>> scanProtonVersions();
445
446 /**
447 * @brief Read Proton compatibility tool mapping for a game from config.vdf
448 * @param appId Steam App ID
449 * @return Proton version name, or empty string if not found/using default
450 */
451 static std::string readSteamProtonVersion(uint32_t appId);
452
453 /**
454 * @brief Write Proton compatibility tool mapping for a game to config.vdf
455 * @param appId Steam App ID
456 * @param protonName Name of the Proton version (e.g.,
457 * "proton-cachyos-10.0-20251120-slr-x86_64")
458 * @return True if successfully written, false otherwise
459 *
460 * The name is normalised via normalizeProtonName() before writing — the
461 * launcher's runner picker stores display strings (with " (system)",
462 * " (Steam-managed)", etc. annotations) but Steam looks up tools by bare
463 * directory name. Writing an annotated string causes Steam to silently
464 * fall back to no compat tool.
465 */
466 static bool writeSteamProtonVersion(uint32_t appId, const std::string& protonName);
467
468 /**
469 * @brief Strip launcher-side display annotations from a Proton name
470 *
471 * Converts "proton-cachyos-slr (system)" -> "proton-cachyos-slr" so the
472 * value can be compared against / written to Steam's CompatToolMapping
473 * (which uses bare tool directory names). Returns empty string for
474 * Steam-managed sentinels ("Native Linux", "Proton (Steam-managed)",
475 * "Proton") — caller should treat empty as "leave Steam's mapping alone".
476 */
477 static std::string normalizeProtonName(const std::string& display);
478
479 /**
480 * @brief Resolve Proton executable path for a game
481 *
482 * Checks the user's CompatToolMapping for explicit per-game Proton config,
483 * then falls back to the best available installed Proton version.
484 *
485 * @param appId Steam App ID
486 * @param[out] outCompatToolName Raw compat tool name from config (e.g., "proton_experimental")
487 * @return Filesystem path to the proton executable, or empty if none found
488 */
489 static std::filesystem::path resolveProtonPath(uint32_t appId, std::string& outCompatToolName);
490
491 /**
492 * @brief Populate a SteamGame with direct-launch information
493 *
494 * Reads appinfo.vdf to find the game executable and resolves the Proton
495 * path. This enables direct Proton launching instead of steam -applaunch.
496 *
497 * @param game SteamGame to populate (modified in place)
498 */
499 static void populateDirectLaunchInfo(SteamGame& game);
500
501 /**
502 * @brief Read Steam playtime statistics for all games from localconfig.vdf
503 * @return Map of App ID to SteamPlaytimeData
504 */
505 static std::map<uint32_t, SteamPlaytimeData> readSteamPlaytimeData();
506
507 /**
508 * @brief Fetch game name from Steam Web API
509 * @param appId Steam App ID
510 * @return Game name if found, empty string otherwise
511 */
512 static std::string fetchGameNameFromSteamAPI(uint32_t appId);
513
514 /**
515 * @brief Load Steam app name cache from GetAppList API
516 *
517 * Fetches the complete list of Steam app names in ONE request and caches it.
518 * Subsequent calls to fetchGameNameFromCache() will be instant.
519 *
520 * @return true if cache was loaded successfully
521 */
522 static bool loadAppNameCache();
523
524 /**
525 * @brief Get game name from pre-loaded cache (instant)
526 * @param appId Steam App ID
527 * @return Game name if in cache, empty string otherwise
528 */
529 static std::string fetchGameNameFromCache(uint32_t appId);
530
531 /**
532 * @brief Check if app name cache is loaded
533 */
534 static bool isAppNameCacheLoaded();
535
536 /**
537 * @brief Fetch enhanced metadata from Steam Web API (type, genres, categories)
538 * @param appId Steam App ID
539 * @param outType Output for app type (game/dlc/demo/tool/etc)
540 * @param outGenres Output for genres list
541 * @param outCategories Output for categories list
542 * @return true if metadata was successfully fetched
543 */
544 static bool fetchSteamMetadata(uint32_t appId, std::string& outType,
545 std::vector<std::string>& outGenres,
546 std::vector<std::string>& outCategories);
547
548 /**
549 * @brief Fetch all Steam metadata in a single API call (OPTIMIZED)
550 *
551 * Fetches name, type, genres, and categories in one network request.
552 * Use this instead of separate fetchGameNameFromSteamAPI + fetchSteamMetadata calls.
553 *
554 * @param appId Steam App ID
555 * @param outName Output for game name
556 * @param outType Output for app type (game/dlc/demo/tool/etc)
557 * @param outGenres Output for genres list
558 * @param outCategories Output for categories list
559 * @return true if metadata was successfully fetched
560 */
561 static bool fetchSteamMetadata(uint32_t appId, std::string& outName, std::string& outType,
562 std::vector<std::string>& outGenres,
563 std::vector<std::string>& outCategories);
564
565 /**
566 * @brief Check if Steam is currently running
567 * @return true if Steam process is detected
568 */
569 static bool isSteamRunning();
570
571 /**
572 * @brief Attempt to gracefully restart Steam (blocking)
573 * @return true if restart was successful
574 */
575 static bool restartSteam();
576
577 /**
578 * @brief Attempt to gracefully restart Steam asynchronously
579 * @return future that will contain true if restart was successful
580 */
581 static std::future<bool> restartSteamAsync();
582
583 // ==========================================================================
584 // Phase 5 Enhancements: Additional Steam Integration
585 // ==========================================================================
586
587 /**
588 * @brief Read Steam Cloud save information for a game from localconfig.vdf
589 * @param appId Steam App ID
590 * @return CloudSaveInfo struct with cloud save status
591 *
592 * Parses the Cloud section from localconfig.vdf:
593 * "Apps" -> "[AppID]" -> "Cloud" -> "cloud", "cloudenabled", "lastsyncstate", etc.
594 */
595 static CloudSaveInfo readSteamCloudSaveInfo(uint32_t appId);
596
597 /**
598 * @brief Read user-defined categories (tags) for a game from localconfig.vdf
599 * @param appId Steam App ID
600 * @return Vector of category/tag names
601 *
602 * Parses the tags section from localconfig.vdf:
603 * "Apps" -> "[AppID]" -> "tags" -> "0" "Category1", "1" "Category2", etc.
604 */
605 static std::vector<std::string> readSteamUserCategories(uint32_t appId);
606
607 /**
608 * @brief Read DLC information from appmanifest ACF file
609 * @param acfFilePath Path to appmanifest_*.acf file
610 * @param libraryPath Steam library root path
611 * @return Vector of DLC information
612 *
613 * Parses InstalledDepots section to detect DLC:
614 * "InstalledDepots" -> "[DepotID]" -> "manifest", "size", etc.
615 */
616 static std::vector<DLCInfo> readDLCFromACF(const std::filesystem::path& acfFilePath,
617 const std::filesystem::path& libraryPath);
618
619 /**
620 * @brief Read all cloud save info for all games at once (batch operation)
621 * @return Map of App ID to CloudSaveInfo
622 *
623 * More efficient than calling readSteamCloudSaveInfo() for each game individually.
624 * Parses localconfig.vdf once and extracts all cloud save data.
625 */
626 static std::map<uint32_t, CloudSaveInfo> readAllCloudSaveInfo();
627
628 /**
629 * @brief Read all user categories for all games at once (batch operation)
630 * @return Map of App ID to vector of category names
631 *
632 * More efficient than calling readSteamUserCategories() for each game individually.
633 */
634 static std::map<uint32_t, std::vector<std::string>> readAllUserCategories();
635
636 /**
637 * @brief Request Steam to uninstall a game via steam:// protocol
638 * @param appId Steam App ID to uninstall
639 * @return true if the uninstall request was sent to Steam
640 *
641 * This opens Steam's uninstall dialog for the game, allowing the user
642 * to confirm the uninstall through Steam's native interface.
643 * Steam will handle removing game files and updating its internal state.
644 */
645 static bool requestUninstallGame(uint32_t appId);
646
647 /**
648 * @brief Force uninstall a Steam game by directly removing files
649 * @param appId Steam App ID to uninstall
650 * @return true if files were successfully removed
651 *
652 * This bypasses Steam's confirmation dialog by:
653 * 1. Removing the game directory from steamapps/common/
654 * 2. Removing the Proton prefix from steamapps/compatdata/ (if exists)
655 * 3. Removing the `appmanifest_{appId}.acf` file
656 *
657 * Steam will detect the missing files on next refresh and update its state.
658 * Use requestUninstallGame() for the preferred Steam-native uninstall.
659 */
660 static bool forceUninstallGame(uint32_t appId);
661
662 /**
663 * @brief Get installation info for a Steam game
664 * @param appId Steam App ID
665 * @param[out] installDir Game installation directory name
666 * @param[out] libraryPath Library path containing the game
667 * @return true if game info was found
668 */
669 static bool getGameInstallInfo(uint32_t appId, std::string& installDir,
670 std::filesystem::path& libraryPath);
671
672 private:
673 /**
674 * @brief Detect Steam installation path
675 * @return Path to Steam root directory
676 */
677 std::filesystem::path detectSteamPath();
678
679 /**
680 * @brief Parse libraryfolders.vdf to find additional libraries
681 * @param steamPath Steam root directory
682 * @return Vector of library paths
683 */
684 std::vector<std::filesystem::path> parseLibraryFolders(const std::filesystem::path& steamPath);
685
686 /**
687 * @brief Scan a single library for games
688 * @param libraryPath Path to Steam library
689 * @return Vector of games in this library
690 */
691 std::vector<SteamGame> scanLibrary(const std::filesystem::path& libraryPath);
692
693 /**
694 * @brief Check if a file is locked by another process
695 * @param filePath Path to the file to check
696 * @return True if file is locked, false otherwise
697 */
698 static bool isFileLocked(const std::filesystem::path& filePath);
699
700 /**
701 * @brief Validate VDF file integrity
702 * @param filePath Path to the VDF file
703 * @return True if file is valid (non-empty, basic structure check), false otherwise
704 */
705 static bool validateVDFFile(const std::filesystem::path& filePath);
706
707 /**
708 * @brief Write file with retry logic and validation
709 * @param filePath Path to the file to write
710 * @param lines Content lines to write
711 * @param backupPath Path to backup file for restoration on failure
712 * @return True if write succeeded and validated, false otherwise
713 */
714 static bool writeVDFFileWithRetry(const std::filesystem::path& filePath,
715 const std::vector<std::string>& lines,
716 const std::filesystem::path& backupPath);
717
718 std::filesystem::path steamPath_; ///< Steam installation directory
719 std::vector<std::filesystem::path> libraries_; ///< All detected library paths
720};
721
722// ==============================================================================
723// Steam Launch Command Builder
724// ==============================================================================
725
726/**
727 * @class SteamLaunchBuilder
728 * @brief Builds Steam game launch commands with CachyOS optimizations
729 */
731{
732 public:
733 /**
734 * @brief Build launch command for Steam game
735 * @param game Game object with Steam configuration
736 * @param config CachyOS gaming configuration
737 * @return Complete launch command string
738 */
739 static std::string buildLaunchCommand(const Game& game, const CachyOSGameConfig& config);
740
741 /**
742 * @brief Build Steam launch URI
743 * @param appId Steam App ID
744 * @return `steam://rungameid/{appId}` URI
745 */
746 static std::string buildSteamURI(uint32_t appId);
747};
748
749// ==============================================================================
750// Steam State Flags (from appmanifest)
751// ==============================================================================
752
753/**
754 * @brief Steam StateFlags bitfield values from appmanifest ACF files
755 *
756 * These flags indicate the current installation/update state of a Steam game.
757 * Multiple flags can be set simultaneously.
758 */
760{
761constexpr uint32_t FullyInstalled = 4; ///< Game is fully installed and playable
762constexpr uint32_t UpdateRequired = 2; ///< Update available (not yet started)
763constexpr uint32_t Downloading = 1024; ///< Currently downloading
764constexpr uint32_t UpdateStarted = 1026; ///< Update in progress (Downloading | UpdateRequired)
765constexpr uint32_t Staging = 2048; ///< Staging files after download
766constexpr uint32_t Preallocating = 64; ///< Pre-allocating disk space
767constexpr uint32_t Reconfiguring = 65536; ///< Reconfiguring after update
768constexpr uint32_t Uninstalling = 131072; ///< Being uninstalled
769
770/**
771 * @brief Check if a game is currently downloading or updating
772 */
773inline bool isDownloading(uint32_t flags)
774{
775 return (flags & Downloading) != 0;
776}
777
778/**
779 * @brief Check if a game is fully installed
780 */
781inline bool isFullyInstalled(uint32_t flags)
782{
783 return flags == FullyInstalled;
784}
785
786/**
787 * @brief Check if a game needs an update
788 */
789inline bool needsUpdate(uint32_t flags)
790{
791 return (flags & UpdateRequired) != 0 && !isDownloading(flags);
792}
793
794/**
795 * @brief Get human-readable state description
796 */
797inline std::string getStateDescription(uint32_t flags)
798{
799 if (flags == FullyInstalled)
800 return "Installed";
801 if ((flags & Uninstalling) != 0)
802 return "Uninstalling";
803 if ((flags & Downloading) != 0)
804 return "Downloading";
805 if ((flags & Staging) != 0)
806 return "Installing";
807 if ((flags & Preallocating) != 0)
808 return "Allocating";
809 if ((flags & UpdateRequired) != 0)
810 return "Update Available";
811 if ((flags & Reconfiguring) != 0)
812 return "Configuring";
813 return "Unknown";
814}
815} // namespace SteamStateFlags
816
817// ==============================================================================
818// Steam Download Progress
819// ==============================================================================
820
821/**
822 * @struct SteamDownloadProgress
823 * @brief Real-time download/installation progress for a Steam game
824 */
826{
827 uint32_t appId = 0; ///< Steam App ID
828 uint32_t stateFlags = 0; ///< Current StateFlags
829 uint64_t bytesDownloaded = 0; ///< Bytes downloaded so far
830 uint64_t bytesToDownload = 0; ///< Total bytes to download
831 uint64_t bytesStaged = 0; ///< Bytes staged for installation
832 uint64_t bytesToStage = 0; ///< Total bytes to stage
833 double downloadProgress = 0.0; ///< Download progress (0.0 to 1.0)
834 double stageProgress = 0.0; ///< Staging progress (0.0 to 1.0)
835 double overallProgress = 0.0; ///< Combined progress (0.0 to 1.0)
836 std::string stateDescription; ///< Human-readable state
837 bool isComplete = false; ///< Installation complete
838 bool isError = false; ///< Error occurred
839
840 // Download speed tracking
841 double downloadSpeedBytesPerSec = 0.0; ///< Current download speed in bytes/sec
842 uint64_t lastBytesDownloaded = 0; ///< Previous bytes downloaded for speed calc
843 std::chrono::steady_clock::time_point lastSpeedUpdate; ///< Time of last speed update
844 int queuePosition = 0; ///< Position in download queue (0 = active, 1+ = queued)
845
846 /**
847 * @brief Calculate progress percentages from byte values
848 */
850 {
851 if (bytesToDownload > 0)
852 {
854 static_cast<double>(bytesDownloaded) / static_cast<double>(bytesToDownload);
855 }
856 if (bytesToStage > 0)
857 {
858 stageProgress = static_cast<double>(bytesStaged) / static_cast<double>(bytesToStage);
859 }
860 // Overall is weighted: 60% download, 40% staging
861 if (bytesToDownload > 0 && bytesToStage > 0)
862 {
864 }
865 else if (bytesToDownload > 0)
866 {
868 }
869 else if (bytesToStage > 0)
870 {
872 }
873
876 }
877
878 /**
879 * @brief Update download speed calculation
880 * Should be called periodically with new progress data
881 */
883 {
884 auto now = std::chrono::steady_clock::now();
885 if (lastSpeedUpdate.time_since_epoch().count() > 0)
886 {
887 auto elapsed =
888 std::chrono::duration_cast<std::chrono::milliseconds>(now - lastSpeedUpdate)
889 .count();
890 if (elapsed > 0 && bytesDownloaded > lastBytesDownloaded)
891 {
892 uint64_t bytesTransferred = bytesDownloaded - lastBytesDownloaded;
894 static_cast<double>(bytesTransferred) * 1000.0 / static_cast<double>(elapsed);
895 }
896 else if (elapsed > 2000)
897 {
898 // If no progress for 2 seconds, speed is effectively 0
900 }
901 }
903 lastSpeedUpdate = now;
904 }
905
906 /**
907 * @brief Get formatted download speed string
908 */
909 std::string getFormattedSpeed() const
910 {
911 if (downloadSpeedBytesPerSec < 1024)
912 {
913 return std::to_string(static_cast<int>(downloadSpeedBytesPerSec)) + " B/s";
914 }
915 else if (downloadSpeedBytesPerSec < 1024 * 1024)
916 {
917 double kbps = downloadSpeedBytesPerSec / 1024.0;
918 char buf[32];
919 snprintf(buf, sizeof(buf), "%.1f KB/s", kbps);
920 return buf;
921 }
922 else
923 {
924 double mbps = downloadSpeedBytesPerSec / (1024.0 * 1024.0);
925 char buf[32];
926 snprintf(buf, sizeof(buf), "%.1f MB/s", mbps);
927 return buf;
928 }
929 }
930};
931
932// ==============================================================================
933// Steam Download Monitor
934// ==============================================================================
935
936/**
937 * @class SteamDownloadMonitor
938 * @brief Monitors Steam download/install progress for games
939 *
940 * This class provides download progress tracking by:
941 * 1. Polling appmanifest ACF files for progress changes
942 * 2. Detecting game launch/exit via process inspection
943 *
944 * Usage:
945 * @code
946 * SteamDownloadMonitor monitor;
947 *
948 * // Set up callbacks
949 * monitor.setOnProgressUpdate([](uint32_t appId, const SteamDownloadProgress& progress) {
950 * updateUI(appId, progress);
951 * });
952 *
953 * // Start monitoring a game being installed
954 * monitor.watchGame(12345);
955 *
956 * // Stop when done
957 * monitor.unwatchGame(12345);
958 * @endcode
959 */
961{
962 public:
964 std::function<void(uint32_t appId, const SteamDownloadProgress& progress)>;
966 std::function<void(uint32_t appId, uint32_t oldState, uint32_t newState)>;
967 using GameLaunchCallback = std::function<void(uint32_t appId, int pid)>;
968 using GameExitCallback = std::function<void(uint32_t appId)>;
969
972
973 // Non-copyable, movable
978
979 // =========================================================================
980 // Monitoring Control
981 // =========================================================================
982
983 /**
984 * @brief Start monitoring Steam downloads
985 * @param pollIntervalMs How often to check for changes (default: 1000ms)
986 */
987 void start(int pollIntervalMs = 1000);
988
989 /**
990 * @brief Stop all monitoring
991 */
992 void stop();
993
994 /**
995 * @brief Check if monitor is running
996 */
997 bool isRunning() const;
998
999 /**
1000 * @brief Add a game to the watch list for progress updates
1001 * @param appId Steam App ID to monitor
1002 */
1003 void watchGame(uint32_t appId);
1004
1005 /**
1006 * @brief Remove a game from the watch list
1007 * @param appId Steam App ID to stop monitoring
1008 */
1009 void unwatchGame(uint32_t appId);
1010
1011 /**
1012 * @brief Get list of currently watched game IDs
1013 */
1014 std::vector<uint32_t> getWatchedGames() const;
1015
1016 /**
1017 * @brief Get current progress for a game (immediate snapshot)
1018 * @param appId Steam App ID
1019 * @return Current download progress, or empty progress if not being monitored
1020 */
1021 SteamDownloadProgress getProgress(uint32_t appId) const;
1022
1023 // =========================================================================
1024 // Process Detection
1025 // =========================================================================
1026
1027 /**
1028 * @brief Check if a Steam game is currently running (by app ID)
1029 * @param appId Steam App ID
1030 * @return PID if running, -1 otherwise
1031 *
1032 * Detects game processes using the reaper PID file Steam creates.
1033 */
1034 static int getRunningGamePid(uint32_t appId);
1035
1036 /**
1037 * @brief Check if Steam is actively downloading/updating anything
1038 * @return true if download activity detected
1039 */
1040 static bool isSteamDownloading();
1041
1042 /**
1043 * @brief Get list of all games currently downloading
1044 * @return Vector of App IDs with active downloads
1045 */
1046 static std::vector<uint32_t> getDownloadingGames();
1047
1048 /**
1049 * @brief Read current state of a game directly from its appmanifest
1050 * @param appId Steam App ID
1051 * @return Current download progress, or empty progress if no manifest exists
1052 *
1053 * This is a static method that reads the appmanifest file directly without
1054 * requiring the game to be watched. Useful for checking initial state of
1055 * games (e.g., to detect partial downloads) before adding them to watch list.
1056 */
1057 static SteamDownloadProgress readGameState(uint32_t appId);
1058
1059 // =========================================================================
1060 // Callbacks
1061 // =========================================================================
1062
1065 void setOnGameLaunch(GameLaunchCallback callback);
1066 void setOnGameExit(GameExitCallback callback);
1067
1068 private:
1069 class Impl;
1070 std::unique_ptr<Impl> impl_;
1071};
1072
1073// ==============================================================================
1074// Steam Update Monitor
1075// ==============================================================================
1076
1077/**
1078 * @struct SteamGameUpdateInfo
1079 * @brief Information about a game's update status
1080 */
1082{
1083 uint32_t appId = 0;
1084 std::string gameName;
1085 uint32_t stateFlags = 0;
1086 bool needsUpdate = false;
1087 bool isDownloading = false;
1088 uint64_t updateSizeBytes = 0; // If known from bytesToDownload
1089 time_t detectedAt = 0; // When update was detected
1090};
1091
1092/**
1093 * @class SteamUpdateMonitor
1094 * @brief Monitors all Steam games for update availability
1095 *
1096 * This class provides library-wide monitoring for game updates by:
1097 * 1. Scanning all appmanifest files periodically
1098 * 2. Detecting StateFlags changes indicating updates available
1099 * 3. Notifying callbacks when new updates are detected
1100 *
1101 * Unlike SteamDownloadMonitor which watches specific games, this monitors
1102 * ALL installed games for update status changes.
1103 *
1104 * Usage:
1105 * @code
1106 * auto& monitor = SteamUpdateMonitor::instance();
1107 * monitor.setOnUpdateAvailable([](const SteamGameUpdateInfo& info) {
1108 * std::cout << info.gameName << " has an update!\n";
1109 * });
1110 * monitor.start(); // Scans every 5 minutes by default
1111 * @endcode
1112 */
1114{
1115 public:
1116 using UpdateAvailableCallback = std::function<void(const SteamGameUpdateInfo& info)>;
1117 using UpdateStartedCallback = std::function<void(const SteamGameUpdateInfo& info)>;
1119 std::function<void(uint32_t appId, const std::string& gameName)>;
1120
1121 // Singleton access
1122 static SteamUpdateMonitor& instance();
1123
1124 // Non-copyable
1127
1128 // =========================================================================
1129 // Monitoring Control
1130 // =========================================================================
1131
1132 /**
1133 * @brief Start monitoring for updates
1134 * @param scanIntervalSeconds How often to scan for updates (default: 300s = 5 min)
1135 */
1136 void start(int scanIntervalSeconds = 300);
1137
1138 /**
1139 * @brief Stop monitoring
1140 */
1141 void stop();
1142
1143 /**
1144 * @brief Check if monitor is running
1145 */
1146 bool isRunning() const;
1147
1148 /**
1149 * @brief Force an immediate scan for updates
1150 * @return Vector of games with updates available
1151 */
1152 std::vector<SteamGameUpdateInfo> scanNow();
1153
1154 /**
1155 * @brief Get all games currently needing updates
1156 */
1157 std::vector<SteamGameUpdateInfo> getGamesNeedingUpdate() const;
1158
1159 /**
1160 * @brief Get count of games needing updates
1161 */
1162 size_t getUpdateCount() const;
1163
1164 /**
1165 * @brief Clear cached update states (force fresh detection)
1166 */
1167 void clearCache();
1168
1169 // =========================================================================
1170 // Callbacks
1171 // =========================================================================
1172
1173 /**
1174 * @brief Set callback for when a new update is detected
1175 */
1177
1178 /**
1179 * @brief Set callback for when an update starts downloading
1180 */
1182
1183 /**
1184 * @brief Set callback for when an update completes
1185 */
1187
1188 private:
1191
1192 class Impl;
1193 std::unique_ptr<Impl> impl_;
1194};
Parser for Steam's KeyValues format ACF manifest files.
static std::optional< SteamGame > parseManifest(const std::filesystem::path &acfFilePath, const std::filesystem::path &libraryPath)
Parse ACF file to extract game metadata.
static std::string detectProtonVersion(uint32_t appId, const std::filesystem::path &libraryPath)
Detect Proton version for a Steam game from appmanifest UserConfig.
Complete representation of a game in the library.
Definition game.h:767
Helper class for discovering and accessing Steam game images.
static std::string getCDNUrl(uint32_t appId, ImageType type)
Build CDN URL for a specific image type.
static bool downloadImage(uint32_t appId, ImageType type, const std::string &outputPath)
Download image from Steam CDN (fallback only).
static GameImagePaths discoverImages(uint32_t appId, const std::filesystem::path &steamRoot)
Find all available images for a Steam game.
static std::filesystem::path getLibraryCachePath(const std::filesystem::path &steamRoot)
Get path to Steam's library cache directory.
void setOnStateChange(StateChangeCallback callback)
void stop()
Stop all monitoring.
static std::vector< uint32_t > getDownloadingGames()
Get list of all games currently downloading.
std::function< void(uint32_t appId, uint32_t oldState, uint32_t newState)> StateChangeCallback
static int getRunningGamePid(uint32_t appId)
Check if a Steam game is currently running (by app ID).
static bool isSteamDownloading()
Check if Steam is actively downloading/updating anything.
SteamDownloadMonitor & operator=(const SteamDownloadMonitor &)=delete
SteamDownloadMonitor(const SteamDownloadMonitor &)=delete
std::function< void(uint32_t appId, int pid)> GameLaunchCallback
void setOnGameExit(GameExitCallback callback)
void start(int pollIntervalMs=1000)
Start monitoring Steam downloads.
std::function< void(uint32_t appId)> GameExitCallback
bool isRunning() const
Check if monitor is running.
void watchGame(uint32_t appId)
Add a game to the watch list for progress updates.
static SteamDownloadProgress readGameState(uint32_t appId)
Read current state of a game directly from its appmanifest.
std::function< void(uint32_t appId, const SteamDownloadProgress &progress)> ProgressCallback
void setOnProgressUpdate(ProgressCallback callback)
void unwatchGame(uint32_t appId)
Remove a game from the watch list.
void setOnGameLaunch(GameLaunchCallback callback)
std::vector< uint32_t > getWatchedGames() const
Get list of currently watched game IDs.
SteamDownloadMonitor(SteamDownloadMonitor &&) noexcept
SteamDownloadProgress getProgress(uint32_t appId) const
Get current progress for a game (immediate snapshot).
Builds Steam game launch commands with CachyOS optimizations.
static std::string buildSteamURI(uint32_t appId)
Build Steam launch URI.
static std::string buildLaunchCommand(const Game &game, const CachyOSGameConfig &config)
Build launch command for Steam game.
bool isSteamInstalled() const
Check if Steam is installed on this system.
static CloudSaveInfo readSteamCloudSaveInfo(uint32_t appId)
Read Steam Cloud save information for a game from localconfig.vdf.
static std::vector< std::pair< std::string, std::filesystem::path > > scanProtonVersions()
Scan for all installed Proton versions.
static std::map< uint32_t, SteamPlaytimeData > readSteamPlaytimeData()
Read Steam playtime statistics for all games from localconfig.vdf.
static std::string normalizeProtonName(const std::string &display)
Strip launcher-side display annotations from a Proton name.
static std::vector< DLCInfo > readDLCFromACF(const std::filesystem::path &acfFilePath, const std::filesystem::path &libraryPath)
Read DLC information from appmanifest ACF file.
static std::string fetchGameNameFromCache(uint32_t appId)
Get game name from pre-loaded cache (instant).
static bool restartSteam()
Attempt to gracefully restart Steam (blocking).
static bool loadAppNameCache()
Load Steam app name cache from GetAppList API.
static std::map< uint32_t, std::vector< std::string > > readAllUserCategories()
Read all user categories for all games at once (batch operation).
static std::string fetchGameNameFromSteamAPI(uint32_t appId)
Fetch game name from Steam Web API.
static bool isAppNameCacheLoaded()
Check if app name cache is loaded.
static bool requestUninstallGame(uint32_t appId)
Request Steam to uninstall a game via steam:// protocol.
static bool forceUninstallGame(uint32_t appId)
Force uninstall a Steam game by directly removing files.
static bool writeSteamProtonVersion(uint32_t appId, const std::string &protonName)
Write Proton compatibility tool mapping for a game to config.vdf.
static std::future< bool > restartSteamAsync()
Attempt to gracefully restart Steam asynchronously.
static bool getGameInstallInfo(uint32_t appId, std::string &installDir, std::filesystem::path &libraryPath)
Get installation info for a Steam game.
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).
std::vector< std::filesystem::path > getLibraryPaths() const
Get list of detected Steam library paths.
static std::string readSteamProtonVersion(uint32_t appId)
Read Proton compatibility tool mapping for a game from config.vdf.
static bool isSteamRunning()
Check if Steam is currently running.
static std::filesystem::path resolveProtonPath(uint32_t appId, std::string &outCompatToolName)
Resolve Proton executable path for a game.
static std::map< uint32_t, CloudSaveInfo > readAllCloudSaveInfo()
Read all cloud save info for all games at once (batch operation).
static void populateDirectLaunchInfo(SteamGame &game)
Populate a SteamGame with direct-launch information.
static bool writeSteamLaunchOptions(uint32_t appId, const std::string &launchOptions)
Write Steam launch options for a game to localconfig.vdf.
static std::vector< std::string > readSteamUserCategories(uint32_t appId)
Read user-defined categories (tags) for a game from localconfig.vdf.
static std::string readSteamLaunchOptions(uint32_t appId)
Read Steam launch options for a game from localconfig.vdf.
SteamLibraryScanner()
Constructor - auto-detects Steam installation.
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).
void clearCache()
Clear cached update states (force fresh detection).
static SteamUpdateMonitor & instance()
void setOnUpdateCompleted(UpdateCompletedCallback callback)
Set callback for when an update completes.
SteamUpdateMonitor & operator=(const SteamUpdateMonitor &)=delete
void setOnUpdateStarted(UpdateStartedCallback callback)
Set callback for when an update starts downloading.
void setOnUpdateAvailable(UpdateAvailableCallback callback)
Set callback for when a new update is detected.
SteamUpdateMonitor(const SteamUpdateMonitor &)=delete
bool isRunning() const
Check if monitor is running.
void stop()
Stop monitoring.
std::function< void(uint32_t appId, const std::string &gameName)> UpdateCompletedCallback
std::function< void(const SteamGameUpdateInfo &info)> UpdateStartedCallback
std::vector< SteamGameUpdateInfo > scanNow()
Force an immediate scan for updates.
size_t getUpdateCount() const
Get count of games needing updates.
std::vector< SteamGameUpdateInfo > getGamesNeedingUpdate() const
Get all games currently needing updates.
void start(int scanIntervalSeconds=300)
Start monitoring for updates.
std::function< void(const SteamGameUpdateInfo &info)> UpdateAvailableCallback
ImageType
Types of game images available.
Definition game.h:478
Steam StateFlags bitfield values from appmanifest ACF files.
std::string getStateDescription(uint32_t flags)
Get human-readable state description.
bool isFullyInstalled(uint32_t flags)
Check if a game is fully installed.
constexpr uint32_t Preallocating
Pre-allocating disk space.
constexpr uint32_t Downloading
Currently downloading.
bool needsUpdate(uint32_t flags)
Check if a game needs an update.
constexpr uint32_t UpdateStarted
Update in progress (Downloading | UpdateRequired).
constexpr uint32_t Uninstalling
Being uninstalled.
constexpr uint32_t UpdateRequired
Update available (not yet started).
bool isDownloading(uint32_t flags)
Check if a game is currently downloading or updating.
constexpr uint32_t Reconfiguring
Reconfiguring after update.
constexpr uint32_t Staging
Staging files after download.
constexpr uint32_t FullyInstalled
Game is fully installed and playable.
ProtonVersion
Available Proton compatibility layer versions.
@ Proton8
Official Proton 8.0.
@ ProtonCachyOS
proton-cachyos (native, no SLR)
@ ProtonGE
Proton GE (community).
@ ProtonCachyOSSLR
proton-cachyos-slr (recommended for anti-cheat)
@ NativeLinux
Native Linux build (no Proton).
@ Proton9
Official Proton 9.0.
@ ProtonExperimental
Official Proton Experimental.
@ SystemDefault
Use Steam's default selection.
std::string getProtonVersionCommand(ProtonVersion version)
Get command/path for Proton version.
const char * getProtonVersionName(ProtonVersion version)
Get human-readable name for Proton version.
CachyOS-specific gaming configuration options.
std::string radvPerftest
RADV_PERFTEST (comma-separated, e.g., "rt,nggc,sam").
bool nvidia4000Fix
PROTON_NVIDIA_LIBS_NO_32BIT (RTX 4000+).
bool useLocalShaderCache
__GL_SHADER_DISK_CACHE=1 (NVIDIA shader cache)
bool enableWayland
PROTON_ENABLE_WAYLAND (experimental, breaks overlay).
bool enableMangoHud
MANGOHUD=1 (performance overlay).
bool enableFSR
WINE_FULLSCREEN_FSR=1 (AMD upscaling).
bool enableDLSSIndicator
PROTON_DLSS_INDICATOR (show DLSS status).
bool useGamePerformanceWrapper
Use game-performance CPU governor wrapper.
bool enableFSR4Upgrade
PROTON_FSR4_UPGRADE (AMD upscaling v4).
bool skipShaderCacheCleanup
__GL_SHADER_DISK_CACHE_SKIP_CLEANUP (NVIDIA)
bool enableGamescope
ENABLE_GAMESCOPE (microcompositor).
bool disableSteamInput
PROTON_NO_STEAMINPUT (disable Steam Input).
bool enableDXVKHDR
DXVK_HDR=1 (DXVK HDR support).
bool enableProtonLog
PROTON_LOG=1 (verbose logging).
bool enableDLSSUpgrade
PROTON_DLSS_UPGRADE (auto-upgrade DLSS).
bool useNTSync
PROTON_USE_NTSYNC=1 (GE-Proton auto-enables).
bool useDXVKAsync
DXVK_ASYNC=1 (async shader compilation).
bool enableFSR4RDNA3Upgrade
PROTON_FSR4_RDNA3_UPGRADE (AMD RDNA3 optimized upscaling).
bool enableNvidiaLibs
PROTON_NVIDIA_LIBS (PhysX/CUDA support).
bool enableXeSSUpgrade
PROTON_XESS_UPGRADE (Intel Arc upscaling).
std::string protonVerb
PROTON_VERB (e.g., "waitforexitandrun").
bool fixStuttering
LD_PRELOAD="" (disables Steam overlay).
std::string buildEnvVars() const
Build environment variable string for launch.
bool preferSDL
PROTON_PREFER_SDL (controller detection workaround).
bool enableHDR
PROTON_ENABLE_HDR (requires Gamescope/Wayland).
bool enableDXVKHud
DXVK_HUD=compiler (show shader compilation).
Information about Steam Cloud save synchronization.
Definition game.h:517
Paths to various game image assets.
Definition game.h:496
Parsed components from Steam launch options string.
bool isEmpty() const
Check if launch options string is empty or only whitespace.
std::vector< std::string > wrappers
Wrapper commands (e.g., game-performance, mangohud).
static ParsedSteamLaunchOptions parse(const std::string &launchOptions)
Parse Steam launch options string.
std::vector< std::string > gameArguments
Arguments after command%.
std::map< std::string, std::string > environmentVariables
Environment variables (KEY=VALUE).
std::string rawString
Original launch options string.
Real-time download/installation progress for a Steam game.
uint64_t bytesToStage
Total bytes to stage.
std::string stateDescription
Human-readable state.
std::string getFormattedSpeed() const
Get formatted download speed string.
uint32_t appId
Steam App ID.
std::chrono::steady_clock::time_point lastSpeedUpdate
Time of last speed update.
bool isError
Error occurred.
uint64_t bytesToDownload
Total bytes to download.
uint64_t lastBytesDownloaded
Previous bytes downloaded for speed calc.
uint64_t bytesStaged
Bytes staged for installation.
double downloadProgress
Download progress (0.0 to 1.0).
double downloadSpeedBytesPerSec
Current download speed in bytes/sec.
double stageProgress
Staging progress (0.0 to 1.0).
void calculateProgress()
Calculate progress percentages from byte values.
void updateSpeed()
Update download speed calculation Should be called periodically with new progress data.
uint64_t bytesDownloaded
Bytes downloaded so far.
bool isComplete
Installation complete.
int queuePosition
Position in download queue (0 = active, 1+ = queued).
uint32_t stateFlags
Current StateFlags.
double overallProgress
Combined progress (0.0 to 1.0).
Information about a game's update status.
Metadata for a Steam game parsed from appmanifest ACF file.
std::string downloadCoverArt(const std::string &coverArtDir) const
Download cover art from Steam CDN.
std::filesystem::path libraryPath
Steam library root path.
uint64_t bytesDownloaded
Bytes downloaded so far.
std::string installDir
Installation directory name.
std::string gameExecutable
Game exe relative to install dir (e.g., "FSD.exe").
time_t steamLastExit
Last exit timestamp from Steam autocloud.
std::string steamType
App type: "game", "dlc", "demo", "tool", "music", etc.
std::string name
Game name.
time_t steamLastPlayed
Last played timestamp from Steam.
bool isInstalled
True if game is installed (has appmanifest), false if owned but not installed.
std::vector< std::string > genres
Game genres from Steam API.
std::vector< DLCInfo > dlc
Installed DLC for this game.
uint32_t steamPlaytime2Weeks
Playtime in last 2 weeks (in minutes).
std::vector< std::string > categories
Steam categories (Single-player, Multi-player, etc.).
uint32_t steamPlaytimeMinutes
Total playtime from Steam (in minutes).
bool metadataFetched
Whether API metadata has been fetched.
bool isProtonGame
Requires Proton (Windows game).
time_t steamLastLaunch
Last launch timestamp from Steam autocloud.
std::filesystem::path gamePath
Full path to game directory.
Game toGame() const
Convert SteamGame to Game object for library.
std::vector< std::string > steamUserCategories
User-defined categories/tags from Steam.
uint32_t appId
Steam App ID.
uint32_t stateFlags
Steam StateFlags from appmanifest.
bool isUpdatePending
Update available but not yet started.
CloudSaveInfo cloudSave
Steam Cloud save information.
time_t lastUpdated
Last update timestamp.
std::string steamBuildId
Steam build ID from appmanifest.
bool isDownloading
Currently downloading/updating.
uint64_t bytesToStage
Total bytes to stage.
std::string compatToolName
Raw compat tool name from Steam config (e.g., "proton_experimental").
uint64_t bytesToDownload
Total bytes to download.
std::string protonVersion
Detected Proton/compatibility tool version from Steam.
std::string gameArguments
Default launch arguments from Steam (e.g., "-nohmd").
uint64_t bytesStaged
Bytes staged for installation.
uint64_t sizeOnDisk
Installation size in bytes.
std::filesystem::path protonPath
Resolved path to proton executable.
Steam playtime and usage statistics from localconfig.vdf.