expose Mng.MaxFPS to lua to set the max playback speed for mngs

This commit is contained in:
Tim Felgentreff 2022-06-15 23:54:11 +02:00
parent a6416559d2
commit 44f77f2a56
3 changed files with 14 additions and 2 deletions

View file

@ -252,6 +252,8 @@ public:
virtual int getHeight() const { return surface->h; }
virtual bool isDirty() const { return true; }
static uint32_t MaxFPS;
mutable bool is_dirty;
std::string name;
FILE *fd;
@ -279,6 +281,8 @@ public:
virtual int getWidth() const { return 0; };
virtual int getHeight() const { return 0; };
virtual bool isDirty() const { return false; };
static inline uint32_t MaxFPS = 15;
};
#endif

View file

@ -63,6 +63,8 @@ public:
bool Load();
void Draw(int x, int y);
void Reset();
static int MaxFPS;
}
class Movie

View file

@ -41,6 +41,11 @@
#include "iolib.h"
#include "iocompat.h"
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
uint32_t Mng::MaxFPS = 15;
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
@ -155,7 +160,9 @@ static mng_uint32 MNG_DECL my_gettickcount(mng_handle)
static mng_bool MNG_DECL my_settimer(mng_handle handle, mng_uint32 msecs)
{
Mng *mng = (Mng *)mng_get_userdata(handle);
mng->ticks = GetTicks() + msecs;
unsigned long ticks = GetTicks();
uint32_t offset = std::max(static_cast<uint32_t>(msecs), static_cast<uint32_t>(1000 / mng->MaxFPS));
mng->ticks = std::max(ticks + offset, mng->ticks + offset);
return MNG_TRUE;
}
@ -199,7 +206,6 @@ Mng::~Mng()
delete[] buffer;
}
/**
** Display a MNG
**