summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index b88c4dbb5..8b9c4e3c0 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -552,6 +552,39 @@ ImageSet *ResourceManager::getImageSet(const std::string &imagePath,
return static_cast<ImageSet*>(get(ss.str(), ImageSetLoader::load, &rl));
}
+
+struct SubImageSetLoader
+{
+ ResourceManager *manager;
+ Image *parent;
+ int width, height;
+ static Resource *load(void *v)
+ {
+ if (!v)
+ return nullptr;
+
+ SubImageSetLoader *rl = static_cast< SubImageSetLoader * >(v);
+ if (!rl->manager)
+ return nullptr;
+
+ if (!rl->parent)
+ return nullptr;
+ ImageSet *res = new ImageSet(rl->parent, rl->width, rl->height);
+ return res;
+ }
+};
+
+ImageSet *ResourceManager::getSubImageSet(Image *parent, int width, int height)
+{
+ if (!parent)
+ return nullptr;
+
+ SubImageSetLoader rl = { this, parent, width, height };
+ std::stringstream ss;
+ ss << parent->getIdPath() << ", set[" << width << "x" << height << "]";
+ return static_cast<ImageSet*>(get(ss.str(), SubImageSetLoader::load, &rl));
+}
+
struct SubImageLoader
{
ResourceManager *manager;
@@ -574,7 +607,7 @@ struct SubImageLoader
};
Image *ResourceManager::getSubImage(Image *parent, int x, int y,
- int width, int height)
+ int width, int height)
{
if (!parent)
return nullptr;