summaryrefslogtreecommitdiff
path: root/src/simpleanimation.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-06 21:12:22 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-07 10:43:54 +0100
commitc74680473e702bacc009897a258387445d6f3eb5 (patch)
tree800cfb1f83f0c69ae8fcd0096949e660152a80b8 /src/simpleanimation.h
parentf9a522c72db959b5d63061ed255735d0230fc7de (diff)
downloadmana-c74680473e702bacc009897a258387445d6f3eb5.tar.gz
mana-c74680473e702bacc009897a258387445d6f3eb5.tar.bz2
mana-c74680473e702bacc009897a258387445d6f3eb5.tar.xz
mana-c74680473e702bacc009897a258387445d6f3eb5.zip
Use the native TMX tile animation format
Rewrote the tile animation loading code based on XML tags, replacing the code that loaded tile animations from tile properties. Also made a number of code simplifications and optimizations: * Replaced a number of pointer members with value members. * Pass around Animation and TileAnimation by value, using std::move to avoid allocating copies. * push -> emplace * push_front -> emplace_front * push_back -> emplace_back * Use range-based for loops * Use std::vector instead of std::list for storing affected tiles (less fragmentation) * Avoid string copies and allocations while parsing CSV layer data. * Replaced xmlNodeGetContent with directly accessing 'content'.
Diffstat (limited to 'src/simpleanimation.h')
-rw-r--r--src/simpleanimation.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/simpleanimation.h b/src/simpleanimation.h
index 558e59ce..a8fb4cba 100644
--- a/src/simpleanimation.h
+++ b/src/simpleanimation.h
@@ -22,33 +22,30 @@
#ifndef SIMPLEANIMAION_H
#define SIMPLEANIMAION_H
+#include "resources/animation.h"
+
#include "utils/xml.h"
-class Animation;
-class Frame;
class Graphics;
-class Image;
/**
* This class is a leightweight alternative to the AnimatedSprite class.
* It hosts a looping animation without actions and directions.
*/
-class SimpleAnimation
+class SimpleAnimation final
{
public:
/**
* Creates a simple animation with an already created \a animation.
* Takes ownership over the given animation.
*/
- SimpleAnimation(Animation *animation);
+ SimpleAnimation(Animation animation);
/**
* Creates a simple animation that creates its animation from XML Data.
*/
SimpleAnimation(xmlNodePtr animationNode,
- const std::string& dyePalettes = std::string());
-
- ~SimpleAnimation();
+ const std::string &dyePalettes = std::string());
void setFrame(int frame);
@@ -70,19 +67,19 @@ class SimpleAnimation
const std::string& dyePalettes = std::string());
/** The hosted animation. */
- Animation *mAnimation;
+ Animation mAnimation;
/** Time in game ticks the current frame is shown. */
- int mAnimationTime;
+ int mAnimationTime = 0;
/** Index of current animation phase. */
- int mAnimationPhase;
+ int mAnimationPhase = 0;
/** Current animation phase. */
- Frame *mCurrentFrame;
+ Frame *mCurrentFrame = nullptr;
/** Tell whether the animation is ready */
- bool mInitialized;
+ bool mInitialized = false;
};
#endif