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