added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git] / src / tools.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 // tools.h
10 // ============================================================================
11
12 #ifndef TOOLS_H
13 #define TOOLS_H
14
15 #include "main.h"
16 #include "game.h"
17
18
19 // for DrawElementShifted
20 #define NO_CUTTING              0
21 #define CUT_ABOVE               (1 << 0)
22 #define CUT_BELOW               (1 << 1)
23 #define CUT_LEFT                (1 << 2)
24 #define CUT_RIGHT               (1 << 3)
25
26 // for masking functions
27 #define NO_MASKING              0
28 #define USE_MASKING             1
29  
30 // for MoveDoor
31 #define DOOR_OPEN_1             (1 << 0)
32 #define DOOR_OPEN_2             (1 << 1)
33 #define DOOR_CLOSE_1            (1 << 2)
34 #define DOOR_CLOSE_2            (1 << 3)
35 #define DOOR_OPEN_ALL           (DOOR_OPEN_1 | DOOR_OPEN_2)
36 #define DOOR_CLOSE_ALL          (DOOR_CLOSE_1 | DOOR_CLOSE_2)
37 #define DOOR_ACTION_1           (DOOR_OPEN_1 | DOOR_CLOSE_1)
38 #define DOOR_ACTION_2           (DOOR_OPEN_2 | DOOR_CLOSE_2)
39 #define DOOR_ACTION             (DOOR_ACTION_1 | DOOR_ACTION_2)
40 #define DOOR_COPY_BACK          (1 << 4)
41 #define DOOR_NO_COPY_BACK       (1 << 5)
42 #define DOOR_NO_DELAY           (1 << 6)
43 #define DOOR_FORCE_ANIM         (1 << 7)
44 #define DOOR_FORCE_REDRAW       (1 << 8)
45 #define DOOR_GET_STATE          (1 << 9)
46 #define DOOR_SET_STATE          (1 << 10)
47
48 #define DOOR_1                  (DOOR_ACTION_1)
49 #define DOOR_2                  (DOOR_ACTION_2)
50 #define DOOR_OPEN               (DOOR_OPEN_ALL)
51 #define DOOR_CLOSE              (DOOR_CLOSE_ALL)
52
53 #define DOOR_INDEX_FROM_TOKEN(x)        ((x) == DOOR_1 ? 0 : 1)
54 #define DOOR_TOKEN_FROM_INDEX(x)        ((x) == 0 ? DOOR_1 ? : DOOR_2)
55 #define REDRAW_DOOR_FROM_TOKEN(x)       ((x) == DOOR_1 ? REDRAW_DOOR_1 : \
56                                          REDRAW_DOOR_2)
57
58 // for Request
59 #define REQ_ASK                 (1 << 0)
60 #define REQ_CONFIRM             (1 << 1)
61 #define REQ_PLAYER              (1 << 2)
62 #define REQ_STAY_OPEN           (1 << 3)
63 #define REQ_STAY_CLOSED         (1 << 4)
64 #define REQ_REOPEN              (1 << 5)
65
66
67 int getFieldbufferOffsetX_RND(int, int);
68 int getFieldbufferOffsetY_RND(int, int);
69
70 int getLevelFromScreenX(int);
71 int getLevelFromScreenY(int);
72
73 int getScreenFieldSizeX(void);
74 int getScreenFieldSizeY(void);
75
76 void DumpTile(int, int);
77 void DumpTileFromScreen(int, int);
78
79 void DrawMaskedBorder_FIELD(void);
80 void DrawMaskedBorder_DOOR_1(void);
81 void DrawMaskedBorder_DOOR_2(void);
82 void DrawMaskedBorder_DOOR_3(void);
83 void DrawMaskedBorder_ALL(void);
84 void DrawMaskedBorder(int);
85 void DrawMaskedBorderToTarget(int);
86 void DrawTileCursor(int, int);
87
88 void SetDrawtoField(int);
89 int GetDrawtoField(void);
90 void RedrawPlayfield(void);
91 void BlitScreenToBitmapExt_RND(Bitmap *, int, int);
92 void BlitScreenToBitmap_RND(Bitmap *);
93 void BlitScreenToBitmap(Bitmap *);
94 void BackToFront(void);
95 void BackToFront_WithFrameDelay(unsigned int);
96
97 void FadeIn(int);
98 void FadeOut(int);
99 void FadeSetEnterMenu(void);
100 void FadeSetLeaveMenu(void);
101 void FadeSetEnterScreen(void);
102 void FadeSetNextScreen(void);
103 void FadeSetLeaveScreen(void);
104 void FadeSetFromType(int);
105 void FadeSetDisabled(void);
106 void FadeSkipNextFadeIn(void);
107 void FadeSkipNextFadeOut(void);
108
109 int getImageFromGraphicOrDefault(int, int);
110 Bitmap *getGlobalBorderBitmapFromStatus(int);
111
112 void ClearField(void);
113
114 void SetBackgroundImage(int, int);
115 void SetWindowBackgroundImageIfDefined(int);
116 void SetMainBackgroundImageIfDefined(int);
117 void SetDoorBackgroundImageIfDefined(int);
118 void SetWindowBackgroundImage(int);
119 void SetMainBackgroundImage(int);
120 void SetDoorBackgroundImage(int);
121 void SetPanelBackground(void);
122 void DrawBackground(int, int, int, int);
123 void DrawBackgroundForFont(int, int, int, int, int);
124 void DrawBackgroundForGraphic(int, int, int, int, int);
125 boolean CheckIfGlobalBorderHasChanged(void);
126 void RedrawGlobalBorder(void);
127
128 void MarkTileDirty(int, int);
129 void SetBorderElement(void);
130 void FloodFillLevel(int, int, int, short[MAX_LEV_FIELDX][MAX_LEV_FIELDY], int, int);
131 void FloodFillLevelExt(int, int, int, int x, int y, short field[x][y], int, int);
132
133 void SetRandomAnimationValue(int, int);
134 void SetAnimationFirstLevel(int);
135 int getGraphicAnimationFrame(int, int);
136 int getGraphicAnimationFrameXY(int, int, int);
137
138 void DrawFixedGraphicAnimation(int, int, int);
139 void DrawFixedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int);
140 void DrawSizedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int, int);
141
142 void DrawLevelGraphicAnimation(int, int, int);
143 void DrawLevelElementAnimation(int, int, int);
144 void DrawLevelGraphicAnimationIfNeeded(int, int, int);
145 void DrawLevelElementAnimationIfNeeded(int, int, int);
146
147 void DrawAllPlayers(void);
148 void DrawPlayerField(int, int);
149 void DrawPlayer(struct PlayerInfo *);
150
151 void getGraphicSourceBitmap(int, int, Bitmap **);
152 void getGraphicSourceXY(int, int, int *, int *, boolean);
153 void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean);
154 void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *);
155 void getFixedGraphicSource(int, int, Bitmap **, int *, int *);
156 void getMiniGraphicSource(int, Bitmap **, int *, int *);
157 void getGlobalAnimGraphicSource(int, int, Bitmap **, int *, int *);
158 void getGraphicSource(int, int, Bitmap **, int *, int *);
159
160 void DrawGraphic(int, int, int, int);
161 void DrawGraphicExt(DrawBuffer *, int, int, int, int);
162 void DrawGraphicThruMask(int, int, int, int);
163 void DrawGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
164
165 void DrawFixedGraphic(int, int, int, int);
166 void DrawFixedGraphicExt(DrawBuffer *, int, int, int, int);
167 void DrawFixedGraphicThruMask(int, int, int, int);
168 void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
169
170 void DrawSizedGraphic(int, int, int, int, int);
171 void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int);
172 void DrawSizedGraphicThruMask(int, int, int, int, int);
173 void DrawSizedGraphicThruMaskExt(DrawBuffer *, int, int, int, int, int);
174
175 void DrawMiniGraphic(int, int, int);
176 void DrawMiniGraphicExt(DrawBuffer *, int, int, int);
177
178 void DrawScreenElementExt(int, int, int, int, int, int, int);
179 void DrawLevelElementExt(int, int, int, int, int, int, int);
180 void DrawScreenElementShifted(int, int, int, int, int, int);
181 void DrawLevelElementShifted(int, int, int, int, int, int);
182 void DrawScreenElementThruMask(int, int, int);
183 void DrawLevelElementThruMask(int, int, int);
184 void DrawLevelFieldThruMask(int, int);
185 void DrawLevelFieldCrumbled(int, int);
186 void DrawLevelFieldCrumbledDigging(int, int, int, int);
187 void DrawLevelFieldCrumbledNeighbours(int, int);
188 void DrawScreenGraphic(int, int, int, int);
189 void DrawLevelGraphic(int, int, int, int);
190 void DrawScreenElement(int, int, int);
191 void DrawLevelElement(int, int, int);
192 void DrawScreenField(int, int);
193 void DrawLevelField(int, int);
194
195 void DrawSizedWallParts_MM(int, int, int, int, boolean, int);
196 void DrawSizedElement(int, int, int, int);
197 void DrawSizedElementThruMask(int, int, int, int);
198 void DrawSizedElementOrWall(int, int, int, int, int);
199
200 void DrawMiniElement(int, int, int);
201 void DrawMiniElementOrWall(int, int, int, int);
202
203 void ShowEnvelope(int);
204 void ShowEnvelopeDoor(char *, int);
205 void DrawEnvelopeRequestToScreen(int);
206
207 void DrawLevel(int);
208 void DrawSizedLevel(int, int, int, int, int);
209 void DrawMiniLevel(int, int, int, int);
210 void DrawPreviewPlayers(void);
211 void DrawPreviewLevelInitial(void);
212 void DrawPreviewLevelAnimation(void);
213
214 void DrawNetworkPlayers(void);
215 void ClearNetworkPlayers(void);
216
217 void WaitForEventToContinue(void);
218 int Request(char *, unsigned int);
219 void InitGraphicCompatibilityInfo_Doors(void);
220 void InitDoors(void);
221 unsigned int OpenDoor(unsigned int);
222 unsigned int CloseDoor(unsigned int);
223 unsigned int GetDoorState(void);
224 unsigned int SetDoorState(unsigned int);
225 unsigned int MoveDoor(unsigned int);
226
227 void DrawSpecialEditorDoor(void);
228 void UndrawSpecialEditorDoor(void);
229
230 void CreateToolButtons(void);
231 void FreeToolButtons(void);
232
233 int map_element_RND_to_EM_cave(int);
234 int map_element_EM_to_RND_cave(int);
235 int map_element_EM_to_RND_game(int);
236 int map_direction_RND_to_EM(int);
237 int map_direction_EM_to_RND(int);
238
239 void map_android_clone_elements_RND_to_EM(struct LevelInfo *);
240 void map_android_clone_elements_EM_to_RND(struct LevelInfo *);
241
242 int map_element_RND_to_SP(int);
243 int map_element_SP_to_RND(int);
244 int map_action_SP_to_RND(int);
245
246 int map_element_RND_to_MM(int);
247 int map_element_MM_to_RND(int);
248 int map_action_MM_to_RND(int);
249 int map_sound_MM_to_RND(int);
250 int map_mm_wall_element(int);
251 int map_mm_wall_element_editor(int);
252
253 int get_next_element(int);
254 int el_act_dir2img(int, int, int);
255 int el_act2img(int, int);
256 int el_dir2img(int, int);
257 int el2baseimg(int);
258 int el2img(int);
259 int el2edimg(int);
260 int el2preimg(int);
261 int el2panelimg(int);
262 int font2baseimg(int);
263
264 int getBeltNrFromBeltElement(int);
265 int getBeltNrFromBeltActiveElement(int);
266 int getBeltNrFromBeltSwitchElement(int);
267 int getBeltDirNrFromBeltElement(int);
268 int getBeltDirNrFromBeltSwitchElement(int);
269 int getBeltDirFromBeltElement(int);
270 int getBeltDirFromBeltSwitchElement(int);
271 int getBeltElementFromBeltNrAndBeltDirNr(int, int);
272 int getBeltElementFromBeltNrAndBeltDir(int, int);
273 int getBeltSwitchElementFromBeltNrAndBeltDirNr(int, int);
274 int getBeltSwitchElementFromBeltNrAndBeltDir(int, int);
275
276 unsigned int InitRND(int);
277 void InitGraphicInfo_EM(void);
278
279 void PlayMenuSoundExt(int);
280 void PlayMenuSound(void);
281 void PlayMenuSoundStereo(int, int);
282 void PlayMenuSoundIfLoopExt(int);
283 void PlayMenuSoundIfLoop(void);
284 void PlayMenuMusicExt(int);
285 void PlayMenuMusic(void);
286 void PlayMenuSoundsAndMusic(void);
287 void FadeMenuSoundsAndMusic(void);
288 void PlaySoundActivating(void);
289 void PlaySoundSelecting(void);
290
291 void SetAnimStatus(int);
292 void SetGameStatus(int);
293 void SetFontStatus(int);
294 void ResetFontStatus(void);
295
296 void SetLevelSetInfo(char *, int);
297
298 void ToggleFullscreenIfNeeded(void);
299 void ChangeWindowScalingIfNeeded(void);
300 void ChangeVsyncModeIfNeeded(void);
301 void ChangeViewportPropertiesIfNeeded(void);
302
303 boolean CheckIfAllViewportsHaveChanged(void);
304 boolean CheckFadeAll(void);
305
306 void OpenURL(char *);
307 void OpenURLFromHash(SetupFileHash *, int);
308
309 void TestGeneratingUUIDs(void);
310
311 #endif  // TOOLS_H