summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-16 20:23:54 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-16 20:23:54 +0000
commit43a80fa64acb7f02cf5305b4a3d2ef6040b4b8c9 (patch)
tree4454ae9c9dfdc70261b47594ac598be10462d8f6 /src
parent7489419558c12ba19eb7d0f26bf5a29149330eb0 (diff)
downloadmana-43a80fa64acb7f02cf5305b4a3d2ef6040b4b8c9.tar.gz
mana-43a80fa64acb7f02cf5305b4a3d2ef6040b4b8c9.tar.bz2
mana-43a80fa64acb7f02cf5305b4a3d2ef6040b4b8c9.tar.xz
mana-43a80fa64acb7f02cf5305b4a3d2ef6040b4b8c9.zip
Use the ResourceManager to get spritesets.
Diffstat (limited to 'src')
-rw-r--r--src/resources/resourcemanager.cpp18
-rw-r--r--src/resources/resourcemanager.h7
2 files changed, 25 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index e9595093..4f409431 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -32,6 +32,8 @@
#include "../log.h"
+#include "../graphic/spriteset.h"
+
ResourceManager *ResourceManager::instance = NULL;
@@ -199,6 +201,22 @@ ResourceManager::getSoundEffect(const std::string &idPath)
return (SoundEffect*)get(SOUND_EFFECT, idPath);
}
+Spriteset* ResourceManager::createSpriteset(const std::string &imagePath,
+ int w, int h)
+{
+ Image *img;
+
+ if (!(img = getImage(imagePath))) {
+ return NULL;
+ }
+
+ Spriteset *result = new Spriteset(img, w, h);
+
+ img->decRef();
+
+ return result;
+}
+
void
ResourceManager::release(const std::string &idPath)
{
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index a5a66901..6ebcd590 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -32,6 +32,7 @@ class Resource;
class Image;
class Music;
class SoundEffect;
+class Spriteset;
/**
* A class for loading and managing resources.
@@ -138,6 +139,12 @@ class ResourceManager
getSoundEffect(const std::string &idPath);
/**
+ * Creates a spriteset based on the image referenced by the given
+ * path and the supplied sprite sizes
+ */
+ Spriteset* createSpriteset(const std::string &imagePath, int w, int h);
+
+ /**
* Releases a resource, removing it from the set of loaded resources.
*/
void