game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
steam_controller.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// steam_controller.h
4// ==============================================================================
5// Controller for Steam integration - UI-agnostic business logic
6// Handles Steam library scanning, game import, and metadata fetching
7// ==============================================================================
8
9#pragma once
10
11#include <cstdint>
12#include <functional>
13#include <memory>
14#include <optional>
15#include <string>
16#include <vector>
17
18namespace core
19{
20
21// ==============================================================================
22// Steam Data Types
23// ==============================================================================
24
26{
27 uint32_t appId = 0;
28 std::string name;
29 std::string installPath;
30 std::string libraryPath;
31 bool isInstalled = false;
32 uint64_t sizeOnDisk = 0;
33 std::string protonVersion; // Detected Proton version if Windows game
34
35 // Metadata (may be fetched separately)
36 std::string description;
37 std::string developer;
38 std::string publisher;
39 std::vector<std::string> genres;
40 std::string releaseDate;
41};
42
44{
45 std::string path;
46 uint64_t totalSpace = 0;
47 uint64_t freeSpace = 0;
48 size_t gameCount = 0;
49};
50
52{
53 std::string name; // Display name (e.g., "Proton 9.0-4")
54 std::string path; // Full path to Proton installation
55 std::string version; // Version string
56 bool isOfficial = false; // Official Valve Proton
57 bool isGE = false; // GE-Proton
58 bool isCachyOS = false; // CachyOS Proton
59};
60
61// ==============================================================================
62// Steam Events
63// ==============================================================================
64
66{
67 size_t current;
68 size_t total;
69 std::string currentGame;
70};
71
77
79{
80 uint32_t appId;
81 std::string name;
82 std::string assignedGameId; // ID in our game library
83};
84
85// ==============================================================================
86// SteamController
87// ==============================================================================
88
90{
91 public:
92 // Callback types
93 using OnScanProgress = std::function<void(const SteamScanProgressEvent&)>;
94 using OnScanComplete = std::function<void(const SteamScanCompleteEvent&)>;
95 using OnGameImported = std::function<void(const SteamGameImportedEvent&)>;
96
99
100 // Non-copyable, movable
104 SteamController& operator=(SteamController&&) noexcept;
105
106 // =========================================================================
107 // Steam Detection
108 // =========================================================================
109
110 /// Check if Steam is installed
111 bool isSteamInstalled() const;
112
113 /// Get Steam installation path
114 std::string getSteamPath() const;
115
116 /// Check if Steam is currently running
117 bool isSteamRunning() const;
118
119 // =========================================================================
120 // Library Scanning
121 // =========================================================================
122
123 /// Get all Steam library paths
124 std::vector<SteamLibraryInfo> getLibraries() const;
125
126 /// Scan all Steam libraries for installed games
127 /// This is a synchronous operation - use scanLibrariesAsync for background scanning
129
130 /// Start async library scan
131 /// Progress and completion are reported via callbacks
133
134 /// Cancel ongoing async scan
136
137 /// Check if a scan is in progress
138 bool isScanInProgress() const;
139
140 /// Get results from last scan
141 const std::vector<SteamGameInfo>& getLastScanResults() const;
142
143 // =========================================================================
144 // Game Queries
145 // =========================================================================
146
147 /// Get info for a specific Steam game by AppID
148 std::optional<SteamGameInfo> getGameInfo(uint32_t appId) const;
149
150 /// Get game name from AppID (uses Steam's app list cache)
151 std::string getGameName(uint32_t appId) const;
152
153 /// Find a Steam game by name (fuzzy match)
154 std::vector<SteamGameInfo> findGamesByName(const std::string& query) const;
155
156 // =========================================================================
157 // Proton Management
158 // =========================================================================
159
160 /// Get all available Proton versions
162
163 /// Get recommended Proton for a game
164 std::optional<ProtonVersionInfo> getRecommendedProton(uint32_t appId) const;
165
166 /// Get the Proton version currently configured for a game
167 std::optional<std::string> getConfiguredProton(uint32_t appId) const;
168
169 // =========================================================================
170 // Cover Art
171 // =========================================================================
172
173 /// Get path to Steam's cached cover art for a game
174 std::optional<std::string> getCoverArtPath(uint32_t appId) const;
175
176 /// Get path to Steam's header image for a game
177 std::optional<std::string> getHeaderImagePath(uint32_t appId) const;
178
179 /// Download cover art from Steam CDN (async)
180 void downloadCoverArt(uint32_t appId,
181 std::function<void(bool success, std::string path)> callback);
182
183 // =========================================================================
184 // Import Operations
185 // =========================================================================
186
187 /// Import a single Steam game to our library
188 /// Returns the assigned game ID, or empty string on failure
189 std::string importGame(uint32_t appId);
190
191 /// Import multiple Steam games
192 /// Returns number of successfully imported games
193 size_t importGames(const std::vector<uint32_t>& appIds);
194
195 /// Import all detected Steam games
197
198 /// Check if a Steam game is already in our library
199 bool isGameImported(uint32_t appId) const;
200
201 // =========================================================================
202 // Event Subscriptions
203 // =========================================================================
204
208
209 private:
210 class Impl;
211 std::unique_ptr<Impl> impl_;
212};
213
214} // namespace core
size_t importAllGames()
Import all detected Steam games.
std::vector< SteamLibraryInfo > getLibraries() const
Get all Steam library paths.
SteamController(const SteamController &)=delete
void setOnScanComplete(OnScanComplete callback)
std::function< void(const SteamScanCompleteEvent &)> OnScanComplete
void setOnScanProgress(OnScanProgress callback)
std::optional< ProtonVersionInfo > getRecommendedProton(uint32_t appId) const
Get recommended Proton for a game.
void cancelScan()
Cancel ongoing async scan.
std::string getGameName(uint32_t appId) const
Get game name from AppID (uses Steam's app list cache).
std::optional< std::string > getConfiguredProton(uint32_t appId) const
Get the Proton version currently configured for a game.
SteamController & operator=(const SteamController &)=delete
SteamController(SteamController &&) noexcept
std::vector< SteamGameInfo > scanLibraries()
Scan all Steam libraries for installed games This is a synchronous operation - use scanLibrariesAsync...
size_t importGames(const std::vector< uint32_t > &appIds)
Import multiple Steam games Returns number of successfully imported games.
std::optional< std::string > getCoverArtPath(uint32_t appId) const
Get path to Steam's cached cover art for a game.
void downloadCoverArt(uint32_t appId, std::function< void(bool success, std::string path)> callback)
Download cover art from Steam CDN (async).
bool isSteamRunning() const
Check if Steam is currently running.
void setOnGameImported(OnGameImported callback)
void scanLibrariesAsync()
Start async library scan Progress and completion are reported via callbacks.
std::optional< std::string > getHeaderImagePath(uint32_t appId) const
Get path to Steam's header image for a game.
std::vector< SteamGameInfo > findGamesByName(const std::string &query) const
Find a Steam game by name (fuzzy match).
bool isScanInProgress() const
Check if a scan is in progress.
std::function< void(const SteamScanProgressEvent &)> OnScanProgress
const std::vector< SteamGameInfo > & getLastScanResults() const
Get results from last scan.
std::function< void(const SteamGameImportedEvent &)> OnGameImported
std::optional< SteamGameInfo > getGameInfo(uint32_t appId) const
Get info for a specific Steam game by AppID.
bool isSteamInstalled() const
Check if Steam is installed.
bool isGameImported(uint32_t appId) const
Check if a Steam game is already in our library.
std::string importGame(uint32_t appId)
Import a single Steam game to our library Returns the assigned game ID, or empty string on failure.
std::string getSteamPath() const
Get Steam installation path.
std::vector< ProtonVersionInfo > getAvailableProtonVersions() const
Get all available Proton versions.
std::vector< std::string > genres