From cb57ac706af399922fcdc1f2f4a3260e2cc510ad Mon Sep 17 00:00:00 2001 From: Euan Date: Mon, 24 Mar 2014 20:46:32 -0400 Subject: [PATCH] Continue rerender event after videos --- src/AVIWrapper.cpp | 13 +++++++++++++ src/PonscripterLabel_event.cpp | 12 +----------- src/PonscripterLabel_sound.cpp | 13 +++++++++++++ src/PonscripterUserEvents.h | 11 +++++++++++ 4 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/PonscripterUserEvents.h diff --git a/src/AVIWrapper.cpp b/src/AVIWrapper.cpp index 1ffd29f1..43fdf47b 100644 --- a/src/AVIWrapper.cpp +++ b/src/AVIWrapper.cpp @@ -31,6 +31,7 @@ #include #include #include +#include "PonscripterUserEvents.h" #define DEFAULT_AUDIOBUF 4096 #define AVI_FINISH_EVENT 12345 @@ -319,6 +320,8 @@ int AVIWrapper::play(bool click_flag) Mix_HookMusic(::audioCallback, this); bool done_flag = false; + bool interrupted_redraw = false; + while (!(done_flag & click_flag) && status == AVI_PLAYING) { SDL_Event event; @@ -337,6 +340,9 @@ int AVIWrapper::play(bool click_flag) case SDL_MOUSEBUTTONDOWN: done_flag = true; break; + case INTERNAL_REDRAW_EVENT: + interrupted_redraw = true; + break; default: break; } @@ -351,6 +357,13 @@ int AVIWrapper::play(bool click_flag) if (a_stream) Mix_HookMusic(NULL, NULL); + + if(interrupted_redraw) { + SDL_Event redraw_event; + redraw_event.type = INTERNAL_REDRAW_EVENT; + SDL_PushEvent(&redraw_event); + } + return ret; } diff --git a/src/PonscripterLabel_event.cpp b/src/PonscripterLabel_event.cpp index 1e438c9c..aa2a902e 100644 --- a/src/PonscripterLabel_event.cpp +++ b/src/PonscripterLabel_event.cpp @@ -29,17 +29,7 @@ #include #endif -#define ONS_TIMER_EVENT (SDL_USEREVENT) -#define ONS_SOUND_EVENT (SDL_USEREVENT + 1) -#define ONS_CDAUDIO_EVENT (SDL_USEREVENT + 2) -#define ONS_MIDI_EVENT (SDL_USEREVENT + 3) -#define ONS_WAVE_EVENT (SDL_USEREVENT + 4) -#define ONS_MUSIC_EVENT (SDL_USEREVENT + 5) - -#define INTERNAL_REDRAW_EVENT (SDL_USEREVENT + 6) - -// This sets up the fadeout event flag for use in mp3 fadeout. Recommend for integration. [Seung Park, 20060621] -#define ONS_FADE_EVENT (SDL_USEREVENT + 7) +#include "PonscripterUserEvents.h" #define EDIT_MODE_PREFIX "[EDIT MODE] " #define EDIT_SELECT_STRING "MP3 vol (m) SE vol (s) Voice vol (v) Numeric variable (n)" diff --git a/src/PonscripterLabel_sound.cpp b/src/PonscripterLabel_sound.cpp index 0a022161..2a7abefd 100644 --- a/src/PonscripterLabel_sound.cpp +++ b/src/PonscripterLabel_sound.cpp @@ -24,6 +24,7 @@ */ #include "PonscripterLabel.h" +#include "PonscripterUserEvents.h" #ifdef LINUX #include #endif @@ -577,6 +578,8 @@ int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag, SMPEG_play(mpeg_sample); bool done_flag = false; + bool interrupted_redraw = false; + while (!(done_flag & click_flag) && SMPEG_status(mpeg_sample) == SMPEG_PLAYING) { @@ -594,6 +597,9 @@ int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag, case SDL_MOUSEBUTTONDOWN: done_flag = true; break; + case INTERNAL_REDRAW_EVENT: + interrupted_redraw = true; + break; default: break; } @@ -695,12 +701,19 @@ int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag, } } overlays.clear(); + + if(interrupted_redraw) { + SDL_Event redraw_event; + redraw_event.type = INTERNAL_REDRAW_EVENT; + SDL_PushEvent(&redraw_event); + } } #else fprintf(stderr, "mpegplay command is disabled.\n"); #endif + return ret; } diff --git a/src/PonscripterUserEvents.h b/src/PonscripterUserEvents.h new file mode 100644 index 00000000..12d0e1f7 --- /dev/null +++ b/src/PonscripterUserEvents.h @@ -0,0 +1,11 @@ +#define ONS_TIMER_EVENT (SDL_USEREVENT) +#define ONS_SOUND_EVENT (SDL_USEREVENT + 1) +#define ONS_CDAUDIO_EVENT (SDL_USEREVENT + 2) +#define ONS_MIDI_EVENT (SDL_USEREVENT + 3) +#define ONS_WAVE_EVENT (SDL_USEREVENT + 4) +#define ONS_MUSIC_EVENT (SDL_USEREVENT + 5) + +#define INTERNAL_REDRAW_EVENT (SDL_USEREVENT + 6) + +// This sets up the fadeout event flag for use in mp3 fadeout. Recommend for integration. [Seung Park, 20060621] +#define ONS_FADE_EVENT (SDL_USEREVENT + 7)