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/)
|
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/199/)
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
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:
|
* Bug Fixes:
|
||||||
----------
|
----------
|
||||||
* Always creating 24-bit canvases, in an attempt to avoid blending
|
* Always creating 24-bit canvases, in an attempt to avoid blending
|
||||||
|
|
|
||||||
|
|
@ -15240,30 +15240,46 @@ static int do_prompt_image_flash_snd(const char *const text,
|
||||||
SDL_FillRect(backup, NULL, SDL_MapRGBA(backup->format, 255, 255, 255, 255));
|
SDL_FillRect(backup, NULL, SDL_MapRGBA(backup->format, 255, 255, 255, 255));
|
||||||
SDL_BlitSurface(screen, NULL, backup, NULL);
|
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.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
oox = ox - w;
|
Uint64 anim_ms = 300;
|
||||||
ooy = oy - w;
|
Uint64 last_ms = SDL_GetTicks64();
|
||||||
|
|
||||||
nx = PROMPT_LEFT + r_ttools.w - w + PROMPTOFFSETX;
|
w = 0;
|
||||||
ny = 2 + canvas->h / 2 - w;
|
|
||||||
|
|
||||||
dest.x = ((nx * w) + (oox * (r_ttools.w - w))) / r_ttools.w;
|
while(w <= r_ttools.w)
|
||||||
dest.y = ((ny * w) + (ooy * (r_ttools.w - w))) / r_ttools.w;
|
{
|
||||||
dest.w = (PROMPT_W - r_ttools.w * 2) + w * 2;
|
Uint64 next_ms = 0;
|
||||||
dest.h = w * 2;
|
|
||||||
SDL_FillRect(screen, &dest,
|
|
||||||
SDL_MapRGB(screen->format, 224 - (int) (w / button_scale),
|
|
||||||
224 - (int) (w / button_scale),
|
|
||||||
244 - (int) (w / button_scale)));
|
|
||||||
|
|
||||||
SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
|
oox = ox - w;
|
||||||
|
ooy = oy - w;
|
||||||
|
|
||||||
if ((w % 8) == 0)
|
nx = PROMPT_LEFT + r_ttools.w - w + PROMPTOFFSETX;
|
||||||
SDL_Delay(1);
|
ny = 2 + canvas->h / 2 - w;
|
||||||
|
|
||||||
if (w == r_ttools.w - 2)
|
dest.x = ((nx * w) + (oox * (r_ttools.w - w))) / r_ttools.w;
|
||||||
SDL_BlitSurface(backup, NULL, screen, NULL);
|
dest.y = ((ny * w) + (ooy * (r_ttools.w - w))) / r_ttools.w;
|
||||||
|
dest.w = (PROMPT_W - r_ttools.w * 2) + w * 2;
|
||||||
|
dest.h = w * 2;
|
||||||
|
SDL_FillRect(screen, &dest,
|
||||||
|
SDL_MapRGB(screen->format, 224 - (int) (w / button_scale),
|
||||||
|
224 - (int) (w / button_scale),
|
||||||
|
244 - (int) (w / button_scale)));
|
||||||
|
|
||||||
|
SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_BlitSurface(backup, NULL, screen, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_FreeSurface(backup);
|
SDL_FreeSurface(backup);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue