ManaPlus
|
#include <spritedef.h>
Public Member Functions | |
const Action * | getAction (const std::string &action, const unsigned num) const |
unsigned | findNumber (const unsigned num) const |
void | addAction (const unsigned hp, const std::string &name, Action *const action) |
int | calcMemoryLocal () const |
int | calcMemoryChilds (const int level) const |
bool | addSequence (const int start, const int end, const int delay, const int offsetX, const int offsetY, const int variant_offset, int repeat, const int rand, const ImageSet *const imageSet, Animation *const animation) const |
Public Member Functions inherited from Resource | |
Resource () | |
~Resource () | |
virtual void | incRef () |
virtual void | decRef () |
std::string | getCounterName () const |
Public Member Functions inherited from MemoryCounter | |
MemoryCounter () | |
virtual | ~MemoryCounter () |
int | calcMemory (const int level) const |
Static Public Member Functions | |
static SpriteDef * | load (const std::string &file, const int variant, const bool prot) |
static SpriteDirection::Type | makeSpriteDirection (const std::string &direction) |
Private Types | |
typedef std::map< std::string, ImageSet * > | ImageSets |
typedef ImageSets::iterator | ImageSetIterator |
typedef ImageSets::const_iterator | ImageSetCIterator |
typedef std::map< std::string, Action * > | ActionMap |
typedef std::map< unsigned, ActionMap * > | Actions |
typedef Actions::const_iterator | ActionsConstIter |
typedef Actions::iterator | ActionsIter |
typedef Actions::const_iterator | ActionsCIter |
Private Member Functions | |
SpriteDef () | |
~SpriteDef () | |
void | loadSprite (const xmlNodePtr spriteNode, const int variant, const std::string &palettes) |
void | loadImageSet (const xmlNodePtr node, const std::string &palettes) |
void | loadAction (const xmlNodePtr node, const int variant_offset) |
void | loadAnimation (const xmlNodePtr animationNode, Action *const action, const ImageSet *const imageSet, const int variant_offset) const |
void | includeSprite (const xmlNodePtr includeNode, const int variant) |
const ImageSet * | getImageSet (const std::string &imageSetName) const |
void | substituteActions () |
void | fixDeadAction () |
void | substituteAction (const std::string &complete, const std::string &with) |
Private Attributes | |
ImageSets | mImageSets |
Actions | mActions |
std::set< std::string > | mProcessedFiles |
Additional Inherited Members | |
Data Fields inherited from Resource | |
time_t | mTimeStamp |
std::string | mIdPath |
std::string | mSource |
unsigned int | mRefCount |
bool | mProtected |
bool | mNotCount |
Defines a class to load an animation.
Definition at line 41 of file spritedef.h.
|
private |
Definition at line 156 of file spritedef.h.
|
private |
Definition at line 157 of file spritedef.h.
|
private |
Definition at line 160 of file spritedef.h.
|
private |
Definition at line 158 of file spritedef.h.
|
private |
Definition at line 159 of file spritedef.h.
|
private |
Definition at line 155 of file spritedef.h.
|
private |
Definition at line 154 of file spritedef.h.
|
private |
Definition at line 153 of file spritedef.h.
|
inlineprivate |
Constructor.
Definition at line 89 of file spritedef.h.
Referenced by calcMemoryLocal(), and load().
|
private |
Destructor.
Definition at line 524 of file spritedef.cpp.
References actions, FOR_EACH, FOR_EACHP, mActions, and mImageSets.
void SpriteDef::addAction | ( | const unsigned | hp, |
const std::string & | name, | ||
Action *const | action | ||
) |
bool SpriteDef::addSequence | ( | const int | start, |
const int | end, | ||
const int | delay, | ||
const int | offsetX, | ||
const int | offsetY, | ||
const int | variant_offset, | ||
int | repeat, | ||
const int | rand, | ||
const ImageSet *const | imageSet, | ||
Animation *const | animation | ||
) | const |
Definition at line 586 of file spritedef.cpp.
References Animation::addFrame(), ImageSet::get(), Resource::mSource, reportAlways, and anonymous_namespace{stringutils.cpp}::start.
Referenced by loadAnimation().
|
virtual |
Reimplemented from MemoryCounter.
Definition at line 674 of file spritedef.cpp.
References MemoryCounter::calcMemory(), FOR_EACH, FOR_EACHP, mActions, and mImageSets.
|
virtual |
Reimplemented from Resource.
Definition at line 660 of file spritedef.cpp.
References Resource::calcMemoryLocal(), FOR_EACH, mProcessedFiles, and SpriteDef().
unsigned SpriteDef::findNumber | ( | const unsigned | num | ) | const |
|
private |
Fix bad timeout in last dead action frame
Definition at line 136 of file spritedef.cpp.
References SpriteAction::DEAD(), FOR_EACH, mActions, and SpriteAction::STAND().
Referenced by load().
const Action * SpriteDef::getAction | ( | const std::string & | action, |
const unsigned | num | ||
) | const |
Returns the specified action.
Definition at line 52 of file spritedef.cpp.
References Logger::log(), logger, and mActions.
|
private |
Definition at line 269 of file spritedef.cpp.
References Resource::mIdPath, mImageSets, Resource::mSource, and reportAlways.
Referenced by loadAction(), and loadAnimation().
|
private |
Include another sprite into this one.
Definition at line 487 of file spritedef.cpp.
References Resource::decRef(), XML::getProperty(), Configuration::getStringValue(), Loader::getXml(), loadSprite(), mProcessedFiles, Resource::mSource, pathJoin(), paths, reportAlways, XML::Document::rootNode(), SkipError_false, and UseVirtFs_true.
Referenced by loadSprite().
|
static |
Loads a sprite definition file.
Definition at line 90 of file spritedef.cpp.
References BLOCK_END, BLOCK_START, Resource::decRef(), fixDeadAction(), Settings::fixDeadAnimation, Configuration::getStringValue(), Loader::getXml(), Resource::incRef(), loadSprite(), mProcessedFiles, Resource::mProtected, Resource::mSource, pathJoin(), paths, reportAlways, XML::Document::rootNode(), settings, SkipError_false, SpriteDef(), substituteActions(), and UseVirtFs_true.
Referenced by anonymous_namespace{spritedefloader.cpp}::SpriteDefLoader::load().
|
private |
Loads an action element.
Definition at line 283 of file spritedef.cpp.
References addAction(), SpriteAction::DEFAULT(), for_each_xml_child_node, getImageSet(), XML::getProperty(), SpriteAction::INVALID, loadAnimation(), mActions, Resource::mIdPath, Resource::mSource, reportAlways, and Action::setNumber().
Referenced by loadSprite().
|
private |
Loads an animation element.
Definition at line 327 of file spritedef.cpp.
References Animation::addFrame(), Animation::addGoto(), Animation::addJump(), Animation::addLabel(), Animation::addPause(), addSequence(), Animation::addTerminator(), ParticleType::Animation, FOR_EACH, for_each_xml_child_node, ImageSet::get(), ImageSet::getHeight(), getImageSet(), XML::getIntProperty(), ImageSet::getOffsetX(), ImageSet::getOffsetY(), XML::getProperty(), ImageSet::getWidth(), SpriteDirection::INVALID, makeSpriteDirection(), mapTileSize, Resource::mIdPath, Resource::mSource, reportAlways, Action::setAnimation(), splitToStringVector(), and anonymous_namespace{stringutils.cpp}::start.
Referenced by loadAction().
|
private |
Loads an imageset element.
Definition at line 238 of file spritedef.cpp.
References Loader::getImageSet(), XML::getProperty(), Dye::instantiate(), mImageSets, Resource::mSource, reportAlways, ImageSet::setOffsetX(), and ImageSet::setOffsetY().
Referenced by loadSprite().
|
private |
Loads a sprite element.
Definition at line 205 of file spritedef.cpp.
References BLOCK_END, BLOCK_START, for_each_xml_child_node, XML::getProperty(), includeSprite(), loadAction(), and loadImageSet().
Referenced by includeSprite(), and load().
|
static |
Converts a string into a SpriteDirection enum.
Definition at line 551 of file spritedef.cpp.
References SpriteDirection::DEFAULT, SpriteDirection::DOWN, SpriteDirection::DOWNLEFT, SpriteDirection::DOWNRIGHT, SpriteDirection::INVALID, SpriteDirection::LEFT, SpriteDirection::RIGHT, SpriteDirection::UP, SpriteDirection::UPLEFT, and SpriteDirection::UPRIGHT.
Referenced by loadAnimation().
|
private |
When there are no animations defined for the action "complete", its animations become a copy of those of the action "with".
Definition at line 155 of file spritedef.cpp.
References FOR_EACH, mActions, and reportTrue.
Referenced by substituteActions().
|
private |
Complete missing actions by copying existing ones.
Definition at line 172 of file spritedef.cpp.
References SpriteAction::ATTACK(), SpriteAction::ATTACKRIDE(), SpriteAction::ATTACKSKY(), SpriteAction::ATTACKWATER(), SpriteAction::CAST(), SpriteAction::CASTRIDE(), SpriteAction::CASTSKY(), SpriteAction::CASTWATER(), SpriteAction::DEAD(), SpriteAction::DEADRIDE(), SpriteAction::DEADSKY(), SpriteAction::DEADWATER(), SpriteAction::DEFAULT(), SpriteAction::FLY(), SpriteAction::MOVE(), SpriteAction::RIDE(), SpriteAction::SIT(), SpriteAction::SITRIDE(), SpriteAction::SITSKY(), SpriteAction::SITTOP(), SpriteAction::SITWATER(), SpriteAction::SPAWN(), SpriteAction::SPAWNRIDE(), SpriteAction::SPAWNSKY(), SpriteAction::SPAWNWATER(), SpriteAction::STAND(), SpriteAction::STANDRIDE(), SpriteAction::STANDSKY(), SpriteAction::STANDWATER(), substituteAction(), and SpriteAction::SWIM().
Referenced by load().
|
private |
Definition at line 163 of file spritedef.h.
Referenced by addAction(), calcMemoryChilds(), findNumber(), fixDeadAction(), getAction(), loadAction(), substituteAction(), and ~SpriteDef().
|
private |
Definition at line 162 of file spritedef.h.
Referenced by calcMemoryChilds(), getImageSet(), loadImageSet(), and ~SpriteDef().
|
private |
Definition at line 164 of file spritedef.h.
Referenced by calcMemoryLocal(), includeSprite(), and load().