|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
#include <launch_controller.h>
Classes | |
| class | Impl |
Public Types | |
| using | OnLaunchError = std::function<void(const LaunchErrorEvent&)> |
| using | OnProcessExited = std::function<void(const ProcessExitedEvent&)> |
| using | OnProcessStarted = std::function<void(const ProcessStartedEvent&)> |
| using | OnStateChanged = std::function<void(const LaunchStateChangedEvent&)> |
Public Member Functions | |
| LaunchController () | |
| LaunchController (const LaunchController &)=delete | |
| LaunchController (LaunchController &&) noexcept | |
| ~LaunchController () | |
| std::vector< RunningGameInfo > | getAllRunningGames () const |
| Get all currently running games. | |
| LaunchState | getGameState (const std::string &gameId) const |
| Get current launch state for a game. | |
| size_t | getRunningGameCount () const |
| Get the number of running games. | |
| std::optional< RunningGameInfo > | getRunningGameInfo (const std::string &gameId) const |
| Get info about a running game (returns nullopt if not running). | |
| std::chrono::seconds | getSessionDuration (const std::string &gameId) const |
| Get current session duration for a running game. | |
| std::string | getSteamStateDescription () const |
| Get Steam state description. | |
| std::chrono::seconds | getTotalSessionPlayTime () const |
| Get total play time recorded for this session. | |
| bool | hasRunningGames () const |
| Check if any game is currently running. | |
| bool | isGameRunning (const std::string &gameId) const |
| Check if a specific game is running. | |
| bool | isSteamRunning () const |
| Check if Steam is running. | |
| bool | killGame (const std::string &gameId) |
| Force kill a running game. | |
| bool | launchGame (const std::string &gameId, const Game &game) |
| Launch a game Returns true if launch was initiated (doesn't mean success yet). | |
| LaunchController & | operator= (const LaunchController &)=delete |
| LaunchController & | operator= (LaunchController &&) noexcept |
| void | requestSteamStart () |
| Request Steam to start (async). | |
| void | setOnLaunchError (OnLaunchError callback) |
| void | setOnProcessExited (OnProcessExited callback) |
| void | setOnProcessStarted (OnProcessStarted callback) |
| void | setOnStateChanged (OnStateChanged callback) |
| void | stopAllGames () |
| Stop all running games. | |
| bool | stopGame (const std::string &gameId) |
| Request graceful stop of a running game. | |
| void | update () |
| Called periodically to update internal state (process monitoring, etc.) UI layer should call this from its main loop or a timer. | |
Definition at line 99 of file launch_controller.h.
| using core::LaunchController::OnLaunchError = std::function<void(const LaunchErrorEvent&)> |
Definition at line 106 of file launch_controller.h.
| using core::LaunchController::OnProcessExited = std::function<void(const ProcessExitedEvent&)> |
Definition at line 105 of file launch_controller.h.
| using core::LaunchController::OnProcessStarted = std::function<void(const ProcessStartedEvent&)> |
Definition at line 104 of file launch_controller.h.
| using core::LaunchController::OnStateChanged = std::function<void(const LaunchStateChangedEvent&)> |
Definition at line 103 of file launch_controller.h.
| core::LaunchController::LaunchController | ( | ) |
Definition at line 63 of file launch_controller.cpp.
Referenced by LaunchController(), LaunchController(), launchGame(), operator=(), and operator=().
| core::LaunchController::~LaunchController | ( | ) |
Definition at line 65 of file launch_controller.cpp.
References GameLaunchManager::instance(), and GameLaunchManager::setCompletionCallback().
|
delete |
References LaunchController().
|
defaultnoexcept |
References LaunchController().
| std::vector< RunningGameInfo > core::LaunchController::getAllRunningGames | ( | ) | const |
Get all currently running games.
Definition at line 311 of file launch_controller.cpp.
References GameProcessManager::getRunningGameIds(), getRunningGameInfo(), and GameProcessManager::instance().
Referenced by operator=().
| LaunchState core::LaunchController::getGameState | ( | const std::string & | gameId | ) | const |
Get current launch state for a game.
Definition at line 253 of file launch_controller.cpp.
References core::Idle, GameProcessManager::instance(), isGameRunning(), and core::Running.
Referenced by operator=().
| size_t core::LaunchController::getRunningGameCount | ( | ) | const |
Get the number of running games.
Definition at line 327 of file launch_controller.cpp.
References GameProcessManager::getRunningGameIds(), and GameProcessManager::instance().
Referenced by operator=().
| std::optional< RunningGameInfo > core::LaunchController::getRunningGameInfo | ( | const std::string & | gameId | ) | const |
Get info about a running game (returns nullopt if not running).
Definition at line 272 of file launch_controller.cpp.
References core::RunningGameInfo::gameId, core::RunningGameInfo::gameModeEnabled, core::RunningGameInfo::gameName, GameProcessManager::getRunningProcessSnapshot(), GameProcessManager::instance(), core::RunningGameInfo::mangoHudEnabled, core::RunningGameInfo::primaryPid, core::RunningGameInfo::protonVersion, core::Running, core::RunningGameInfo::startTime, core::RunningGameInfo::state, core::RunningGameInfo::trackedPid, core::RunningGameInfo::trackedProcessName, and core::RunningGameInfo::winePrefix.
Referenced by getAllRunningGames(), and operator=().
| std::chrono::seconds core::LaunchController::getSessionDuration | ( | const std::string & | gameId | ) | const |
Get current session duration for a running game.
Definition at line 367 of file launch_controller.cpp.
References GameProcessManager::getGameSessionDuration(), and GameProcessManager::instance().
Referenced by operator=().
| std::string core::LaunchController::getSteamStateDescription | ( | ) | const |
Get Steam state description.
Definition at line 346 of file launch_controller.cpp.
References SteamProcessMonitor::instance(), SteamProcessMonitor::NOT_RUNNING, SteamProcessMonitor::RUNNING, SteamProcessMonitor::STARTING, and SteamProcessMonitor::STOPPING.
Referenced by operator=().
| std::chrono::seconds core::LaunchController::getTotalSessionPlayTime | ( | ) | const |
Get total play time recorded for this session.
Definition at line 389 of file launch_controller.cpp.
References GameProcessManager::instance(), and isGameRunning().
Referenced by operator=().
| bool core::LaunchController::hasRunningGames | ( | ) | const |
Check if any game is currently running.
Definition at line 243 of file launch_controller.cpp.
References GameProcessManager::getRunningGameIds(), and GameProcessManager::instance().
Referenced by operator=().
| bool core::LaunchController::isGameRunning | ( | const std::string & | gameId | ) | const |
Check if a specific game is running.
Definition at line 248 of file launch_controller.cpp.
References GameProcessManager::instance(), and GameProcessManager::isGameRunning().
Referenced by getGameState(), getTotalSessionPlayTime(), killGame(), launchGame(), operator=(), and stopGame().
| bool core::LaunchController::isSteamRunning | ( | ) | const |
Check if Steam is running.
Definition at line 336 of file launch_controller.cpp.
References SteamProcessMonitor::getCurrentState(), SteamProcessMonitor::instance(), and SteamProcessMonitor::RUNNING.
Referenced by operator=().
| bool core::LaunchController::killGame | ( | const std::string & | gameId | ) |
Force kill a running game.
Definition at line 197 of file launch_controller.cpp.
References core::LaunchStateChangedEvent::gameId, GameProcessManager::instance(), isGameRunning(), core::Killing, core::LaunchStateChangedEvent::message, core::LaunchStateChangedEvent::newState, core::LaunchStateChangedEvent::oldState, core::Running, and GameProcessManager::stopGame().
Referenced by operator=().
| bool core::LaunchController::launchGame | ( | const std::string & | gameId, |
| const Game & | game ) |
Launch a game Returns true if launch was initiated (doesn't mean success yet).
Definition at line 78 of file launch_controller.cpp.
References LaunchController(), Logger::error(), core::LaunchErrorEvent::errorMessage, core::LaunchErrorEvent::gameId, core::LaunchStateChangedEvent::gameId, core::Idle, GameLaunchManager::instance(), GameProcessManager::instance(), isGameRunning(), core::LaunchErrorEvent::isRecoverable, launchGame(), core::LaunchStateChangedEvent::message, core::LaunchStateChangedEvent::newState, core::LaunchStateChangedEvent::oldState, core::PreparingLaunch, GameLaunchManager::requestLaunch(), and GameLaunchManager::setCompletionCallback().
Referenced by launchGame(), and operator=().
|
delete |
References LaunchController().
|
defaultnoexcept |
References LaunchController(), getAllRunningGames(), getGameState(), getRunningGameCount(), getRunningGameInfo(), getSessionDuration(), getSteamStateDescription(), getTotalSessionPlayTime(), hasRunningGames(), isGameRunning(), isSteamRunning(), killGame(), launchGame(), requestSteamStart(), setOnLaunchError(), setOnProcessExited(), setOnProcessStarted(), setOnStateChanged(), stopAllGames(), stopGame(), and update().
| void core::LaunchController::requestSteamStart | ( | ) |
Request Steam to start (async).
Definition at line 341 of file launch_controller.cpp.
References SteamProcessMonitor::instance(), and SteamProcessMonitor::requestSteamStart().
Referenced by operator=().
| void core::LaunchController::setOnLaunchError | ( | OnLaunchError | callback | ) |
Definition at line 429 of file launch_controller.cpp.
Referenced by operator=().
| void core::LaunchController::setOnProcessExited | ( | OnProcessExited | callback | ) |
Definition at line 423 of file launch_controller.cpp.
Referenced by operator=().
| void core::LaunchController::setOnProcessStarted | ( | OnProcessStarted | callback | ) |
Definition at line 417 of file launch_controller.cpp.
Referenced by operator=().
| void core::LaunchController::setOnStateChanged | ( | OnStateChanged | callback | ) |
Definition at line 411 of file launch_controller.cpp.
Referenced by operator=().
| void core::LaunchController::stopAllGames | ( | ) |
Stop all running games.
Definition at line 229 of file launch_controller.cpp.
References GameProcessManager::getRunningGameIds(), GameProcessManager::instance(), and GameProcessManager::stopGame().
Referenced by operator=().
| bool core::LaunchController::stopGame | ( | const std::string & | gameId | ) |
Request graceful stop of a running game.
Definition at line 165 of file launch_controller.cpp.
References core::LaunchStateChangedEvent::gameId, GameProcessManager::instance(), isGameRunning(), core::LaunchStateChangedEvent::message, core::LaunchStateChangedEvent::newState, core::LaunchStateChangedEvent::oldState, core::Running, GameProcessManager::stopGame(), and core::Stopping.
Referenced by operator=().
| void core::LaunchController::update | ( | ) |
Called periodically to update internal state (process monitoring, etc.) UI layer should call this from its main loop or a timer.
Definition at line 439 of file launch_controller.cpp.
References core::Completed, core::ProcessExitedEvent::exitCode, core::LaunchStateChangedEvent::gameId, core::ProcessExitedEvent::gameId, core::ProcessStartedEvent::gameId, GameProcessManager::getLastExitCode(), GameProcessManager::getRunningProcessSnapshot(), GameProcessManager::instance(), GameSessionService::instance(), GameProcessManager::isGameRunning(), core::Killing, core::Launching, core::LaunchStateChangedEvent::message, core::LaunchStateChangedEvent::newState, core::LaunchStateChangedEvent::oldState, GameSessionService::onGameStarted(), GameSessionService::onGameStopped(), core::PreparingLaunch, core::ProcessStartedEvent::processId, core::ProcessStartedEvent::processName, core::Running, core::ProcessExitedEvent::sessionDuration, core::Stopping, GameProcessManager::update(), and core::VerifyingStart.
Referenced by operator=().