Start of the video* API methods.

This commit is contained in:
Scott Duensing 2020-03-21 20:31:06 -05:00
parent cc14222fcd
commit ffd8a7abd3

View file

@ -95,6 +95,15 @@ typedef struct FontS {
UT_hash_handle hh; UT_hash_handle hh;
} FontT; } FontT;
typedef struct VideoS {
int32_t id;
int32_t handle;
int64_t lastFrame;
SDL_Texture *texture;
SDL_Surface *surface;
UT_hash_handle hh;
} VideoT;
typedef struct MappingS { typedef struct MappingS {
char *name; char *name;
int32_t frameworkIndex; int32_t frameworkIndex;
@ -180,6 +189,7 @@ typedef struct GlobalS {
int32_t nextSpriteId; int32_t nextSpriteId;
int32_t nextSoundId; int32_t nextSoundId;
int32_t nextFontId; int32_t nextFontId;
int32_t nextVideoId;
int32_t effectsVolume; int32_t effectsVolume;
int32_t keyboardMode; int32_t keyboardMode;
int32_t frameFileHandle; int32_t frameFileHandle;
@ -198,6 +208,7 @@ typedef struct GlobalS {
bool mouseEnabled; bool mouseEnabled;
bool mouseGrabbed; bool mouseGrabbed;
bool requestScreenShot; bool requestScreenShot;
VideoT *videoList;
SpriteT *spriteList; SpriteT *spriteList;
SoundT *soundList; SoundT *soundList;
FontT *fontList; FontT *fontList;
@ -244,6 +255,7 @@ int32_t apiFontPrint32_t(lua_State *L);
int32_t apiFontQuality(lua_State *L); int32_t apiFontQuality(lua_State *L);
int32_t apiFontSelect(lua_State *L); int32_t apiFontSelect(lua_State *L);
int32_t apiFontToSprite(lua_State *L); int32_t apiFontToSprite(lua_State *L);
int32_t apiFontUnload(lua_State *L);
int32_t apiKeyboardGetMode(lua_State *L); int32_t apiKeyboardGetMode(lua_State *L);
int32_t apiKeyboardSetMode(lua_State *L); int32_t apiKeyboardSetMode(lua_State *L);
@ -264,6 +276,15 @@ int32_t apiOverlayPlot(lua_State *L);
int32_t apiOverlayPrint(lua_State *L); int32_t apiOverlayPrint(lua_State *L);
int32_t apiOverlaySetResolution(lua_State *L); int32_t apiOverlaySetResolution(lua_State *L);
int32_t apiSingeDisablePauseKey(lua_State *L);
int32_t apiSingeEnablePauseKey(lua_State *L);
int32_t apiSingeGetPauseFlag(lua_State *L);
int32_t apiSingeGetScriptPath(lua_State *L);
int32_t apiSingeSetGameName(lua_State *L);
int32_t apiSingeSetPauseFlag(lua_State *L);
int32_t apiSingeQuit(lua_State *L);
int32_t apiSingeVersion(lua_State *L);
int32_t apiSoundLoad(lua_State *L); int32_t apiSoundLoad(lua_State *L);
int32_t apiSoundPlay(lua_State *L); int32_t apiSoundPlay(lua_State *L);
int32_t apiSoundPause(lua_State *L); int32_t apiSoundPause(lua_State *L);
@ -273,26 +294,33 @@ int32_t apiSoundStop(lua_State *L);
int32_t apiSoundSetVolume(lua_State *L); int32_t apiSoundSetVolume(lua_State *L);
int32_t apiSoundGetVolume(lua_State *L); int32_t apiSoundGetVolume(lua_State *L);
int32_t apiSoundFullStop(lua_State *L); int32_t apiSoundFullStop(lua_State *L);
int32_t apiSoundUnload(lua_State *L);
int32_t apiSpriteDraw(lua_State *L); int32_t apiSpriteDraw(lua_State *L);
int32_t apiSpriteGetHeight(lua_State *L); int32_t apiSpriteGetHeight(lua_State *L);
int32_t apiSpriteGetWidth(lua_State *L); int32_t apiSpriteGetWidth(lua_State *L);
int32_t apiSpriteLoad(lua_State *L); int32_t apiSpriteLoad(lua_State *L);
int32_t apiSpriteUnload(lua_State *L);
int32_t apiVideoDraw(lua_State *L);
int32_t apiVideoGetFrame(lua_State *L);
int32_t apiVideoGetFrameCount(lua_State *L);
int32_t apiVideoGetHeight(lua_State *L);
int32_t apiVideoGetVolume(lua_State *L);
int32_t apiVideoGetWidth(lua_State *L);
int32_t apiVideoIsPlaying(lua_State *L);
int32_t apiVideoLoad(lua_State *L);
int32_t apiVideoPause(lua_State *L);
int32_t apiVideoPlay(lua_State *L);
int32_t apiVideoSeek(lua_State *L);
int32_t apiVideoSetVolume(lua_State *L);
int32_t apiVideoUnload(lua_State *L);
int32_t apiVldpGetHeight(lua_State *L); int32_t apiVldpGetHeight(lua_State *L);
int32_t apiVldpGetPixel(lua_State *L); int32_t apiVldpGetPixel(lua_State *L);
int32_t apiVldpGetWidth(lua_State *L); int32_t apiVldpGetWidth(lua_State *L);
int32_t apiVldpVerbose(lua_State *L); int32_t apiVldpVerbose(lua_State *L);
int32_t apiSingeDisablePauseKey(lua_State *L);
int32_t apiSingeEnablePauseKey(lua_State *L);
int32_t apiSingeGetPauseFlag(lua_State *L);
int32_t apiSingeGetScriptPath(lua_State *L);
int32_t apiSingeSetGameName(lua_State *L);
int32_t apiSingeSetPauseFlag(lua_State *L);
int32_t apiSingeQuit(lua_State *L);
int32_t apiSingeVersion(lua_State *L);
void doIndexDisplay(int32_t percent); void doIndexDisplay(int32_t percent);
void doLogos(void); void doLogos(void);
void callLua(const char *func, const char *sig, ...); void callLua(const char *func, const char *sig, ...);
@ -913,6 +941,36 @@ int32_t apiFontSelect(lua_State *L) {
} }
int32_t apiFontUnload(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
double d;
FontT *font = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our font structure
HASH_FIND_INT(_global.fontList, &id, font);
if (!font) luaDie(L, "fontUnload", "No font at index %d in apiFontUnload.", id);
HASH_DEL(_global.fontList, font);
TTF_CloseFont(font->font);
free(font);
result = true;
}
}
if (result) {
luaTrace(L, "fontUnload", "%d", id);
} else {
luaTrace(L, "fontUnload", "Failed!");
}
return 0;
}
int32_t apiFontToSprite(lua_State *L) { int32_t apiFontToSprite(lua_State *L) {
int32_t n = lua_gettop(L); int32_t n = lua_gettop(L);
int32_t result = -1; int32_t result = -1;
@ -1638,6 +1696,36 @@ int32_t apiSoundFullStop(lua_State *L) {
} }
int32_t apiSoundUnload(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
double d;
SoundT *sound = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our sound structure
HASH_FIND_INT(_global.soundList, &id, sound);
if (!sound) luaDie(L, "soundUnload", "No sound at index %d in apiSoundUnload.", id);
HASH_DEL(_global.soundList, sound);
Mix_FreeChunk(sound->chunk);
free(sound);
result = true;
}
}
if (result) {
luaTrace(L, "soundUnload", "%d", id);
} else {
luaTrace(L, "soundUnload", "Failed!");
}
return 0;
}
int32_t apiSpriteDraw(lua_State *L) { int32_t apiSpriteDraw(lua_State *L) {
int32_t n = lua_gettop(L); int32_t n = lua_gettop(L);
int32_t id = -1; int32_t id = -1;
@ -1707,10 +1795,6 @@ int32_t apiSpriteGetWidth(lua_State *L) {
double d; double d;
SpriteT *sprite = NULL; SpriteT *sprite = NULL;
lua_Debug ar;
lua_getstack(L, 1, &ar);
lua_getinfo(L, "nSl", &ar);
if (n == 1) { if (n == 1) {
if (lua_isstring(L, 1)) { if (lua_isstring(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d; d = lua_tonumber(L, 1); id = (int32_t)d;
@ -1763,6 +1847,468 @@ int32_t apiSpriteLoad(lua_State *L) {
} }
int32_t apiSpriteUnload(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
double d;
SpriteT *sprite = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our sprite structure
HASH_FIND_INT(_global.spriteList, &id, sprite);
if (!sprite) luaDie(L, "spriteUnload", "No sprite at index %d in apiSpriteUnload.", id);
HASH_DEL(_global.spriteList, sprite);
SDL_FreeSurface(sprite->surface);
free(sprite);
result = true;
}
}
if (result) {
luaTrace(L, "spriteUnload", "%d", id);
} else {
luaTrace(L, "spriteUnload", "Failed!");
}
return 0;
}
int32_t apiVideoDraw(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
int32_t w = 0;
int32_t h = 0;
int64_t frame = 0;
double d = 0.0;
VideoT *video = NULL;
SDL_Rect dest;
if (n == 5) {
if (lua_isnumber(L, 1)) {
if (lua_isnumber(L, 2)) {
if (lua_isnumber(L, 3)) {
if (lua_isnumber(L, 4)) {
if (lua_isnumber(L, 5)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
d = lua_tonumber(L, 2); dest.x = (int32_t)d;
d = lua_tonumber(L, 3); dest.y = (int32_t)d;
d = lua_tonumber(L, 4); dest.w = (int32_t)d - dest.x;
d = lua_tonumber(L, 5); dest.h = (int32_t)d - dest.y;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoDraw", "No video at index %d in apiVideoDraw.", id);
frame = videoUpdate(video->handle, &video->texture);
// New Frame?
if (frame != video->lastFrame) {
// Get new frame into a surface - this is slow
if (video->surface) SDL_FreeSurface(video->surface);
SDL_QueryTexture(video->texture, NULL, NULL, &w, &h);
video->surface = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 255);
SDL_SetColorKey(video->surface, SDL_FALSE, 0);
if (!video->surface) utilDie("%s", SDL_GetError());
if (SDL_SetRenderTarget(_global.renderer, video->texture) < 0) luaDie(L, "videoDraw", "%s", SDL_GetError());
if (SDL_RenderReadPixels(_global.renderer, NULL, video->surface->format->format, video->surface->pixels, video->surface->pitch) != 0) luaDie(L, "videoDraw", "%s", SDL_GetError());
if (SDL_SetRenderTarget(_global.renderer, NULL) < 0) luaDie(L, "videoDraw", "%s", SDL_GetError());
}
// Render frame into overlay
SDL_SetColorKey(_global.overlay, SDL_FALSE, 0);
if (SDL_BlitScaled(video->surface, NULL, _global.overlay, &dest) != 0) luaDie(L, "videoDraw", "%s", SDL_GetError());
result = true;
}
}
}
}
}
}
if (result) {
luaTrace(L, "videoDraw", "%d %d %d %d %d %ld", id, dest.x, dest.y, dest.x + dest.w, dest.y + dest.h, frame);
} else {
luaTrace(L, "videoDraw", "Failed!");
}
return 0;
}
int32_t apiVideoGetFrame(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int64_t r = 0;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoGetFrame", "No video at index %d in apiVideoGetFrame.", id);
r = videoGetFrame(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoGetFrame", "%d %ld", id, r);
} else {
luaTrace(L, "videoGetFrame", "Failed!");
}
lua_pushnumber(L, r);
return 1;
}
int32_t apiVideoGetFrameCount(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int64_t r = 0;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoGetFrameCount", "No video at index %d in apiVideoGetFrameCount.", id);
r = videoGetFrameCount(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoGetFrameCount", "%d %ld", id, r);
} else {
luaTrace(L, "videoGetFrameCount", "Failed!");
}
lua_pushnumber(L, r);
return 1;
}
int32_t apiVideoGetHeight(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t r = 0;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoGetHeight", "No video at index %d in apiVideoGetHeight.", id);
r = videoGetHeight(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoGetHeight", "%d %d", id, r);
} else {
luaTrace(L, "videoGetHeight", "Failed!");
}
lua_pushnumber(L, r);
return 1;
}
int32_t apiVideoGetVolume(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t left = 0;
int32_t right = 0;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoGetVolume", "No video at index %d in apiVideoGetVolume.", id);
videoGetVolume(video->handle, &left, &right);
result = true;
}
}
if (result) {
luaTrace(L, "videoGetVolume", "%d %d %d", id, left, right);
} else {
luaTrace(L, "videoGetVolume", "Failed!");
}
lua_pushnumber(L, left);
lua_pushnumber(L, right);
return 2;
}
int32_t apiVideoGetWidth(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t r = 0;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoGetWidth", "No video at index %d in apiVideoGetWidth.", id);
r = videoGetWidth(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoGetWidth", "%d %d", id, r);
} else {
luaTrace(L, "videoGetWidth", "Failed!");
}
lua_pushnumber(L, r);
return 1;
}
int32_t apiVideoIsPlaying(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t r = 0;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoIsPlaying", "No video at index %d in apiVideoIsPlaying.", id);
r = videoIsPlaying(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoIsPlaying", "%d %d", id, r);
} else {
luaTrace(L, "videoIsPlaying", "Failed!");
}
lua_pushnumber(L, r);
return 1;
}
int32_t apiVideoLoad(lua_State *L) {
int32_t n = lua_gettop(L);
int32_t result = -1;
const char *name = NULL;
VideoT *video = NULL;
if (n == 1) {
if (lua_isstring(L, 1)) {
name = lua_tostring(L, 1);
video = (VideoT *)calloc(1, sizeof(VideoT));
if (!video) luaDie(L, "videoLoad", "Unable to allocate new video.");
// Load this video.
//***TODO*** For the menu system, this data dir is likely to cause problems.
video->handle = videoLoad((char *)name, _conf.dataDir, false, _global.renderer);
if (video->handle < 0) luaDie(L, "videoLoad", "Failed to load video: %s", name);
video->id = _global.nextVideoId;
video->lastFrame = -1;
result = _global.nextVideoId++;
HASH_ADD_INT(_global.videoList, id, video);
}
}
if (result >= 0) {
luaTrace(L, "fontVideo", "%s %d", name, result);
} else {
luaTrace(L, "fontVideo", "Failed!");
}
lua_pushnumber(L, result);
return 1;}
int32_t apiVideoPause(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoPause", "No video at index %d in apiVideoPause.", id);
videoPause(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoPause", "%d", id);
} else {
luaTrace(L, "videoPause", "Failed!");
}
return 0;
}
int32_t apiVideoPlay(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoPlay", "No video at index %d in apiVideoPlay.", id);
videoPlay(video->handle);
result = true;
}
}
if (result) {
luaTrace(L, "videoPlay", "%d", id);
} else {
luaTrace(L, "videoPlay", "Failed!");
}
return 0;
}
int32_t apiVideoSeek(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
int64_t frame = 0;
double d;
VideoT *video = NULL;
if (n == 2) {
if (lua_isnumber(L, 1)) {
if (lua_isnumber(L, 2)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
d = lua_tonumber(L, 2); frame = (int64_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoSeek", "No video at index %d in apiVideoSeek.", id);
videoSeek(video->handle, frame);
result = true;
}
}
}
if (result) {
luaTrace(L, "videoSeek", "%d %ld", id, frame);
} else {
luaTrace(L, "videoSeek", "Failed!");
}
return 0;
}
int32_t apiVideoSetVolume(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
int32_t left = 0;
int32_t right = 0;
double d;
VideoT *video = NULL;
if (n == 3) {
if (lua_isnumber(L, 1)) {
if (lua_isnumber(L, 2)) {
if (lua_isnumber(L, 3)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
d = lua_tonumber(L, 2); left = (int32_t)d;
d = lua_tonumber(L, 3); right = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoSetVolume", "No video at index %d in apiVideoSetVolume.", id);
if (left < 0) left = 0;
if (left > 100) left = 100;
if (right < 0) right = 0;
if (right > 100) right = 100;
videoSetVolume(video->handle, left, right);
result = true;
}
}
}
}
if (result) {
luaTrace(L, "videoSetVolume", "%d", id, left, right);
} else {
luaTrace(L, "videoSetVolume", "Failed!");
}
return 0;
}
int32_t apiVideoUnload(lua_State *L) {
int32_t n = lua_gettop(L);
bool result = false;
int32_t id = -1;
double d;
VideoT *video = NULL;
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); id = (int32_t)d;
// Get our video structure
HASH_FIND_INT(_global.videoList, &id, video);
if (!video) luaDie(L, "videoUnload", "No video at index %d in apiVideoUnload.", id);
HASH_DEL(_global.videoList, video);
videoUnload(video->handle);
if (video->surface) SDL_FreeSurface(video->surface);
free(video);
result = true;
}
}
if (result) {
luaTrace(L, "videoUnload", "%d", id);
} else {
luaTrace(L, "videoUnload", "Failed!");
}
return 0;
}
int32_t apiVldpGetHeight(lua_State *L) { int32_t apiVldpGetHeight(lua_State *L) {
int32_t height = 0; int32_t height = 0;
if (_global.videoHandle >= 0) height = videoGetHeight(_global.videoHandle); if (_global.videoHandle >= 0) height = videoGetHeight(_global.videoHandle);
@ -2603,6 +3149,8 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
SoundT *soundTemp = NULL; SoundT *soundTemp = NULL;
FontT *font = NULL; FontT *font = NULL;
FontT *fontTemp = NULL; FontT *fontTemp = NULL;
VideoT *video = NULL;
VideoT *videoTemp = NULL;
SDL_Event event; SDL_Event event;
ManyMouseEvent mouseEvent; ManyMouseEvent mouseEvent;
MouseT *mouse = NULL; MouseT *mouse = NULL;
@ -2777,6 +3325,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
lua_register(_global.luaContext, "fontQuality", apiFontQuality); lua_register(_global.luaContext, "fontQuality", apiFontQuality);
lua_register(_global.luaContext, "fontSelect", apiFontSelect); lua_register(_global.luaContext, "fontSelect", apiFontSelect);
lua_register(_global.luaContext, "fontToSprite", apiFontToSprite); lua_register(_global.luaContext, "fontToSprite", apiFontToSprite);
lua_register(_global.luaContext, "fontUnload", apiFontUnload);
lua_register(_global.luaContext, "keyboardGetMode", apiKeyboardGetMode); lua_register(_global.luaContext, "keyboardGetMode", apiKeyboardGetMode);
lua_register(_global.luaContext, "keyboardSetMode", apiKeyboardSetMode); lua_register(_global.luaContext, "keyboardSetMode", apiKeyboardSetMode);
@ -2806,20 +3355,36 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
lua_register(_global.luaContext, "singeSetGameName", apiSingeSetGameName); lua_register(_global.luaContext, "singeSetGameName", apiSingeSetGameName);
lua_register(_global.luaContext, "singeGetScriptPath", apiSingeGetScriptPath); lua_register(_global.luaContext, "singeGetScriptPath", apiSingeGetScriptPath);
lua_register(_global.luaContext, "soundLoad", apiSoundLoad);
lua_register(_global.luaContext, "soundPlay", apiSoundPlay);
lua_register(_global.luaContext, "soundPause", apiSoundPause);
lua_register(_global.luaContext, "soundResume", apiSoundResume);
lua_register(_global.luaContext, "soundIsPlaying", apiSoundIsPlaying);
lua_register(_global.luaContext, "soundStop", apiSoundStop);
lua_register(_global.luaContext, "soundSetVolume", apiSoundSetVolume);
lua_register(_global.luaContext, "soundGetVolume", apiSoundGetVolume);
lua_register(_global.luaContext, "soundFullStop", apiSoundFullStop); lua_register(_global.luaContext, "soundFullStop", apiSoundFullStop);
lua_register(_global.luaContext, "soundGetVolume", apiSoundGetVolume);
lua_register(_global.luaContext, "soundIsPlaying", apiSoundIsPlaying);
lua_register(_global.luaContext, "soundLoad", apiSoundLoad);
lua_register(_global.luaContext, "soundPause", apiSoundPause);
lua_register(_global.luaContext, "soundPlay", apiSoundPlay);
lua_register(_global.luaContext, "soundResume", apiSoundResume);
lua_register(_global.luaContext, "soundSetVolume", apiSoundSetVolume);
lua_register(_global.luaContext, "soundStop", apiSoundStop);
lua_register(_global.luaContext, "soundUnload", apiSoundUnload);
lua_register(_global.luaContext, "spriteDraw", apiSpriteDraw); lua_register(_global.luaContext, "spriteDraw", apiSpriteDraw);
lua_register(_global.luaContext, "spriteGetHeight", apiSpriteGetHeight); lua_register(_global.luaContext, "spriteGetHeight", apiSpriteGetHeight);
lua_register(_global.luaContext, "spriteGetWidth", apiSpriteGetWidth); lua_register(_global.luaContext, "spriteGetWidth", apiSpriteGetWidth);
lua_register(_global.luaContext, "spriteLoad", apiSpriteLoad); lua_register(_global.luaContext, "spriteLoad", apiSpriteLoad);
lua_register(_global.luaContext, "spriteUnload", apiSpriteUnload);
lua_register(_global.luaContext, "videoDraw", apiVideoDraw);
lua_register(_global.luaContext, "videoGetFrame", apiVideoGetFrame);
lua_register(_global.luaContext, "videoGetFrameCount", apiVideoGetFrameCount);
lua_register(_global.luaContext, "videoGetHeight", apiVideoGetHeight);
lua_register(_global.luaContext, "videoGetVolume", apiVideoGetVolume);
lua_register(_global.luaContext, "videoGetWidth", apiVideoGetWidth);
lua_register(_global.luaContext, "videoIsPlaying", apiVideoIsPlaying);
lua_register(_global.luaContext, "videoLoad", apiVideoLoad);
lua_register(_global.luaContext, "videoPause", apiVideoPause);
lua_register(_global.luaContext, "videoPlay", apiVideoPlay);
lua_register(_global.luaContext, "videoSeek", apiVideoSeek);
lua_register(_global.luaContext, "videoSetVolume", apiVideoSetVolume);
lua_register(_global.luaContext, "videoUnload", apiVideoUnload);
lua_register(_global.luaContext, "vldpGetHeight", apiVldpGetHeight); lua_register(_global.luaContext, "vldpGetHeight", apiVldpGetHeight);
lua_register(_global.luaContext, "vldpGetPixel", apiVldpGetPixel); lua_register(_global.luaContext, "vldpGetPixel", apiVldpGetPixel);
@ -2933,7 +3498,8 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
y = (int32_t)(videoGetHeight(_global.videoHandle) * _global.overlayScaleY); y = (int32_t)(videoGetHeight(_global.videoHandle) * _global.overlayScaleY);
_global.overlay = SDL_CreateRGBSurfaceWithFormat(0, x, y, 32, SDL_PIXELFORMAT_BGRA32); _global.overlay = SDL_CreateRGBSurfaceWithFormat(0, x, y, 32, SDL_PIXELFORMAT_BGRA32);
if (_global.overlay == NULL) utilDie("%s", SDL_GetError()); if (_global.overlay == NULL) utilDie("%s", SDL_GetError());
SDL_SetColorKey(_global.overlay, true, 0); //SDL_SetColorKey(_global.overlay, SDL_TRUE, 0);
SDL_SetColorKey(_global.overlay, SDL_FALSE, 0);
// Mouse setup // Mouse setup
_global.mouseCount = ManyMouse_Init(); _global.mouseCount = ManyMouse_Init();
@ -2954,9 +3520,9 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
} }
// Grab mouse // Grab mouse
_global.mouseGrabbed = true; // _global.mouseGrabbed = true;
SDL_SetWindowGrab(_global.window, SDL_TRUE); // SDL_SetWindowGrab(_global.window, SDL_TRUE);
SDL_ShowCursor(SDL_DISABLE); // SDL_ShowCursor(SDL_DISABLE);
// Clear axis cache // Clear axis cache
for (x=0; x<AXIS_COUNT; x++) { for (x=0; x<AXIS_COUNT; x++) {
@ -3309,7 +3875,14 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
free(sprite); free(sprite);
} }
// Unload video // Unload videos
HASH_ITER(hh, _global.videoList, video, videoTemp) {
HASH_DEL(_global.videoList, video);
if (video->surface) SDL_FreeSurface(video->surface);
free(video);
}
// Unload background video
if (_conf.isFrameFile) { if (_conf.isFrameFile) {
frameFileUnload(_global.frameFileHandle); frameFileUnload(_global.frameFileHandle);
} else { } else {