rnd-19990124-1
authorHolger Schemel <info@artsoft.org>
Sun, 24 Jan 1999 19:22:57 +0000 (20:22 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:33:10 +0000 (10:33 +0200)
12 files changed:
src/buttons.c
src/buttons.h
src/editor.c
src/editor.h
src/events.c
src/game.c
src/game.h
src/init.c
src/screens.c
src/screens.h
src/tape.c
src/tape.h

index f8d181e497dc4f618b952451a1233c252c481354..721a8335b47a7d899595d4f7720f26582b2f4a4a 100644 (file)
 
 /* some positions in the game control window */
 #define GAME_BUTTON_STOP_XPOS  (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_STOP_YPOS  (GAME_CONTROL_YPOS)
 #define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_PAUSE_YPOS (GAME_CONTROL_YPOS)
 #define GAME_BUTTON_PLAY_XPOS  (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_PLAY_YPOS  (GAME_CONTROL_YPOS)
 #define GAME_BUTTON_ANY_YPOS   (GAME_CONTROL_YPOS)
 
 #define ON_GAME_BUTTON(x,y)    ((x)>=(DX+GAME_CONTROL_XPOS) && \
 /********** drawing buttons and corresponding displays **********/
 /****************************************************************/
 
+void OLD_DrawVideoDisplay(unsigned long state, unsigned long value)
+{
+  int i;
+  int part_label = 0, part_symbol = 1;
+  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
+  static char *monatsname[12] =
+  {
+    "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
+    "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
+  };
+  static int video_pos[5][2][4] =
+  {
+    {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
+       VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
+     { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
+       VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
+
+    {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
+       VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
+     { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
+       VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
+
+    {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
+       VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
+     { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
+       VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
+
+    {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
+       VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
+     { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
+       VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
+
+    {{ 0,0,
+       0,0 },
+     { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
+       VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }}
+  };
+
+  if (state & VIDEO_STATE_PBEND_OFF)
+  {
+    int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
+
+    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+             cx + VIDEO_REC_LABEL_XPOS,
+             cy + VIDEO_REC_LABEL_YPOS,
+             VIDEO_PBEND_LABEL_XSIZE,
+             VIDEO_PBEND_LABEL_YSIZE,
+             VX + VIDEO_REC_LABEL_XPOS,
+             VY + VIDEO_REC_LABEL_YPOS);
+  }
+
+  for(i=0;i<10;i++)
+  {
+    if (state & (1<<i))
+    {
+      int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
+
+      if (i%2)                 /* i ungerade => STATE_ON / PRESS_OFF */
+       cx = DOOR_GFX_PAGEX4;
+      else
+       cx = DOOR_GFX_PAGEX3;   /* i gerade => STATE_OFF / PRESS_ON */
+
+      if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
+       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+                 cx + video_pos[pos][part_label][xpos],
+                 cy + video_pos[pos][part_label][ypos],
+                 video_pos[pos][part_label][xsize],
+                 video_pos[pos][part_label][ysize],
+                 VX + video_pos[pos][part_label][xpos],
+                 VY + video_pos[pos][part_label][ypos]);
+      if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
+       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+                 cx + video_pos[pos][part_symbol][xpos],
+                 cy + video_pos[pos][part_symbol][ypos],
+                 video_pos[pos][part_symbol][xsize],
+                 video_pos[pos][part_symbol][ysize],
+                 VX + video_pos[pos][part_symbol][xpos],
+                 VY + video_pos[pos][part_symbol][ypos]);
+    }
+  }
+
+  if (state & VIDEO_STATE_FFWD_ON)
+  {
+    int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
+
+    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+             cx + VIDEO_PLAY_SYMBOL_XPOS,
+             cy + VIDEO_PLAY_SYMBOL_YPOS,
+             VIDEO_PLAY_SYMBOL_XSIZE - 2,
+             VIDEO_PLAY_SYMBOL_YSIZE,
+             VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
+             VY + VIDEO_PLAY_SYMBOL_YPOS);
+  }
+
+  if (state & VIDEO_STATE_PBEND_ON)
+  {
+    int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
+
+    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+             cx + VIDEO_PBEND_LABEL_XPOS,
+             cy + VIDEO_PBEND_LABEL_YPOS,
+             VIDEO_PBEND_LABEL_XSIZE,
+             VIDEO_PBEND_LABEL_YSIZE,
+             VX + VIDEO_REC_LABEL_XPOS,
+             VY + VIDEO_REC_LABEL_YPOS);
+  }
+
+  if (state & VIDEO_STATE_DATE_ON)
+  {
+    int tag = value % 100;
+    int monat = (value/100) % 100;
+    int jahr = (value/10000);
+
+    DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
+            int2str(tag,2),FS_SMALL,FC_SPECIAL1);
+    DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
+            monatsname[monat],FS_SMALL,FC_SPECIAL1);
+    DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
+            int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
+  }
+
+  if (state & VIDEO_STATE_TIME_ON)
+  {
+    int min = value / 60;
+    int sec = value % 60;
+
+    DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
+            int2str(min,2),FS_SMALL,FC_SPECIAL1);
+    DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
+            int2str(sec,2),FS_SMALL,FC_SPECIAL1);
+  }
+
+  if (state & VIDEO_STATE_DATE)
+    redraw_mask |= REDRAW_VIDEO_1;
+  if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
+    redraw_mask |= REDRAW_VIDEO_2;
+  if (state & VIDEO_PRESS)
+    redraw_mask |= REDRAW_VIDEO_3;
+}
+
 void DrawVideoDisplay(unsigned long state, unsigned long value)
 {
   int i;
@@ -1615,12 +1758,12 @@ struct GadgetInfo *CreateGadget(int first_tag, ...)
        new_gadget->state = va_arg(ap, unsigned long);
        break;
 
-      case GDI_RADIO_NR:
-       new_gadget->radio_nr = va_arg(ap, unsigned long);
+      case GDI_CHECKED:
+       new_gadget->checked = va_arg(ap, boolean);
        break;
 
-      case GDI_RADIO_PRESSED:
-       new_gadget->radio_pressed = va_arg(ap, boolean);
+      case GDI_RADIO_NR:
+       new_gadget->radio_nr = va_arg(ap, unsigned long);
        break;
 
       case GDI_NUMBER_VALUE:
@@ -1871,13 +2014,14 @@ static void CheckRangeOfNumericInputGadget(struct GadgetInfo *gi)
 static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
 {
   int state = (pressed ? 1 : 0);
-  struct GadgetDesign *gd = (gi->radio_pressed ?
+  struct GadgetDesign *gd = (gi->checked ?
                             &gi->alt_design[state] :
                             &gi->design[state]);
 
   switch (gi->type)
   {
     case GD_TYPE_NORMAL_BUTTON:
+    case GD_TYPE_CHECK_BUTTON:
     case GD_TYPE_RADIO_BUTTON:
       XCopyArea(display, gd->pixmap, drawto, gc,
                gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
@@ -2247,7 +2391,11 @@ void HandleGadgets(int mx, int my, int button)
 
   if (gadget_pressed)
   {
-    if (gi->type == GD_TYPE_RADIO_BUTTON)
+    if (gi->type == GD_TYPE_CHECK_BUTTON)
+    {
+      gi->checked = !gi->checked;
+    }
+    else if (gi->type == GD_TYPE_RADIO_BUTTON)
     {
       struct GadgetInfo *rgi = gadget_list_first_entry;
 
@@ -2258,14 +2406,14 @@ void HandleGadgets(int mx, int my, int button)
            rgi->radio_nr == gi->radio_nr &&
            rgi != gi)
        {
-         rgi->radio_pressed = FALSE;
+         rgi->checked = FALSE;
          DrawGadget(rgi, DG_UNPRESSED, DG_DIRECT);
        }
 
        rgi = rgi->next;
       }
 
-      gi->radio_pressed = TRUE;
+      gi->checked = TRUE;
     }
     else if (gi->type & GD_TYPE_SCROLLBAR)
     {
index 064a65ada51e8a3947d5bed5ca6e2235573d63ef..afbcfe8ce756e13bc69b861a2d735a056d6c6261 100644 (file)
@@ -276,14 +276,16 @@ int CheckCountButtons(int, int, int);
 
 /* gadget types */
 #define GD_TYPE_NORMAL_BUTTON          (1 << 0)
-#define GD_TYPE_RADIO_BUTTON           (1 << 1)
-#define GD_TYPE_DRAWING_AREA           (1 << 2)
-#define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 3)
-#define GD_TYPE_TEXTINPUT_NUMERIC      (1 << 4)
-#define GD_TYPE_SCROLLBAR_VERTICAL     (1 << 5)
-#define GD_TYPE_SCROLLBAR_HORIZONTAL   (1 << 6)
+#define GD_TYPE_CHECK_BUTTON           (1 << 1)
+#define GD_TYPE_RADIO_BUTTON           (1 << 2)
+#define GD_TYPE_DRAWING_AREA           (1 << 3)
+#define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 4)
+#define GD_TYPE_TEXTINPUT_NUMERIC      (1 << 5)
+#define GD_TYPE_SCROLLBAR_VERTICAL     (1 << 6)
+#define GD_TYPE_SCROLLBAR_HORIZONTAL   (1 << 7)
 
 #define GD_TYPE_BUTTON                 (GD_TYPE_NORMAL_BUTTON | \
+                                        GD_TYPE_CHECK_BUTTON | \
                                         GD_TYPE_RADIO_BUTTON)
 #define GD_TYPE_SCROLLBAR              (GD_TYPE_SCROLLBAR_VERTICAL | \
                                         GD_TYPE_SCROLLBAR_HORIZONTAL)
@@ -316,8 +318,8 @@ int CheckCountButtons(int, int, int);
 #define GDI_HEIGHT                     5
 #define GDI_TYPE                       6
 #define GDI_STATE                      7
-#define GDI_RADIO_NR                   8
-#define GDI_RADIO_PRESSED              9
+#define GDI_CHECKED                    8
+#define GDI_RADIO_NR                   9
 #define GDI_NUMBER_VALUE               10
 #define GDI_NUMBER_MIN                 11
 #define GDI_NUMBER_MAX                 12
@@ -393,8 +395,8 @@ struct GadgetInfo
   int width, height;                   /* gadget size */
   unsigned long type;                  /* type (button, text input, ...) */
   unsigned long state;                 /* state (pressed, released, ...) */
+  boolean checked;                     /* check/radio button state */
   int radio_nr;                                /* number of radio button series */
-  boolean radio_pressed;               /* radio button state */
   boolean mapped;                      /* gadget is active */
   struct GadgetDesign design[2];       /* 0: normal; 1: pressed */
   struct GadgetDesign alt_design[2];   /* alternative design */
index 15eab774ed38ce2fa34dea64d6f52e5a092dba6b..f15d401660cc29c0a14d099c1895467167c47c44 100644 (file)
@@ -414,7 +414,7 @@ static struct
   int width, height;
   int type;
   int gadget_id;
-  char *text;
+  char *infotext;
 } scrollbar_info[ED_NUM_SCROLLBARS] =
 {
   {
@@ -447,7 +447,6 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *);
 static void HandleTextInputGadgets(struct GadgetInfo *);
 
 static struct GadgetInfo *level_editor_gadget[ED_NUM_GADGETS];
-static boolean level_editor_gadgets_created = FALSE;
 
 static int drawing_function = ED_CTRL_ID_SINGLE_ITEMS;
 static int last_drawing_function = ED_CTRL_ID_SINGLE_ITEMS;
@@ -875,14 +874,6 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll)
   BackToFront();
 }
 
-void InitLevelEditorGadgets()
-{
-  int i;
-
-  for (i=0; i<ED_NUM_GADGETS; i++)
-    level_editor_gadget[i] = NULL;
-}
-
 static void CreateControlButtons()
 {
   Pixmap gd_pixmap = pix[PIX_DOOR];
@@ -899,7 +890,7 @@ static void CreateControlButtons()
     int gd_x1, gd_x2, gd_y1, gd_y2;
     int button_type;
     int radio_button_nr;
-    boolean radio_button_pressed;
+    boolean checked;
 
     if (id == ED_CTRL_ID_SINGLE_ITEMS ||
        id == ED_CTRL_ID_CONNECTED_ITEMS ||
@@ -914,14 +905,14 @@ static void CreateControlButtons()
     {
       button_type = GD_TYPE_RADIO_BUTTON;
       radio_button_nr = 1;
-      radio_button_pressed = (id == drawing_function ? TRUE : FALSE);
+      checked = (id == drawing_function ? TRUE : FALSE);
       event_mask = GD_EVENT_PRESSED;
     }
     else
     {
       button_type = GD_TYPE_NORMAL_BUTTON;
       radio_button_nr = 0;
-      radio_button_pressed = FALSE;
+      checked = FALSE;
 
       if (id == ED_CTRL_ID_WRAP_LEFT ||
          id == ED_CTRL_ID_WRAP_RIGHT ||
@@ -967,7 +958,7 @@ static void CreateControlButtons()
                      GDI_TYPE, button_type,
                      GDI_STATE, GD_BUTTON_UNPRESSED,
                      GDI_RADIO_NR, radio_button_nr,
-                     GDI_RADIO_PRESSED, radio_button_pressed,
+                     GDI_CHECKED, checked,
                      GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
                      GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y1,
                      GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2,
@@ -1251,7 +1242,7 @@ static void CreateScrollbarGadgets()
     gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
-                     GDI_INFO_TEXT, scrollbar_info[i].text,
+                     GDI_INFO_TEXT, scrollbar_info[i].infotext,
                      GDI_X, SX + scrollbar_info[i].x,
                      GDI_Y, SY + scrollbar_info[i].y,
                      GDI_WIDTH, scrollbar_info[i].width,
@@ -1275,18 +1266,13 @@ static void CreateScrollbarGadgets()
   }
 }
 
-static void CreateLevelEditorGadgets()
+void CreateLevelEditorGadgets()
 {
-  if (level_editor_gadgets_created)
-    return;
-
   CreateControlButtons();
   CreateCounterButtons();
   CreateDrawingAreas();
   CreateTextInputGadgets();
   CreateScrollbarGadgets();
-
-  level_editor_gadgets_created = TRUE;
 }
 
 static void MapControlButtons()
@@ -1461,10 +1447,7 @@ void DrawLevelEd()
 
   OpenDoor(DOOR_OPEN_1);
 
-  if (!level_editor_gadgets_created)
-    CreateLevelEditorGadgets();
-  else
-    strcpy(level_editor_gadget[ED_CTRL_ID_LEVEL_NAME]->text.value, level.name);
+  strcpy(level_editor_gadget[ED_CTRL_ID_LEVEL_NAME]->text.value, level.name);
 
   MapControlButtons();
 
index 665ff1b8d0b5c2462a0a82a87ce5b1ee93d439ad..a25e6ea6b5163347b6f8aad34d14abcf9cbdfae0 100644 (file)
@@ -24,7 +24,7 @@ extern int element_shift;
 extern int editor_element[];
 extern int elements_in_list;
 
-void InitLevelEditorGadgets();
+void CreateLevelEditorGadgets();
 void UnmapLevelEditorGadgets();
 void DrawLevelEd(void);
 void LevelEd(int, int, int);
index 15106c87bfe2a8b4963048e09f51f3b60572b79a..5542bd4117a45e6aa570c5e7d32581e3d6b093c3 100644 (file)
@@ -312,9 +312,11 @@ void HandleButton(int mx, int my, int button)
     old_mx = mx;
     old_my = my;
 
+    /*
     HandleVideoButtons(mx,my, button);
     HandleSoundButtons(mx,my, button);
     HandleGameButtons(mx,my, button);
+    */
   }
 
   HandleGadgets(mx, my, button);
index 4514b646f2ca304e1f51546cab27cd22dcf5a6dc..73cab1164f2c8c48b934128ce355bf0f85784376 100644 (file)
 #define SC_SCHLUESSEL          9
 #define SC_ZEITBONUS           10
 
+/* game button identifiers */
+#define GAME_CTRL_ID_STOP              0
+#define GAME_CTRL_ID_PAUSE             1
+#define GAME_CTRL_ID_PLAY              2
+#define SOUND_CTRL_ID_MUSIC            3
+#define SOUND_CTRL_ID_LOOPS            4
+#define SOUND_CTRL_ID_SIMPLE           5
+
+#define NUM_GAME_BUTTONS               6
+
+/* forward declaration for internal use */
+static void MapGameButtons();
+static void HandleGameButtons(struct GadgetInfo *);
+
+static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS];
 
 
 
@@ -595,18 +610,31 @@ void InitGame()
              DOOR_GFX_PAGEX1 + XX_TIME, DOOR_GFX_PAGEY1 + YY_TIME,
              int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW);
 
