stmm-games-doc  0.32.0
Classes | Public Member Functions | Static Public Member Functions | List of all members
stmg::StdConfig Class Reference
Inheritance diagram for stmg::StdConfig:
Inheritance graph
[legend]

Classes

class  CapabilityAssignment
 Tells how device capabilities can be assigned (or not) to players. More...
 
struct  Init
 
class  KeyAction
 The key action class. More...
 

Public Member Functions

 StdConfig (StdConfig::Init &&oInit) noexcept
 Constructor. More...
 
const std::string & getAppName () const noexcept override
 The name of the application. More...
 
const std::string & getAppVersion () const noexcept override
 The version of the application. More...
 
shared_ptr< stmi::DeviceManagergetDeviceManager () const noexcept override
 Get the device manager. More...
 
const AppConstraintsgetAppConstraints () const noexcept override
 The application constraints. More...
 
const CapabilityAssignmentgetCapabilityAssignment () const noexcept
 How capabilities are assigned (or not) to players. More...
 
int32_t getTotKeyActions () const noexcept override
 The total number of key actions. More...
 
int32_t getKeyActionId (const std::string &sKeyActionName) const noexcept override
 Get to the key action id from its name. More...
 
bool isEventAssignedToActivePlayer () const noexcept override
 Tells whether events should be assigned to the active player. More...
 
bool soundEnabled () const noexcept override
 Whether the game plays sounds. More...
 
bool canPlayPerPlayerSounds () const noexcept override
 Whether allows playback devices to be assigned to players. More...
 
bool isTestMode () const noexcept override
 Whether in testing mode. More...
 
int32_t getMaxGamePlayedHistory () const noexcept
 The maximum number of games in the recently played games history. More...
 
shared_ptr< stmi::PlaybackCapabilitygetDefaultPlayback () const noexcept
 Get the default playback capability. More...
 
const KeyActiongetKeyAction (int32_t nKeyActionId) const noexcept
 Get Key Action data. More...
 
const NamedObjIndex< shared_ptr< Option > > & getOptions (OwnerType eOwner) const noexcept override
 Get the options for an owner type. More...
 
const shared_ptr< Option > & getOption (OwnerType eOwner, const std::string &sName) const noexcept override
 Get an option by name. More...
 
int32_t getTotVisibleOptions () const noexcept
 
int32_t getTotVisibleOptions (OwnerType eOwner) const noexcept
 
- Public Member Functions inherited from stmg::AppConfig
virtual ~AppConfig () noexcept=default
 

Static Public Member Functions

static const std::string & getAIOptionName () noexcept
 The AI option name. More...
 
static const std::string & getSoundEnabledOptionName () noexcept
 The sound enabled option name. More...
 
static const std::string & getPerPlayerSoundOptionName () noexcept
 The "per player sound" option name. More...
 
static const std::string & getSoundVolumeOptionName () noexcept
 The sound volume option name. More...
 
static shared_ptr< BoolOptioncreateAIOption (OwnerType eOwnerType, const std::string &sAIOptionDesc) noexcept
 Create an AI option to pass to the constructor StdConfig::StdConfig(). More...
 
static shared_ptr< BoolOptioncreateSoundEnabledOption (bool bSoundEnabled) noexcept
 Create the SoundEnabled option to pass to the constructor of StdConfig. More...
 
static shared_ptr< BoolOptioncreatePerPlayerSoundOption (const std::string &sOptionDesc) noexcept
 Create the PerPlayerSound option to pass to the constructor of StdConfig. More...
 
static shared_ptr< IntOptioncreateSoundVolumeOption (OwnerType eOwnerType, const std::string &sOptionDesc, const shared_ptr< BoolOption > &refPerPlayerSound, const shared_ptr< BoolOption > &refAIPlayer) noexcept
 Create a SoundVolume option to pass to the constructor of StdConfig. More...
 

Constructor & Destructor Documentation

◆ StdConfig()

stmg::StdConfig::StdConfig ( StdConfig::Init &&  oInit)
explicitnoexcept

Constructor.

An option cannot be slave of an option that is not also in Init::m_aOptions.

An AI BoolOption is always defined for each type of owner and created automatically if not in Init::m_aOptions. If you need to create an AI option use StdConfig::createAIOption(). AI options should be passed with Init::m_aOptions only if AI players are allowed, that is if getAppConstraints().allowsAI() == true. If created automatically AI options are placed before all other options (passed in Init::m_aOptions).

Sound options are always defined and created automatically if not in Init::m_aOptions. If you need to create a sound option use StdConfig::createSoundEnabledOption(), StdConfig::createPerPlayerSoundOption(), StdConfig::createSoundVolumeOption().

Sound options should only be passed in Init::m_aOptions if Init::m_bSoundEnabled == true. The option created by StdConfig::createSoundEnabledOption() should only be passed if Init::m_bSoundPerPlayerAllowed == true. The option created by StdConfig::createSoundVolumeOption() for players should only be passed if Init::m_bSoundPerPlayerAllowed == true.

Parameters
oInitThe initialization structure.

Member Function Documentation

◆ canPlayPerPlayerSounds()

bool stmg::StdConfig::canPlayPerPlayerSounds ( ) const
inlineoverridevirtualnoexcept

Whether allows playback devices to be assigned to players.

If true the game allows playback devices such as head phones to be assigned to each player for personalized output. Ignored if playsSounds() returns false.

Returns
Whether sounds can be player specific.

Implements stmg::AppConfig.

◆ createAIOption()

static shared_ptr<BoolOption> stmg::StdConfig::createAIOption ( OwnerType  eOwnerType,
const std::string &  sAIOptionDesc 
)
staticnoexcept

Create an AI option to pass to the constructor StdConfig::StdConfig().

This function should only be used if getAppConstraints().allowsAI() == true.

If an AI option for a certain owner type is not passed to the constructor it is created automatically with some default description string. This function allows you to create the option and set the description string and possibly use it as a master option for another slave option (ex. 'AISmartness').

If the owner is game, the created option is readonly and invisible and the default value is true iff AI players are allowed.

If the owner is team, the option is readonly. It is visible iff AI players are allowed. The default value should be ignored since a team should be considered AI only if all its players are AI.

If the owner is player, the option is modifiable and visible iff AI players are allowed. The default value is false (human player).

Parameters
eOwnerTypeThe owner type.
sAIOptionDescThe description of the option.
Returns
The AI option for a certain owner type.

◆ createPerPlayerSoundOption()

static shared_ptr<BoolOption> stmg::StdConfig::createPerPlayerSoundOption ( const std::string &  sOptionDesc)
staticnoexcept

Create the PerPlayerSound option to pass to the constructor of StdConfig.

Parameters
sOptionDescThe description of the option.
Returns
The PerPlayerSound game option.

◆ createSoundEnabledOption()

static shared_ptr<BoolOption> stmg::StdConfig::createSoundEnabledOption ( bool  bSoundEnabled)
staticnoexcept

Create the SoundEnabled option to pass to the constructor of StdConfig.

The created option is owned by game and is read-only and invisible. Its default value is set to bSoundEnabled. It must be the same as Init::m_bSoundEnabled.

This function allows you to create the option to possibly use it as a master option for another slave option (ex. 'EnableCountdownSounds').

Parameters
bSoundEnabledWhether sound is enabled or not.
Returns
The unique SoundEnabled option.

◆ createSoundVolumeOption()

static shared_ptr<IntOption> stmg::StdConfig::createSoundVolumeOption ( OwnerType  eOwnerType,
const std::string &  sOptionDesc,
const shared_ptr< BoolOption > &  refPerPlayerSound,
const shared_ptr< BoolOption > &  refAIPlayer 
)
staticnoexcept

Create a SoundVolume option to pass to the constructor of StdConfig.

Parameters
eOwnerTypeThe owner type. Must either OwnerTyoe::GAME or OwnerTyoe::PLAYER.
sOptionDescThe description of the option.
refPerPlayerSoundThe master PerPlayerSound option possibly created with createSoundEnabledOption(). Cannot be null
refAIPlayerThe master AI option if eOwnerType == OwnerTyoe::PLAYER and AI allowed, otherwise must be null.
Returns
The SoundVolume option.

◆ getAIOptionName()

static const std::string& stmg::StdConfig::getAIOptionName ( )
staticnoexcept

The AI option name.

This name is the same for OwnerType::GAME, OwnerType::TEAM and OwnerType::PLAYER options.

The option, if passed to the constructor with m_aOptions, must be a BoolOption, not be a slave.

Returns
The AI option name.

◆ getAppConstraints()

const AppConstraints& stmg::StdConfig::getAppConstraints ( ) const
inlineoverridevirtualnoexcept

The application constraints.

Returns
The constraints.

Implements stmg::AppConfig.

◆ getAppName()

const std::string& stmg::StdConfig::getAppName ( ) const
inlineoverridevirtualnoexcept

The name of the application.

Returns
The application name. Cannot be empty.

Implements stmg::AppConfig.

◆ getAppVersion()

const std::string& stmg::StdConfig::getAppVersion ( ) const
inlineoverridevirtualnoexcept

The version of the application.

Returns
The application version. Cannot be empty.

Implements stmg::AppConfig.

◆ getCapabilityAssignment()

const CapabilityAssignment& stmg::StdConfig::getCapabilityAssignment ( ) const
inlinenoexcept

How capabilities are assigned (or not) to players.

Returns
The mode.

◆ getDefaultPlayback()

shared_ptr<stmi::PlaybackCapability> stmg::StdConfig::getDefaultPlayback ( ) const
noexcept

Get the default playback capability.

Returns
The playback capability or null if none found.

◆ getDeviceManager()

shared_ptr<stmi::DeviceManager> stmg::StdConfig::getDeviceManager ( ) const
inlineoverridevirtualnoexcept

Get the device manager.

The device manager is the source of the input events.

Returns
The device manager. Cannot be null.

Implements stmg::AppConfig.

◆ getKeyAction()

const KeyAction& stmg::StdConfig::getKeyAction ( int32_t  nKeyActionId) const
noexcept

Get Key Action data.

Parameters
nKeyActionIdThe key action id. Cannot be a negative number.
Returns
The key action object or undefined if not a valid id.

◆ getKeyActionId()

int32_t stmg::StdConfig::getKeyActionId ( const std::string &  sKeyActionName) const
overridevirtualnoexcept

Get to the key action id from its name.

Parameters
sKeyActionNameThe key action name.
Returns
The key action id or -1 if not found.

Implements stmg::AppConfig.

◆ getMaxGamePlayedHistory()

int32_t stmg::StdConfig::getMaxGamePlayedHistory ( ) const
inlinenoexcept

The maximum number of games in the recently played games history.

Returns
The maximum number of remembered games. Is >= 0.

◆ getOption()

const shared_ptr<Option>& stmg::StdConfig::getOption ( OwnerType  eOwner,
const std::string &  sName 
) const
overridevirtualnoexcept

Get an option by name.

Parameters
eOwnerThe owner type.
sNameThe name of the option. Cannot be empty.
Returns
The option or null if not defined.

Implements stmg::AppConfig.

◆ getOptions()

const NamedObjIndex< shared_ptr<Option> >& stmg::StdConfig::getOptions ( OwnerType  eOwner) const
overridevirtualnoexcept

Get the options for an owner type.

Parameters
eOwnerThe owner type.
Returns
The options.

Implements stmg::AppConfig.

◆ getPerPlayerSoundOptionName()

static const std::string& stmg::StdConfig::getPerPlayerSoundOptionName ( )
staticnoexcept

The "per player sound" option name.

Returns
The option name.

◆ getSoundEnabledOptionName()

static const std::string& stmg::StdConfig::getSoundEnabledOptionName ( )
staticnoexcept

The sound enabled option name.

Returns
The option name.

◆ getSoundVolumeOptionName()

static const std::string& stmg::StdConfig::getSoundVolumeOptionName ( )
staticnoexcept

The sound volume option name.

Returns
The option name.

◆ getTotKeyActions()

int32_t stmg::StdConfig::getTotKeyActions ( ) const
overridevirtualnoexcept

The total number of key actions.

A valid key action id is a number from 0 to getTotKeyActions()-1.

Returns
The total number of key actions.

Implements stmg::AppConfig.

◆ getTotVisibleOptions() [1/2]

int32_t stmg::StdConfig::getTotVisibleOptions ( ) const
noexcept

◆ getTotVisibleOptions() [2/2]

int32_t stmg::StdConfig::getTotVisibleOptions ( OwnerType  eOwner) const
noexcept

◆ isEventAssignedToActivePlayer()

bool stmg::StdConfig::isEventAssignedToActivePlayer ( ) const
inlineoverridevirtualnoexcept

Tells whether events should be assigned to the active player.

If this function returns true, the game, when it receives an event from a device's capability that wasn't assigned to a player in the preferences, will try to assign it to the unique active human player. If more than one human player is active at the moment the event is received, it is dropped.

This is useful in turn based games where the two players use the same device (ex. the mouse). Be aware that it can cause inconsistencies. Example: if between the press and the release of a joystick button the active player is changed the release event is sent to a different player.

Returns
Whether to look for a target human player for an unassigned event.

Implements stmg::AppConfig.

◆ isTestMode()

bool stmg::StdConfig::isTestMode ( ) const
inlineoverridevirtualnoexcept

Whether in testing mode.

This flag can be used to output additional information.

Returns
Whether testing.

Implements stmg::AppConfig.

◆ soundEnabled()

bool stmg::StdConfig::soundEnabled ( ) const
inlineoverridevirtualnoexcept

Whether the game plays sounds.

If this function returns false sounds are not played and the view preferences should not show widgets to choose the volume.

Returns
Whether sounds activated.

Implements stmg::AppConfig.