ResourceCenter Class Reference
[C++ Wrapper for SDL]

Provide loader (with cache) for SDL resources.

This class is a singleton. You can access it from anywhere. It provides image and font loader, with a transparent caching system. It is usually loaded within the SDLWindow class. More...

#include <ResourceCenter.hh>

List of all members.

Public Member Functions

const std::string & getResourcePrefix () const
 Get the ressource prefix path.
void setResourcePrefix (const std::string &prefix="")
 Change the ressource prefix path.
Surface getImage (const std::string &filename, double zoom=1., double angle=0.)
 Load an image, with cache enabled.
TTF_Font * getFont (const std::string font_name, int font_size)
 Load a font file.
void releaseFont (TTF_Font *font)
 Release a font.
void printStatistics ()
 Print cache info.

Static Public Member Functions

static ResourceCentergetInst ()
 Get the instance of this class.

Classes

struct  LoadedFont
 Storage for already loaded fonts, with their carateristics.


Detailed Description

Provide loader (with cache) for SDL resources.

This class is a singleton. You can access it from anywhere. It provides image and font loader, with a transparent caching system. It is usually loaded within the SDLWindow class.


Member Function Documentation

TTF_Font * ResourceCenter::getFont ( const std::string  font_name,
int  font_size 
)

Load a font file.

Parameters:
font_name Font filename to load, relative to current prefix + "font/" directory.
font_size The size of the font (typically between 10-20).
Returns:
A valid font. Can't be NULL.
Exceptions:
TTFError Thrown if font couldn't be opened.
Note:
Caller is reponsible of calling releaseFont when it has finished.

Surface ResourceCenter::getImage ( const std::string &  filename,
double  zoom = 1.,
double  angle = 0. 
)

Load an image, with cache enabled.

If the image, with specified angle and zoom level, can be found in the cache, it is not reloaded. Otherwise, a copy will be kept for further call.

Parameters:
filename Image file to load.
zoom Zoom level to apply, wrt the original image.
angle Rotate image, wrt the original image (0-360 degre).
Exceptions:
SDLError Thrown if the file could not be opened.

const std::string & ResourceCenter::getResourcePrefix (  )  const

Get the ressource prefix path.

By default, it points to the installed shared directory (pkgdatadir) of the program.

Returns:
Prefix path.

void ResourceCenter::releaseFont ( TTF_Font *  font  ) 

Release a font.

Parameters:
font The font to release.

void ResourceCenter::setResourcePrefix ( const std::string &  prefix = ""  ) 

Change the ressource prefix path.

Parameters:
prefix Path to set. If it is an empty string, the default location is set.


The documentation for this class was generated from the following files:
Generated on Sat Jun 23 16:12:42 2007 for Stechec/TBT by  doxygen 1.4.7