+
+
+#if 0
   DrawGameButton(BUTTON_GAME_STOP);
   DrawGameButton(BUTTON_GAME_PAUSE);
   DrawGameButton(BUTTON_GAME_PLAY);
   DrawSoundDisplay(BUTTON_SOUND_MUSIC  | (setup.sound_music  ? BUTTON_ON : 0));
   DrawSoundDisplay(BUTTON_SOUND_LOOPS  | (setup.sound_loops  ? BUTTON_ON : 0));
   DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (setup.sound_simple ? BUTTON_ON : 0));
+#else
+  UnmapGameButtons();
+  game_gadget[SOUND_CTRL_ID_MUSIC]->checked = setup.sound_music;
+  game_gadget[SOUND_CTRL_ID_LOOPS]->checked = setup.sound_loops;
+  game_gadget[SOUND_CTRL_ID_SIMPLE]->checked = setup.sound_simple;
+  MapGameButtons();
+#endif
+
   XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc,
            DX + GAME_CONTROL_XPOS, DY + GAME_CONTROL_YPOS,
            GAME_CONTROL_XSIZE, 2 * GAME_CONTROL_YSIZE,
            DOOR_GFX_PAGEX1 + GAME_CONTROL_XPOS,
            DOOR_GFX_PAGEY1 + GAME_CONTROL_YPOS);
 
