rnd-19990314-2-src
[rocksndiamonds.git] / src / tools.c
index 49e65e5c89ef16c5920b6d07eda6a643e1f1d7b6..a5224ae11bfabbbe570dd1f12c898c2a79aebf31 100644 (file)
@@ -314,26 +314,41 @@ void ClearWindow()
   redraw_mask |= REDRAW_FIELD;
 }
 
+int getFontWidth(int font_size, int font_type)
+{
+  return (font_size == FS_BIG ? FONT1_XSIZE :
+         font_type == FC_SPECIAL1 ? FONT3_XSIZE :
+         font_type == FC_SPECIAL2 ? FONT4_XSIZE :
+         font_type == FC_SPECIAL3 ? FONT5_XSIZE :
+         FONT2_XSIZE);
+}
+
+int getFontHeight(int font_size, int font_type)
+{
+  return (font_size == FS_BIG ? FONT1_YSIZE :
+         font_type == FC_SPECIAL1 ? FONT3_YSIZE :
+         font_type == FC_SPECIAL2 ? FONT4_YSIZE :
+         font_type == FC_SPECIAL3 ? FONT5_YSIZE :
+         FONT2_YSIZE);
+}
+
 void DrawTextFCentered(int y, int font_type, char *format, ...)
 {
-  char buffer[FULL_SXSIZE / FONT3_XSIZE + 10];
-  int font_xsize;
+  char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
+  int font_width = getFontWidth(FS_SMALL, font_type);
   va_list ap;
 
-  font_xsize = (font_type < FC_SPECIAL1 ? FONT2_XSIZE :
-               font_type < FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE);
-
   va_start(ap, format);
   vsprintf(buffer, format, ap);
   va_end(ap);
 
-  DrawText(SX + (SXSIZE - strlen(buffer) * font_xsize) / 2, SY + y,
+  DrawText(SX + (SXSIZE - strlen(buffer) * font_width) / 2, SY + y,
           buffer, FS_SMALL, font_type);
 }
 
 void DrawTextF(int x, int y, int font_type, char *format, ...)
 {
-  char buffer[FULL_SXSIZE / FONT3_XSIZE + 10];
+  char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
   va_list ap;
 
   va_start(ap, format);
@@ -362,23 +377,24 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
 
   if (font_size != FS_SMALL && font_size != FS_BIG)
     font_size = FS_SMALL;
-  if (font_type < FC_RED || font_type > FC_SPECIAL2)
+  if (font_type < FC_RED || font_type > FC_SPECIAL3)
     font_type = FC_RED;
 
-  font_width = (font_size == FS_BIG ? FONT1_XSIZE :
-               font_type < FC_SPECIAL1 ? FONT2_XSIZE :
-               font_type < FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE);
-  font_height = (font_size == FS_BIG ? FONT1_XSIZE :
-                font_type < FC_SPECIAL2 ? FONT2_XSIZE : FONT4_XSIZE);
+  font_width = getFontWidth(font_size, font_type);
+  font_height = getFontHeight(font_size, font_type);
+
   font_pixmap = (font_size == FS_BIG ? PIX_BIGFONT : PIX_SMALLFONT);
   font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : FONT2_YSIZE) *
                FONT_LINES_PER_FONT);
 
+  if (font_type == FC_SPECIAL3)
+    font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT;
+
   while (*text)
   {
     char c = *text++;
 
-    if (c == '~' && font_size == FS_SMALL && font_type <= FC_YELLOW)
+    if (c == '~' && font_size == FS_SMALL)
     {
       print_inverse = TRUE;
       continue;
@@ -473,7 +489,7 @@ void DrawPlayer(struct PlayerInfo *player)
       DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]);
       DrawLevelFieldThruMask(last_jx, last_jy);
     }
-    else if (last_element == EL_DYNAMIT)
+    else if (last_element == EL_DYNAMITE_ACTIVE)
       DrawDynamite(last_jx, last_jy);
     else
       DrawLevelField(last_jx, last_jy);
@@ -502,7 +518,7 @@ void DrawPlayer(struct PlayerInfo *player)
 
   if (Store[jx][jy])
     DrawLevelElement(jx, jy, Store[jx][jy]);
-  else if (element != EL_DYNAMIT && element != EL_DYNABOMB)
+  else if (!IS_ACTIVE_BOMB(element))
     DrawLevelField(jx, jy);
 
   /* draw player himself */
@@ -615,13 +631,13 @@ void DrawPlayer(struct PlayerInfo *player)
     }
   }
 
-  /* draw things in front of player (EL_DYNAMIT or EL_DYNABOMB) */
+  /* draw things in front of player (active dynamite or dynabombs) */
 
-  if (element == EL_DYNAMIT || element == EL_DYNABOMB)
+  if (IS_ACTIVE_BOMB(element))
   {
     graphic = el2gfx(element);
 
-    if (element == EL_DYNAMIT)
+    if (element == EL_DYNAMITE_ACTIVE)
     {
       if ((phase = (96 - MovDelay[jx][jy]) / 12) > 6)
        phase = 6;
@@ -963,6 +979,9 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
   src_pixmap = pix[pixmap_nr];
   drawing_gc = clip_gc[pixmap_nr];
 
+  src_x += cx;
+  src_y += cy;
+
   dest_x = FX + x * TILEX + dx;
   dest_y = FY + y * TILEY + dy;
 
@@ -1094,21 +1113,6 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element,
     }
     else if (element != EL_SP_INFOTRON)
       graphic += phase2;
-
-    /*
-    if (element == EL_SP_ZONK)
-    {
-      if (dir == MV_LEFT)
-       graphic += (4 - phase4) % 4;
-      else if (dir == MV_RIGHT)
-       graphic += phase4;
-      else
-       graphic += phase2 * 2;
-    }
-    else if (element != EL_SP_INFOTRON)
-      graphic += phase2 * (element == EL_FELSBROCKEN ? 2 : 1);
-    */
-
   }
   else if (element == EL_SIEB_LEER || element == EL_SIEB2_LEER ||
           element == EL_SIEB_VOLL || element == EL_SIEB2_VOLL)
@@ -1481,21 +1485,7 @@ void DrawLevel()
     for(y=BY1; y<=BY2; y++)
       DrawScreenField(x, y);
 
-
-#if 1
-
   redraw_mask |= REDRAW_FIELD;
-
-#else
-
-  if (setup.soft_scrolling)
-    XCopyArea(display, fieldbuffer, backbuffer, gc,
-             FX, FY, SXSIZE, SYSIZE, SX, SY);
-
-  redraw_mask |= (REDRAW_FIELD | REDRAW_FROM_BACKBUFFER);
-
-#endif
-
 }
 
 void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y)
@@ -1513,9 +1503,6 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y)
 {
   int x, y;
 
-  /* determine border element for this level */
-  SetBorderElement();
-
   XFillRectangle(display, drawto, gc,
                 xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE);
 
@@ -1742,7 +1729,10 @@ boolean Request(char *text, unsigned int req_state)
            DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
   OpenDoor(DOOR_OPEN_1);
+
+#if 0
   ClearEventQueue();
+#endif
 
   if (!(req_state & REQUEST_WAIT_FOR))
     return(FALSE);
@@ -2071,7 +2061,25 @@ unsigned int MoveDoor(unsigned int door_state)
   if (door_state & DOOR_ACTION_2)
     door2 = door_state & DOOR_ACTION_2;
 
-  return(door1 | door2);
+  return (door1 | door2);
+}
+
+void DrawSpecialEditorDoor()
+{
+  /* draw bigger toolbox window */
+  XCopyArea(display, pix[PIX_DOOR], drawto, gc,
+           DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12);
+
+  redraw_mask |= REDRAW_ALL;
+}
+
+void UndrawSpecialEditorDoor()
+{
+  /* draw normal tape recorder window */
+  XCopyArea(display, pix[PIX_BACK], drawto, gc,
+           562, 344, 108, 56, EX - 4, EY - 12);
+
+  redraw_mask |= REDRAW_ALL;
 }
 
 int ReadPixel(Drawable d, int x, int y)
@@ -2188,6 +2196,11 @@ static struct
   }
 };
 
+static void DoNotDisplayInfoText(void *ptr)
+{
+  return;
+}
+
 void CreateToolButtons()
 {
   int i;
@@ -2235,6 +2248,7 @@ void CreateToolButtons()
                      GDI_DECORATION_SHIFTING, 1, 1,
                      GDI_EVENT_MASK, event_mask,
                      GDI_CALLBACK_ACTION, HandleToolButtons,
+                     GDI_CALLBACK_INFO, DoNotDisplayInfoText,
                      GDI_END);
 
     if (gi == NULL)
@@ -2318,7 +2332,7 @@ int el2gfx(int element)
     case EL_KOKOSNUSS:         return GFX_KOKOSNUSS;
     case EL_LIFE:              return GFX_LIFE;
     case EL_LIFE_ASYNC:                return GFX_LIFE_ASYNC;
-    case EL_DYNAMIT:           return GFX_DYNAMIT;
+    case EL_DYNAMITE_ACTIVE:   return GFX_DYNAMIT;
     case EL_BADEWANNE:         return GFX_BADEWANNE;
     case EL_BADEWANNE1:                return GFX_BADEWANNE1;
     case EL_BADEWANNE2:                return GFX_BADEWANNE2;
@@ -2339,7 +2353,7 @@ int el2gfx(int element)
     case EL_PFORTE2X:          return GFX_PFORTE2X;
     case EL_PFORTE3X:          return GFX_PFORTE3X;
     case EL_PFORTE4X:          return GFX_PFORTE4X;
-    case EL_DYNAMIT_AUS:       return GFX_DYNAMIT_AUS;
+    case EL_DYNAMITE_INACTIVE: return GFX_DYNAMIT_AUS;
     case EL_PACMAN:            return GFX_PACMAN;
     case EL_PACMAN_R:          return GFX_PACMAN_R;
     case EL_PACMAN_O:          return GFX_PACMAN_O;
@@ -2369,7 +2383,10 @@ int el2gfx(int element)
     case EL_SIEB2_LEER:                return GFX_SIEB2_LEER;
     case EL_SIEB2_VOLL:                return GFX_SIEB2_VOLL;
     case EL_SIEB2_TOT:         return GFX_SIEB2_TOT;
-    case EL_DYNABOMB:          return GFX_DYNABOMB;
+    case EL_DYNABOMB_ACTIVE_1: return GFX_DYNABOMB;
+    case EL_DYNABOMB_ACTIVE_2: return GFX_DYNABOMB;
+    case EL_DYNABOMB_ACTIVE_3: return GFX_DYNABOMB;
+    case EL_DYNABOMB_ACTIVE_4: return GFX_DYNABOMB;
     case EL_DYNABOMB_NR:       return GFX_DYNABOMB_NR;
     case EL_DYNABOMB_SZ:       return GFX_DYNABOMB_SZ;
     case EL_DYNABOMB_XL:       return GFX_DYNABOMB_XL;