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

#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.

Detailed Description

Definition at line 99 of file launch_controller.h.

Member Typedef Documentation

◆ OnLaunchError

using core::LaunchController::OnLaunchError = std::function<void(const LaunchErrorEvent&)>

Definition at line 106 of file launch_controller.h.

◆ OnProcessExited

using core::LaunchController::OnProcessExited = std::function<void(const ProcessExitedEvent&)>

Definition at line 105 of file launch_controller.h.

◆ OnProcessStarted

Definition at line 104 of file launch_controller.h.

◆ OnStateChanged

Definition at line 103 of file launch_controller.h.

Constructor & Destructor Documentation

◆ LaunchController() [1/3]

core::LaunchController::LaunchController ( )

◆ ~LaunchController()

core::LaunchController::~LaunchController ( )

◆ LaunchController() [2/3]

core::LaunchController::LaunchController ( const LaunchController & )
delete

References LaunchController().

◆ LaunchController() [3/3]

core::LaunchController::LaunchController ( LaunchController && )
defaultnoexcept

References LaunchController().

Member Function Documentation

◆ getAllRunningGames()

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=().

◆ getGameState()

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=().

◆ getRunningGameCount()

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=().

◆ getRunningGameInfo()

◆ getSessionDuration()

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=().

◆ getSteamStateDescription()

std::string core::LaunchController::getSteamStateDescription ( ) const

◆ getTotalSessionPlayTime()

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=().

◆ hasRunningGames()

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=().

◆ isGameRunning()

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().

◆ isSteamRunning()

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=().

◆ killGame()

◆ launchGame()

◆ operator=() [1/2]

LaunchController & core::LaunchController::operator= ( const LaunchController & )
delete

References LaunchController().

◆ operator=() [2/2]

◆ requestSteamStart()

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=().

◆ setOnLaunchError()

void core::LaunchController::setOnLaunchError ( OnLaunchError callback)

Definition at line 429 of file launch_controller.cpp.

Referenced by operator=().

◆ setOnProcessExited()

void core::LaunchController::setOnProcessExited ( OnProcessExited callback)

Definition at line 423 of file launch_controller.cpp.

Referenced by operator=().

◆ setOnProcessStarted()

void core::LaunchController::setOnProcessStarted ( OnProcessStarted callback)

Definition at line 417 of file launch_controller.cpp.

Referenced by operator=().

◆ setOnStateChanged()

void core::LaunchController::setOnStateChanged ( OnStateChanged callback)

Definition at line 411 of file launch_controller.cpp.

Referenced by operator=().

◆ stopAllGames()

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=().

◆ stopGame()

◆ update()


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