src/ResourceManager/FontResource.cpp

Go to the documentation of this file.
00001 /* Crown and Cutlass
00002  * FontResource Code
00003  */
00004 
00005 #include <string>
00006 #include <guichan.hpp>
00007 #include "../Log.h"
00008 #include "IResource.h"
00009 #include "FontResource.h"
00010 
00011 using namespace std;
00012 
00013 const string FontResource::s_type = string("Font");
00014 
00015 FontResource::FontResource(string name, string filename, string characters): IResource(name) {
00016   m_filename = filename;
00017   m_characters = characters;
00018   m_font = NULL;
00019 
00020   Log::s_log->Message("FontResource %s created (Key: %s) \"%s\"", m_name.c_str(), GetKey().c_str(), characters.c_str());
00021 }
00022 
00023 FontResource::~FontResource() {
00024   if (m_font != NULL) {
00025     Log::s_log->Message("Warning: %s font resource deleted before unload", m_name.c_str());
00026     Unload();
00027   }
00028   Log::s_log->Message("FontResource %s destroyed", m_name.c_str());
00029 }
00030 
00031 string FontResource::GetType() {
00032   return s_type;
00033 }
00034 
00035 void FontResource::Load() {
00036   m_font = new gcn::ImageFont(m_filename, m_characters);
00037   Log::s_log->Message("FontResource %s loaded", m_name.c_str());
00038 }
00039 
00040 void FontResource::Unload() {
00041   delete m_font;
00042   m_font = NULL;
00043   Log::s_log->Message("FontResource %s unloaded", m_name.c_str());
00044 }
00045 
00046 gcn::ImageFont* FontResource::GetImageFont() {
00047   return m_font;
00048 }

Generated on Mon Jan 8 22:34:12 2007 for CrownandCutlass by  doxygen 1.4.7