X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftape.c;h=8e2f627da65b5b0c32b2b1127fe56bd9c592e157;hb=d6338db94d8402c3f47a422069d352fced1e496e;hp=abcaf4817c4551e9d231671a4a5a235146cdcef4;hpb=9dc1a9b929ed268df501e7d2b00f51f4521f8b5e;p=rocksndiamonds.git diff --git a/src/tape.c b/src/tape.c index abcaf481..8e2f627d 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]; @@ -347,17 +349,17 @@ void DrawVideoDisplay(unsigned int state, unsigned int value) DrawVideoDisplay_DateTime(state, value); } -void DrawVideoDisplayLabel(unsigned int state) +static void DrawVideoDisplayLabel(unsigned int state) { DrawVideoDisplay(state, VIDEO_DISPLAY_LABEL_ONLY); } -void DrawVideoDisplaySymbol(unsigned int state) +static void DrawVideoDisplaySymbol(unsigned int state) { DrawVideoDisplay(state, VIDEO_DISPLAY_SYMBOL_ONLY); } -void DrawVideoDisplayCurrentState() +static 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; @@ -463,7 +465,7 @@ void TapeDeactivateDisplayOff(boolean redraw_display) /* tape logging functions */ /* ========================================================================= */ -void PrintTapeReplayProgress(boolean replay_finished) +static void PrintTapeReplayProgress(boolean replay_finished) { static unsigned int counter_last = -1; unsigned int counter = Counter(); @@ -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,23 +598,12 @@ void TapeStartRecording(int random_seed) audio.sound_deactivated = FALSE; } -static void TapeStartGameRecording() +static void TapeStartGameRecording(void) { - TapeStartRecording(level.random_seed); - -#if defined(NETWORK_AVALIABLE) - if (options.network) - { - SendToServer_StartPlaying(); - - return; - } -#endif - - InitGame(); + StartGameActions(network.enabled, TRUE, level.random_seed); } -static void TapeAppendRecording() +static void TapeAppendRecording(void) { if (!tape.playing || !tape.pausing) return; @@ -640,7 +631,7 @@ static void TapeAppendRecording() UpdateAndDisplayGameControlValues(); } -void TapeHaltRecording() +void TapeHaltRecording(void) { tape.counter++; @@ -653,7 +644,7 @@ void TapeHaltRecording() tape.length_seconds = GetTapeLengthSeconds(); } -void TapeStopRecording() +void TapeStopRecording(void) { if (tape.recording) TapeHaltRecording(); @@ -780,7 +771,7 @@ void TapeTogglePause(boolean toggle_mode) } } -void TapeStartPlaying() +void TapeStartPlaying(void) { if (TAPE_IS_EMPTY(tape)) return; @@ -803,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; @@ -822,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); @@ -917,7 +908,7 @@ byte *TapePlayAction() return action; } -void TapeStop() +void TapeStop(void) { if (tape.pausing) TapeTogglePause(TAPE_TOGGLE_MANUAL); @@ -935,7 +926,7 @@ void TapeStop() } } -unsigned int GetTapeLengthFrames() +unsigned int GetTapeLengthFrames(void) { unsigned int tape_length_frames = 0; int i; @@ -949,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); } @@ -973,7 +964,7 @@ static void TapeStartWarpForward(int mode) DrawVideoDisplayCurrentState(); } -static void TapeStopWarpForward() +static void TapeStopWarpForward(void) { tape.fast_forward = FALSE; tape.warp_forward = FALSE; @@ -986,9 +977,9 @@ static void TapeStopWarpForward() DrawVideoDisplayCurrentState(); } -static void TapeSingleStep() +static void TapeSingleStep(void) { - if (options.network) + if (network.enabled) return; if (!tape.pausing) @@ -999,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) { @@ -1025,7 +1016,7 @@ void TapeQuickSave() SaveEngineSnapshotSingle(); } -void TapeQuickLoad() +void TapeQuickLoad(void) { char *filename = getTapeFilename(level_nr); @@ -1088,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; } @@ -1116,7 +1132,7 @@ void InsertSolutionTape() * tape autoplay functions * ------------------------------------------------------------------------- */ -void AutoPlayTape() +void AutoPlayTape(void) { static LevelDirTree *autoplay_leveldir = NULL; static boolean autoplay_initialized = FALSE; @@ -1284,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; @@ -1303,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, @@ -1324,7 +1350,7 @@ void CreateTapeButtons() } } -void FreeTapeButtons() +void FreeTapeButtons(void) { int i; @@ -1332,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; @@ -1359,7 +1385,7 @@ void MapTapeButtons() MapGameButtonsOnTape(); } -void UnmapTapeButtons() +void UnmapTapeButtons(void) { int i; @@ -1370,7 +1396,7 @@ void UnmapTapeButtons() UnmapGameButtonsOnTape(); } -void RedrawTapeButtons() +void RedrawTapeButtons(void) { int i; @@ -1384,7 +1410,7 @@ void RedrawTapeButtons() redraw_mask &= ~REDRAW_ALL; } -void RedrawOrRemapTapeButtons() +void RedrawOrRemapTapeButtons(void) { if (tape_gadget[TAPE_CTRL_ID_PLAY]->mapped) { @@ -1514,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; }