/* 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;
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:
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);
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;
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)
{
/* 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)
#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
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 */
int width, height;
int type;
int gadget_id;
- char *text;
+ char *infotext;
} scrollbar_info[ED_NUM_SCROLLBARS] =
{
{
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;
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];
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 ||
{
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 ||
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,
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,
}
}
-static void CreateLevelEditorGadgets()
+void CreateLevelEditorGadgets()
{
- if (level_editor_gadgets_created)
- return;
-
CreateControlButtons();
CreateCounterButtons();
CreateDrawingAreas();
CreateTextInputGadgets();
CreateScrollbarGadgets();
-
- level_editor_gadgets_created = TRUE;
}
static void MapControlButtons()
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();
extern int editor_element[];
extern int elements_in_list;
-void InitLevelEditorGadgets();
+void CreateLevelEditorGadgets();
void UnmapLevelEditorGadgets();
void DrawLevelEd(void);
void LevelEd(int, int, int);
old_mx = mx;
old_my = my;
+ /*
HandleVideoButtons(mx,my, button);
HandleSoundButtons(mx,my, button);
HandleGameButtons(mx,my, button);
+ */
}
HandleGadgets(mx, my, button);
#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];
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)
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;
+ }
+}
void RaiseScore(int);
void RaiseScoreElement(int);
+void CreateGameButtons();
+void UnmapGameButtons();
+
#endif
#include "sound.h"
#include "screens.h"
#include "editor.h"
+#include "game.h"
+#include "tape.h"
#include "tools.h"
#include "files.h"
#include "joystick.h"
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[])
InitSoundServer();
InitJoysticks();
InitRND(NEW_RANDOMIZE);
- InitLevelEditorGadgets();
signal(SIGINT, CloseAllAndExit);
signal(SIGTERM, CloseAllAndExit);
XFlush(display);
InitGfx();
+ InitGadgets();
InitElementProperties();
DrawMainMenu();
}
}
+void InitGadgets()
+{
+ CreateLevelEditorGadgets();
+ CreateGameButtons();
+ CreateTapeButtons();
+}
+
void InitElementProperties()
{
int i,j;
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();
void HandleVideoButtons(int mx, int my, int button)
{
+ return;
+
+
+
+
if (game_status != MAINMENU && game_status != PLAYING)
return;
void HandleSoundButtons(int mx, int my, int button)
{
+
+
+
+ return;
+
+
+
if (game_status != PLAYING)
return;
void HandleGameButtons(int mx, int my, int button)
{
+
+
+
+ return;
+
+
+
if (game_status != PLAYING)
return;
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 */
#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()
{
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;
+ }
+}
void TapeErase(void);
unsigned int GetTapeLength(void);
+void CreateTapeButtons();
+void MapTapeButtons();
+void UnmapTapeButtons();
+
#endif