provide definitions for Mng and Movie images for tolua, even when those aren't supported
This commit is contained in:
parent
25849d1eaa
commit
5f3b7892e7
7 changed files with 48 additions and 20 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -28,3 +28,5 @@ obj-*
|
|||
./tolua.cpp.rule
|
||||
build
|
||||
.vscode
|
||||
.clangd
|
||||
compile_commands.json
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
Movie() : rect(NULL), yuv_overlay(NULL), surface(NULL), need_data(true), start_time(0),
|
||||
is_dirty(true), Width(0), Height(0), data(NULL), f(NULL) {};
|
||||
~Movie();
|
||||
int Load(const std::string &filename, int w, int h);
|
||||
bool Load(const std::string &filename, int w, int h);
|
||||
bool IsPlaying() const { return is_dirty; }
|
||||
|
||||
//guichan
|
||||
|
@ -124,6 +124,23 @@ extern int OggGetNextPage(ogg_page *page, ogg_sync_state *sync, CFile *f);
|
|||
|
||||
extern int VorbisProcessData(OggData *data, char *buffer);
|
||||
|
||||
#else
|
||||
|
||||
/// empty class for lua scripts
|
||||
class Movie : public gcn::Image
|
||||
{
|
||||
public:
|
||||
Movie() : {};
|
||||
~Movie();
|
||||
bool Load(const std::string &filename, int w, int h) { return false; }
|
||||
bool IsPlaying() const { return false; }
|
||||
//guichan
|
||||
virtual void *_getData() const { return NULL; };
|
||||
virtual int getWidth() const { return 0; }
|
||||
virtual int getHeight() const { return 0; }
|
||||
virtual bool isDirty() const { return false; }
|
||||
};
|
||||
|
||||
#endif // USE_VORBIS
|
||||
|
||||
/// Play a movie file
|
||||
|
|
|
@ -147,7 +147,7 @@ class Mng : public gcn::Image
|
|||
public:
|
||||
Mng();
|
||||
~Mng();
|
||||
int Load(const std::string &name);
|
||||
bool Load(const std::string &name);
|
||||
void Reset();
|
||||
void Draw(int x, int y);
|
||||
|
||||
|
@ -166,6 +166,23 @@ public:
|
|||
unsigned long ticks;
|
||||
int iteration;
|
||||
};
|
||||
#else
|
||||
/// empty class for lua scripts
|
||||
class Mng : public gcn::Image
|
||||
{
|
||||
public:
|
||||
Mng();
|
||||
~Mng();
|
||||
bool Load(const std::string &name) { return false; }
|
||||
void Reset() {};
|
||||
void Draw(int x, int y) {};
|
||||
|
||||
//guichan
|
||||
virtual void *_getData() const { return NULL; };
|
||||
virtual int getWidth() const { return 0; }
|
||||
virtual int getHeight() const { return 0; }
|
||||
virtual bool isDirty() const { return false; }
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -330,12 +330,8 @@ class ScrollArea : public BasicContainer
|
|||
class ImageWidget : public Widget
|
||||
{
|
||||
ImageWidget(CGraphic *image);
|
||||
#ifdef USE_MNG
|
||||
ImageWidget(Mng *image);
|
||||
#endif
|
||||
#if defined(USE_THEORA) && defined(USE_VORBIS)
|
||||
ImageWidget(Movie *image);
|
||||
#endif
|
||||
};
|
||||
|
||||
class Button : public Widget
|
||||
|
|
|
@ -51,23 +51,19 @@ 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);
|
||||
bool Load(const std::string name);
|
||||
void Draw(int x, int y);
|
||||
void Reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_THEORA) && defined(USE_VORBIS)
|
||||
class Movie
|
||||
{
|
||||
public:
|
||||
Movie();
|
||||
int Load(const std::string name, int w, int h);
|
||||
bool Load(const std::string name, int w, int h);
|
||||
bool IsPlaying();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -223,12 +223,12 @@ void Mng::Draw(int x, int y)
|
|||
**
|
||||
** @param name Name of the MNG file
|
||||
*/
|
||||
int Mng::Load(const std::string &name)
|
||||
bool Mng::Load(const std::string &name)
|
||||
{
|
||||
this->name = LibraryFileName(name.c_str());
|
||||
handle = mng_initialize(this, my_alloc, my_free, MNG_NULL);
|
||||
if (handle == MNG_NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
mng_setcb_openstream(handle, my_openstream);
|
||||
mng_setcb_closestream(handle, my_closestream);
|
||||
|
@ -247,9 +247,9 @@ int Mng::Load(const std::string &name)
|
|||
}
|
||||
|
||||
if (!surface || iteration == 0x7fffffff) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -459,7 +459,7 @@ static void RenderToSurface(SDL_Surface *surface, SDL_Texture *yuv_overlay, SDL_
|
|||
free(yuv);
|
||||
}
|
||||
|
||||
int Movie::Load(const std::string &name, int w, int h)
|
||||
bool Movie::Load(const std::string &name, int w, int h)
|
||||
{
|
||||
Width = w;
|
||||
Height = h;
|
||||
|
@ -468,7 +468,7 @@ int Movie::Load(const std::string &name, int w, int h)
|
|||
f = new CFile();
|
||||
if (f->open(filename.c_str(), CL_OPEN_READ) == -1) {
|
||||
fprintf(stderr, "Can't open file '%s'\n", name.c_str());
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
rect = (SDL_Rect*)calloc(sizeof(SDL_Rect), 1);
|
||||
|
@ -486,10 +486,10 @@ int Movie::Load(const std::string &name, int w, int h)
|
|||
if (surface == NULL) {
|
||||
fprintf(stderr, "SDL_CreateRGBSurface: %s\n", SDL_GetError());
|
||||
f->close();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void *Movie::_getData() const
|
||||
|
|
Loading…
Reference in a new issue