X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftape.c;h=bcec56b049427e1a2a1a0d69415d5844c2509714;hp=447ce12c92367faa1ff10491ac8761d450fe693b;hb=115ce6f2da1914d68b0fe0e5f9082973190dacdd;hpb=2c7c5df21805bb03a1ef56e7577c1d7d1cc3f599 diff --git a/src/tape.c b/src/tape.c index 447ce12c..bcec56b0 100644 --- a/src/tape.c +++ b/src/tape.c @@ -28,16 +28,18 @@ #define TAPE_CTRL_ID_PAUSE 3 #define TAPE_CTRL_ID_RECORD 4 #define TAPE_CTRL_ID_PLAY 5 +#define TAPE_CTRL_ID_INSERT_SOLUTION 6 +#define TAPE_CTRL_ID_PLAY_SOLUTION 7 -#define NUM_TAPE_BUTTONS 6 +#define NUM_TAPE_BUTTONS 8 /* values for tape handling */ #define TAPE_PAUSE_SECONDS_BEFORE_DEATH 5 /* forward declaration for internal use */ static void HandleTapeButtons(struct GadgetInfo *); -static void TapeStopWarpForward(); -static float GetTapeLengthSecondsFloat(); +static void TapeStopWarpForward(void); +static float GetTapeLengthSecondsFloat(void); static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS]; @@ -357,7 +359,7 @@ void DrawVideoDisplaySymbol(unsigned int state) DrawVideoDisplay(state, VIDEO_DISPLAY_SYMBOL_ONLY); } -void DrawVideoDisplayCurrentState() +void DrawVideoDisplayCurrentState(void) { int state = 0; @@ -396,7 +398,7 @@ void DrawVideoDisplayCurrentState() DrawVideoDisplaySymbol(state); } -void DrawCompleteVideoDisplay() +void DrawCompleteVideoDisplay(void) { struct GraphicInfo *g_tape = &graphic_info[IMG_BACKGROUND_TAPE]; @@ -440,7 +442,7 @@ void DrawCompleteVideoDisplay() 0, 0); } -void TapeDeactivateDisplayOn() +void TapeDeactivateDisplayOn(void) { SetDrawDeactivationMask(REDRAW_FIELD); audio.sound_deactivated = TRUE; @@ -510,12 +512,12 @@ void TapeSetDateFromEpochSeconds(time_t epoch_seconds) tape.date = 10000 * (lt->tm_year % 100) + 100 * lt->tm_mon + lt->tm_mday; } -void TapeSetDateFromNow() +void TapeSetDateFromNow(void) { TapeSetDateFromEpochSeconds(time(NULL)); } -void TapeErase() +void TapeErase(void) { int i; @@ -548,7 +550,7 @@ void TapeErase() tape.use_mouse = (level.game_engine_type == GAME_ENGINE_TYPE_MM); } -static void TapeRewind() +static void TapeRewind(void) { tape.counter = 0; tape.delay_played = 0; @@ -596,12 +598,12 @@ void TapeStartRecording(int random_seed) audio.sound_deactivated = FALSE; } -static void TapeStartGameRecording() +static void TapeStartGameRecording(void) { - StartGameActions(options.network, TRUE, level.random_seed); + StartGameActions(network.enabled, TRUE, level.random_seed); } -static void TapeAppendRecording() +static void TapeAppendRecording(void) { if (!tape.playing || !tape.pausing) return; @@ -629,7 +631,7 @@ static void TapeAppendRecording() UpdateAndDisplayGameControlValues(); } -void TapeHaltRecording() +void TapeHaltRecording(void) { tape.counter++; @@ -642,7 +644,7 @@ void TapeHaltRecording() tape.length_seconds = GetTapeLengthSeconds(); } -void TapeStopRecording() +void TapeStopRecording(void) { if (tape.recording) TapeHaltRecording(); @@ -769,7 +771,7 @@ void TapeTogglePause(boolean toggle_mode) } } -void TapeStartPlaying() +void TapeStartPlaying(void) { if (TAPE_IS_EMPTY(tape)) return; @@ -792,14 +794,14 @@ void TapeStartPlaying() audio.sound_deactivated = FALSE; } -static void TapeStartGamePlaying() +static void TapeStartGamePlaying(void) { TapeStartPlaying(); InitGame(); } -void TapeStopPlaying() +void TapeStopPlaying(void) { tape.playing = FALSE; tape.pausing = FALSE; @@ -811,7 +813,7 @@ void TapeStopPlaying() MapTapeEjectButton(); } -byte *TapePlayAction() +byte *TapePlayAction(void) { int update_delay = FRAMES_PER_SECOND / 2; boolean update_video_display = (FrameCounter % update_delay == 0); @@ -906,7 +908,7 @@ byte *TapePlayAction() return action; } -void TapeStop() +void TapeStop(void) { if (tape.pausing) TapeTogglePause(TAPE_TOGGLE_MANUAL); @@ -924,7 +926,7 @@ void TapeStop() } } -unsigned int GetTapeLengthFrames() +unsigned int GetTapeLengthFrames(void) { unsigned int tape_length_frames = 0; int i; @@ -938,12 +940,12 @@ unsigned int GetTapeLengthFrames() return tape_length_frames; } -unsigned int GetTapeLengthSeconds() +unsigned int GetTapeLengthSeconds(void) { return (GetTapeLengthFrames() * GAME_FRAME_DELAY / 1000); } -static float GetTapeLengthSecondsFloat() +static float GetTapeLengthSecondsFloat(void) { return ((float)GetTapeLengthFrames() * GAME_FRAME_DELAY / 1000); } @@ -962,7 +964,7 @@ static void TapeStartWarpForward(int mode) DrawVideoDisplayCurrentState(); } -static void TapeStopWarpForward() +static void TapeStopWarpForward(void) { tape.fast_forward = FALSE; tape.warp_forward = FALSE; @@ -975,9 +977,9 @@ static void TapeStopWarpForward() DrawVideoDisplayCurrentState(); } -static void TapeSingleStep() +static void TapeSingleStep(void) { - if (options.network) + if (network.enabled) return; if (!tape.pausing) @@ -988,7 +990,7 @@ static void TapeSingleStep() DrawVideoDisplay(VIDEO_STATE_1STEP(tape.single_step), 0); } -void TapeQuickSave() +void TapeQuickSave(void) { if (game_status == GAME_MODE_MAIN) { @@ -1014,7 +1016,7 @@ void TapeQuickSave() SaveEngineSnapshotSingle(); } -void TapeQuickLoad() +void TapeQuickLoad(void) { char *filename = getTapeFilename(level_nr); @@ -1077,27 +1079,52 @@ void TapeQuickLoad() } } -void InsertSolutionTape() +boolean hasSolutionTape(void) { + boolean tape_file_exists = fileExists(getSolutionTapeFilename(level_nr)); boolean level_has_tape = (level.game_engine_type == GAME_ENGINE_TYPE_SP && level.native_sp_level->demo.is_available); - if (!fileExists(getSolutionTapeFilename(level_nr)) && !level_has_tape) + return (tape_file_exists || level_has_tape); +} + +boolean InsertSolutionTape(void) +{ + if (!hasSolutionTape()) { Request("No solution tape for this level!", REQ_CONFIRM); - return; + return FALSE; } + if (!TAPE_IS_STOPPED(tape)) + TapeStop(); + // if tape recorder already contains a tape, remove it without asking TapeErase(); LoadSolutionTape(level_nr); + DrawCompleteVideoDisplay(); + if (TAPE_IS_EMPTY(tape)) + { Request("Loading solution tape for this level failed!", REQ_CONFIRM); - DrawCompleteVideoDisplay(); + return FALSE; + } + + return TRUE; +} + +boolean PlaySolutionTape(void) +{ + if (!InsertSolutionTape()) + return FALSE; + + TapeStartGamePlaying(); + + return TRUE; } @@ -1105,7 +1132,7 @@ void InsertSolutionTape() * tape autoplay functions * ------------------------------------------------------------------------- */ -void AutoPlayTape() +void AutoPlayTape(void) { static LevelDirTree *autoplay_leveldir = NULL; static boolean autoplay_initialized = FALSE; @@ -1273,16 +1300,25 @@ static struct { IMG_GFX_TAPE_BUTTON_PLAY, &tape.button.play, TAPE_CTRL_ID_PLAY, "play tape" + }, + { + IMG_GFX_TAPE_BUTTON_INSERT_SOLUTION,&tape.button.insert_solution, + TAPE_CTRL_ID_INSERT_SOLUTION, "insert solution tape" + }, + { + IMG_GFX_TAPE_BUTTON_PLAY_SOLUTION, &tape.button.play_solution, + TAPE_CTRL_ID_PLAY_SOLUTION, "play solution tape" } }; -void CreateTapeButtons() +void CreateTapeButtons(void) { int i; for (i = 0; i < NUM_TAPE_BUTTONS; i++) { - struct GraphicInfo *gfx = &graphic_info[tapebutton_info[i].graphic]; + int graphic = tapebutton_info[i].graphic; + struct GraphicInfo *gfx = &graphic_info[graphic]; struct XY *pos = tapebutton_info[i].pos; struct GadgetInfo *gi; int gd_x = gfx->src_x; @@ -1292,6 +1328,7 @@ void CreateTapeButtons() int id = i; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_IMAGE_ID, graphic, GDI_INFO_TEXT, tapebutton_info[i].infotext, GDI_X, VX + pos->x, GDI_Y, VY + pos->y, @@ -1313,7 +1350,7 @@ void CreateTapeButtons() } } -void FreeTapeButtons() +void FreeTapeButtons(void) { int i; @@ -1321,19 +1358,19 @@ void FreeTapeButtons() FreeGadget(tape_gadget[i]); } -void MapTapeEjectButton() +void MapTapeEjectButton(void) { UnmapGadget(tape_gadget[TAPE_CTRL_ID_EXTRA]); MapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]); } -void MapTapeWarpButton() +void MapTapeWarpButton(void) { UnmapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]); MapGadget(tape_gadget[TAPE_CTRL_ID_EXTRA]); } -void MapTapeButtons() +void MapTapeButtons(void) { int i; @@ -1348,7 +1385,7 @@ void MapTapeButtons() MapGameButtonsOnTape(); } -void UnmapTapeButtons() +void UnmapTapeButtons(void) { int i; @@ -1359,7 +1396,7 @@ void UnmapTapeButtons() UnmapGameButtonsOnTape(); } -void RedrawTapeButtons() +void RedrawTapeButtons(void) { int i; @@ -1373,7 +1410,7 @@ void RedrawTapeButtons() redraw_mask &= ~REDRAW_ALL; } -void RedrawOrRemapTapeButtons() +void RedrawOrRemapTapeButtons(void) { if (tape_gadget[TAPE_CTRL_ID_PLAY]->mapped) { @@ -1503,6 +1540,16 @@ static void HandleTapeButtonsExt(int id) break; + case TAPE_CTRL_ID_INSERT_SOLUTION: + InsertSolutionTape(); + + break; + + case TAPE_CTRL_ID_PLAY_SOLUTION: + PlaySolutionTape(); + + break; + default: break; }