diff options
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/mailviewwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/minimap.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 81 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.h | 13 |
5 files changed, 41 insertions, 63 deletions
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); |