+
+
   OpenDoor(DOOR_OPEN_ALL);
 
   if (setup.sound_music)
@@ -4800,3 +4828,237 @@ void RaiseScoreElement(int element)
       break;
   }
 }
+
+/* ---------- new game button stuff ---------------------------------------- */
+
+/* graphic position values for game buttons */
+#define GAME_BUTTON_XSIZE      30
+#define GAME_BUTTON_YSIZE      30
+#define GAME_BUTTON_XPOS       5
+#define GAME_BUTTON_YPOS       215
+#define SOUND_BUTTON_XPOS      5
+#define SOUND_BUTTON_YPOS      (GAME_BUTTON_YPOS + GAME_BUTTON_YSIZE)
+
+#define GAME_BUTTON_STOP_XPOS  (GAME_BUTTON_XPOS + 0 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_PAUSE_XPOS (GAME_BUTTON_XPOS + 1 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_PLAY_XPOS  (GAME_BUTTON_XPOS + 2 * GAME_BUTTON_XSIZE)
+#define SOUND_BUTTON_MUSIC_XPOS        (SOUND_BUTTON_XPOS + 0 * GAME_BUTTON_XSIZE)
+#define SOUND_BUTTON_LOOPS_XPOS        (SOUND_BUTTON_XPOS + 1 * GAME_BUTTON_XSIZE)
+#define SOUND_BUTTON_SIMPLE_XPOS (SOUND_BUTTON_XPOS + 2 * GAME_BUTTON_XSIZE)
+
+static struct
+{
+  int x, y;
+  int gadget_id;
+  char *infotext;
+} gamebutton_info[NUM_GAME_BUTTONS] =
+{
+  {
+    GAME_BUTTON_STOP_XPOS,     GAME_BUTTON_YPOS,
+    GAME_CTRL_ID_STOP,
+    "stop game"
+  },
+  {
+    GAME_BUTTON_PAUSE_XPOS,    GAME_BUTTON_YPOS,
+    GAME_CTRL_ID_PAUSE,
+    "pause game"
+  },
+  {
+    GAME_BUTTON_PLAY_XPOS,     GAME_BUTTON_YPOS,
+    GAME_CTRL_ID_PLAY,
+    "play game"
+  },
+  {
+    SOUND_BUTTON_MUSIC_XPOS,   SOUND_BUTTON_YPOS,
+    SOUND_CTRL_ID_MUSIC,
+    "background music on/off"
+  },
+  {
+    SOUND_BUTTON_LOOPS_XPOS,   SOUND_BUTTON_YPOS,
+    SOUND_CTRL_ID_LOOPS,
+    "sound loops on/off"
+  },
+  {
+    SOUND_BUTTON_SIMPLE_XPOS,  SOUND_BUTTON_YPOS,
+    SOUND_CTRL_ID_SIMPLE,
+    "normal sounds on/off"
+  }
+};
+
+void CreateGameButtons()
+{
+  Pixmap gd_pixmap = pix[PIX_DOOR];
+  struct GadgetInfo *gi;
+  unsigned long event_mask;
+  int i;
+
+  for (i=0; i<NUM_GAME_BUTTONS; i++)
+  {
+    int id = i;
+    int gd_xoffset, gd_yoffset;
+    int gd_x1, gd_x2, gd_y1, gd_y2;
+    int button_type;
+    boolean checked;
+
+    gd_xoffset = gamebutton_info[i].x;
+    gd_yoffset = gamebutton_info[i].y;
+    gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
+    gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
+
+    if (id == GAME_CTRL_ID_STOP ||
+       id == GAME_CTRL_ID_PAUSE ||
+       id == GAME_CTRL_ID_PLAY)
+    {
+      button_type = GD_TYPE_NORMAL_BUTTON;
+      checked = FALSE;
+      event_mask = GD_EVENT_RELEASED;
+      gd_y1  = DOOR_GFX_PAGEY1 + gd_yoffset - GAME_BUTTON_YSIZE;
+      gd_y2  = DOOR_GFX_PAGEY1 + gd_yoffset - GAME_BUTTON_YSIZE;
+    }
+    else
+    {
+      button_type = GD_TYPE_CHECK_BUTTON;
+      checked =
+       ((id == SOUND_CTRL_ID_MUSIC && setup.sound_music) ||
+        (id == SOUND_CTRL_ID_LOOPS && setup.sound_loops) ||
+        (id == SOUND_CTRL_ID_SIMPLE && setup.sound_simple) ? TRUE : FALSE);
+      event_mask = GD_EVENT_PRESSED;
+      gd_y1  = DOOR_GFX_PAGEY1 + gd_yoffset;
+      gd_y2  = DOOR_GFX_PAGEY1 + gd_yoffset - GAME_BUTTON_YSIZE;
+    }
+
+    gi = CreateGadget(GDI_CUSTOM_ID, id,
+                     GDI_INFO_TEXT, gamebutton_info[i].infotext,
+                     GDI_X, DX + gd_xoffset,
+                     GDI_Y, DY + gd_yoffset,
+                     GDI_WIDTH, GAME_BUTTON_XSIZE,
+                     GDI_HEIGHT, GAME_BUTTON_YSIZE,
+                     GDI_TYPE, button_type,
+                     GDI_STATE, GD_BUTTON_UNPRESSED,
+                     GDI_CHECKED, checked,
+                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
+                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y1,
+                     GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2,
+                     GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
+                     GDI_EVENT_MASK, event_mask,
+                     GDI_CALLBACK_ACTION, HandleGameButtons,
+                     GDI_END);
+
+    if (gi == NULL)
+      Error(ERR_EXIT, "cannot create gadget");
+
+    game_gadget[id] = gi;
+  }
+}
+
+static void MapGameButtons()
+{
+  int i;
+
+  for (i=0; i<NUM_GAME_BUTTONS; i++)
+    MapGadget(game_gadget[i]);
+}
+
+void UnmapGameButtons()
+{
+  int i;
+
+  for (i=0; i<NUM_GAME_BUTTONS; i++)
+    UnmapGadget(game_gadget[i]);
+}
+
+static void HandleGameButtons(struct GadgetInfo *gi)
+{
+  int id = gi->custom_id;
+
+  if (game_status != PLAYING)
+    return;
+
+  switch (id)
+  {
+    case GAME_CTRL_ID_STOP:
+      if (AllPlayersGone)
+      {
+       CloseDoor(DOOR_CLOSE_1);
+       game_status = MAINMENU;
+       DrawMainMenu();
+       break;
+      }
+
+      if (Request("Do you really want to quit the game ?",
+                 REQ_ASK | REQ_STAY_CLOSED))
+      { 
+#ifndef MSDOS
+       if (options.network)
+         SendToServer_StopPlaying();
+       else
+#endif
+       {
+         game_status = MAINMENU;
+         DrawMainMenu();
+       }
+      }
+      else
+       OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
+      break;
+
+    case GAME_CTRL_ID_PAUSE:
+      if (options.network)
+      {
+#ifndef MSDOS
+       if (tape.pausing)
+         SendToServer_ContinuePlaying();
+       else
+         SendToServer_PausePlaying();
+#endif
+      }
+      else
+       TapeTogglePause();
+      break;
+
+    case GAME_CTRL_ID_PLAY:
+      if (tape.pausing)
+      {
+#ifndef MSDOS
+       if (options.network)
+         SendToServer_ContinuePlaying();
+       else
+#endif
+       {
+         tape.pausing = FALSE;
+         DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
+       }
+      }
+      break;
+
+    case SOUND_CTRL_ID_MUSIC:
+      if (setup.sound_music)
+      { 
+       setup.sound_music = FALSE;
+       FadeSound(background_loop[level_nr % num_bg_loops]);
+      }
+      else if (sound_loops_allowed)
+      { 
+       setup.sound = setup.sound_music = TRUE;
+       PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
+      }
+      break;
+
+    case SOUND_CTRL_ID_LOOPS:
+      if (setup.sound_loops)
+       setup.sound_loops = FALSE;
+      else if (sound_loops_allowed)
+       setup.sound = setup.sound_loops = TRUE;
+      break;
+
+    case SOUND_CTRL_ID_SIMPLE:
+      if (setup.sound_simple)
+       setup.sound_simple = FALSE;
+      else if (sound_status==SOUND_AVAILABLE)
+       setup.sound = setup.sound_simple = TRUE;
+      break;
+
+    default:
+      break;
+  }
+}
index 6f698b64a52c000de2834afa0040145796f2f580..8e33f098209ecf14cde3865631260073dd779173 100644 (file)
@@ -78,4 +78,7 @@ void PlaySoundLevel(int, int, int);
 void RaiseScore(int);
 void RaiseScoreElement(int);
 
