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

Service for generating smart game setting recommendations. More...

#include <game_suggestion_service.h>

Public Types

using SuggestionsCallback = std::function<void(const GameSuggestions&)>

Static Public Member Functions

static int applySuggestions (Game &game, const GameSuggestions &suggestions, SuggestionPriority applyLevel=SuggestionPriority::Recommended)
 Apply suggestions to a game's runner config.
static std::string categoryToString (SuggestionCategory category)
 Get category as human-readable string.
static std::vector< std::string > checkConflicts (const GameSuggestions &suggestions)
 Check for conflicting environment variables.
static GameSuggestions getLocalSuggestions (const Game &game)
 Get local-only suggestions (no network requests).
static GameSuggestions getSuggestions (const Game &game)
 Get suggestions for a game.
static GameSuggestions getSuggestions (int steamAppId, const std::string &gameName)
 Get suggestions by Steam App ID.
static void getSuggestionsAsync (const Game &game, SuggestionsCallback callback)
 Get suggestions asynchronously.
static void getSuggestionsAsync (int steamAppId, const std::string &gameName, SuggestionsCallback callback)
 Get suggestions by Steam App ID asynchronously.
static bool isRunnerAvailable (const std::string &runnerName)
 Check if a runner exists on the system.
static std::string priorityToString (SuggestionPriority priority)
 Get priority as human-readable string.
static void setCapabilitiesOverrideForTesting (const SystemCapabilities *caps)
 Override the SystemCapabilities consulted by suggestion generation.
static bool validateSuggestion (const GameSuggestion &suggestion, std::string &reason)
 Validate a suggestion before applying.

Detailed Description

Service for generating smart game setting recommendations.

Definition at line 196 of file game_suggestion_service.h.

Member Typedef Documentation

◆ SuggestionsCallback

using GameSuggestionService::SuggestionsCallback = std::function<void(const GameSuggestions&)>

Definition at line 200 of file game_suggestion_service.h.

Member Function Documentation

◆ applySuggestions()

int GameSuggestionService::applySuggestions ( Game & game,
const GameSuggestions & suggestions,
SuggestionPriority applyLevel = SuggestionPriority::Recommended )
static

Apply suggestions to a game's runner config.

Parameters
gameGame to modify (in-place)
suggestionsSuggestions to apply
applyLevelWhat priority level to auto-apply
Returns
Number of suggestions applied

Definition at line 2137 of file game_suggestion_service.cpp.

References GameRunnerConfig::arguments, checkConflicts(), Logger::debug(), GameRunnerConfig::environmentVariables, GameSuggestions::gameName, Logger::info(), priorityToString(), Proton, GameRunnerConfig::protonVersion, Game::runner, Game::runnerConfig, GameRunnerConfig::runnerVersion, GameSuggestions::suggestions, validateSuggestion(), Logger::warn(), and GameRunnerConfig::wineDLL.

◆ categoryToString()

std::string GameSuggestionService::categoryToString ( SuggestionCategory category)
static

Get category as human-readable string.

Definition at line 2531 of file game_suggestion_service.cpp.

References Audio, Compatibility, Environment, General, Graphics, Input, Performance, and Runner.

◆ checkConflicts()

std::vector< std::string > GameSuggestionService::checkConflicts ( const GameSuggestions & suggestions)
static

Check for conflicting environment variables.

Parameters
suggestionsAll suggestions being applied
Returns
Vector of conflict descriptions (empty if no conflicts)

Definition at line 2425 of file game_suggestion_service.cpp.

References AMD, Intel, NVIDIA, and GameSuggestions::suggestions.

Referenced by applySuggestions().

◆ getLocalSuggestions()

GameSuggestions GameSuggestionService::getLocalSuggestions ( const Game & game)
static

Get local-only suggestions (no network requests).

Parameters
gameThe game to get suggestions for
Returns
GameSuggestions based on system detection only (GPU, kernel, CachyOS)

