summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-22 14:14:34 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-22 14:14:34 +0300
commitda05d9dd98315378bdded216184294f376643191 (patch)
treeffc4b984c73c3bb68d26a1df6481634254075744 /src
parentec856b2026c7ceecab5f74942bb36661d7c6ae67 (diff)
downloadmv-da05d9dd98315378bdded216184294f376643191.tar.gz
mv-da05d9dd98315378bdded216184294f376643191.tar.bz2
mv-da05d9dd98315378bdded216184294f376643191.tar.xz
mv-da05d9dd98315378bdded216184294f376643191.zip
Use resource manager as global variable.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp12
-rw-r--r--src/animatedsprite.cpp6
-rw-r--r--src/animationdelayload.cpp3
-rw-r--r--src/being/actorsprite.cpp4
-rw-r--r--src/client.cpp37
-rw-r--r--src/dirs.cpp21
-rw-r--r--src/dyetool/client.cpp16
-rw-r--r--src/dyetool/dyemain.cpp10
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/gui.cpp3
-rw-r--r--src/gui/models/langlistmodel.h3
-rw-r--r--src/gui/popups/itempopup.cpp7
-rw-r--r--src/gui/theme.cpp17
-rw-r--r--src/gui/widgets/browserbox.cpp6
-rw-r--r--src/gui/widgets/desktop.cpp7
-rw-r--r--src/gui/widgets/emotepage.cpp2
-rw-r--r--src/gui/widgets/icon.cpp2
-rw-r--r--src/gui/widgets/skilldata.cpp3
-rw-r--r--src/gui/windows/mailviewwindow.cpp3
-rw-r--r--src/gui/windows/minimap.cpp3
-rw-r--r--src/gui/windows/npcdialog.cpp4
-rw-r--r--src/gui/windows/updaterwindow.cpp81
-rw-r--r--src/gui/windows/updaterwindow.h13
-rw-r--r--src/item.cpp6
-rw-r--r--src/particle/particle.cpp4
-rw-r--r--src/particle/particleemitter.cpp21
-rw-r--r--src/render/shaders/shadersmanager.cpp5
-rw-r--r--src/resources/ambientlayer.cpp11
-rw-r--r--src/resources/atlasmanager.cpp15
-rw-r--r--src/resources/atlasresource.cpp3
-rw-r--r--src/resources/image.cpp4
-rw-r--r--src/resources/map/map.cpp8
-rw-r--r--src/resources/map/mapitem.cpp7
-rw-r--r--src/resources/mapreader.cpp8
-rw-r--r--src/resources/resource.cpp3
-rw-r--r--src/resources/resourcemanager.cpp5
-rw-r--r--src/resources/resourcemanager.h6
-rw-r--r--src/resources/spritedef.cpp4
-rw-r--r--src/simpleanimation.cpp4
-rw-r--r--src/soundmanager.cpp10
-rw-r--r--src/textcommand.cpp3
-rw-r--r--src/utils/files.cpp10
42 files changed, 157 insertions, 246 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 329202612..5dd1cbb6c 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1001,7 +1001,7 @@ impHandler0(who)
impHandler0(cleanGraphics)
{
- ResourceManager::getInstance()->clearCache();
+ resourceManager->clearCache();
if (debugChatTab)
{
@@ -1216,24 +1216,22 @@ impHandler(dump)
if (!debugChatTab)
return false;
- ResourceManager *const resman = ResourceManager::getInstance();
-
if (!event.args.empty())
{
- ResourceManager::Resources *res = resman->getResources();
+ ResourceManager::Resources *res = resourceManager->getResources();
// TRANSLATORS: dump command
showRes(_("Resource images:"), res);
- res = resman->getOrphanedResources();
+ res = resourceManager->getOrphanedResources();
// TRANSLATORS: dump command
showRes(_("Resource orphaned images:"), res);
}
else
{
- ResourceManager::Resources *res = resman->getResources();
+ ResourceManager::Resources *res = resourceManager->getResources();
// TRANSLATORS: dump command
debugChatTab->chatLog(_("Resource images:") + toString(res->size()),
ChatMsgType::BY_SERVER);
- res = resman->getOrphanedResources();
+ res = resourceManager->getOrphanedResources();
// TRANSLATORS: dump command
debugChatTab->chatLog(_("Resource orphaned images:")
+ toString(res->size()),
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 92b7a4cba..785a00e7f 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -63,8 +63,7 @@ AnimatedSprite::AnimatedSprite(SpriteDef *const sprite) :
AnimatedSprite *AnimatedSprite::load(const std::string &filename,
const int variant)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- SpriteDef *const s = resman->getSprite(filename, variant);
+ SpriteDef *const s = resourceManager->getSprite(filename, variant);
if (!s)
return nullptr;
AnimatedSprite *const as = new AnimatedSprite(s);
@@ -78,8 +77,7 @@ AnimatedSprite *AnimatedSprite::delayedLoad(const std::string &filename,
{
if (!mEnableCache)
return load(filename, variant);
- ResourceManager *const resman = ResourceManager::getInstance();
- Resource *const res = resman->getFromCache(filename, variant);
+ Resource *const res = resourceManager->getFromCache(filename, variant);
if (res)
{
res->decRef();
diff --git a/src/animationdelayload.cpp b/src/animationdelayload.cpp
index fa979d864..c52355963 100644
--- a/src/animationdelayload.cpp
+++ b/src/animationdelayload.cpp
@@ -55,8 +55,7 @@ void AnimationDelayLoad::load()
{
if (mSprite)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- SpriteDef *const s = resman->getSprite(mFileName, mVariant);
+ SpriteDef *const s = resourceManager->getSprite(mFileName, mVariant);
if (!s)
return;
mSprite->setSprite(s);
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 4b9a4b61a..951243cc7 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -281,7 +281,6 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
}
else
{
- ResourceManager *const resman = ResourceManager::getInstance();
std::string imagePath;
switch (imageType)
{
@@ -296,8 +295,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
break;
}
imagePath = combineDye2(imagePath, color);
-
- Image *img = resman->getImage(imagePath);
+ Image *img = resourceManager->getImage(imagePath);
if (!img)
img = Theme::getImageFromTheme("unknown-item.png");
diff --git a/src/client.cpp b/src/client.cpp
index 2e3cc7374..8c8276f7e 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -278,8 +278,7 @@ void Client::gameInit()
#endif
ResourceManager::init();
- const ResourceManager *const resman = ResourceManager::getInstance();
- if (!resman->setWriteDir(settings.localDataDir))
+ if (!resourceManager->setWriteDir(settings.localDataDir))
{
logger->error(strprintf("%s couldn't be set as home directory! "
"Exiting.", settings.localDataDir.c_str()));
@@ -358,10 +357,10 @@ void Client::gameInit()
// Add the main data directories to our PhysicsFS search path
if (!settings.options.dataPath.empty())
- resman->addToSearchPath(settings.options.dataPath, false);
+ resourceManager->addToSearchPath(settings.options.dataPath, false);
// Add the local data directory to PhysicsFS search path
- resman->addToSearchPath(settings.localDataDir, false);
+ resourceManager->addToSearchPath(settings.localDataDir, false);
TranslationManager::loadCurrentLang();
WindowManager::initTitle();
@@ -933,8 +932,7 @@ int Client::gameExec()
{
delete2(mGame);
Game::clearInstance();
- ResourceManager *const resman = ResourceManager::getInstance();
- resman->cleanOrphans();
+ resourceManager->cleanOrphans();
Party::clearParties();
Guild::clearGuilds();
NpcDialog::clearDialogs();
@@ -980,12 +978,10 @@ int Client::gameExec()
logger->log1("State: CHOOSE SERVER");
mCurrentServer.supportUrl.clear();
settings.supportUrl.clear();
- ResourceManager *const resman
- = ResourceManager::getInstance();
if (settings.options.dataPath.empty())
{
// Add customdata directory
- resman->searchAndRemoveArchives(
+ resourceManager->searchAndRemoveArchives(
"customdata/",
"zip");
}
@@ -998,15 +994,19 @@ int Client::gameExec()
if (!settings.options.skipUpdate)
{
- resman->searchAndRemoveArchives(
- settings.updatesDir + "/local/",
+ resourceManager->searchAndRemoveArchives(
+ settings.updatesDir +
+ "/local/",
"zip");
- resman->removeFromSearchPath(settings.localDataDir
- + dirSeparator + settings.updatesDir + "/local/");
+ resourceManager->removeFromSearchPath(
+ settings.localDataDir +
+ dirSeparator +
+ settings.updatesDir +
+ "/local/");
}
- resman->clearCache();
+ resourceManager->clearCache();
loginData.clearUpdateHost();
serverVersion = 0;
@@ -1191,15 +1191,12 @@ int Client::gameExec()
BLOCK_START("Client::gameExec STATE_LOAD_DATA")
logger->log1("State: LOAD DATA");
- const ResourceManager *const resman
- = ResourceManager::getInstance();
-
// If another data path has been set,
// we don't load any other files...
if (settings.options.dataPath.empty())
{
// Add customdata directory
- resman->searchAndAddArchives(
+ resourceManager->searchAndAddArchives(
"customdata/",
"zip",
false);
@@ -1207,12 +1204,12 @@ int Client::gameExec()
if (!settings.options.skipUpdate)
{
- resman->searchAndAddArchives(
+ resourceManager->searchAndAddArchives(
settings.updatesDir + "/local/",
"zip",
false);
- resman->addToSearchPath(settings.localDataDir
+ resourceManager->addToSearchPath(settings.localDataDir
+ dirSeparator + settings.updatesDir + "/local/",
false);
}
diff --git a/src/dirs.cpp b/src/dirs.cpp
index e5b3f395b..4e9c5fbd9 100644
--- a/src/dirs.cpp
+++ b/src/dirs.cpp
@@ -190,9 +190,9 @@ void Dirs::extractDataDir()
void Dirs::mountDataDir()
{
- const ResourceManager *const resman = ResourceManager::getInstance();
- resman->addToSearchPath(PKG_DATADIR "data/perserver/default", false);
- resman->addToSearchPath("data/perserver/default", false);
+ resourceManager->addToSearchPath(PKG_DATADIR "data/perserver/default",
+ false);
+ resourceManager->addToSearchPath("data/perserver/default", false);
#if defined __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
@@ -206,27 +206,28 @@ void Dirs::mountDataDir()
CFRelease(resourcesURL);
// possible crash
strncat(path, "/data", PATH_MAX - 1);
- resman->addToSearchPath(path, false);
+ resourceManager->addToSearchPath(path, false);
// possible this need for support run client from dmg images.
// mPackageDir = path;
#endif
- resman->addToSearchPath(PKG_DATADIR "data", false);
+ resourceManager->addToSearchPath(PKG_DATADIR "data", false);
setPackageDir(PKG_DATADIR "data");
- resman->addToSearchPath("data", false);
+ resourceManager->addToSearchPath("data", false);
#ifdef ANDROID
#ifdef USE_SDL2
if (getenv("APPDIR"))
{
const std::string appDir = getenv("APPDIR");
- resman->addToSearchPath(appDir + "/data", false);
- resman->addToSearchPath(appDir + "/data/perserver/default", false);
+ resourceManager->addToSearchPath(appDir + "/data", false);
+ resourceManager->addToSearchPath(appDir + "/data/perserver/default",
+ false);
}
#endif
#endif
#if defined __native_client__
- resman->addToSearchPath(_nacl_dir.append("/data"), false);
+ resourceManager->addToSearchPath(_nacl_dir.append("/data"), false);
#endif
// Add branding/data to PhysFS search path
@@ -244,7 +245,7 @@ void Dirs::mountDataDir()
#endif
if (loc > 0)
{
- resman->addToSearchPath(path.substr(
+ resourceManager->addToSearchPath(path.substr(
0, loc + 1).append("data"), false);
}
}
diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp
index 4722237d8..77964bd17 100644
--- a/src/dyetool/client.cpp
+++ b/src/dyetool/client.cpp
@@ -167,8 +167,7 @@ void Client::gameInit()
#endif
ResourceManager::init();
- const ResourceManager *const resman = ResourceManager::getInstance();
- if (!resman->setWriteDir(settings.localDataDir))
+ if (!resourceManager->setWriteDir(settings.localDataDir))
{
logger->error(strprintf("%s couldn't be set as home directory! "
"Exiting.", settings.localDataDir.c_str()));
@@ -246,10 +245,10 @@ void Client::gameInit()
// Add the main data directories to our PhysicsFS search path
if (!settings.options.dataPath.empty())
- resman->addToSearchPath(settings.options.dataPath, false);
+ resourceManager->addToSearchPath(settings.options.dataPath, false);
// Add the local data directory to PhysicsFS search path
- resman->addToSearchPath(settings.localDataDir, false);
+ resourceManager->addToSearchPath(settings.localDataDir, false);
TranslationManager::loadCurrentLang();
WindowManager::initTitle();
@@ -587,15 +586,12 @@ int Client::gameExec()
BLOCK_START("Client::gameExec STATE_LOAD_DATA")
logger->log1("State: LOAD DATA");
- const ResourceManager *const resman
- = ResourceManager::getInstance();
-
// If another data path has been set,
// we don't load any other files...
if (settings.options.dataPath.empty())
{
// Add customdata directory
- resman->searchAndAddArchives(
+ resourceManager->searchAndAddArchives(
"customdata/",
"zip",
false);
@@ -603,12 +599,12 @@ int Client::gameExec()
if (!settings.options.skipUpdate)
{
- resman->searchAndAddArchives(
+ resourceManager->searchAndAddArchives(
settings.updatesDir + "/local/",
"zip",
false);
- resman->addToSearchPath(settings.localDataDir
+ resourceManager->addToSearchPath(settings.localDataDir
+ dirSeparator + settings.updatesDir + "/local/",
false);
}
diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp
index 1d5f55a6d..84334ec21 100644
--- a/src/dyetool/dyemain.cpp
+++ b/src/dyetool/dyemain.cpp
@@ -75,10 +75,10 @@ int main(int argc, char **argv)
imageHelper = new SDLImageHelper;
#endif
- ResourceManager *resman = new ResourceManager;
- resman->setWriteDir(".");
- resman->addToSearchPath(".", false);
- resman->addToSearchPath("/", false);
+ ResourceManager::init();
+ resourceManager->setWriteDir(".");
+ resourceManager->addToSearchPath(".", false);
+ resourceManager->addToSearchPath("/", false);
std::string src = argv[1];
std::string dst;
if (argc == 4)
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
dst = argv[2];
}
- Image *image = resman->getImage(src);
+ Image *image = resourceManager->getImage(src);
if (!image)
{
printf("Error loading image\n");
diff --git a/src/game.cpp b/src/game.cpp
index 0d239fa3e..9fe4c2508 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -994,8 +994,7 @@ void Game::changeMap(const std::string &mapPath)
BLOCK_START("Game::changeMap")
resetAdjustLevel();
- ResourceManager *const resman = ResourceManager::getInstance();
- resman->cleanProtected();
+ resourceManager->cleanProtected();
if (popupManager)
{
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index e2d6ca054..330f2c54b 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -295,8 +295,7 @@ Gui::~Gui()
void Gui::logic()
{
BLOCK_START("Gui::logic")
- ResourceManager *const resman = ResourceManager::getInstance();
- resman->clearScheduled();
+ resourceManager->clearScheduled();
if (!mTop)
{
diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h
index 62bc15e3e..f442982ff 100644
--- a/src/gui/models/langlistmodel.h
+++ b/src/gui/models/langlistmodel.h
@@ -84,10 +84,9 @@ class LangListModel final : public ExtendedListModel
public:
LangListModel()
{
- ResourceManager *const resman = ResourceManager::getInstance();
for (int f = 0; f < langs_count; f ++)
{
- mIcons[f] = resman->getImage("graphics/flags/"
+ mIcons[f] = resourceManager->getImage("graphics/flags/"
+ LANG_NAME[f].icon);
}
}
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index a97b2480b..a9afe136a 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -175,10 +175,9 @@ void ItemPopup::setItem(const ItemInfo &item,
if (showImage)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- Image *const image = resman->getImage(combineDye2(
- paths.getStringValue("itemIcons").append(
- item.getDisplay().image), item.getDyeIconColorsString(color)));
+ Image *const image = resourceManager->getImage(combineDye2(
+ paths.getStringValue("itemIcons").append(item.getDisplay().image),
+ item.getDyeIconColorsString(color)));
mIcon->setImage(image);
if (image)
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 000994368..90c351476 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -347,8 +347,7 @@ struct SkinHelper final
height(),
rect(),
node(),
- image(),
- resman()
+ image()
{
}
@@ -362,7 +361,6 @@ struct SkinHelper final
ImageRect *rect;
XmlNodePtr *node;
Image *image;
- ResourceManager *resman;
bool loadList(const SkinParameter *const params,
const size_t size) A_NONNULL(2)
@@ -372,7 +370,7 @@ struct SkinHelper final
const SkinParameter &param = params[f];
if (partType == param.name)
{
- rect->grid[param.index] = resman->getSubImage(
+ rect->grid[param.index] = resourceManager->getSubImage(
image, xPos, yPos, width, height);
return true;
}
@@ -430,7 +428,6 @@ Skin *Theme::readSkin(const std::string &filename, const bool full)
if (widgetType == "Window")
{
SkinHelper helper;
- helper.resman = ResourceManager::getInstance();
const int globalXPos = XML::getProperty(widgetNode, "xpos", 0);
const int globalYPos = XML::getProperty(widgetNode, "ypos", 0);
for_each_xml_child_node(partNode, widgetNode)
@@ -635,15 +632,13 @@ std::string Theme::resolveThemePath(const std::string &path)
Image *Theme::getImageFromTheme(const std::string &path)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- return resman->getImage(resolveThemePath(path));
+ return resourceManager->getImage(resolveThemePath(path));
}
ImageSet *Theme::getImageSetFromTheme(const std::string &path,
const int w, const int h)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- return resman->getImageSet(resolveThemePath(path), w, h);
+ return resourceManager->getImageSet(resolveThemePath(path), w, h);
}
static int readColorType(const std::string &type)
@@ -1143,8 +1138,8 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
const SDL_Rect &rect2 = image->mBounds;
if (rect2.w && rect2.h)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- ImageSet *const imageSet = resman->getSubImageSet(image, w, h);
+ ImageSet *const imageSet = resourceManager->getSubImageSet(
+ image, w, h);
theme->unload(skin);
return imageSet;
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index d5eb6b89a..ea6ca7be4 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -121,7 +121,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mSkin = theme->load(skin, "browserbox.xml");
if (mInstances == 0)
{
- mEmotes = ResourceManager::getInstance()->getImageSet(
+ mEmotes = resourceManager->getImageSet(
"graphics/sprites/chatemotes.png", 17, 18);
}
mInstances ++;
@@ -570,8 +570,6 @@ int BrowserBox::calcHeight()
Color selColor[2] = {mForegroundColor, mForegroundColor2};
const Color textColor[2] = {mForegroundColor, mForegroundColor2};
- ResourceManager *const resman = ResourceManager::getInstance();
-
mLineParts.clear();
FOR_EACH (TextRowCIter, i, mTextRows)
@@ -601,7 +599,7 @@ int BrowserBox::calcHeight()
const size_t sz = str.size();
if (sz > 2 && str.substr(sz - 1) == "~")
str = str.substr(0, sz - 1);
- Image *const img = resman->getImage(str);
+ Image *const img = resourceManager->getImage(str);
if (img)
{
img->incRef();
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 18cb7b138..9fdc11a61 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -172,10 +172,9 @@ void Desktop::setBestFittingWallpaper()
if (nWallPaper)
{
- ResourceManager *const resman = ResourceManager::getInstance();
if (mWallpaper)
{
- resman->decRefDelete(mWallpaper);
+ resourceManager->decRefDelete(mWallpaper);
mWallpaper = nullptr;
}
@@ -188,12 +187,12 @@ void Desktop::setBestFittingWallpaper()
|| nWallPaper->getHeight() != height))
{
// We rescale to obtain a fullscreen wallpaper...
- Image *const newRsclWlPpr = resman->getRescaled(
+ Image *const newRsclWlPpr = resourceManager->getRescaled(
nWallPaper, width, height);
if (newRsclWlPpr)
{
- resman->decRefDelete(nWallPaper);
+ resourceManager->decRefDelete(nWallPaper);
// We replace the resource in the resource manager
mWallpaper = newRsclWlPpr;
}
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index f40a855ec..7a9eee261 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -39,7 +39,7 @@ EmotePage::EmotePage(const Widget2 *const widget) :
Widget(widget),
MouseListener(),
WidgetListener(),
- mEmotes(ResourceManager::getInstance()->getImageSet(
+ mEmotes(resourceManager->getImageSet(
"graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)),
mVertexes(new ImageCollection),
mSelectedIndex(-1)
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 4be9ae127..5876b1201 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -32,7 +32,7 @@
Icon::Icon(const Widget2 *const widget,
const std::string &file) :
Widget(widget),
- mImage(ResourceManager::getInstance()->getImage(file))
+ mImage(resourceManager->getImage(file))
{
if (mImage)
{
diff --git a/src/gui/widgets/skilldata.cpp b/src/gui/widgets/skilldata.cpp
index 6137d768b..826d1d719 100644
--- a/src/gui/widgets/skilldata.cpp
+++ b/src/gui/widgets/skilldata.cpp
@@ -59,9 +59,8 @@ SkillData::~SkillData()
void SkillData::setIcon(const std::string &iconPath)
{
- ResourceManager *const res = ResourceManager::getInstance();
if (!iconPath.empty())
- icon = res->getImage(iconPath);
+ icon = resourceManager->getImage(iconPath);
if (!icon)
{
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 1ba871cd6..5e2159f5f 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -107,10 +107,9 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer(0, n++, mMessageLabel);
if (message->itemId)
{
- ResourceManager *const resman = ResourceManager::getInstance();
const ItemInfo &item = ItemDB::get(message->itemId);
// +++ need use message->cards and ItemColorManager for colors
- Image *const image = resman->getImage(combineDye2(
+ Image *const image = resourceManager->getImage(combineDye2(
paths.getStringValue("itemIcons").append(
item.getDisplay().image),
item.getDyeIconColorsString(ItemColor_one)));
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 502ebf91a..06531c69b 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -168,7 +168,6 @@ void Minimap::setMap(const Map *const map)
{
std::string tempname = paths.getStringValue("minimaps").append(
map->getFilename()).append(".png");
- ResourceManager *const resman = ResourceManager::getInstance();
std::string minimapName = map->getProperty("minimap");
@@ -183,7 +182,7 @@ void Minimap::setMap(const Map *const map)
minimapName = tempname;
}
- mMapImage = resman->getImage(minimapName);
+ mMapImage = resourceManager->getImage(minimapName);
mCustomMapImage = false;
}
}
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 992fd7e9c..bda9b3039 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -597,8 +597,6 @@ void NpcDialog::addChoice(const std::string &choice)
void NpcDialog::parseListItems(const std::string &itemString)
{
std::istringstream iss(itemString);
- ResourceManager *const resman = ResourceManager::getInstance();
-
std::string tmp;
const std::string path = paths.getStringValue("guiIcons");
while (getline(iss, tmp, ':'))
@@ -614,7 +612,7 @@ void NpcDialog::parseListItems(const std::string &itemString)
else
{
mItems.push_back(tmp.substr(pos + 1));
- Image *const img = resman->getImage(std::string(
+ Image *const img = resourceManager->getImage(std::string(
path).append(tmp.substr(0, pos)).append(".png"));
mImages.push_back(img);
}
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 9330539ab..79dfe29aa 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -639,7 +639,6 @@ void UpdaterWindow::download()
void UpdaterWindow::loadUpdates()
{
- const ResourceManager *const resman = ResourceManager::getInstance();
if (mUpdateFiles.empty())
{ // updates not downloaded
mUpdateFiles = loadXMLFile(std::string(mUpdatesDir).append(
@@ -661,17 +660,17 @@ void UpdaterWindow::loadUpdates()
const UpdateFile &file = mUpdateFiles[mUpdateIndex];
if (!file.group.empty())
continue;
- UpdaterWindow::addUpdateFile(resman, mUpdatesDir,
- fixPath, file.name, false);
+ UpdaterWindow::addUpdateFile(mUpdatesDir,
+ fixPath,
+ file.name,
+ false);
}
- loadManaPlusUpdates(mUpdatesDir, resman);
- loadMods(mUpdatesDir, resman, mUpdateFiles);
+ loadManaPlusUpdates(mUpdatesDir);
+ loadMods(mUpdatesDir, mUpdateFiles);
}
void UpdaterWindow::loadLocalUpdates(const std::string &dir)
{
- const ResourceManager *const resman = ResourceManager::getInstance();
-
std::vector<UpdateFile> updateFiles = loadXMLFile(
std::string(dir).append("/").append(xmlUpdateFile), false);
@@ -691,16 +690,17 @@ void UpdaterWindow::loadLocalUpdates(const std::string &dir)
const UpdateFile &file = updateFiles[updateIndex];
if (!file.group.empty())
continue;
- UpdaterWindow::addUpdateFile(resman, dir,
- fixPath, file.name, false);
+ UpdaterWindow::addUpdateFile(dir,
+ fixPath,
+ file.name,
+ false);
}
- loadManaPlusUpdates(dir, resman);
- loadMods(dir, resman, updateFiles);
+ loadManaPlusUpdates(dir);
+ loadMods(dir, updateFiles);
}
void UpdaterWindow::unloadUpdates(const std::string &dir)
{
- const ResourceManager *const resman = ResourceManager::getInstance();
std::vector<UpdateFile> updateFiles = loadXMLFile(
std::string(dir).append("/").append(xmlUpdateFile), true);
@@ -714,17 +714,15 @@ void UpdaterWindow::unloadUpdates(const std::string &dir)
for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
updateFiles.size()); updateIndex < sz; updateIndex ++)
{
- UpdaterWindow::removeUpdateFile(resman, dir, fixPath,
+ UpdaterWindow::removeUpdateFile(dir,
+ fixPath,
updateFiles[updateIndex].name);
}
- unloadManaPlusUpdates(dir, resman);
+ unloadManaPlusUpdates(dir);
}
-void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
- const ResourceManager *const resman)
+void UpdaterWindow::loadManaPlusUpdates(const std::string &dir)
{
- if (!resman)
- return;
std::string fixPath = dir + "/fix";
std::vector<UpdateFile> updateFiles = loadXMLFile(
std::string(fixPath).append("/").append(xmlUpdateFile), false);
@@ -742,16 +740,13 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
std::string fileName = std::string(fixPath).append(
"/").append(name);
if (!stat(fileName.c_str(), &statbuf))
- resman->addToSearchPath(fileName, false);
+ resourceManager->addToSearchPath(fileName, false);
}
}
}
-void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir,
- const ResourceManager *const resman)
+void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir)
{
- if (!resman)
- return;
const std::string fixPath = dir + "/fix";
const std::vector<UpdateFile> updateFiles = loadXMLFile(
std::string(fixPath).append("/").append(xmlUpdateFile), true);
@@ -766,44 +761,39 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir,
const std::string file = std::string(
fixPath).append("/").append(name);
if (!stat(file.c_str(), &statbuf))
- resman->removeFromSearchPath(file);
+ resourceManager->removeFromSearchPath(file);
}
}
}
-void UpdaterWindow::addUpdateFile(const ResourceManager *const resman,
- const std::string &restrict path,
+void UpdaterWindow::addUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
const std::string &restrict file,
const bool append)
{
- if (!resman)
- return;
const std::string tmpPath = std::string(path).append("/").append(file);
if (!append)
- resman->addToSearchPath(tmpPath, append);
+ resourceManager->addToSearchPath(tmpPath, append);
const std::string fixFile = std::string(fixPath).append("/").append(file);
struct stat statbuf;
if (!stat(fixFile.c_str(), &statbuf))
- resman->addToSearchPath(fixFile, append);
+ resourceManager->addToSearchPath(fixFile, append);
if (append)
- resman->addToSearchPath(tmpPath, append);
+ resourceManager->addToSearchPath(tmpPath, append);
}
-void UpdaterWindow::removeUpdateFile(const ResourceManager *const resman,
- const std::string &restrict path,
+void UpdaterWindow::removeUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
const std::string &restrict file)
{
- if (!resman)
- return;
- resman->removeFromSearchPath(std::string(path).append("/").append(file));
+ resourceManager->removeFromSearchPath(
+ std::string(path).append("/").append(file));
const std::string fixFile = std::string(fixPath).append("/").append(file);
struct stat statbuf;
if (!stat(fixFile.c_str(), &statbuf))
- resman->removeFromSearchPath(fixFile);
+ resourceManager->removeFromSearchPath(fixFile);
}
void UpdaterWindow::logic()
@@ -1086,11 +1076,8 @@ void UpdaterWindow::loadFile(std::string file)
}
void UpdaterWindow::loadMods(const std::string &dir,
- const ResourceManager *const resman,
const std::vector<UpdateFile> &updateFiles)
{
- if (!resman)
- return;
ModDB::load();
std::string modsString = serverConfig.getValue("mods", "");
std::set<std::string> modsList;
@@ -1107,8 +1094,10 @@ void UpdaterWindow::loadMods(const std::string &dir,
it = modsList.find(file.group);
if (it != modsList.end())
{
- UpdaterWindow::addUpdateFile(resman, dir,
- fixPath, file.name, false);
+ UpdaterWindow::addUpdateFile(dir,
+ fixPath,
+ file.name,
+ false);
}
}
@@ -1132,7 +1121,7 @@ void UpdaterWindow::loadMods(const std::string &dir,
std::string fileName = std::string(fixPath).append(
"/").append(name);
if (!stat(fileName.c_str(), &statbuf))
- resman->addToSearchPath(fileName, false);
+ resourceManager->addToSearchPath(fileName, false);
}
}
}
@@ -1143,7 +1132,6 @@ void UpdaterWindow::loadMods(const std::string &dir,
void UpdaterWindow::loadDirMods(const std::string &dir)
{
ModDB::load();
- const ResourceManager *const resman = ResourceManager::getInstance();
const ModInfos &mods = ModDB::getAll();
std::string modsString = serverConfig.getValue("mods", "");
@@ -1160,14 +1148,13 @@ void UpdaterWindow::loadDirMods(const std::string &dir)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
- resman->addToSearchPath(dir + "/" + localDir, false);
+ resourceManager->addToSearchPath(dir + "/" + localDir, false);
}
}
}
void UpdaterWindow::unloadMods(const std::string &dir)
{
- const ResourceManager *const resman = ResourceManager::getInstance();
const ModInfos &mods = ModDB::getAll();
std::string modsString = serverConfig.getValue("mods", "");
StringVect modsList;
@@ -1183,7 +1170,7 @@ void UpdaterWindow::unloadMods(const std::string &dir)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
- resman->removeFromSearchPath(dir + "/" + localDir);
+ resourceManager->removeFromSearchPath(dir + "/" + localDir);
}
}
}
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index 7c70817b0..be8b67938 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -122,27 +122,22 @@ class UpdaterWindow final : public Window,
static void unloadUpdates(const std::string &dir);
- static void addUpdateFile(const ResourceManager *const resman,
- const std::string &restrict path,
+ static void addUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
const std::string &restrict file,
const bool append);
- static void removeUpdateFile(const ResourceManager *const resman,
- const std::string &restrict path,
+ static void removeUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
const std::string &filerestrict);
- static void loadManaPlusUpdates(const std::string &dir,
- const ResourceManager *const resman);
+ static void loadManaPlusUpdates(const std::string &dir);
- static void unloadManaPlusUpdates(const std::string &dir,
- const ResourceManager *const resman);
+ static void unloadManaPlusUpdates(const std::string &dir);
static unsigned long getFileHash(const std::string &filePath);
static void loadMods(const std::string &dir,
- const ResourceManager *const resman,
const std::vector<UpdateFile> &updateFiles);
static void loadDirMods(const std::string &dir);
diff --git a/src/item.cpp b/src/item.cpp
index 50ccf374a..9a534cfad 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -93,14 +93,13 @@ void Item::setId(const int id,
if (mImage)
mImage->decRef();
- ResourceManager *const resman = ResourceManager::getInstance();
const ItemInfo &info = getInfo();
mTags = info.getTags();
const std::string dye = combineDye2(paths.getStringValue(
"itemIcons").append(info.getDisplay().image),
info.getDyeIconColorsString(color));
- mImage = resman->getImage(dye);
+ mImage = resourceManager->getImage(dye);
if (!mImage)
{
@@ -120,9 +119,8 @@ bool Item::isHaveTag(const int tagId) const
Image *Item::getImage(const int id,
const ItemColor color)
{
- ResourceManager *const resman = ResourceManager::getInstance();
const ItemInfo &info = ItemDB::get(id);
- Image *image = resman->getImage(combineDye2(paths.getStringValue(
+ Image *image = resourceManager->getImage(combineDye2(paths.getStringValue(
"itemIcons").append(info.getDisplay().image),
info.getDyeIconColorsString(color)));
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index f270dcc79..9dee09754 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -301,8 +301,6 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
return nullptr;
}
- ResourceManager *const resman = ResourceManager::getInstance();
-
// Parse particles
for_each_xml_child_node(effectChildNode, rootNode)
{
@@ -337,7 +335,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
}
if (!imageSrc.empty() && !dyePalettes.empty())
Dye::instantiate(imageSrc, dyePalettes);
- Image *const img = resman->getImage(imageSrc);
+ Image *const img = resourceManager->getImage(imageSrc);
newParticle = new ImageParticle(img);
newParticle->setMap(mMap);
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
index 69593a0e5..af9b32fe4 100644
--- a/src/particle/particleemitter.cpp
+++ b/src/particle/particleemitter.cpp
@@ -109,10 +109,7 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtrConst emitterNode,
{
if (!dyePalettes.empty())
Dye::instantiate(image, dyePalettes);
-
- ResourceManager *const resman
- = ResourceManager::getInstance();
- mParticleImage = resman->getImage(image);
+ mParticleImage = resourceManager->getImage(image);
}
}
else if (name == "subimage")
@@ -124,13 +121,10 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtrConst emitterNode,
{
if (!dyePalettes.empty())
Dye::instantiate(image, dyePalettes);
-
- ResourceManager *const resman
- = ResourceManager::getInstance();
- Image *img = resman->getImage(image);
+ Image *img = resourceManager->getImage(image);
if (img)
{
- mParticleImage = resman->getSubImage(img,
+ mParticleImage = resourceManager->getSubImage(img,
XML::getProperty(propertyNode, "x", 0),
XML::getProperty(propertyNode, "y", 0),
XML::getProperty(propertyNode, "width", 0),
@@ -363,17 +357,16 @@ ParticleEmitter::ParticleEmitter(const ParticleEmitter &o)
ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
{
- ResourceManager *const resman = ResourceManager::getInstance();
ImageSet *imageset = nullptr;
const int subX = XML::getProperty(node, "subX", -1);
if (subX != -1)
{
- Image *const img = resman->getImage(XML::getProperty(
+ Image *const img = resourceManager->getImage(XML::getProperty(
node, "imageset", ""));
if (!img)
return nullptr;
- Image *const img2 = resman->getSubImage(img, subX,
+ Image *const img2 = resourceManager->getSubImage(img, subX,
XML::getProperty(node, "subY", 0),
XML::getProperty(node, "subWidth", 0),
XML::getProperty(node, "subHeight", 0));
@@ -383,7 +376,7 @@ ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
return nullptr;
}
- imageset = resman->getSubImageSet(img2,
+ imageset = resourceManager->getSubImageSet(img2,
XML::getProperty(node, "width", 0),
XML::getProperty(node, "height", 0));
img2->decRef();
@@ -391,7 +384,7 @@ ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
}
else
{
- imageset = resman->getImageSet(
+ imageset = resourceManager->getImageSet(
XML::getProperty(node, "imageset", ""),
XML::getProperty(node, "width", 0),
XML::getProperty(node, "height", 0));
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
index ac1ecb9e0..345093074 100644
--- a/src/render/shaders/shadersmanager.cpp
+++ b/src/render/shaders/shadersmanager.cpp
@@ -65,14 +65,13 @@ Shader *ShadersManager::createShader(const unsigned int type,
ShaderProgram *ShadersManager::createProgram(const std::string &vertex,
const std::string &fragment)
{
- ResourceManager *const resman = ResourceManager::getInstance();
Shader *const vertexShader = static_cast<Shader*>(
- resman->getShader(GL_VERTEX_SHADER, vertex));
+ resourceManager->getShader(GL_VERTEX_SHADER, vertex));
if (!vertexShader)
return nullptr;
Shader *const fragmentShader = static_cast<Shader*>(
- resman->getShader(GL_FRAGMENT_SHADER, fragment));
+ resourceManager->getShader(GL_FRAGMENT_SHADER, fragment));
if (!fragmentShader)
{
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 391cc1410..454758e88 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -59,11 +59,12 @@ AmbientLayer::AmbientLayer(Image *const img,
{
// Rescale the overlay to keep the ratio as if we were on
// the default resolution...
- Image *const rescaledOverlay = ResourceManager::getInstance()->
- getRescaled(mImage, static_cast<int>(mImage->mBounds.w)
- / defaultScreenWidth * width,
- static_cast<int>(mImage->mBounds.h)
- / defaultScreenHeight * height);
+ Image *const rescaledOverlay = resourceManager->getRescaled(
+ mImage,
+ static_cast<int>(mImage->mBounds.w) /
+ defaultScreenWidth * width,
+ static_cast<int>(mImage->mBounds.h) /
+ defaultScreenHeight * height);
if (rescaledOverlay)
mImage = rescaledOverlay;
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index 23a1ec653..a3836ad46 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -101,19 +101,18 @@ void AtlasManager::loadImages(const StringVect &files,
std::vector<Image*> &images)
{
BLOCK_START("AtlasManager::loadImages")
- ResourceManager *const resman = ResourceManager::getInstance();
FOR_EACH (StringVectCIter, it, files)
{
const std::string str = *it;
// check is image with same name already in cache
// and if yes, move it to deleted set
- Resource *const res = resman->getTempResource(str);
+ Resource *const res = resourceManager->getTempResource(str);
if (res)
{
// increase counter because in moveToDeleted it will be decreased.
res->incRef();
- resman->moveToDeleted(res);
+ resourceManager->moveToDeleted(res);
}
std::string path = str;
@@ -321,7 +320,6 @@ void AtlasManager::injectToResources(const AtlasResource *const resource)
{
if (!resource)
return;
- ResourceManager *const resman = ResourceManager::getInstance();
FOR_EACH (std::vector<TextureAtlas*>::const_iterator,
it, resource->atlases)
{
@@ -331,14 +329,14 @@ void AtlasManager::injectToResources(const AtlasResource *const resource)
{
Image *const image = atlas->atlasImage;
if (image)
- resman->addResource(atlas->name, image);
+ resourceManager->addResource(atlas->name, image);
FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
AtlasItem *const item = *it2;
if (!item)
continue;
// add each atlas sub image to resources
- resman->addResource(item->name, item->image);
+ resourceManager->addResource(item->name, item->image);
}
}
}
@@ -348,7 +346,6 @@ void AtlasManager::moveToDeleted(AtlasResource *const resource)
{
if (!resource)
return;
- ResourceManager *const resman = ResourceManager::getInstance();
FOR_EACH (std::vector<TextureAtlas*>::iterator, it, resource->atlases)
{
// move each atlas image to deleted
@@ -359,7 +356,7 @@ void AtlasManager::moveToDeleted(AtlasResource *const resource)
if (image)
{
// move each atlas image to deleted
- resman->moveToDeleted(image);
+ resourceManager->moveToDeleted(image);
}
FOR_EACH (std::vector<AtlasItem*>::iterator, it2, atlas->items)
{
@@ -370,7 +367,7 @@ void AtlasManager::moveToDeleted(AtlasResource *const resource)
if (image2)
{
// move each atlas sub image to deleted
- resman->moveToDeleted(image2);
+ resourceManager->moveToDeleted(image2);
}
}
}
diff --git a/src/resources/atlasresource.cpp b/src/resources/atlasresource.cpp
index 0ec211979..9f27446bd 100644
--- a/src/resources/atlasresource.cpp
+++ b/src/resources/atlasresource.cpp
@@ -53,8 +53,7 @@ AtlasResource::~AtlasResource()
delete atlas;
}
}
- ResourceManager *const resman = ResourceManager::getInstance();
- resman->clearDeleted(false);
+ resourceManager->clearDeleted(false);
}
void AtlasResource::incRef()
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index fc1c5fa4f..ef15a26b2 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -185,14 +185,12 @@ Image::~Image()
void Image::SDLCleanCache()
{
- ResourceManager *const resman = ResourceManager::getInstance();
-
for (std::map<float, SDL_Surface*>::iterator
i = mAlphaCache.begin(), i_end = mAlphaCache.end();
i != i_end; ++i)
{
if (mSDLSurface != i->second)
- resman->scheduleDelete(i->second);
+ resourceManager->scheduleDelete(i->second);
i->second = nullptr;
}
mAlphaCache.clear();
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index b96abc7d2..cc2d3487a 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -222,8 +222,6 @@ void Map::optionChanged(const std::string &value)
void Map::initializeAmbientLayers()
{
- ResourceManager *const resman = ResourceManager::getInstance();
-
// search for "foreground*" or "overlay*" (old term) in map properties
for (int i = 0; /* terminated by a break */; i++)
{
@@ -243,7 +241,8 @@ void Map::initializeAmbientLayers()
break; // the FOR loop
}
- Image *const img = resman->getImage(getProperty(name + "image"));
+ Image *const img = resourceManager->getImage(
+ getProperty(name + "image"));
if (img)
{
int mask = atoi(getProperty(name + "mask").c_str());
@@ -270,7 +269,8 @@ void Map::initializeAmbientLayers()
toString(i)).append("image")); i ++)
{
const std::string name("background" + toString(i));
- Image *const img = resman->getImage(getProperty(name + "image"));
+ Image *const img = resourceManager->getImage(
+ getProperty(name + "image"));
if (img)
{
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
index 44f3ec889..ae45a0efb 100644
--- a/src/resources/map/mapitem.cpp
+++ b/src/resources/map/mapitem.cpp
@@ -114,14 +114,9 @@ void MapItem::setType(const int type)
}
if (!name.empty())
- {
- ResourceManager *const resman = ResourceManager::getInstance();
- mImage = resman->getImage(name);
- }
+ mImage = resourceManager->getImage(name);
else
- {
mImage = nullptr;
- }
}
void MapItem::setPos(const int x, const int y)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index f2ec5633d..8283a4268 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -330,7 +330,6 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
const std::string fileName = path.substr(path.rfind("/") + 1);
map->setProperty("shortName", fileName);
- ResourceManager *const resman = ResourceManager::getInstance();
#ifdef USE_OPENGL
BLOCK_START("MapReader::readMap load atlas")
@@ -339,7 +338,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
const MapInfo *const info = MapDB::getMapAtlas(fileName);
if (info)
{
- map->setAtlas(resman->getAtlas(
+ map->setAtlas(resourceManager->getAtlas(
info->atlas, *info->files));
}
}
@@ -460,7 +459,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
map->clearIndexedTilesets();
map->setActorsFix(0, atoi(map->getProperty("actorsfix").c_str()));
map->reduce();
- map->setWalkLayer(resman->getWalkLayer(fileName, map));
+ map->setWalkLayer(resourceManager->getWalkLayer(fileName, map));
unloadTempLayers();
map->updateDrawLayersList();
BLOCK_END("MapReader::readMap xml")
@@ -946,8 +945,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
if (!source.empty())
{
- ResourceManager *const resman = ResourceManager::getInstance();
- Image *const tilebmp = resman->getImage(
+ Image *const tilebmp = resourceManager->getImage(
resolveRelativePath(pathDir, source));
if (tilebmp)
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index 6ff66e303..f6fda29a1 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -65,7 +65,6 @@ void Resource::decRef()
if (mRefCount == 0 && !mNotCount)
{
// Warn the manager that this resource is no longer used.
- ResourceManager *const resman = ResourceManager::getInstance();
- resman->release(this);
+ resourceManager->release(this);
}
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 50d6ccb6d..b32126403 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -954,11 +954,6 @@ void ResourceManager::decRefDelete(Resource *const res)
}
}
-ResourceManager *ResourceManager::getInstance()
-{
- return resourceManager;
-}
-
void ResourceManager::deleteInstance()
{
#ifdef DUMP_LEAKED_RESOURCES
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index 9e3480380..6557afecf 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -220,12 +220,6 @@ class ResourceManager final
void clearScheduled();
/**
- * Returns an instance of the class, creating one if it does not
- * already exist.
- */
- static ResourceManager *getInstance() RETURNS_NONNULL A_WARN_UNUSED;
-
- /**
* Deletes the class instance if it exists.
*/
static void deleteInstance();
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 20d0537d1..d63ffdd8e 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -232,8 +232,8 @@ void SpriteDef::loadImageSet(const XmlNodePtr node,
std::string imageSrc = XML::getProperty(node, "src", "");
Dye::instantiate(imageSrc, palettes);
- ResourceManager *const resman = ResourceManager::getInstance();
- ImageSet *const imageSet = resman->getImageSet(imageSrc, width, height);
+ ImageSet *const imageSet = resourceManager->getImageSet(imageSrc,
+ width, height);
if (!imageSet)
{
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index 2943d5d92..90f39fbc9 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -156,8 +156,8 @@ void SimpleAnimation::initializeAnimation(const XmlNodePtr animationNode,
if (!imagePath.empty() && !dyePalettes.empty())
Dye::instantiate(imagePath, dyePalettes);
- const ImageSet *const imageset = ResourceManager::getInstance()
- ->getImageSet(XML::getProperty(animationNode, "imageset", ""),
+ const ImageSet *const imageset = resourceManager->getImageSet(
+ XML::getProperty(animationNode, "imageset", ""),
XML::getProperty(animationNode, "width", 0),
XML::getProperty(animationNode, "height", 0));
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
index 8a6170c7f..3002d39f7 100644
--- a/src/soundmanager.cpp
+++ b/src/soundmanager.cpp
@@ -255,8 +255,8 @@ void SoundManager::setSfxVolume(const int volume)
static SDLMusic *loadMusic(const std::string &fileName)
{
- ResourceManager *const resman = ResourceManager::getInstance();
- return resman->getMusic(paths.getStringValue("music").append(fileName));
+ return resourceManager->getMusic(
+ paths.getStringValue("music").append(fileName));
}
void SoundManager::playMusic(const std::string &fileName)
@@ -378,8 +378,7 @@ void SoundManager::playSfx(const std::string &path,
tmpPath = path;
else
tmpPath = paths.getValue("sfx", "sfx/").append(path);
- ResourceManager *const resman = ResourceManager::getInstance();
- SoundEffect *const sample = resman->getSoundEffect(tmpPath);
+ SoundEffect *const sample = resourceManager->getSoundEffect(tmpPath);
if (sample)
{
logger->log("SoundManager::playSfx() Playing: %s", path.c_str());
@@ -421,8 +420,7 @@ void SoundManager::playGuiSfx(const std::string &path)
tmpPath = path;
else
tmpPath = paths.getValue("sfx", "sfx/").append(path);
- ResourceManager *const resman = ResourceManager::getInstance();
- SoundEffect *const sample = resman->getSoundEffect(tmpPath);
+ SoundEffect *const sample = resourceManager->getSoundEffect(tmpPath);
if (sample)
{
logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str());
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 549b32896..7f2a66748 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -115,9 +115,8 @@ void TextCommand::loadImage()
if (getIcon().empty())
return;
- ResourceManager *const resman = ResourceManager::getInstance();
const SpriteDisplay display = ItemDB::get(getIcon()).getDisplay();
- mImage = resman->getImage(paths.getStringValue("itemIcons")
+ mImage = resourceManager->getImage(paths.getStringValue("itemIcons")
.append(display.image));
if (!mImage)
diff --git a/src/utils/files.cpp b/src/utils/files.cpp
index 1c942823a..578865503 100644
--- a/src/utils/files.cpp
+++ b/src/utils/files.cpp
@@ -45,8 +45,7 @@ void Files::extractLocale()
const std::string fileName2 = std::string(getenv(
"APPDIR")).append("/locale.zip");
- const ResourceManager *const resman = ResourceManager::getInstance();
- resman->addToSearchPath(fileName2, false);
+ resourceManager->addToSearchPath(fileName2, false);
const std::string localDir = std::string(getenv("APPDIR")).append("/");
char **rootDirs = PhysFs::enumerateFiles("locale");
@@ -66,7 +65,7 @@ void Files::extractLocale()
}
}
PhysFs::freeList(rootDirs);
- resman->removeFromSearchPath(fileName2);
+ resourceManager->removeFromSearchPath(fileName2);
remove(fileName2.c_str());
}
#endif // ANDROID
@@ -123,10 +122,9 @@ void Files::extractZip(const std::string &restrict zipName,
const std::string &restrict inDir,
const std::string &restrict outDir)
{
- const ResourceManager *const resman = ResourceManager::getInstance();
- resman->addToSearchPath(zipName, false);
+ resourceManager->addToSearchPath(zipName, false);
copyPhysFsDir(inDir, outDir);
- resman->removeFromSearchPath(zipName);
+ resourceManager->removeFromSearchPath(zipName);
remove(zipName.c_str());
}