+void CreateGameButtons();
+void UnmapGameButtons();
+
 #endif
index 77c5fb65e88283a984432e09eaa2d26e62ee5acd..b92780b6e32130eee8eb92defdc08e2b35c9b0ff 100644 (file)
@@ -18,6 +18,8 @@
 #include "sound.h"
 #include "screens.h"
 #include "editor.h"
+#include "game.h"
+#include "tape.h"
 #include "tools.h"
 #include "files.h"
 #include "joystick.h"
@@ -48,6 +50,7 @@ static void InitSoundServer(void);
 static void InitWindow(int, char **);
 static void InitGfx(void);
 static void LoadGfx(int, struct PictureFileInfo *);
+static void InitGadgets(void);
 static void InitElementProperties(void);
 
 void OpenAll(int argc, char *argv[])
@@ -67,7 +70,6 @@ void OpenAll(int argc, char *argv[])
   InitSoundServer();
   InitJoysticks();
   InitRND(NEW_RANDOMIZE);
-  InitLevelEditorGadgets();
 
   signal(SIGINT, CloseAllAndExit);
   signal(SIGTERM, CloseAllAndExit);
@@ -79,6 +81,7 @@ void OpenAll(int argc, char *argv[])
   XFlush(display);
 
   InitGfx();
+  InitGadgets();
   InitElementProperties();
 
   DrawMainMenu();
