added storing active or opening/closing request dialog area into texture
authorHolger Schemel <info@artsoft.org>
Fri, 18 Dec 2020 01:24:11 +0000 (02:24 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 18 Dec 2020 01:24:11 +0000 (02:24 +0100)
src/main.h
src/tools.c

index 6dc9881ff5f355cb5bb5b9a0927b234430432c9a..4745e393ef2f57cc4ca2d0ff7550bdcb6980b34e 100644 (file)
@@ -2894,6 +2894,11 @@ struct RequestInfo
   boolean autowrap;
   boolean centered;
   boolean wrap_single_words;
+
+  // run-time values
+  Bitmap *bitmap;
+  int sx, sy;
+  int xsize, ysize;
 };
 
 struct PreviewInfo
index 68ec63e915fa22e3ac77b9da29a0dfef29130544..92d0fa3f1be1351d0f7ad66af4bd68752509cafc 100644 (file)
@@ -2810,6 +2810,40 @@ 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;
+}
+
 static void setRequestBasePosition(int *x, int *y)
 {
   int sx_base, sy_base;
@@ -2960,6 +2994,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 +3077,8 @@ static void AnimateEnvelopeRequest(int anim_mode, int action)
       }
     }
 
+    PrepareEnvelopeRequestToScreen(backbuffer, dst_x, dst_y, width, height);
+
     redraw_mask |= REDRAW_FIELD;
 
     BackToFront();
@@ -4527,6 +4565,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();