mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-16 18:01:40 +00:00
FormSpec: 9-slice images, animated_images, and fgimg_middle (#12453)
* FormSpec: 9-slice images and animated_images * Add fgimg_middle; clean up code * Address issues, add tests * Fix stupid error; bump formspec version * Re-add image[] elements without a size
This commit is contained in:
parent
5a562a597c
commit
f7bcf7fa46
15 changed files with 222 additions and 204 deletions
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "irrlichttypes_extrabloated.h"
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
class ISimpleTextureSource;
|
||||
|
@ -8,21 +9,33 @@ class ISimpleTextureSource;
|
|||
class GUIAnimatedImage : public gui::IGUIElement {
|
||||
public:
|
||||
GUIAnimatedImage(gui::IGUIEnvironment *env, gui::IGUIElement *parent,
|
||||
s32 id, const core::rect<s32> &rectangle, const std::string &texture_name,
|
||||
s32 frame_count, s32 frame_duration, ISimpleTextureSource *tsrc);
|
||||
s32 id, const core::rect<s32> &rectangle);
|
||||
|
||||
virtual void draw() override;
|
||||
|
||||
void setFrameIndex(s32 frame);
|
||||
void setTexture(video::ITexture *texture) { m_texture = texture; };
|
||||
video::ITexture *getTexture() const { return m_texture; };
|
||||
|
||||
void setMiddleRect(const core::rect<s32> &middle) { m_middle = middle; };
|
||||
core::rect<s32> getMiddleRect() const { return m_middle; };
|
||||
|
||||
void setFrameDuration(u64 duration) { m_frame_duration = duration; };
|
||||
u64 getFrameDuration() const { return m_frame_duration; };
|
||||
|
||||
void setFrameCount(s32 count) { m_frame_count = std::max(count, 1); };
|
||||
s32 getFrameCount() const { return m_frame_count; };
|
||||
|
||||
void setFrameIndex(s32 frame) { m_frame_idx = std::max(frame, 0); };
|
||||
s32 getFrameIndex() const { return m_frame_idx; };
|
||||
|
||||
private:
|
||||
ISimpleTextureSource *m_tsrc;
|
||||
|
||||
video::ITexture *m_texture = nullptr;
|
||||
|
||||
u64 m_global_time = 0;
|
||||
s32 m_frame_idx = 0;
|
||||
s32 m_frame_count = 1;
|
||||
u64 m_frame_duration = 1;
|
||||
u64 m_frame_duration = 0;
|
||||
u64 m_frame_time = 0;
|
||||
|
||||
core::rect<s32> m_middle;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue