X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftape.c;h=15a8dc2098973ee82bf3654264fac7f5e4a7657d;hp=2cc0b39962eba632c9606af412956264e3a64f64;hb=5d50a7e10873581345ee63a5afafd43dbd45809b;hpb=7600b7d74df219d2a0956e03cea3af49226903c2 diff --git a/src/tape.c b/src/tape.c index 2cc0b399..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() { @@ -109,16 +126,20 @@ void TapeRecordDelay() void TapeTogglePause() { + unsigned long state; + if (!tape.recording && !tape.playing) return; tape.pausing = !tape.pausing; tape.fast_forward = FALSE; tape.pause_before_death = FALSE; - DrawVideoDisplay((tape.pausing ? - VIDEO_STATE_PAUSE_ON : - VIDEO_STATE_PAUSE_OFF) | VIDEO_STATE_PBEND_OFF, - 0); + + state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF); + if (tape.playing) + state |= VIDEO_STATE_PBEND_OFF; + + DrawVideoDisplay(state, 0); } void TapeStartPlaying() @@ -199,7 +220,7 @@ boolean TapePlayDelay() DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY); } - if (level.time-TimeLeft > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH) + if (TimePlayed > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH) { TapeTogglePause(); return(FALSE); @@ -252,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; + } +}