summaryrefslogtreecommitdiff
path: root/src/simpleanimation.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-02-07 19:07:04 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-02-07 19:07:04 +0100
commita3157908d23fd711ea96797dffce064953cb8fb6 (patch)
tree2f237b21118461a9948f3ccb829f62038564dedf /src/simpleanimation.cpp
parent1208d5383a9bfd03f338ccf71fb9764790b2e1a9 (diff)
downloadmana-a3157908d23fd711ea96797dffce064953cb8fb6.tar.gz
mana-a3157908d23fd711ea96797dffce064953cb8fb6.tar.bz2
mana-a3157908d23fd711ea96797dffce064953cb8fb6.tar.xz
mana-a3157908d23fd711ea96797dffce064953cb8fb6.zip
Nicer way of indicating that we're waiting on the server
No longer a dialog with an annoying progress bar (due to going back and forth), but rather a progress indicator that integrates better with the background.
Diffstat (limited to 'src/simpleanimation.cpp')
-rw-r--r--src/simpleanimation.cpp126
1 files changed, 65 insertions, 61 deletions
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index b90ee685..f13ed18b 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -19,9 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "simpleanimation.h"
+
#include "graphics.h"
#include "log.h"
-#include "simpleanimation.h"
#include "resources/animation.h"
#include "resources/image.h"
@@ -37,11 +38,73 @@ SimpleAnimation::SimpleAnimation(Animation *animation):
}
SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode):
+ mAnimation(new Animation),
mAnimationTime(0),
mAnimationPhase(0)
{
- mAnimation = new Animation;
+ initializeAnimation(animationNode);
+ mCurrentFrame = mAnimation->getFrame(0);
+}
+
+SimpleAnimation::~SimpleAnimation()
+{
+ delete mAnimation;
+}
+
+bool SimpleAnimation::draw(Graphics *graphics, int posX, int posY) const
+{
+ if (!mCurrentFrame || !mCurrentFrame->image)
+ return false;
+
+ return graphics->drawImage(mCurrentFrame->image,
+ posX + mCurrentFrame->offsetX,
+ posY + mCurrentFrame->offsetY);
+}
+
+void SimpleAnimation::reset()
+{
+ mAnimationTime = 0;
+ mAnimationPhase = 0;
+}
+
+void SimpleAnimation::setFrame(int frame)
+{
+ if (frame < 0)
+ frame = 0;
+ if (frame >= mAnimation->getLength())
+ frame = mAnimation->getLength() - 1;
+ mAnimationPhase = frame;
+ mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
+}
+
+void SimpleAnimation::update(int timePassed)
+{
+ mAnimationTime += timePassed;
+
+ while (mAnimationTime > mCurrentFrame->delay && mCurrentFrame->delay > 0)
+ {
+ mAnimationTime -= mCurrentFrame->delay;
+ mAnimationPhase++;
+
+ if (mAnimationPhase >= mAnimation->getLength())
+ mAnimationPhase = 0;
+
+ mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
+ }
+}
+
+int SimpleAnimation::getLength() const
+{
+ return mAnimation->getLength();
+}
+
+Image *SimpleAnimation::getCurrentImage() const
+{
+ return mCurrentFrame->image;
+}
+void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode)
+{
ImageSet *imageset = ResourceManager::getInstance()->getImageSet(
XML::getProperty(animationNode, "imageset", ""),
XML::getProperty(animationNode, "width", 0),
@@ -109,63 +172,4 @@ SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode):
mAnimation->addTerminator();
}
}
-
- mCurrentFrame = mAnimation->getFrame(0);
-}
-
-bool SimpleAnimation::draw(Graphics* graphics, int posX, int posY) const
-{
- if (!mCurrentFrame || !mCurrentFrame->image)
- return false;
-
- return graphics->drawImage(mCurrentFrame->image,
- posX + mCurrentFrame->offsetX,
- posY + mCurrentFrame->offsetY);
-}
-
-void SimpleAnimation::reset()
-{
- mAnimationTime = 0;
- mAnimationPhase = 0;
-}
-
-void SimpleAnimation::setFrame(int frame)
-{
- if (frame < 0)
- frame = 0;
- if (frame >= mAnimation->getLength())
- frame = mAnimation->getLength() - 1;
- mAnimationPhase = frame;
- mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
-}
-
-void SimpleAnimation::update(int timePassed)
-{
- mAnimationTime += timePassed;
-
- while (mAnimationTime > mCurrentFrame->delay && mCurrentFrame->delay > 0)
- {
- mAnimationTime -= mCurrentFrame->delay;
- mAnimationPhase++;
-
- if (mAnimationPhase >= mAnimation->getLength())
- mAnimationPhase = 0;
-
- mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
- }
-}
-
-int SimpleAnimation::getLength() const
-{
- return mAnimation->getLength();
-}
-
-Image *SimpleAnimation::getCurrentImage() const
-{
- return mCurrentFrame->image;
-}
-
-SimpleAnimation::~SimpleAnimation()
-{
- delete mAnimation;
}