From: Holger Schemel Date: Sun, 24 Jan 1999 19:22:57 +0000 (+0100) Subject: rnd-19990124-1 X-Git-Tag: 1.3.0^2~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cc17a49a1a63c1df0e55a5afd510698e21b71dfe;p=rocksndiamonds.git rnd-19990124-1 --- diff --git a/src/buttons.c b/src/buttons.c index f8d181e4..721a8335 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -132,8 +132,11 @@ /* 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) && \ @@ -340,6 +343,146 @@ /********** 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< 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) { diff --git a/src/buttons.h b/src/buttons.h index 064a65ad..afbcfe8c 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -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 */ diff --git a/src/editor.c b/src/editor.c index 15eab774..f15d4016 100644 --- a/src/editor.c +++ b/src/editor.c @@ -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; itext.value, level.name); + strcpy(level_editor_gadget[ED_CTRL_ID_LEVEL_NAME]->text.value, level.name); MapControlButtons(); diff --git a/src/editor.h b/src/editor.h index 665ff1b8..a25e6ea6 100644 --- a/src/editor.h +++ b/src/editor.h @@ -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); diff --git a/src/events.c b/src/events.c index 15106c87..5542bd41 100644 --- a/src/events.c +++ b/src/events.c @@ -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); diff --git a/src/game.c b/src/game.c index 4514b646..73cab116 100644 --- a/src/game.c +++ b/src/game.c @@ -91,6 +91,21 @@ #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; icustom_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; + } +} diff --git a/src/game.h b/src/game.h index 6f698b64..8e33f098 100644 --- a/src/game.h +++ b/src/game.h @@ -78,4 +78,7 @@ void PlaySoundLevel(int, int, int); void RaiseScore(int); void RaiseScoreElement(int); +void CreateGameButtons(); +void UnmapGameButtons(); + #endif diff --git a/src/init.c b/src/init.c index 77c5fb65..b92780b6 100644 --- a/src/init.c +++ b/src/init.c @@ -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; diff --git a/src/screens.c b/src/screens.c index 109b1283..b5640b61 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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; diff --git a/src/screens.h b/src/screens.h index 39e30153..ccb6cd50 100644 --- a/src/screens.h +++ b/src/screens.h @@ -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 */ diff --git a/src/tape.c b/src/tape.c index 41b328b2..9bf4a8c5 100644 --- a/src/tape.c +++ b/src/tape.c @@ -15,6 +15,23 @@ #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; icustom_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; + } +} diff --git a/src/tape.h b/src/tape.h index 31151088..1f2a4d8f 100644 --- a/src/tape.h +++ b/src/tape.h @@ -31,4 +31,8 @@ void TapeStop(void); void TapeErase(void); unsigned int GetTapeLength(void); +void CreateTapeButtons(); +void MapTapeButtons(); +void UnmapTapeButtons(); + #endif