]> Dogcows Code - chaz/yoink/blobdiff - src/Animation.cc
library class revamped as manager, goodbye tilemap
[chaz/yoink] / src / Animation.cc
index 598361bf97143c28cb1ca2d78d495692d50f6d31..477997037230b125635f28cf4980d8ffa3d3cc3a 100644 (file)
@@ -29,7 +29,7 @@
 #include <map>
 #include <vector>
 
-#include <Moof/Library.hh>
+#include <Moof/Manager.hh>
 #include <Moof/Log.hh>
 #include <Moof/Script.hh>
 
@@ -47,7 +47,7 @@
 
 class Animation::Impl
 {
-       friend class Animation;
+public:
 
        /**
         * Contains "global" animation data for the various animations which get
@@ -55,10 +55,9 @@ class Animation::Impl
         * which wants to use these loaded sequences.
         */
 
-       class Data : public Mf::Library<Data>
+       class Data : public Mf::Manager<Data>
        {
-               friend class Impl;
-               friend class Mf::Library<Data>;
+       public:
 
                /**
                 * A frame of an animation sequence.  A frame is merely an index which
@@ -68,7 +67,7 @@ class Animation::Impl
 
                class Frame
                {
-                       friend class Impl;
+               public:
 
                        unsigned        mIndex;                                 ///< Frame index.
                        Mf::Scalar      mDuration;                              ///< Frame duration.
@@ -98,9 +97,9 @@ class Animation::Impl
                 * that they should be played.
                 */
 
-               struct Sequence
+               class Sequence
                {
-                       friend class Impl;
+               public:
 
                        std::vector<Frame>      mFrames;                ///< List of frames.
                        Mf::Scalar                      mDelay;                 ///< Scale frame durations.
@@ -161,10 +160,10 @@ class Animation::Impl
                 * individual sequence.
                 */
 
-               void loadFromFile()
+               void init(const std::string& name)
                {
                        Mf::Script script;
-                       std::string filePath = Animation::getPath(getName());
+                       std::string filePath = Animation::getPath(name);
 
                        script.importBaseLibrary();
                        importLogFunctions(script);
@@ -186,7 +185,7 @@ class Animation::Impl
                        std::string nameStr;
                        name.get(nameStr);
 
-                       sequences.insert(std::pair<std::string,Sequence>(nameStr,
+                       mSequences.insert(std::pair<std::string,Sequence>(nameStr,
                                                Sequence(script, table)));
 
                        return 0;
@@ -208,18 +207,7 @@ class Animation::Impl
                }
 
 
-               /**
-                * Construction is initialization.  The animation class data container
-                * registers itself as a mippleton and then loads the animation data.
-                */
-
-               explicit Data(const std::string& name) :
-                       Mf::Library<Data>(name)
-               {
-                       loadFromFile();
-               }
-
-               std::map<std::string,Sequence> sequences;               ///< List of sequences.
+               std::map<std::string,Sequence> mSequences;              ///< List of sequences.
        };
 
 
@@ -246,9 +234,9 @@ class Animation::Impl
        {
                std::map<std::string,Data::Sequence>::iterator it;
 
-               it = mData->sequences.find(name);
+               it = mData->mSequences.find(name);
 
-               if (it != mData->sequences.end())
+               if (it != mData->mSequences.end())
                {
                        mCurrentSequence = &(*it).second;
                        mFrameCounter = 0;
This page took 0.022254 seconds and 4 git commands to generate.