Safe to call from the UI thread. Skips ProtonDB lookups.

Definition at line 2622 of file game_suggestion_service.cpp.

References GameSuggestions::detectedGPU, GameSuggestions::gameName, GameSuggestions::isCachyOS, Game::metadata, Game::name, GameMetadata::steamAppId, and GameSuggestions::steamAppId.

◆ getSuggestions() [1/2]

GameSuggestions GameSuggestionService::getSuggestions ( const Game & game)
static

Get suggestions for a game.

Parameters
gameThe game to get suggestions for
Returns
GameSuggestions with all recommendations

This may make network requests to ProtonDB. For UI updates, prefer getSuggestionsAsync().

Definition at line 389 of file game_suggestion_service.cpp.

References getSuggestions(), Game::metadata, Game::name, and GameMetadata::steamAppId.

Referenced by getSuggestions(), getSuggestionsAsync(), and RecommendationsWidget::loadRecommendations().

◆ getSuggestions() [2/2]

◆ getSuggestionsAsync() [1/2]

void GameSuggestionService::getSuggestionsAsync ( const Game & game,
SuggestionsCallback callback )
static

Get suggestions asynchronously.

Parameters
gameThe game to get suggestions for
callbackFunction to call with results

Definition at line 564 of file game_suggestion_service.cpp.

References getSuggestionsAsync(), Game::metadata, Game::name, and GameMetadata::steamAppId.

Referenced by getSuggestionsAsync().

◆ getSuggestionsAsync() [2/2]

void GameSuggestionService::getSuggestionsAsync ( int steamAppId,
const std::string & gameName,
SuggestionsCallback callback )
static

Get suggestions by Steam App ID asynchronously.

Parameters
steamAppIdSteam App ID
gameNameGame name
callbackFunction to call with results

Definition at line 569 of file game_suggestion_service.cpp.

References getSuggestions(), and Logger::warn().

◆ isRunnerAvailable()

bool GameSuggestionService::isRunnerAvailable ( const std::string & runnerName)
static

Check if a runner exists on the system.

Parameters
runnerNameThe runner name to check
Returns
true if the runner is available

Definition at line 2339 of file game_suggestion_service.cpp.

References Logger::debug(), and Logger::warn().

Referenced by validateSuggestion().

◆ priorityToString()

std::string GameSuggestionService::priorityToString ( SuggestionPriority priority)
static

Get priority as human-readable string.

Definition at line 2514 of file game_suggestion_service.cpp.

References Critical, Informational, Optional, and Recommended.

Referenced by applySuggestions(), and getSuggestions().

◆ setCapabilitiesOverrideForTesting()

void GameSuggestionService::setCapabilitiesOverrideForTesting ( const SystemCapabilities * caps)
static

Override the SystemCapabilities consulted by suggestion generation.

Intended for unit tests that need to exercise platform-dependent branches deterministically (e.g., NTSync available, CachyOS detected, AMD vs NVIDIA GPU).

When set to non-null, every internal capabilities read returns the override instead of calling SystemInfoService::instance(). Reset to nullptr to restore normal behaviour.

Not thread-safe — intended for single-threaded test code.

Definition at line 2581 of file game_suggestion_service.cpp.

◆ validateSuggestion()

bool GameSuggestionService::validateSuggestion ( const GameSuggestion & suggestion,
std::string & reason )
static

Validate a suggestion before applying.

Parameters
suggestionThe suggestion to validate
reasonOutput: reason if invalid
Returns
true if the suggestion can be safely applied

Validation checks:

  • Runner exists on the system
  • Environment variable keys are valid
  • No known conflicting combinations
  • Values are within expected ranges

Definition at line 2241 of file game_suggestion_service.cpp.

References AMD, GameSuggestion::envKey, GameSuggestion::envValue, Intel, isRunnerAvailable(), NVIDIA, and GameSuggestion::recommendedRunner.

Referenced by applySuggestions().


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