X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftape.c;h=15a8dc2098973ee82bf3654264fac7f5e4a7657d;hb=fd18ece8535cd87bd72989d7d39092d55b283939;hp=41b328b240d99b30d68619e1f7f534c24eb5a27a;hpb=2a4878a4c2873df0426a22c357533656928748c8;p=rocksndiamonds.git diff --git a/src/tape.c b/src/tape.c index 41b328b2..15a8dc20 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() +{ + 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; + } +}