mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-23 22:55:39 +00:00
722468129e
Also changed some vectors.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
// SPDX-License-Identifier: MIT
|
|
//
|
|
// EmulationStation Desktop Edition
|
|
// AnimatedImageComponent.h
|
|
//
|
|
// Creates animation from multiple images files.
|
|
//
|
|
|
|
#ifndef ES_CORE_COMPONENTS_ANIMATED_IMAGE_COMPONENT_H
|
|
#define ES_CORE_COMPONENTS_ANIMATED_IMAGE_COMPONENT_H
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
class ImageComponent;
|
|
|
|
struct AnimationFrame {
|
|
std::string path;
|
|
int time;
|
|
};
|
|
|
|
struct AnimationDef {
|
|
AnimationFrame* frames;
|
|
size_t frameCount;
|
|
bool loop;
|
|
};
|
|
|
|
class AnimatedImageComponent : public GuiComponent
|
|
{
|
|
public:
|
|
AnimatedImageComponent(Window* window);
|
|
|
|
void load(const AnimationDef* def); // No reference to def is kept after loading is complete.
|
|
|
|
void reset(); // Set to frame 0.
|
|
|
|
void update(int deltaTime) override;
|
|
void render(const glm::mat4& trans) override;
|
|
|
|
void onSizeChanged() override;
|
|
|
|
private:
|
|
typedef std::pair<std::unique_ptr<ImageComponent>, int> ImageFrame;
|
|
|
|
std::vector<ImageFrame> mFrames;
|
|
|
|
bool mLoop;
|
|
bool mEnabled;
|
|
int mFrameAccumulator;
|
|
int mCurrentFrame;
|
|
};
|
|
|
|
#endif // ES_CORE_COMPONENTS_ANIMATED_IMAGE_COMPONENT_H
|