fixed name of element 'beamer' to 'teleporter'
[rocksndiamonds.git] / src / tape.h
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // tape.h
10 // ============================================================================
11
12 #ifndef TAPE_H
13 #define TAPE_H
14
15
16 /* values for TapeTogglePause() */
17 #define TAPE_TOGGLE_AUTOMATIC   0
18 #define TAPE_TOGGLE_MANUAL      (1 << 0)
19 #define TAPE_TOGGLE_PLAY_PAUSE  (1 << 1)
20
21 /* values for tape properties */
22 #define MAX_TAPE_LEN            (1000 * FRAMES_PER_SECOND) /* max.time x fps */
23
24 /* values for tape mouse actions */
25 #define TAPE_ACTION_LX          0
26 #define TAPE_ACTION_LY          1
27 #define TAPE_ACTION_BUTTON      2
28 #define TAPE_ACTION_UNUSED      3
29
30 /* some positions in the video tape control window */
31 #define VIDEO_DISPLAY1_XPOS     5
32 #define VIDEO_DISPLAY1_YPOS     5
33 #define VIDEO_DISPLAY2_XPOS     5
34 #define VIDEO_DISPLAY2_YPOS     41
35 #define VIDEO_DISPLAY_XSIZE     90
36 #define VIDEO_DISPLAY_YSIZE     31
37 #define VIDEO_BUTTON_XSIZE      18
38 #define VIDEO_BUTTON_YSIZE      18
39 #define VIDEO_CONTROL_XPOS      5
40 #define VIDEO_CONTROL_YPOS      77
41 #define VIDEO_CONTROL_XSIZE     VIDEO_DISPLAY_XSIZE
42 #define VIDEO_CONTROL_YSIZE     VIDEO_BUTTON_YSIZE
43
44 /* values for video tape control */
45 #define VIDEO_STATE_PLAY_OFF    (1 << 0)
46 #define VIDEO_STATE_PLAY_ON     (1 << 1)
47 #define VIDEO_STATE_REC_OFF     (1 << 2)
48 #define VIDEO_STATE_REC_ON      (1 << 3)
49 #define VIDEO_STATE_PAUSE_OFF   (1 << 4)
50 #define VIDEO_STATE_PAUSE_ON    (1 << 5)
51 #define VIDEO_STATE_DATE_OFF    (1 << 6)
52 #define VIDEO_STATE_DATE_ON     (1 << 7)
53 #define VIDEO_STATE_TIME_OFF    (1 << 8)
54 #define VIDEO_STATE_TIME_ON     (1 << 9)
55 #define VIDEO_STATE_FRAME_OFF   (1 << 10)
56 #define VIDEO_STATE_FRAME_ON    (1 << 11)
57 #define VIDEO_STATE_FFWD_OFF    (1 << 12)
58 #define VIDEO_STATE_FFWD_ON     (1 << 13)
59 #define VIDEO_STATE_WARP_OFF    (1 << 14)
60 #define VIDEO_STATE_WARP_ON     (1 << 15)
61 #define VIDEO_STATE_WARP2_OFF   (1 << 16)
62 #define VIDEO_STATE_WARP2_ON    (1 << 17)
63 #define VIDEO_STATE_PBEND_OFF   (1 << 18)
64 #define VIDEO_STATE_PBEND_ON    (1 << 19)
65 #define VIDEO_STATE_1STEP_OFF   (1 << 20)
66 #define VIDEO_STATE_1STEP_ON    (1 << 21)
67
68 #define VIDEO_PRESS_PLAY_ON     (1 << 22)
69 #define VIDEO_PRESS_PLAY_OFF    (1 << 23)
70 #define VIDEO_PRESS_REC_ON      (1 << 24)
71 #define VIDEO_PRESS_REC_OFF     (1 << 25)
72 #define VIDEO_PRESS_PAUSE_ON    (1 << 26)
73 #define VIDEO_PRESS_PAUSE_OFF   (1 << 27)
74 #define VIDEO_PRESS_STOP_ON     (1 << 28)
75 #define VIDEO_PRESS_STOP_OFF    (1 << 29)
76 #define VIDEO_PRESS_EJECT_ON    (1 << 30)
77 #define VIDEO_PRESS_EJECT_OFF   (1 << 31)
78
79 #define VIDEO_STATE_PLAY(x)  ((x) ? VIDEO_STATE_PLAY_ON : VIDEO_STATE_PLAY_OFF)
80 #define VIDEO_STATE_REC(x)   ((x) ? VIDEO_STATE_REC_ON  : VIDEO_STATE_REC_OFF)
81 #define VIDEO_STATE_PAUSE(x) ((x) ? VIDEO_STATE_PAUSE_ON: VIDEO_STATE_PAUSE_OFF)
82 #define VIDEO_STATE_DATE(x)  ((x) ? VIDEO_STATE_DATE_ON : VIDEO_STATE_DATE_OFF)
83 #define VIDEO_STATE_TIME(x)  ((x) ? VIDEO_STATE_TIME_ON : VIDEO_STATE_TIME_OFF)
84 #define VIDEO_STATE_FRAME(x) ((x) ? VIDEO_STATE_FRAME_ON: VIDEO_STATE_FRAME_OFF)
85 #define VIDEO_STATE_FFWD(x)  ((x) ? VIDEO_STATE_FFWD_ON : VIDEO_STATE_FFWD_OFF)
86 #define VIDEO_STATE_WARP(x)  ((x) ? VIDEO_STATE_WARP_ON : VIDEO_STATE_WARP_OFF)
87 #define VIDEO_STATE_WARP2(x) ((x) ? VIDEO_STATE_WARP2_ON: VIDEO_STATE_WARP2_OFF)
88 #define VIDEO_STATE_PBEND(x) ((x) ? VIDEO_STATE_PBEND_ON: VIDEO_STATE_PBEND_OFF)
89 #define VIDEO_STATE_1STEP(x) ((x) ? VIDEO_STATE_1STEP_ON: VIDEO_STATE_1STEP_OFF)
90
91 #define VIDEO_PRESS_PLAY(x)  ((x) ? VIDEO_PRESS_PLAY_ON : VIDEO_PRESS_PLAY_OFF)
92 #define VIDEO_PRESS_REC(x)   ((x) ? VIDEO_PRESS_REC_ON  : VIDEO_PRESS_REC_OFF)
93 #define VIDEO_PRESS_PAUSE(x) ((x) ? VIDEO_PRESS_PAUSE_ON: VIDEO_PRESS_PAUSE_OFF)
94 #define VIDEO_PRESS_STOP(x)  ((x) ? VIDEO_PRESS_STOP_ON : VIDEO_PRESS_STOP_OFF)
95 #define VIDEO_PRESS_EJECT(x) ((x) ? VIDEO_PRESS_EJECT_ON: VIDEO_PRESS_EJECT_OFF)
96
97 /* tags to draw video display labels or symbols only */
98 /* (negative values to prevent misinterpretation in DrawVideoDisplay(), where
99    the variable "value" is also used for tape length -- better fix this) */
100 #define VIDEO_DISPLAY_DEFAULT           0
101 #define VIDEO_DISPLAY_LABEL_ONLY        -1
102 #define VIDEO_DISPLAY_SYMBOL_ONLY       -2
103
104
105 struct TapeButtonInfo
106 {
107   struct XY eject;
108   struct XY stop;
109   struct XY pause;
110   struct XY record;
111   struct XY play;
112 };
113
114 struct TapeSymbolInfo
115 {
116   struct XY eject;
117   struct XY stop;
118   struct XY pause;
119   struct XY record;
120   struct XY play;
121   struct XY fast_forward;
122   struct XY warp_forward;
123   struct XY warp_forward_blind;
124   struct XY pause_before_end;
125   struct XY single_step;
126 };
127
128 struct TapeLabelInfo
129 {
130   struct XY eject;
131   struct XY stop;
132   struct XY pause;
133   struct XY record;
134   struct XY play;
135   struct XY fast_forward;
136   struct XY warp_forward;
137   struct XY warp_forward_blind;
138   struct XY pause_before_end;
139   struct XY single_step;
140   struct XY date;
141   struct XY time;
142 };
143
144 struct TapeTextInfo
145 {
146   struct TextPosInfo date;
147   struct TextPosInfo date_yyyy;
148   struct TextPosInfo date_yy;
149   struct TextPosInfo date_mon;
150   struct TextPosInfo date_mm;
151   struct TextPosInfo date_dd;
152
153   struct TextPosInfo time;
154   struct TextPosInfo time_hh;
155   struct TextPosInfo time_mm;
156   struct TextPosInfo time_ss;
157
158   struct TextPosInfo frame;
159 };
160
161 struct TapeInfo
162 {
163   int file_version;     /* file format version the tape is stored with    */
164   int game_version;     /* game release version the tape was created with */
165   int engine_version;   /* game engine version the tape was recorded with */
166
167   char *level_identifier;
168   int level_nr;
169   unsigned int random_seed;
170   unsigned int date;
171   unsigned int counter;
172   unsigned int length;
173   unsigned int length_frames;
174   unsigned int length_seconds;
175   unsigned int delay_played;
176   boolean pause_before_end;
177   boolean recording, playing, pausing;
178   boolean fast_forward;
179   boolean warp_forward;
180   boolean deactivate_display;
181   boolean auto_play;
182   boolean auto_play_level_solved;
183   boolean quick_resume;
184   boolean single_step;
185   boolean changed;
186   boolean player_participates[MAX_PLAYERS];
187   int num_participating_players;
188   int centered_player_nr_next;
189   boolean set_centered_player;
190
191   boolean use_mouse;
192
193   struct
194   {
195     byte action[MAX_PLAYERS];
196     byte delay;
197   } pos[MAX_TAPE_LEN];
198
199   struct TapeButtonInfo button;
200   struct TapeSymbolInfo symbol;
201   struct TapeLabelInfo label;
202   struct TapeTextInfo text;
203
204   boolean show_game_buttons;    /* show game buttons in tape viewport */
205
206   boolean no_valid_file;        /* set when tape file missing or invalid */
207 };
208
209
210 void DrawVideoDisplay(unsigned int, unsigned int);
211 void DrawCompleteVideoDisplay(void);
212
213 void TapeDeactivateDisplayOn();
214 void TapeDeactivateDisplayOff(boolean);
215
216 void TapeSetDateFromEpochSeconds(time_t);
217 void TapeSetDateFromNow();
218
219 void TapeStartRecording(int);
220 void TapeHaltRecording(void);
221 void TapeStopRecording(void);
222 boolean TapeAddAction(byte *);
223 void TapeRecordAction(byte *);
224 void TapeTogglePause(boolean);
225 void TapeStartPlaying(void);
226 void TapeStopPlaying(void);
227 byte *TapePlayAction(void);
228 void TapeStop(void);
229 void TapeErase(void);
230 unsigned int GetTapeLengthFrames(void);
231 unsigned int GetTapeLengthSeconds(void);
232 void TapeQuickSave(void);
233 void TapeQuickLoad(void);
234 void InsertSolutionTape(void);
235
236 void AutoPlayTape(void);
237
238 void CreateTapeButtons();
239 void FreeTapeButtons();
240 void MapTapeEjectButton();
241 void MapTapeWarpButton();
242 void MapTapeButtons();
243 void UnmapTapeButtons();
244 void RedrawTapeButtons();
245 void RedrawOrRemapTapeButtons();
246
247 void HandleTapeButtonKeys(Key);
248
249 #endif