CRM64Pro GDK v0.14.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
CRM64Pro::ConfigMgr

Config Manager class. More...

Detailed Description

Config Manager class.

Public Member Functions

bool info (Sint32 iMode=0) override
 Request Configuration Manager information.
bool audioInit (eAudioFreq eAF=AF_DEFAULT, eAudioSample eAS=AS_DEFAULT, eAudioMode eAM=AM_DEFAULT)
 Initialize the audio system.
bool audioStatus (eAudioFreq *eAF=nullptr, eAudioSample *eAS=nullptr, eAudioMode *eAM=nullptr)
 Check audio system status.
bool audioClose ()
 Close the audio system.
bool audioSetDriver (eConfigAudioDriver eCAD)
 Set the audio driver.
eConfigAudioDriver audioGetDriver () const
 Get the audio driver.
const char * audioGetDriverInUse () const
 Get the audio driver name in use.
bool audioSetMasterGain (float fGain)
 Set Master gain (Volume).
float audioGetMasterGain () const
 Get Master gain (Volume).
bool audioSetTagGain (eAudioTrackTag eTag, float fGain)
 Set Gain (Volume) for a specific audio track tag category.
float audioGetTagGain (eAudioTrackTag eTag) const
 Get the current gain for a specific audio track tag category.
MIX_Mixer * audioGetMixer () const
 Get the internal SDL3 Mixer Device handle.
Sint32 create (const string &sName, Uint32 iUnused=0) override
 Create a new screen.
bool close (Sint32 idScreen) override
 Close and destroy a screen.
Sint32 getCount () const override
 Get number of loaded objects.
Sint32 setName (Sint32 idScreen, const string &sName) override
 Change the object name.
void reset (Sint32 iMode=0)
 Set all default values, close audio system, remove all existing screens and create the "default" screen.
Screenget (Sint32 idScreen=0)
 Get a pointer to the screen using its handle.
Screenget (SDL_Window *wScreen)
 Get a pointer to the screen using a SDL_Window pointer.
Sint32 save (const string &sConfigXML, const string &sCDCFile="")
 Save current audio/screens configuration.
Sint32 loadFromFile (const string &sConfigXML)
 Load audio/screen configuration from a file.
Sint32 load (const string &sCDCFile, const string &sConfigXML)
 Load audio/screen configuration from a CDC file.
Sint32 load (const Sint32 idCDC, const string &sConfigXML)
 Load audio/screen configuration from a CDC file.
Sint32 setup (const string &sConfigXML, const string &sConfigCDC="", const string &sCustomSetupXML="")
 Open the setup window for configuring audio/screen settings.
Sint32 setup (const string &sConfigXML, Sint32 idConfigCDC, const string &sCustomSetupXML="")
 Open the setup window for configuring audio/screen settings.

Public Attributes

Uint8 iMTFriendly

Member Function Documentation

◆ info()

bool CRM64Pro::ConfigMgr::info ( Sint32 iMode = 0)
override

Request Configuration Manager information.

Writes manager information to the default log. Displays: general settings (multithread friendly flag), graphics information (displays, renderer drivers, screens), and audio information (devices, drivers, output).

Parameters
iMode-1 to display only manager information. 0 (default) to display manager and all screens. Specific object ID to display manager and only that screen.
Returns
true on success or false on failure.

◆ audioInit()

bool CRM64Pro::ConfigMgr::audioInit ( eAudioFreq eAF = AF_DEFAULT,
eAudioSample eAS = AS_DEFAULT,
eAudioMode eAM = AM_DEFAULT )

Initialize the audio system.

The first call to this method initializes the SDL audio subsystem.

Parameters
eAFAudio frequency. Default AF_DEFAULT (44100Hz).
eASAudio sample format. Default AS_DEFAULT (S16SYS).
eAMAudio mode. Default AM_DEFAULT (Stereo).
Returns
true on success or false on failure.

◆ audioStatus()

bool CRM64Pro::ConfigMgr::audioStatus ( eAudioFreq * eAF = nullptr,
eAudioSample * eAS = nullptr,
eAudioMode * eAM = nullptr )

Check audio system status.

Parameters
eAF::eAudioFreq enum pointer filled in with audio frequency. If nullptr (default), this value is not retrieved.
eAS::eAudioSample enum pointer filled in with audio sampling. If nullptr (default), this value is not retrieved.
eAM::eAudioMode enum pointer filled in with audio mode. If nullptr (default), this value is not retrieved.
Returns
true on success (audio output is enabled) or false when audio output is disabled.

◆ audioClose()

bool CRM64Pro::ConfigMgr::audioClose ( )

Close the audio system.

Recommended to call at the very end of your application, after closing all resources and before Main::Terminate(). If not called, it will be automatically called on Main::Terminate().

Warning
When closing the audio system, all loaded music is also cleaned up. If your application continues, you must reload music resources. Note: audio resources are kept.
Returns
true on success or false on failure.

◆ audioSetDriver()

bool CRM64Pro::ConfigMgr::audioSetDriver ( eConfigAudioDriver eCAD)

Set the audio driver.

