Register our own SDL event for Stamp descr. playback

Sometimes wasn't working.  See https://sourceforge.net/p/tuxpaint/bugs/293/

Committing on behalf of Pere.
This commit is contained in:
Bill Kendrick 2024-10-02 21:25:58 -07:00
parent d4d662ed7a
commit 380728fb33
2 changed files with 27 additions and 18 deletions

View file

@ -6,7 +6,7 @@ Copyright (c) 2002-2024
Various contributors (see below, and AUTHORS.txt) Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/ https://tuxpaint.org/
2024.September.30 (0.9.34) 2024.October.2 (0.9.34)
* New Magic Tools: * New Magic Tools:
---------------- ----------------
* "Comic Dots", draws repeating dots (using a multiply blend) * "Comic Dots", draws repeating dots (using a multiply blend)
@ -106,6 +106,11 @@ https://tuxpaint.org/
with by the user. Avoiding this. with by the user. Avoiding this.
Pere Pujal i Carabantes <perepujal@gmail.com> Pere Pujal i Carabantes <perepujal@gmail.com>
* Sometimes Stamp spoken description sounds would not play
after sound effects finished.
Closes https://sourceforge.net/p/tuxpaint/bugs/293
Pere Pujal i Carabantes <perepujal@gmail.com>
2024.July.17 (0.9.33) 2024.July.17 (0.9.33)
* New Magic Tools: * New Magic Tools:
---------------- ----------------

View file

@ -2580,6 +2580,7 @@ int brushflag, xnew, ynew, eraflag, lineflag, magicflag, keybd_flag,
int cur_thing; int cur_thing;
SDL_TimerID scrolltimer_dialog = TIMERID_NONE; /* Used by Open, Open->Slideshow, and New dialogs */ SDL_TimerID scrolltimer_dialog = TIMERID_NONE; /* Used by Open, Open->Slideshow, and New dialogs */
Uint32 TP_SDL_MOUSEBUTTONSCROLL; Uint32 TP_SDL_MOUSEBUTTONSCROLL;
Uint32 TP_USEREVENT_PLAYDESCSOUND;
/** /**
* --- MAIN LOOP! --- * --- MAIN LOOP! ---
@ -2618,6 +2619,7 @@ static void mainloop(void)
#endif #endif
TP_SDL_MOUSEBUTTONSCROLL = SDL_RegisterEvents(1); TP_SDL_MOUSEBUTTONSCROLL = SDL_RegisterEvents(1);
TP_USEREVENT_PLAYDESCSOUND = SDL_RegisterEvents(1);
SDL_TimerID scrolltimer_selector = TIMERID_NONE, scrolltimer_tool = TIMERID_NONE; SDL_TimerID scrolltimer_selector = TIMERID_NONE, scrolltimer_tool = TIMERID_NONE;
SDL_Event event; SDL_Event event;
SDLKey key; SDLKey key;
@ -6026,7 +6028,8 @@ static void mainloop(void)
else else
draw_tux_text(TUX_GREAT, "", 1); draw_tux_text(TUX_GREAT, "", 1);
} }
else if (event.user.code == USEREVENT_PLAYDESCSOUND) }
else if (event.type == TP_USEREVENT_PLAYDESCSOUND)
{ {
/* Play a stamp's spoken description (because the sound effect just finished) */ /* Play a stamp's spoken description (because the sound effect just finished) */
/* (This event is pushed into the queue by playstampdesc(), which /* (This event is pushed into the queue by playstampdesc(), which
@ -6048,7 +6051,6 @@ static void mainloop(void)
} }
#endif #endif
} }
}
else if (event.type == SDL_MOUSEBUTTONUP) else if (event.type == SDL_MOUSEBUTTONUP)
{ {
if (scrolling_selector) if (scrolling_selector)
@ -13212,7 +13214,7 @@ static void playstampdesc(int chan)
{ {
debug("Stamp SFX ended. Pushing event to play description sound..."); debug("Stamp SFX ended. Pushing event to play description sound...");
playsound_event.type = SDL_USEREVENT; playsound_event.type = TP_USEREVENT_PLAYDESCSOUND;
playsound_event.user.code = USEREVENT_PLAYDESCSOUND; playsound_event.user.code = USEREVENT_PLAYDESCSOUND;
playsound_event.user.data1 = (void *)(intptr_t) cur_stamp[stamp_group]; //EP added (intptr_t) to avoid warning on x64 playsound_event.user.data1 = (void *)(intptr_t) cur_stamp[stamp_group]; //EP added (intptr_t) to avoid warning on x64
@ -29507,7 +29509,9 @@ int TP_EventFilter( __attribute__((unused))
event->type == SDL_TEXTINPUT || event->type == SDL_TEXTINPUT ||
event->type == SDL_APP_WILLENTERBACKGROUND || event->type == SDL_APP_WILLENTERBACKGROUND ||
event->type == SDL_APP_WILLENTERFOREGROUND || event->type == SDL_APP_WILLENTERFOREGROUND ||
event->type == SDL_APP_DIDENTERBACKGROUND || event->type == SDL_APP_DIDENTERFOREGROUND) event->type == SDL_APP_DIDENTERBACKGROUND ||
event->type == SDL_APP_DIDENTERFOREGROUND ||
event->type == TP_USEREVENT_PLAYDESCSOUND)
return 1; return 1;
return 0; return 0;