Pausing implemented.
This commit is contained in:
parent
39748f28fb
commit
885b1cea4a
1 changed files with 46 additions and 1 deletions
|
@ -101,6 +101,7 @@ typedef struct VideoS {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
int32_t handle;
|
int32_t handle;
|
||||||
int64_t lastFrame;
|
int64_t lastFrame;
|
||||||
|
bool wasPlayingBeforePause;
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
UT_hash_handle hh;
|
UT_hash_handle hh;
|
||||||
|
@ -206,6 +207,7 @@ typedef struct GlobalS {
|
||||||
bool mouseEnabled;
|
bool mouseEnabled;
|
||||||
bool mouseGrabbed;
|
bool mouseGrabbed;
|
||||||
bool requestScreenShot;
|
bool requestScreenShot;
|
||||||
|
bool wasPlayingBeforePause;
|
||||||
VideoT *videoList;
|
VideoT *videoList;
|
||||||
SpriteT *spriteList;
|
SpriteT *spriteList;
|
||||||
SoundT *soundList;
|
SoundT *soundList;
|
||||||
|
@ -337,6 +339,7 @@ void putPixel(int32_t x, int32_t y);
|
||||||
void startControllers(void);
|
void startControllers(void);
|
||||||
void stopControllers(void);
|
void stopControllers(void);
|
||||||
void takeScreenshot(void);
|
void takeScreenshot(void);
|
||||||
|
void updatePauseState(void);
|
||||||
|
|
||||||
#ifdef DEBUG_TOOLS
|
#ifdef DEBUG_TOOLS
|
||||||
void luaStackDump(lua_State *L);
|
void luaStackDump(lua_State *L);
|
||||||
|
@ -2635,6 +2638,7 @@ int32_t apiSingeSetPauseFlag(lua_State *L) {
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
if (lua_isboolean(L, 1)) {
|
if (lua_isboolean(L, 1)) {
|
||||||
_global.pauseState = (bool)lua_toboolean(L, 1);
|
_global.pauseState = (bool)lua_toboolean(L, 1);
|
||||||
|
updatePauseState();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3217,7 +3221,8 @@ void processKey(bool down, int32_t keysym, int32_t scancode) {
|
||||||
//utilSay("Sending move %d - %s %d - %s", move, _global.controlMappings[move].name, _global.controlMappings[move].input[index], down ? "down" : "up");
|
//utilSay("Sending move %d - %s %d - %s", move, _global.controlMappings[move].name, _global.controlMappings[move].input[index], down ? "down" : "up");
|
||||||
if (!down) {
|
if (!down) {
|
||||||
if ((move == INPUT_PAUSE) && (_global.pauseEnabled)) {
|
if ((move == INPUT_PAUSE) && (_global.pauseEnabled)) {
|
||||||
//***TODO*** g_game->toggle_game_pause();
|
_global.pauseState = _global.pauseState ? false : true;
|
||||||
|
updatePauseState();
|
||||||
}
|
}
|
||||||
if (move == INPUT_GRAB) {
|
if (move == INPUT_GRAB) {
|
||||||
if (_global.mouseGrabbed) {
|
if (_global.mouseGrabbed) {
|
||||||
|
@ -4148,3 +4153,43 @@ void takeScreenshot(void) {
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
free(pixels);
|
free(pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void updatePauseState(void) {
|
||||||
|
VideoT *video = NULL;
|
||||||
|
VideoT *videoTemp = NULL;
|
||||||
|
|
||||||
|
if (_global.pauseState) {
|
||||||
|
// Pause laserdisc
|
||||||
|
if (!_global.discStopped) {
|
||||||
|
if (videoIsPlaying(_global.videoHandle)) {
|
||||||
|
_global.wasPlayingBeforePause = true;
|
||||||
|
videoPause(_global.videoHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Pause videos
|
||||||
|
HASH_ITER(hh, _global.videoList, video, videoTemp) {
|
||||||
|
if (videoIsPlaying(video->handle)) {
|
||||||
|
video->wasPlayingBeforePause = true;
|
||||||
|
videoPause(video->handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Pause sounds
|
||||||
|
Mix_Pause(-1);
|
||||||
|
} else {
|
||||||
|
// Resume laserdisc
|
||||||
|
if ((!_global.discStopped) && (_global.wasPlayingBeforePause)) {
|
||||||
|
_global.wasPlayingBeforePause = false;
|
||||||
|
videoPlay(_global.videoHandle);
|
||||||
|
}
|
||||||
|
// Resume videos
|
||||||
|
HASH_ITER(hh, _global.videoList, video, videoTemp) {
|
||||||
|
if (video->wasPlayingBeforePause) {
|
||||||
|
video->wasPlayingBeforePause = false;
|
||||||
|
videoPlay(video->handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Resume laserdisc
|
||||||
|
Mix_Resume(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue