Peoplemon  0.1.0
Peoplemon 3 game source documentation
WalkAnimations.cpp
Go to the documentation of this file.
2 
3 #include <BLIB/Util/FileUtil.hpp>
4 
5 namespace core
6 {
7 namespace res
8 {
9 bool WalkAnimations::loadFromDirectory(const std::string& path) {
10  using AnimationManager = bl::resource::ResourceManager<bl::gfx::a2d::AnimationData>;
12 
13  if (!AnimationManager::initializeExisting(FileUtil::joinPath(path, "up.anim"), *this)) {
14  return false;
15  }
16  maxLen = getLength();
17 
18  prepareForStates(4);
19  bl::gfx::a2d::AnimationData temp;
20  if (!AnimationManager::initializeExisting(FileUtil::joinPath(path, "right.anim"), temp)) {
21  return false;
22  }
23  maxLen = std::max(maxLen, temp.getLength());
24  addState(1, temp);
25 
26  if (!AnimationManager::initializeExisting(FileUtil::joinPath(path, "down.anim"), temp)) {
27  return false;
28  }
29  maxLen = std::max(maxLen, temp.getLength());
30  addState(2, temp);
31 
32  if (!AnimationManager::initializeExisting(FileUtil::joinPath(path, "left.anim"), temp)) {
33  return false;
34  }
35  maxLen = std::max(maxLen, temp.getLength());
36  addState(3, temp);
37 
38  return true;
39 }
40 
41 bool WalkAnimationLoader::load(const std::string& path, const char*, std::size_t, std::istream&,
42  WalkAnimations& result) {
43  return result.loadFromDirectory(path);
44 }
45 
46 } // namespace res
47 } // namespace core
bl::resource::ResourceManager< bl::gfx::a2d::AnimationData > AnimationManager
Definition: Resources.hpp:20
Core classes and functionality for both the editor and game.
bl::util::FileUtil FileUtil
Extension of animation data that loads and combines the animations for each movement direction into a...
bool loadFromDirectory(const std::string &path)
Loads the walking animations from the given directory.
virtual bool load(const std::string &path, const char *, std::size_t, std::istream &, WalkAnimations &result) override
Loads the walking animations from the given path.