SdlManager Class Reference
[SDL based classesSingle inited classes]

The central class, that manages Sdl*-classes. More...

#include <sdlmanager.h>

Collaboration diagram for SdlManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC bool init ()
DECLSPEC bool init (TiXmlElement *el)
DECLSPEC bool init (Uint32 width, Uint32 height, Uint32 &depth, bool fullscreen=true)
DECLSPEC void destroy ()
bool isAudioInited ()
 
Returns:
true, if audio can be used, false if not

bool isVideoInited ()
 
Returns:
true, if video can be used, false if not

DECLSPEC void refreshSoundVolumes ()
DECLSPEC SdlAudiogetAudioByName (const char *name)
DECLSPEC SdlSurfacegetSurfaceByName (const char *name)
DECLSPEC SdlSurfaceContainergetSurfacesByName (const char *name)
DECLSPEC SdlMusicListgetMusicsByName (const char *name)
SdlSurfacegetDisplay ()
DECLSPEC bool getScreenSize (int &w, int &h)
DECLSPEC SDL_Rect getScreenRect ()
DECLSPEC bool screenShot (const char *fn=0, bool nooverwrite=true)

Static Public Member Functions

static void grabInput (void)
 Grabs the mouse+keyboard input, so that only this apps recieves events.
static void ungrabInput (void)
 Ungrabs the mouse+keyboard input, so that other apps can recieve input events.
static DECLSPEC SdlManagergetThe ()

Static Public Attributes

static SdlManagerthe
static bool bGrabInputEnabled
 indicates, whether or not, input grabbing is enabled

Friends

class SdlAudio
class SdlSurface
class SdlSurfaceContainer
class SdlMusicList

Detailed Description

The central class, that manages Sdl*-classes.

This class provides functions to initialize and access audio and graphic resources. It also contains methods to get video and audio settings and a function to make screenshots.

This class can only be used in one variable at a time. So do not initialize it more than once, but it is required once, if you need a user interface.


Member Function Documentation

bool SdlManager::init (  ) 

Initializes video and audio, using a screen resolution of 1024*768*32Bit.

Returns:
true, if video and audio could be initialized, false if at least one failed

bool SdlManager::init ( TiXmlElement el  ) 

Initializes video and audio, using a XML node to set the screen resolution.

Parameters:
el a XML element, that contains attributes, telling the resolution:
  • Width: width of the resolution (in pixels, x direction); if it is not specified, resolution will be set to 1024.
  • Height: height of the resolution (in pixels, y direction); if it is not specified, resolution will be set to 768.
  • Depth: color depth of the resolution in bits; if it is not specified, resolution will be set to 32.
  • Fullscreen: (a boolean value) whether to use fullscreen-mode or not; if not specified, fullscreen-mode will be activated; if true, input is grabbed, otherwise not Furthermore by putting a subnode "WaitOnStart", containing the attribute "value", the function will delay for the given amount (in msecs).
Returns:
true, if video and audio could be initialized, false if at least one failed

bool SdlManager::init ( Uint32  width,
Uint32  height,
Uint32 &  depth,
bool  fullscreen = true 
)

Initializes video and audio, using the params to set the screen resolution.

Parameters:
width of the resolution (in pixels, x direction)
height of the resolution (in pixels, y direction)
depth color depth of the resolution in bits
fullscreen whether to use fullscreen-mode or not; true by default; if true, input is grabbed, otherwise not
Returns:
true, if video and audio could be initialized, false if at least one failed

void SdlManager::destroy (  ) 

Uninitializes the manager. All resources will be freed and the audio mixer will be closed.

void SdlManager::refreshSoundVolumes (  ) 

Refreshes the sound volumes of all sound resources. This is necessary, when changing sound-volume globally.

SdlAudio * SdlManager::getAudioByName ( const char *  name  ) 

Use this function, if you have only the name and no resource of the sound you need.

Parameters:
name the name of the audio resource to return
Returns:
a pointer to the audio resource with the given name

SdlSurface * SdlManager::getSurfaceByName ( const char *  name  ) 

Use this function, if you have only the name and no resource of the surface you need.

Parameters:
name the name of the surface resource to return
Returns:
a pointer to the surface resource with the given name

SdlSurfaceContainer * SdlManager::getSurfacesByName ( const char *  name  ) 

Use this function, if you have only the name and no resource of the list of surfaces you need.

Parameters:
name the name of the surface list resource to return
Returns:
a pointer to the surface list resource with the given name

SdlMusicList * SdlManager::getMusicsByName ( const char *  name  ) 

Use this function, if you have only the name and no resource of the list of songs/audios you need.

Parameters:
name the name of the audio list resource to return
Returns:
a pointer to the audio list resource with the given name

SdlSurface* SdlManager::getDisplay (  )  [inline]

Returns:
a pointer to the surface that will be shown, when the next frame becomes active.

bool SdlManager::getScreenSize ( int &  w,
int &  h 
)

Use this to get the resolution of the screen and to ask, whether fullscreen-mode is active or not.

Parameters:
w reference, where the width will be stored
h reference, where the height will be stored
Returns:
true, if fullscreen-mode is active; false if it is not

SDL_Rect SdlManager::getScreenRect (  ) 

Returns:
the screen's rect (top-left corner is at (0|0); width and height equal the values of getScreenSize())

bool SdlManager::screenShot ( const char *  fn = 0,
bool  nooverwrite = true 
)

Makes a screenshot of the currently visible screen and saves the picture to a file with the bitmap format.

Parameters:
fn the filename, where the bitmap will be saved. Use "%d" in it to set the number of the photo there (if nooverwrite is false) or to place a number there in order not to overwrite another photo (if nooverwrite true)
if NULL, "./screens/photo%d.bmp" will be used
nooverwrite if false and the given filename exists, the file will be overwritten; if true, no file will be overwritten, but if "%d" does not occur in fn, and fn exists, the photo will not be saved
Returns:
true, if the photo was saved, false if not

SdlManager * SdlManager::getThe (  )  [static]

Returns:
a pointer to the SdlManager-variable, or NULL if not initialized. (There is only one SdlManager-variable allowed in an application)
Every netrinjo-class that can only exist once at a time, has this static function.
See also:
Single inited classes


Member Data Documentation

SdlManager * SdlManager::the [static]

only accessible in Linux, and equals the result of getThe()


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:33 2007 for netrinjo by  doxygen 1.5.1