summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/theme.cpp5
-rw-r--r--src/particle/particleemitter.cpp5
-rw-r--r--src/resources/loaders/subimagesetloader.cpp78
-rw-r--r--src/resources/loaders/subimagesetloader.h38
-rw-r--r--src/resources/resourcemanager/resourcemanager.cpp35
-rw-r--r--src/resources/resourcemanager/resourcemanager.h4
8 files changed, 126 insertions, 45 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2b9db603c..862c91690 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -727,6 +727,8 @@ SET(SRCS
resources/loaders/musicloader.h
resources/loaders/subimageloader.cpp
resources/loaders/subimageloader.h
+ resources/loaders/subimagesetloader.cpp
+ resources/loaders/subimagesetloader.h
resources/resourcemanager/resourcemanager.cpp
resources/resourcemanager/resourcemanager.h
resources/safeopenglimagehelper.cpp
@@ -1425,6 +1427,8 @@ SET(DYE_CMD_SRCS
resources/loaders/musicloader.h
resources/loaders/subimageloader.cpp
resources/loaders/subimageloader.h
+ resources/loaders/subimagesetloader.cpp
+ resources/loaders/subimagesetloader.h
resources/resourcemanager/resourcemanager.cpp
resources/resourcemanager/resourcemanager.h
resources/sdl2softwareimagehelper.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 98be2ad80..3e0e436b1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -398,6 +398,8 @@ SRC += events/actionevent.h \
resources/loaders/musicloader.h \
resources/loaders/subimageloader.cpp \
resources/loaders/subimageloader.h \
+ resources/loaders/subimagesetloader.cpp \
+ resources/loaders/subimagesetloader.h \
resources/resourcemanager/resourcemanager.cpp \
resources/resourcemanager/resourcemanager.h \
resources/safeopenglimagehelper.cpp \
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index d17f1ae85..f3100a9cb 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -40,8 +40,7 @@
#include "resources/loaders/imageloader.h"
#include "resources/loaders/imagesetloader.h"
#include "resources/loaders/subimageloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
+#include "resources/loaders/subimagesetloader.h"
#include "utils/dtor.h"
#include "utils/files.h"
@@ -1151,7 +1150,7 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
const SDL_Rect &rect2 = image->mBounds;
if (rect2.w && rect2.h)
{
- ImageSet *const imageSet = resourceManager->getSubImageSet(
+ ImageSet *const imageSet = Loader::getSubImageSet(
image, w, h);
theme->unload(skin);
return imageSet;
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
index a4c565393..552831abc 100644
--- a/src/particle/particleemitter.cpp
+++ b/src/particle/particleemitter.cpp
@@ -37,8 +37,7 @@
#include "resources/loaders/imageloader.h"
#include "resources/loaders/imagesetloader.h"
#include "resources/loaders/subimageloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
+#include "resources/loaders/subimagesetloader.h"
#include "debug.h"
@@ -389,7 +388,7 @@ ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
return nullptr;
}
- imageset = resourceManager->getSubImageSet(img2,
+ imageset = Loader::getSubImageSet(img2,
XML::getProperty(node, "width", 0),
XML::getProperty(node, "height", 0));
img2->decRef();
diff --git a/src/resources/loaders/subimagesetloader.cpp b/src/resources/loaders/subimagesetloader.cpp
new file mode 100644
index 000000000..39068bce3
--- /dev/null
+++ b/src/resources/loaders/subimagesetloader.cpp
@@ -0,0 +1,78 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "logger.h"
+
+#include "resources/image.h"
+#include "resources/imageset.h"
+
+#include "resources/resourcemanager/resourcemanager.h"
+
+#include "resources/loaders/subimagesetloader.h"
+
+#include "utils/checkutils.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+namespace
+{
+ struct SubImageSetLoader final
+ {
+ Image *parent;
+ int width;
+ int height;
+ static Resource *load(const void *const v)
+ {
+ if (!v)
+ return nullptr;
+
+ const SubImageSetLoader *const
+ rl = static_cast<const SubImageSetLoader *const>(v);
+
+ if (!rl->parent)
+ return nullptr;
+ ImageSet *const res = new ImageSet(rl->parent,
+ rl->width, rl->height);
+ return res;
+ }
+ };
+} // namespace
+
+ImageSet *Loader::getSubImageSet(Image *const parent,
+ const int width,
+ const int height)
+{
+ if (!parent)
+ return nullptr;
+
+ const SubImageSetLoader rl = { parent, width, height };
+ std::string str = std::string(
+ parent->getIdPath()).append(
+ ", set[").append(toString(
+ width)).append(
+ "x").append(toString(
+ height)).append(
+ "]");
+ return static_cast<ImageSet*>(resourceManager->get(str,
+ SubImageSetLoader::load, &rl));
+}
diff --git a/src/resources/loaders/subimagesetloader.h b/src/resources/loaders/subimagesetloader.h
new file mode 100644
index 000000000..b50f58647
--- /dev/null
+++ b/src/resources/loaders/subimagesetloader.h
@@ -0,0 +1,38 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_LOADERS_SUBIMAGESETLOADER_H
+#define RESOURCES_LOADERS_SUBIMAGESETLOADER_H
+
+#include "localconsts.h"
+
+class Image;
+class ImageSet;
+
+namespace Loader
+{
+ ImageSet *getSubImageSet(Image *const parent,
+ const int width,
+ const int height) A_WARN_UNUSED;
+} // namespace Loader
+
+#endif // RESOURCES_LOADERS_SUBIMAGESETLOADER_H
diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp
index 2f32b7c71..539e89d3a 100644
--- a/src/resources/resourcemanager/resourcemanager.cpp
+++ b/src/resources/resourcemanager/resourcemanager.cpp
@@ -527,41 +527,6 @@ Resource *ResourceManager::get(const std::string &idPath,
return resource;
}
-struct SubImageSetLoader final
-{
- ResourceManager *manager;
- Image *parent;
- int width, height;
- static Resource *load(const void *const v)
- {
- if (!v)
- return nullptr;
-
- const SubImageSetLoader *const
- rl = static_cast<const SubImageSetLoader *const>(v);
- if (!rl->manager)
- return nullptr;
-
- if (!rl->parent)
- return nullptr;
- ImageSet *const res = new ImageSet(rl->parent, rl->width, rl->height);
- return res;
- }
-};
-
-ImageSet *ResourceManager::getSubImageSet(Image *const parent,
- const int width, const int height)
-{
- if (!parent)
- return nullptr;
-
- const 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));
-}
-
#ifdef USE_OPENGL
struct AtlasLoader final
{
diff --git a/src/resources/resourcemanager/resourcemanager.h b/src/resources/resourcemanager/resourcemanager.h
index 2c54aeb5a..d8b080b68 100644
--- a/src/resources/resourcemanager/resourcemanager.h
+++ b/src/resources/resourcemanager/resourcemanager.h
@@ -133,10 +133,6 @@ class ResourceManager final : public MemoryCounter
*/
bool addResource(const std::string &idPath, Resource *const resource);
- ImageSet *getSubImageSet(Image *const parent,
- const int width,
- const int height) A_WARN_UNUSED;
-
#ifdef USE_OPENGL
Resource *getAtlas(const std::string &name,
const StringVect &files) A_WARN_UNUSED;