]> Dogcows Code - chaz/yoink/blobdiff - src/Animation.cc
renamed mippleton to library
[chaz/yoink] / src / Animation.cc
index b449a0fbd97a500e36cd10e987831117fee4bf08..c694aecc44b0b3ef8df581c0a85d0efa8ac17f5e 100644 (file)
@@ -29,8 +29,8 @@
 #include <map>
 #include <vector>
 
+#include <Moof/Library.hh>
 #include <Moof/Log.hh>
-#include <Moof/Mippleton.hh>
 #include <Moof/Script.hh>
 
 #include "Animation.hh"
@@ -55,10 +55,10 @@ class Animation::Impl
         * which wants to use these loaded sequences.
         */
 
-       class Data : public Mf::Mippleton<Data>
+       class Data : public Mf::Library<Data>
        {
                friend class Impl;
-               friend class Mf::Mippleton<Data>;
+               friend class Mf::Library<Data>;
 
                /**
                 * A frame of an animation sequence.  A frame is merely an index which
@@ -66,10 +66,12 @@ class Animation::Impl
                 * and the duration that is how long the slide will be shown.
                 */
 
-               struct Frame
+               class Frame
                {
-                       unsigned        index;                                  ///< Frame index.
-                       Mf::Scalar      duration;                               ///< Frame duration.
+                       friend class Impl;
+
+                       unsigned        mIndex;                                 ///< Frame index.
+                       Mf::Scalar      mDuration;                              ///< Frame duration.
 
                        /**
                         * Construction is initialization.  The frame data is loaded from a
@@ -77,15 +79,15 @@ class Animation::Impl
                         */
                
                        Frame(Mf::Script& script, Mf::Script::Value table) :
-                               index(0),
-                               duration(1.0)
+                               mIndex(0),
+                               mDuration(1.0)
                        {
                                table.pushField("index");
-                               script[-1].get(index);
+                               script[-1].get(mIndex);
                                script.pop();
 
                                table.pushField("duration");
-                               script[-1].get(duration);
+                               script[-1].get(mDuration);
                                script.pop();
                        }
                };
@@ -98,10 +100,12 @@ class Animation::Impl
 
                struct Sequence
                {
-                       std::vector<Frame>      frames;                 ///< List of frames.
-                       Mf::Scalar                      delay;                  ///< Scale frame durations.
-                       bool                            loop;                   ///< Does the sequence repeat?
-                       std::string                     next;                   ///< Next sequence name.
+                       friend class Impl;
+
+                       std::vector<Frame>      mFrames;                ///< List of frames.
+                       Mf::Scalar                      mDelay;                 ///< Scale frame durations.
+                       bool                            mLoop;                  ///< Does the sequence repeat?
+                       std::string                     mNext;                  ///< Next sequence name.
 
                        /**
                         * Construction is initialization.  The constructor loads sequence
@@ -111,19 +115,19 @@ class Animation::Impl
                         */
 
                        Sequence(Mf::Script& script, Mf::Script::Value table) :
-                               delay(0.0),
-                               loop(true)
+                               mDelay(0.0),
+                               mLoop(true)
                        {
                                table.pushField("delay");
-                               script[-1].get(delay);
+                               script[-1].get(mDelay);
                                script.pop();
 
                                table.pushField("loop");
-                               script[-1].get(loop);
+                               script[-1].get(mLoop);
                                script.pop();
 
                                table.pushField("next");
-                               script[-1].get(next);
+                               script[-1].get(mNext);
                                script.pop();
 
                                // TODO - sequence class/type not yet implemented
@@ -140,7 +144,7 @@ class Animation::Impl
                                                script.push(index);
                                                frameTable.pushField();
 
-                                               if (top.isTable()) frames.push_back(Frame(script, top));
+                                               if (top.isTable()) mFrames.push_back(Frame(script, top));
                                                else               break;
 
                                                ++index;
@@ -210,7 +214,7 @@ class Animation::Impl
                 */
 
                explicit Data(const std::string& name) :
-                       Mf::Mippleton<Data>(name)
+                       Mf::Library<Data>(name)
                {
                        loadFromFile();
                }
@@ -224,12 +228,12 @@ class Animation::Impl
         */
 
        Impl(const std::string& name) :
-               data(Data::getInstance(name)),
-               currentSequence(0),
-               frameCounter(0),
-               frameIndex(0),
-               timeAccum(0),
-               frameDuration(0) {}
+               mData(Data::getInstance(name)),
+               mCurrentSequence(0),
+               mFrameCounter(0),
+               mFrameIndex(0),
+               mTimeAccum(0),
+               mFrameDuration(0) {}
 
 
        /**
@@ -242,16 +246,16 @@ class Animation::Impl
        {
                std::map<std::string,Data::Sequence>::iterator it;
 
-               it = data->sequences.find(name);
+               it = mData->sequences.find(name);
 
-               if (it != data->sequences.end())
+               if (it != mData->sequences.end())
                {
-                       currentSequence = &(*it).second;
-                       frameCounter = 0;
-                       frameIndex = currentSequence->frames[0].index;
-                       timeAccum = 0.0;
-                       frameDuration = currentSequence->delay *
-                               currentSequence->frames[0].duration;
+                       mCurrentSequence = &(*it).second;
+                       mFrameCounter = 0;
+                       mFrameIndex = mCurrentSequence->mFrames[0].mIndex;
+                       mTimeAccum = 0.0;
+                       mFrameDuration = mCurrentSequence->mDelay *
+                               mCurrentSequence->mFrames[0].mDuration;
                }
        }
 
@@ -267,62 +271,62 @@ class Animation::Impl
 
        void update(Mf::Scalar t, Mf::Scalar dt)
        {
-               if (currentSequence)
+               if (mCurrentSequence)
                {
-                       timeAccum += dt;
+                       mTimeAccum += dt;
 
-                       if (timeAccum >= frameDuration)
+                       if (mTimeAccum >= mFrameDuration)
                        {
-                               if (++frameCounter >= currentSequence->frames.size())
+                               if (++mFrameCounter >= mCurrentSequence->mFrames.size())
                                {
-                                       if (!currentSequence->next.empty())
+                                       if (!mCurrentSequence->mNext.empty())
                                        {
-                                               startSequence(currentSequence->next);
+                                               startSequence(mCurrentSequence->mNext);
                                        }
-                                       else if (currentSequence->loop)
+                                       else if (mCurrentSequence->mLoop)
                                        {
-                                               frameCounter = 0;
+                                               mFrameCounter = 0;
                                        }
                                        else
                                        {
-                                               frameCounter--;
-                                               currentSequence = 0;
+                                               mFrameCounter--;
+                                               mCurrentSequence = 0;
                                        }
                                }
 
-                               frameIndex = currentSequence->frames[frameCounter].index;
-                               timeAccum = frameDuration - timeAccum;
-                               frameDuration = currentSequence->delay *
-                                       currentSequence->frames[frameCounter].duration;
+                               mFrameIndex = mCurrentSequence->mFrames[mFrameCounter].mIndex;
+                               mTimeAccum = mFrameDuration - mTimeAccum;
+                               mFrameDuration = mCurrentSequence->mDelay *
+                                       mCurrentSequence->mFrames[mFrameCounter].mDuration;
                        }
                }
        }
 
-       boost::shared_ptr<Data> data;                           ///< Internal data.
+       boost::shared_ptr<Data> mData;                          ///< Internal data.
 
-       Data::Sequence*                 currentSequence;        ///< Active sequence.
-       unsigned                                frameCounter;           ///< Current frame.
-       unsigned                                frameIndex;                     ///< Index of current frame.
-       Mf::Scalar                              timeAccum;                      ///< Time accumulation.
-       Mf::Scalar                              frameDuration;          ///< Scaled frame duration.
+       Data::Sequence*                 mCurrentSequence;       ///< Active sequence.
+       unsigned                                mFrameCounter;          ///< Current frame.
+       unsigned                                mFrameIndex;            ///< Index of current frame.
+       Mf::Scalar                              mTimeAccum;                     ///< Time accumulation.
+       Mf::Scalar                              mFrameDuration;         ///< Scaled frame duration.
 };
 
 
 Animation::Animation(const std::string& name) :
        // pass through
-       impl_(new Animation::Impl(name)) {}
+       mImpl(new Animation::Impl(name)) {}
 
 
 void Animation::startSequence(const std::string& name)
 {
        // pass through
-       impl_->startSequence(name);
+       mImpl->startSequence(name);
 }
 
 void Animation::update(Mf::Scalar t, Mf::Scalar dt)
 {
        // pass through
-       impl_->update(t, dt);
+       mImpl->update(t, dt);
 }
 
 
@@ -333,7 +337,7 @@ void Animation::update(Mf::Scalar t, Mf::Scalar dt)
 
 unsigned Animation::getFrame() const
 {
-       return impl_->frameIndex;
+       return mImpl->mFrameIndex;
 }
 
 
This page took 0.026981 seconds and 4 git commands to generate.