2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "common.hpp"
|
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "drawtypes/label.hpp"
|
|
|
|
#include "utils/mixins.hpp"
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
LEMONBUDDY_NS
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
namespace drawtypes {
|
|
|
|
class animation : public non_copyable_mixin<animation> {
|
|
|
|
public:
|
|
|
|
explicit animation(int framerate_ms) : m_framerate_ms(framerate_ms) {}
|
|
|
|
explicit animation(vector<icon_t>&& frames, int framerate_ms)
|
|
|
|
: m_frames(forward<decltype(frames)>(frames))
|
|
|
|
, m_framerate_ms(framerate_ms)
|
|
|
|
, m_framecount(m_frames.size())
|
|
|
|
, m_lastupdate(chrono::system_clock::now()) {}
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
void add(icon_t&& frame);
|
|
|
|
icon_t get();
|
|
|
|
int framerate();
|
|
|
|
operator bool();
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
protected:
|
2016-11-02 15:22:45 -04:00
|
|
|
void tick();
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
vector<icon_t> m_frames;
|
|
|
|
int m_framerate_ms = 1000;
|
|
|
|
int m_frame = 0;
|
|
|
|
int m_framecount = 0;
|
|
|
|
chrono::system_clock::time_point m_lastupdate;
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
|
2016-10-25 01:10:03 -04:00
|
|
|
using animation_t = shared_ptr<animation>;
|
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
animation_t load_animation(
|
|
|
|
const config& conf, string section, string name = "animation", bool required = true);
|
2016-05-19 10:41:06 -04:00
|
|
|
}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
LEMONBUDDY_NS_END
|