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