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

Config Manager class. More...

Detailed Description

Config Manager class.

Public Member Functions

bool info (Sint32 iMode=0) override
 Request Configuration Manager information.
void setMTFriendly (Uint8 iDelayMS)
 Set the multithread-friendly scheduler yield.
Uint8 getMTFriendly () const
 Get the multithread-friendly scheduler yield.
bool audioInit (eConfigAudioFreq eAF=CAF_DEFAULT, eConfigAudioSample eAS=CAS_DEFAULT, eConfigAudioMode eAM=CAM_DEFAULT)
 Initialize the audio system.
bool audioIsReady (eConfigAudioFreq *eAF=nullptr, eConfigAudioSample *eAS=nullptr, eConfigAudioMode *eAM=nullptr)
 Check whether the audio system is ready.
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 ()
 Get the internal SDL3 Mixer Device handle.
Sint32 create (const string &sName, Uint32 iReserved=0) override
 Create a new screen.
Sint32 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 (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.

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. A specific screen ID displays manager information and only that screen.
Returns
true on success, or false on failure.

◆ setMTFriendly()

void CRM64Pro::ConfigMgr::setMTFriendly ( Uint8 iDelayMS)

Set the multithread-friendly scheduler yield.

Parameters
iDelayMSDelay in milliseconds after each render frame. Use 0 to disable it. Valid range: [0, 255].

◆ getMTFriendly()

Uint8 CRM64Pro::ConfigMgr::getMTFriendly ( ) const

Get the multithread-friendly scheduler yield.

Returns
Delay in milliseconds after each render frame. 0 means disabled.

◆ audioInit()

bool CRM64Pro::ConfigMgr::audioInit ( eConfigAudioFreq eAF = CAF_DEFAULT,
eConfigAudioSample eAS = CAS_DEFAULT,
eConfigAudioMode eAM = CAM_DEFAULT )

Initialize the audio system.

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

Parameters
eAFAudio frequency. Default ::CAF_DEFAULT resolves to ::CAF_44K (44100 Hz).
eASAudio sample format. Default ::CAS_DEFAULT resolves to ::CAS_16.
eAMAudio mode. Default CAM_DEFAULT (Stereo).
Returns
true on success, or false on failure.

◆ audioIsReady()

bool CRM64Pro::ConfigMgr::audioIsReady ( eConfigAudioFreq * eAF = nullptr,
eConfigAudioSample * eAS = nullptr,
eConfigAudioMode * eAM = nullptr )

Check whether the audio system is ready.

Parameters
eAF::eConfigAudioFreq enum pointer filled in with audio frequency. If nullptr (default), this value is not retrieved.
eAS::eConfigAudioSample enum pointer filled in with audio sampling. If nullptr (default), this value is not retrieved.
eAM::eConfigAudioMode enum pointer filled in with audio mode. If nullptr (default), this value is not retrieved.
Returns
true when the audio system is initialized and audio output is enabled, or false otherwise.

◆ 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
Borrowed pointer to the driver name string, or nullptr on failure/not initialized.
Note
The returned pointer must not be deleted or stored long-term. It remains valid until the next audio driver change or audio shutdown.

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

Get the internal SDL3 Mixer Device handle.

Returns the raw pointer to the initialized MIX_Mixer device.

Returns
Borrowed mutable pointer to the active MIX_Mixer, or nullptr if audio is not initialized.
Note
The returned pointer must not be destroyed. It remains valid while audio is initialized.
Warning
This pointer is provided for SDL_mixer interop only.

◆ create()

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

Create a new screen.

Parameters
sNamethe name to give to the screen object (e.g. 'pScreen'). Must be unique and shorter than 64 characters.
iReservedReserved for future use. Pass 0.
Returns
Greater than 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()

Sint32 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
0 on success, or a negative error code 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. 'pScreen'). Must be unique and shorter than 64 characters.
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
Borrowed pointer to the Screen object, or nullptr if not found.
Note
The returned pointer must not be deleted. It remains valid until the Screen is closed or ConfigMgr is reset or terminated.

◆ 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
Borrowed pointer to the Screen object, or nullptr if not found.
Note
The returned pointer must not be deleted. It remains valid until the Screen is closed or ConfigMgr is reset or terminated.