Dialog popup animation speed fix
Play the dialog popup animation at a consistent speed across platforms. Also, fix the issue with dialog box trail not clearing after the final render.
This commit is contained in:
parent
a66c25dad5
commit
7103897bc7
2 changed files with 38 additions and 18 deletions
|
|
@ -181,6 +181,10 @@ https://tuxpaint.org/
|
|||
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/199/)
|
||||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
|
||||
* Play dialog popup animation at a consistent speed across platforms.
|
||||
Also, fix the issue with animation not clearing after the final render.
|
||||
Mark Kim <markuskimius@gmail.com>
|
||||
|
||||
* Bug Fixes:
|
||||
----------
|
||||
* Always creating 24-bit canvases, in an attempt to avoid blending
|
||||
|
|
|
|||
|
|
@ -15240,8 +15240,22 @@ static int do_prompt_image_flash_snd(const char *const text,
|
|||
SDL_FillRect(backup, NULL, SDL_MapRGBA(backup->format, 255, 255, 255, 255));
|
||||
SDL_BlitSurface(screen, NULL, backup, NULL);
|
||||
|
||||
for (w = 0; w <= r_ttools.w; w = w + 2)
|
||||
/*
|
||||
* This loop creates an animation effect of the dialog box popping up. To
|
||||
* ensure the animation plays at the same speed regardless of the platform and
|
||||
* resource available at the time, capture the rate at which each frame is
|
||||
* being drawn and draw the next frame at the adaptive rate.
|
||||
*/
|
||||
{
|
||||
Uint64 anim_ms = 300;
|
||||
Uint64 last_ms = SDL_GetTicks64();
|
||||
|
||||
w = 0;
|
||||
|
||||
while(w <= r_ttools.w)
|
||||
{
|
||||
Uint64 next_ms = 0;
|
||||
|
||||
oox = ox - w;
|
||||
ooy = oy - w;
|
||||
|
||||
|
|
@ -15259,10 +15273,12 @@ static int do_prompt_image_flash_snd(const char *const text,
|
|||
|
||||
SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
|
||||
|
||||
if ((w % 8) == 0)
|
||||
SDL_Delay(1);
|
||||
/* Calculate the amount by which to move to the next animation frame */
|
||||
next_ms = SDL_GetTicks64();
|
||||
w += (next_ms - last_ms) * r_ttools.w / anim_ms;
|
||||
last_ms = next_ms;
|
||||
}
|
||||
|
||||
if (w == r_ttools.w - 2)
|
||||
SDL_BlitSurface(backup, NULL, screen, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue