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>
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 ResourceCenter * | getInst () |
| Get the instance of this class. | |
Classes | |
| struct | LoadedFont |
| Storage for already loaded fonts, with their carateristics. | |
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.
| TTF_Font * ResourceCenter::getFont | ( | const std::string | font_name, | |
| int | font_size | |||
| ) |
Load a font file.
| font_name | Font filename to load, relative to current prefix + "font/" directory. | |
| font_size | The size of the font (typically between 10-20). |
| TTFError | Thrown if font couldn't be opened. |
| 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.
| filename | Image file to load. | |
| zoom | Zoom level to apply, wrt the original image. | |
| angle | Rotate image, wrt the original image (0-360 degre). |
| 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.
| void ResourceCenter::releaseFont | ( | TTF_Font * | font | ) |
Release a font.
| font | The font to release. |
| void ResourceCenter::setResourcePrefix | ( | const std::string & | prefix = "" |
) |
Change the ressource prefix path.
| prefix | Path to set. If it is an empty string, the default location is set. |
1.4.7