rnd-19990112-1
[rocksndiamonds.git] / src / tools.c
index 1c27d8cae76cd2c3a4f5a45ed10c6bb14ef02a85..fe3291faea48c4958ac3fdfda7554a5b736e6020 100644 (file)
@@ -349,6 +349,7 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
 {
   int font_width, font_height, font_start;
   int font_pixmap;
+  boolean print_inverse = FALSE;
 
   if (font_size != FS_SMALL && font_size != FS_BIG)
     font_size = FS_SMALL;
@@ -364,10 +365,16 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
   font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : FONT2_YSIZE) *
                FONT_LINES_PER_FONT);
 
-  while(*text)
+  while (*text)
   {
     char c = *text++;
 
+    if (c == '~' && font_size == FS_SMALL && font_type <= FC_YELLOW)
+    {
+      print_inverse = TRUE;
+      continue;
+    }
+
     if (c >= 'a' && c <= 'z')
       c = 'A' + (c - 'a');
     else if (c == 'ä' || c == 'Ä')
@@ -378,10 +385,27 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
       c = 93;
 
     if (c >= 32 && c <= 95)
-      XCopyArea(display, pix[font_pixmap], d, gc,
-               ((c - 32) % FONT_CHARS_PER_LINE) * font_width,
-               ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start,
-               font_width, font_height, x, y);
+    {
+      int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width;
+      int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start;
+      int dest_x = x, dest_y = y;
+
+      if (print_inverse)
+      {
+       XCopyArea(display, pix[font_pixmap], d, gc,
+                 FONT_CHARS_PER_LINE * font_width,
+                 3 * font_height + font_start,
+                 font_width, font_height, x, y);
+
+       XSetClipOrigin(display, clip_gc[font_pixmap],
+                      dest_x - src_x, dest_y - src_y);
+       XCopyArea(display, pix[font_pixmap], drawto, clip_gc[font_pixmap],
+                 0, 0, font_width, font_height, dest_x, dest_y);
+      }
+      else
+       XCopyArea(display, pix[font_pixmap], d, gc,
+                 src_x, src_y, font_width, font_height, dest_x, dest_y);
+    }
 
     x += font_width;
   }
@@ -1205,7 +1229,12 @@ void DrawScreenField(int x, int y)
 
   if (!IN_LEV_FIELD(ux, uy))
   {
-    DrawScreenElement(x, y, EL_BETON);
+    if (ux < -1 || ux > lev_fieldx || uy < -1 || uy > lev_fieldy)
+      element = EL_LEERRAUM;
+    else
+      element = BorderElement;
+
+    DrawScreenElement(x, y, element);
     return;
   }
 
@@ -1365,10 +1394,8 @@ void DrawMiniLevel(int scroll_x, int scroll_y)
 {
   int x,y;
 
-  ClearWindow();
-
-  for(x=0; x<2*SCR_FIELDX; x++)
-    for(y=0; y<2*SCR_FIELDY; y++)
+  for(x=0; x<ED_FIELDX; x++)
+    for(y=0; y<ED_FIELDY; y++)
       DrawMiniElementOrWall(x, y, scroll_x, scroll_y);
 
   redraw_mask |= REDRAW_FIELD;
@@ -1378,6 +1405,9 @@ void DrawMicroLevel(int xpos, int ypos)
 {
   int x,y;
 
+  /* determine border element for this level */
+  SetBorderElement();
+
   XFillRectangle(display, drawto, gc,
                 xpos - MICRO_TILEX, ypos - MICRO_TILEY,
                 MICRO_TILEX * (STD_LEV_FIELDX + 2),
@@ -1394,7 +1424,7 @@ void DrawMicroLevel(int xpos, int ypos)
                         Ur[x][y]);
       else if (x >= -1 && x < lev_fieldx+1 && y >= -1 && y < lev_fieldy+1)
        DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY,
-                        EL_BETON);
+                        BorderElement);
 
   XFillRectangle(display, drawto,gc, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);