Load GUI from XML

This commit is contained in:
2015-03-10 00:48:25 +01:00
parent 9d7dd452c7
commit 884fd8bb52
21 changed files with 1019 additions and 119 deletions

33
ImageProvider.cc Normal file
View File

@@ -0,0 +1,33 @@
#include <SDL2/SDL_image.h>
#include "ImageProvider.hh"
template<>
std::unique_ptr<ImageProvider> Singleton<ImageProvider>::instance{nullptr};
template<>
std::once_flag Singleton<ImageProvider>::instance_flag{};
ImageProvider::ImageProvider()
{
}
SDL_Surface *ImageProvider::getImage(std::string const& name)
{
auto it = imageCache_.find(name);
if(it == imageCache_.end()) {
SDLSurfaceUPtr image{IMG_Load(name.c_str())};
if (!image)
throw SDLException{};
tie(it, std::ignore) = imageCache_.insert(make_pair(name, std::move(image)));
}
return it->second.get();
}
void ImageProvider::cleanup()
{
imageCache_.clear();
}