rnd-20100615-1-src
[rocksndiamonds.git] / src / tape.c
index 116f11cf51da41b9ce5c3e3ad44f273712b835d5..1b9d64ae0c2a36097cf6b107067fd05da29b756b 100644 (file)
@@ -1197,90 +1197,38 @@ void AutoPlayTape()
 
 /* ---------- new tape button stuff ---------------------------------------- */
 
-/* graphic position values for tape buttons */
-#define TAPE_BUTTON_XSIZE      18
-#define TAPE_BUTTON_YSIZE      18
-#define TAPE_BUTTON_XPOS       5
-#define TAPE_BUTTON_YPOS       77
-
-#define TAPE_BUTTON_EJECT_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
-#define TAPE_BUTTON_EXTRA_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
-#define TAPE_BUTTON_STOP_XPOS  (TAPE_BUTTON_XPOS + 1 * TAPE_BUTTON_XSIZE)
-#define TAPE_BUTTON_PAUSE_XPOS (TAPE_BUTTON_XPOS + 2 * TAPE_BUTTON_XSIZE)
-#define TAPE_BUTTON_RECORD_XPOS        (TAPE_BUTTON_XPOS + 3 * TAPE_BUTTON_XSIZE)
-#define TAPE_BUTTON_PLAY_XPOS  (TAPE_BUTTON_XPOS + 4 * TAPE_BUTTON_XSIZE)
-
 static struct
 {
-#if 1
-  struct Rect *tbi;
   int graphic;
-#else
-  int x, y;
-#endif
+  struct Rect *pos;
   int gadget_id;
   char *infotext;
 } tapebutton_info[NUM_TAPE_BUTTONS] =
 {
   {
-#if 1
-    &tape.button.eject,
-    IMG_TAPE_BUTTON_GFX_EJECT,
-#else
-    TAPE_BUTTON_EJECT_XPOS,    TAPE_BUTTON_YPOS,
-#endif
-    TAPE_CTRL_ID_EJECT,
-    "eject tape"
+    IMG_TAPE_BUTTON_GFX_EJECT,         &tape.button.eject,
+    TAPE_CTRL_ID_EJECT,                        "eject tape"
   },
   {
-#if 1
-    &tape.button.eject,                /* (same position as "eject" button) */
-    IMG_TAPE_BUTTON_GFX_EXTRA,
-#else
-    TAPE_BUTTON_EXTRA_XPOS,    TAPE_BUTTON_YPOS,
-#endif
-    TAPE_CTRL_ID_EXTRA,
-    "extra functions"
+    /* (same position as "eject" button) */
+    IMG_TAPE_BUTTON_GFX_EXTRA,         &tape.button.eject,
+    TAPE_CTRL_ID_EXTRA,                        "extra functions"
   },
   {
-#if 1
-    &tape.button.stop,
-    IMG_TAPE_BUTTON_GFX_STOP,
-#else
-    TAPE_BUTTON_STOP_XPOS,     TAPE_BUTTON_YPOS,
-#endif
-    TAPE_CTRL_ID_STOP,
-    "stop tape"
+    IMG_TAPE_BUTTON_GFX_STOP,          &tape.button.stop,
+    TAPE_CTRL_ID_STOP,                 "stop tape"
   },
   {
-#if 1
-    &tape.button.pause,
-    IMG_TAPE_BUTTON_GFX_PAUSE,
-#else
-    TAPE_BUTTON_PAUSE_XPOS,    TAPE_BUTTON_YPOS,
-#endif
-    TAPE_CTRL_ID_PAUSE,
-    "pause tape"
+    IMG_TAPE_BUTTON_GFX_PAUSE,         &tape.button.pause,
+    TAPE_CTRL_ID_PAUSE,                        "pause tape"
   },
   {
-#if 1
-    &tape.button.record,
-    IMG_TAPE_BUTTON_GFX_RECORD,
-#else
-    TAPE_BUTTON_RECORD_XPOS,   TAPE_BUTTON_YPOS,
-#endif
-    TAPE_CTRL_ID_RECORD,
-    "record tape"
+    IMG_TAPE_BUTTON_GFX_RECORD,                &tape.button.record,
+    TAPE_CTRL_ID_RECORD,               "record tape"
   },
   {
-#if 1
-    &tape.button.play,
-    IMG_TAPE_BUTTON_GFX_PLAY,
-#else
-    TAPE_BUTTON_PLAY_XPOS,     TAPE_BUTTON_YPOS,
-#endif
-    TAPE_CTRL_ID_PLAY,
-    "play tape"
+    IMG_TAPE_BUTTON_GFX_PLAY,          &tape.button.play,
+    TAPE_CTRL_ID_PLAY,                 "play tape"
   }
 };
 
@@ -1290,58 +1238,25 @@ void CreateTapeButtons()
 
   for (i = 0; i < NUM_TAPE_BUTTONS; i++)
   {
-#if 1
-    // struct TapeButtonInfo *tbi = tapebutton_info[i].tbi;
-    int graphic = tapebutton_info[i].graphic;
-    Bitmap *gd_bitmap = graphic_info[graphic].bitmap;
-#else
-    Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
-#endif
+    struct GraphicInfo *gfx = &graphic_info[tapebutton_info[i].graphic];
+    struct Rect *pos = tapebutton_info[i].pos;
     struct GadgetInfo *gi;
-    int gd_xoffset, gd_yoffset;
-#if 1
-    int gd_x1, gd_x2, gd_y1, gd_y2;
-#else
-    int gd_x1, gd_x2, gd_y;
-#endif
+    int gd_x = gfx->src_x;
+    int gd_y = gfx->src_y;
+    int gd_xp = gfx->src_x + gfx->pressed_xoffset;
+    int gd_yp = gfx->src_y + gfx->pressed_yoffset;
     int id = i;
 
-#if 1
-    gd_x1 = graphic_info[graphic].src_x;
-    gd_y1 = graphic_info[graphic].src_y;
-    gd_x2 = gd_x1 + graphic_info[graphic].pressed_xoffset;
-    gd_y2 = gd_y1 + graphic_info[graphic].pressed_yoffset;
-    gd_xoffset = tapebutton_info[i].tbi->x;
-    gd_yoffset = tapebutton_info[i].tbi->y;
-#else
-    gd_xoffset = tapebutton_info[i].x;
-    gd_yoffset = tapebutton_info[i].y;
-    gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
-    gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
-    gd_y  = DOOR_GFX_PAGEY2 + gd_yoffset;
-
-    if (i == TAPE_CTRL_ID_EXTRA)
-    {
-      gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
-      gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
-    }
-#endif
-
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_INFO_TEXT, tapebutton_info[i].infotext,
-                     GDI_X, VX + gd_xoffset,
-                     GDI_Y, VY + gd_yoffset,
-                     GDI_WIDTH, TAPE_BUTTON_XSIZE,
-                     GDI_HEIGHT, TAPE_BUTTON_YSIZE,
+                     GDI_X, VX + pos->x,
+                     GDI_Y, VY + pos->y,
+                     GDI_WIDTH, gfx->width,
+                     GDI_HEIGHT, gfx->height,
                      GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
-#if 1
-                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
-                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
-#else
-                     GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
-                     GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
-#endif
+                     GDI_DESIGN_UNPRESSED, gfx->bitmap, gd_x, gd_y,
+                     GDI_DESIGN_PRESSED, gfx->bitmap, gd_xp, gd_yp,
                      GDI_DIRECT_DRAW, FALSE,
                      GDI_EVENT_MASK, GD_EVENT_RELEASED,
                      GDI_CALLBACK_ACTION, HandleTapeButtons,