expose mng to lua as a gcn::Image for easy use in widgets

This commit is contained in:
Tim Felgentreff 2020-06-27 12:45:54 +02:00
parent eb2b23749d
commit 1563d98f35
4 changed files with 28 additions and 1 deletions
src

View file

@ -142,7 +142,7 @@ public:
#ifdef USE_MNG
#include <libmng.h>
class Mng
class Mng : public gcn::Image
{
public:
Mng();
@ -151,6 +151,11 @@ public:
void Reset();
void Draw(int x, int y);
//guichan
virtual void *_getData() const;
virtual int getWidth() const { return surface->h; }
virtual int getHeight() const { return surface->w; }
std::string name;
FILE *fd;
mng_handle handle;

View file

@ -330,6 +330,9 @@ class ScrollArea : public BasicContainer
class ImageWidget : public Widget
{
ImageWidget(CGraphic *image);
#ifdef USE_MNG
ImageWidget(Mng *image);
#endif
};
class Button : public Widget

View file

@ -50,3 +50,14 @@ class CColor {
void SetColorCycleAll(bool value);
void ClearAllColorCyclingRange();
void AddColorCyclingRange(unsigned int startColorIndex, unsigned int endColorIndex);
#ifdef USE_MNG
class Mng
{
public:
Mng();
int Load(const std::string name);
void Draw(int x, int y);
void Reset();
}
#endif

View file

@ -262,6 +262,14 @@ void Mng::Reset()
mng_display(handle);
}
void* Mng::_getData() const
{
if (ticks <= GetTicks()) {
mng_display_resume(handle);
}
return surface;
}
#endif // USE_MNG
//@}