00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "CEGUIImagesetManager.h"
00027 #include "CEGUIExceptions.h"
00028 #include "CEGUILogger.h"
00029 #include "CEGUIImageset.h"
00030
00031
00032 namespace CEGUI
00033 {
00034
00035
00036
00037
00038 template<> ImagesetManager* Singleton<ImagesetManager>::ms_Singleton = NULL;
00039
00040
00041
00042
00043
00044 ImagesetManager::ImagesetManager(void)
00045 {
00046 Logger::getSingleton().logEvent((utf8*)"CEGUI::ImagesetManager singleton created");
00047 }
00048
00049
00050
00051
00052
00053 ImagesetManager::~ImagesetManager(void)
00054 {
00055 Logger::getSingleton().logEvent((utf8*)"---- Begining cleanup of Imageset system ----");
00056
00057 destroyAllImagesets();
00058
00059 Logger::getSingleton().logEvent((utf8*)"CEGUI::ImagesetManager singleton destroyed");
00060 }
00061
00062
00063
00064
00065
00066
00067 Imageset* ImagesetManager::createImageset(const String& name, Texture* texture)
00068 {
00069 Logger::getSingleton().logEvent((utf8*)"Attempting to create Imageset '" + name +"' with texture only.");
00070
00071 if (isImagesetPresent(name))
00072 {
00073 throw AlreadyExistsException("ImagesetManager::createImageset - An Imageset object named '" + name + "' already exists.");
00074 }
00075
00076 Imageset* temp = new Imageset(name, texture);
00077 d_imagesets[name] = temp;
00078
00079 return temp;
00080 }
00081
00082
00083
00084
00085
00086 Imageset* ImagesetManager::createImageset(const String& filename, const String& resourceGroup)
00087 {
00088 Logger::getSingleton().logEvent((utf8*)"Attempting to create an Imageset from the information specified in file '" + filename + "'.");
00089
00090 Imageset* temp = new Imageset(filename, resourceGroup);
00091
00092 String name = temp->getName();
00093
00094 if (isImagesetPresent(name))
00095 {
00096 delete temp;
00097
00098 throw AlreadyExistsException("ImagesetManager::createImageset - An Imageset object named '" + name + "' already exists.");
00099 }
00100
00101 d_imagesets[name] = temp;
00102
00103 return temp;
00104 }
00105
00106
00107
00108
00109
00110 void ImagesetManager::destroyImageset(const String& name)
00111 {
00112 ImagesetRegistry::iterator pos = d_imagesets.find(name);
00113
00114 if (pos != d_imagesets.end())
00115 {
00116 String tmpName(name);
00117
00118 delete pos->second;
00119 d_imagesets.erase(pos);
00120
00121 Logger::getSingleton().logEvent((utf8*)"Imageset '" + tmpName +"' has been destroyed.", Informative);
00122 }
00123
00124 }
00125
00126
00127
00128
00129
00130 void ImagesetManager::destroyImageset(Imageset* imageset)
00131 {
00132 if (imageset != NULL)
00133 {
00134 destroyImageset(imageset->getName());
00135 }
00136
00137 }
00138
00139
00140
00141
00142
00143 void ImagesetManager::destroyAllImagesets(void)
00144 {
00145 while (!d_imagesets.empty())
00146 {
00147 destroyImageset(d_imagesets.begin()->first);
00148 }
00149 }
00150
00151
00152
00153
00154 Imageset* ImagesetManager::getImageset(const String& name) const
00155 {
00156 ImagesetRegistry::const_iterator pos = d_imagesets.find(name);
00157
00158 if (pos == d_imagesets.end())
00159 {
00160 throw UnknownObjectException("ImagesetManager::getImageset - No Imageset named '" + name + "' is present in the system.");
00161 }
00162
00163 return pos->second;
00164 }
00165
00166
00167
00168
00169
00170
00171 void ImagesetManager::notifyScreenResolution(const Size& size)
00172 {
00173
00174 ImagesetRegistry::iterator pos = d_imagesets.begin(), end = d_imagesets.end();
00175
00176 for (; pos != end; ++pos)
00177 {
00178 pos->second->notifyScreenResolution(size);
00179 }
00180
00181 }
00182
00183
00184 ImagesetManager& ImagesetManager::getSingleton(void)
00185 {
00186 return Singleton<ImagesetManager>::getSingleton();
00187 }
00188
00189
00190 ImagesetManager* ImagesetManager::getSingletonPtr(void)
00191 {
00192 return Singleton<ImagesetManager>::getSingletonPtr();
00193 }
00194
00195
00196
00197
00198
00199
00200 ImagesetManager::ImagesetIterator ImagesetManager::getIterator(void) const
00201 {
00202 return ImagesetIterator(d_imagesets.begin(), d_imagesets.end());
00203 }
00204
00205
00206 }