X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftools.c;h=f0fcae2929884c3eb2fc751a08b6a82313584c3d;hb=51309ee0f66e213ee621bbc5389a33124f64519a;hp=7eb432119ef905c6acbbb24f8e78c0a8474034cd;hpb=fa1cf5ef4a93a5e1202a4a4af019af2477708906;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 7eb43211..f0fcae29 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2810,6 +2810,53 @@ void ShowEnvelope(int envelope_nr) BackToFront(); } +static void PrepareEnvelopeRequestToScreen(Bitmap *bitmap, int sx, int sy, + int xsize, int ysize) +{ + if (!global.use_envelope_request || + request.sort_priority <= 0) + return; + + if (request.bitmap == NULL || + xsize > request.xsize || + ysize > request.ysize) + { + if (request.bitmap != NULL) + FreeBitmap(request.bitmap); + + request.bitmap = CreateBitmap(xsize, ysize, DEFAULT_DEPTH); + + SDL_Surface *surface = request.bitmap->surface; + + if ((request.bitmap->surface_masked = SDLGetNativeSurface(surface)) == NULL) + Fail("SDLGetNativeSurface() failed"); + } + + BlitBitmap(bitmap, request.bitmap, sx, sy, xsize, ysize, 0, 0); + + SDLFreeBitmapTextures(request.bitmap); + SDLCreateBitmapTextures(request.bitmap); + + // set envelope request run-time values + request.sx = sx; + request.sy = sy; + request.xsize = xsize; + request.ysize = ysize; +} + +void DrawEnvelopeRequestToScreen(int drawing_target, int drawing_stage) +{ + if (global.use_envelope_request && + game.request_active_or_moving && + request.sort_priority > 0 && + drawing_target == DRAW_TO_SCREEN && + drawing_stage == DRAW_GLOBAL_ANIM_STAGE_2) + { + BlitToScreen(request.bitmap, 0, 0, request.xsize, request.ysize, + request.sx, request.sy); + } +} + static void setRequestBasePosition(int *x, int *y) { int sx_base, sy_base; @@ -2960,6 +3007,8 @@ static void DrawEnvelopeRequest(char *text) // store readily prepared envelope request for later use when animating BlitBitmap(backbuffer, bitmap_db_store_2, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); + PrepareEnvelopeRequestToScreen(bitmap_db_store_2, sx, sy, width, height); + if (text_door_style) free(text_door_style); } @@ -3041,6 +3090,8 @@ static void AnimateEnvelopeRequest(int anim_mode, int action) } } + PrepareEnvelopeRequestToScreen(backbuffer, dst_x, dst_y, width, height); + redraw_mask |= REDRAW_FIELD; BackToFront(); @@ -4527,6 +4578,8 @@ static int RequestHandleEvents(unsigned int req_state) BlitBitmap(drawto, bitmap_db_store_2, sx, sy, width, height, sx, sy); } } + + PrepareEnvelopeRequestToScreen(drawto, sx, sy, width, height); } BackToFront();