Parameters
eCADaudio driver. Check ::eConfigAudioDriver enum for further information.
Returns
true on success or false on failure.
Note
Once audio is initialized, this method has no effect.

◆ audioGetDriver()

eConfigAudioDriver CRM64Pro::ConfigMgr::audioGetDriver ( ) const

Get the audio driver.

Returns the audio driver set by default or by audioSetDriver() method. Note that it could differ from the driver in use. Use audioGetDriverInUse() to get the actual driver.

Returns
::eConfigAudioDriver enum value on success or CAD_ERROR on failure.

◆ audioGetDriverInUse()

const char * CRM64Pro::ConfigMgr::audioGetDriverInUse ( ) const

Get the audio driver name in use.

Returns the audio driver name in use (e.g., "wasapi", "directsound", "pulseaudio"). The audio must be initialized.

Returns
The driver name string or nullptr on failure/not initialized.

◆ audioSetMasterGain()

bool CRM64Pro::ConfigMgr::audioSetMasterGain ( float fGain)

Set Master gain (Volume).

Sets the global volume for the mixer device.

Parameters
fGainVolume float (0.0f to 2.0f). 1.0f is nominal.
Returns
true on success or false on failure.

◆ audioGetMasterGain()

float CRM64Pro::ConfigMgr::audioGetMasterGain ( ) const

Get Master gain (Volume).

Returns
the global volume for all the tracks (0.0f - 2.0f).

◆ audioSetTagGain()

bool CRM64Pro::ConfigMgr::audioSetTagGain ( eAudioTrackTag eTag,
float fGain )

Set Gain (Volume) for a specific audio track tag category.

Updates the stored volume for the tag category and immediately updates all active tracks of that type.

Parameters
eTagThe tag category to update (Music, SFX, etc).
fGainVolume (0.0f - 2.0f). 1.0f is nominal.
Returns
true on success or false on failure.

◆ audioGetTagGain()

float CRM64Pro::ConfigMgr::audioGetTagGain ( eAudioTrackTag eTag) const

Get the current gain for a specific audio track tag category.

Retrieves the stored volume multiplier for the given tag.

Parameters
eTagThe tag category to query (Music, SFX, etc).
Returns
The gain value for the given tag (0.0f - 2.0f).

◆ audioGetMixer()

MIX_Mixer * CRM64Pro::ConfigMgr::audioGetMixer ( ) const

Get the internal SDL3 Mixer Device handle.

Returns the raw pointer to the initialized MIX_Mixer device. This is primarily used internally by AudioTrackMgr to create tracks.

Returns
A pointer to the active MIX_Mixer, or nullptr if audio is not initialized.

◆ create()

Sint32 CRM64Pro::ConfigMgr::create ( const string & sName,
Uint32 iUnused = 0 )
override

Create a new screen.

Parameters
sNamethe name to give to the screen object (e.g. 'myScreen'). The object name must be unique with a maximum of 64 characters or will be truncated.
iUnusedunused for the time being.
Returns
>0 on success (the Screen id) or a negative error code on failure.
Note
Once created, the screen is ready to be modified and eventually shown using Screen::show().

◆ close()

bool CRM64Pro::ConfigMgr::close ( Sint32 idScreen)
override

Close and destroy a screen.

Parameters
idScreen0 for closing all screens or the Screen id. This removes the screen and all associated resources (SDL window, SDL renderer, etc.). Additionally, it informs ImageMgr to remove all textures created for the screen.
Returns
true on success or false on failure.
Note
If you forget to close a Screen, it will be automatically closed when the GDK terminates.

◆ getCount()

Sint32 CRM64Pro::ConfigMgr::getCount ( ) const
override

Get number of loaded objects.

Returns
Number of screen objects.

◆ setName()

Sint32 CRM64Pro::ConfigMgr::setName ( Sint32 idScreen,
const string & sName )
override

Change the object name.

Parameters
idScreenScreen id.
sNamethe name to give to the screen object (e.g. 'myScreen'). The object name must be unique with a maximum of 64 characters or will be truncated.
Returns
0 on success, or a negative error code on failure.

◆ reset()

void CRM64Pro::ConfigMgr::reset ( Sint32 iMode = 0)

Set all default values, close audio system, remove all existing screens and create the "default" screen.

Parameters
iMode0 for resetting general, audio and screen values or 1 for resetting only the screen values.

◆ get() [1/2]

Screen * CRM64Pro::ConfigMgr::get ( Sint32 idScreen = 0)

Get a pointer to the screen using its handle.

Parameters
idScreenScreen id. By default, selects the default screen.
Returns
nullptr if screen object was not found, or a valid pointer to the screen object.

◆ get() [2/2]

Screen * CRM64Pro::ConfigMgr::get ( SDL_Window * wScreen)

Get a pointer to the screen using a SDL_Window pointer.

Parameters
wScreenSDL_Window pointer.
Returns
nullptr if no screen with that SDL_Window is found, otherwise a valid pointer to the screen object.

Member Data Documentation

◆ iMTFriendly

Uint8 CRM64Pro::ConfigMgr::iMTFriendly

When set to 1 or greater, yields to the OS scheduler for at least this many milliseconds after each render frame. Disabled by default (0).