From 1563d98f350fddc2365ad73d83ef01ead1ad97ab Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Sat, 27 Jun 2020 12:45:54 +0200 Subject: [PATCH] expose mng to lua as a gcn::Image for easy use in widgets --- src/include/video.h | 7 ++++++- src/tolua/ui.pkg | 3 +++ src/tolua/video.pkg | 11 +++++++++++ src/video/mng.cpp | 8 ++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/include/video.h b/src/include/video.h index e69b6f0f4..4d5b36549 100644 --- a/src/include/video.h +++ b/src/include/video.h @@ -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; diff --git a/src/tolua/ui.pkg b/src/tolua/ui.pkg index aeaa4ec88..a5cda5286 100644 --- a/src/tolua/ui.pkg +++ b/src/tolua/ui.pkg @@ -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 diff --git a/src/tolua/video.pkg b/src/tolua/video.pkg index 4ff4aae05..9f7ab44a9 100644 --- a/src/tolua/video.pkg +++ b/src/tolua/video.pkg @@ -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 diff --git a/src/video/mng.cpp b/src/video/mng.cpp index 9bac5f79b..bc5422cf3 100644 --- a/src/video/mng.cpp +++ b/src/video/mng.cpp @@ -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 //@}