@@ -791,6 +794,13 @@ void LoadGfx(int pos, struct PictureFileInfo *pic)
   }
 }
 
+void InitGadgets()
+{
+  CreateLevelEditorGadgets();
+  CreateGameButtons();
+  CreateTapeButtons();
+}
+
 void InitElementProperties()
 {
   int i,j;
index 109b1283b9cadc833b9d5bc21d37f71a8ceb85c7..b5640b614922f9430839e9c8cd0727fac880b22a 100644 (file)
@@ -68,8 +68,10 @@ void DrawMainMenu()
     return;
   }
 
-  /* needed if last screen was the level editor */
+  /* unmap gadgets from last screen, map gadgets for main menu screen */
   UnmapLevelEditorGadgets();
+  UnmapGameButtons();
+  MapTapeButtons();
 
   FadeSounds();
   GetPlayerConfig();
@@ -2112,6 +2114,11 @@ void HandleGameActions()
 
 void HandleVideoButtons(int mx, int my, int button)
 {
+  return;
+
+
+
+
   if (game_status != MAINMENU && game_status != PLAYING)
     return;
 
@@ -2216,6 +2223,13 @@ void HandleVideoButtons(int mx, int my, int button)
 
 void HandleSoundButtons(int mx, int my, int button)
 {
+
+
+
+  return;
+
+
+
   if (game_status != PLAYING)
     return;
 
@@ -2277,6 +2291,13 @@ void HandleSoundButtons(int mx, int my, int button)
 
 void HandleGameButtons(int mx, int my, int button)
 {
+
+
+
+  return;
+
+
+
   if (game_status != PLAYING)
     return;
 
index 39e301538a40d1e97bad2979932d154f29bf8266..ccb6cd50b0e7139d58642dcdfa1a6288f870f32c 100644 (file)
@@ -37,8 +37,5 @@ void HandleSetupInputScreen(int, int, int, int, int);
 void CustomizeKeyboard(int);
 void CalibrateJoystick(int);
 void HandleGameActions(void);
-void HandleVideoButtons(int, int, int);
-void HandleSoundButtons(int, int, int);
-void HandleGameButtons(int, int, int);
 
 #endif /* SCREENS_H */
index 41b328b240d99b30d68619e1f7f534c24eb5a27a..9bf4a8c5fb8c5458b20de9c10c07bf088910f459 100644 (file)
 #include "misc.h"
 #include "game.h"
 #include "buttons.h"
+#include "tools.h"
+#include "files.h"
+#include "network.h"
+
+/* tape button identifiers */
+#define TAPE_CTRL_ID_EJECT             0
+#define TAPE_CTRL_ID_STOP              1
+#define TAPE_CTRL_ID_PAUSE             2
+#define TAPE_CTRL_ID_RECORD            3
+#define TAPE_CTRL_ID_PLAY              4
+
+#define NUM_TAPE_BUTTONS               5
+
+/* forward declaration for internal use */
+static void HandleTapeButtons(struct GadgetInfo *);
+
+static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
 
 void TapeStartRecording()
 {
@@ -256,3 +273,210 @@ unsigned int GetTapeLength()
 
   return(tape_length * GAME_FRAME_DELAY / 1000);
 }
+
+/* ---------- 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_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
+{
+  int x, y;
+  int gadget_id;
+  char *infotext;
+} tapebutton_info[NUM_TAPE_BUTTONS] =
+{
+  {
+    TAPE_BUTTON_EJECT_XPOS,    TAPE_BUTTON_YPOS,
+    TAPE_CTRL_ID_EJECT,
+    "eject tape"
+  },
+  {
+    TAPE_BUTTON_STOP_XPOS,     TAPE_BUTTON_YPOS,
+    TAPE_CTRL_ID_STOP,
+    "stop tape"
+  },
+  {
+    TAPE_BUTTON_PAUSE_XPOS,    TAPE_BUTTON_YPOS,
+    TAPE_CTRL_ID_PAUSE,
+    "pause tape"
+  },
+  {
+    TAPE_BUTTON_RECORD_XPOS,   TAPE_BUTTON_YPOS,
+    TAPE_CTRL_ID_RECORD,
+    "record tape"
+  },
+  {
+    TAPE_BUTTON_PLAY_XPOS,     TAPE_BUTTON_YPOS,
+    TAPE_CTRL_ID_PLAY,
+    "play tape"
+  }
+};
+
+void CreateTapeButtons()
+{
+  Pixmap gd_pixmap = pix[PIX_DOOR];
+  struct GadgetInfo *gi;
+  int i;
+
+  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+  {
+    int id = i;
+    int gd_xoffset, gd_yoffset;
+    int gd_x1, gd_x2, gd_y;
+
+    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;
+
+    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_TYPE, GD_TYPE_NORMAL_BUTTON,
+                     GDI_STATE, GD_BUTTON_UNPRESSED,
+                     GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
+                     GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
+                     GDI_EVENT_MASK, GD_EVENT_RELEASED,
+                     GDI_CALLBACK_ACTION, HandleTapeButtons,
+                     GDI_END);
+
+    if (gi == NULL)
+      Error(ERR_EXIT, "cannot create gadget");
+
+    tape_gadget[id] = gi;
+  }
+}
+
+void MapTapeButtons()
+{
+  int i;
+
+  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+    MapGadget(tape_gadget[i]);
+}
+
+void UnmapTapeButtons()
+{
+  int i;
+
+  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+    UnmapGadget(tape_gadget[i]);
+}
+
+static void HandleTapeButtons(struct GadgetInfo *gi)
+{
+  int id = gi->custom_id;
+
+  if (game_status != MAINMENU && game_status != PLAYING)
+    return;
+
+  switch (id)
+  {
+    case TAPE_CTRL_ID_EJECT:
+      TapeStop();
+      if (TAPE_IS_EMPTY(tape))
+      {
+       LoadTape(level_nr);
+       if (TAPE_IS_EMPTY(tape))
+         Request("No tape for this level !", REQ_CONFIRM);
+      }
+      else
+      {
+       if (tape.changed)
+         SaveTape(tape.level_nr);
+       TapeErase();
+      }
+      DrawCompleteVideoDisplay();
+      break;
+
+    case TAPE_CTRL_ID_STOP:
+      TapeStop();
+      break;
+
+    case TAPE_CTRL_ID_PAUSE:
+      TapeTogglePause();
+      break;
+
+    case TAPE_CTRL_ID_RECORD:
+      if (TAPE_IS_STOPPED(tape))
+      {
+       TapeStartRecording();
+
+#ifndef MSDOS
+       if (options.network)
+         SendToServer_StartPlaying();
+       else
+#endif
+       {
+         game_status = PLAYING;
+         InitGame();
+       }
+      }
+      else if (tape.pausing)
+      {
+       if (tape.playing)       /* PLAYING -> PAUSING -> RECORDING */
+       {
+         tape.pos[tape.counter].delay = tape.delay_played;
+         tape.playing = FALSE;
+         tape.recording = TRUE;
+         tape.changed = TRUE;
+
+         DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
+       }
+       else
+         TapeTogglePause();
+      }
+      break;
+
+    case TAPE_CTRL_ID_PLAY:
+      if (TAPE_IS_EMPTY(tape))
+       break;
+
+      if (TAPE_IS_STOPPED(tape))
+      {
+       TapeStartPlaying();
+
+       game_status = PLAYING;
+       InitGame();
+      }
+      else if (tape.playing)
+      {
+       if (tape.pausing)                       /* PAUSE -> PLAY */
+         TapeTogglePause();
+       else if (!tape.fast_forward)            /* PLAY -> FAST FORWARD PLAY */
+       {
+         tape.fast_forward = TRUE;
+         DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
+       }
+       else if (!tape.pause_before_death)      /* FFWD PLAY -> + AUTO PAUSE */
+       {
+         tape.pause_before_death = TRUE;
+         DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
+       }
+       else                                    /* -> NORMAL PLAY */
+       {
+         tape.fast_forward = FALSE;
+         tape.pause_before_death = FALSE;
+         DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);
+       }
+      }
+      break;
+
+    default:
+      break;
+  }
+}
index 31151088d2d04681ae011921aff9781824e590d4..1f2a4d8fe6a5b09cf03161ff10d766cf164b9753 100644 (file)
@@ -31,4 +31,8 @@ void TapeStop(void);
 void TapeErase(void);
 unsigned int GetTapeLength(void);
 
+void CreateTapeButtons();
+void MapTapeButtons();
+void UnmapTapeButtons();
+
 #endif