void LocalPlayer::loadTargetCursor(const std::string &filename, const int width, const int height, const bool outRange, const TargetCursorSize &size) { assert(size > -1); assert(size < 3); ResourceManager *resman = ResourceManager::getInstance(); ImageSet *currentImageSet = resman->getImageSet(filename, width, height); Animation *anim = new Animation(); for (unsigned int i = 0; i < currentImageSet->size(); ++i) { anim->addFrame(currentImageSet->get(i), 75, (16 - (currentImageSet->getWidth() / 2)), (16 - (currentImageSet->getHeight() / 2))); } SimpleAnimation *currentCursor = new SimpleAnimation(anim); const int index = outRange ? 1 : 0; mTargetCursorImages[index][size] = currentImageSet; mTargetCursor[index][size] = currentCursor; }
void SpriteDef::loadImageSet(XmlNodePtr node, const std::string &palettes) { const std::string name = XML::getProperty(node, "name", ""); // We don't allow redefining image sets. This way, an included sprite // definition will use the already loaded image set with the same name. if (mImageSets.find(name) != mImageSets.end()) return; const int width = XML::getProperty(node, "width", 0); const int height = XML::getProperty(node, "height", 0); std::string imageSrc = XML::getProperty(node, "src", ""); Dye::instantiate(imageSrc, palettes); ResourceManager *resman = ResourceManager::getInstance(); ImageSet *imageSet = resman->getImageSet(imageSrc, width, height); if (!imageSet) { logger->log1("Couldn't load imageset!"); return; } imageSet->setOffsetX(XML::getProperty(node, "offsetX", 0)); imageSet->setOffsetY(XML::getProperty(node, "offsetY", 0)); mImageSets[name] = imageSet; }