ScummVM API documentation
game_menu.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef M4_BURGER_GUI_GAME_MENU_H
24 #define M4_BURGER_GUI_GAME_MENU_H
25 
26 #include "graphics/surface.h"
27 #include "m4/m4_types.h"
28 #include "m4/graphics/gr_buff.h"
29 #include "m4/gui/gui_univ.h"
30 
31 namespace M4 {
32 namespace Burger {
33 namespace GUI {
34 
35 typedef bool (*ItemHandlerFunction)(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
36 typedef void (*DrawFunction)(void *source, void *dest, int32 x1, int32 y1, int32 x2, int32 y2);
37 typedef void (*DestroyFunction)(void *theItem);
38 typedef M4CALLBACK CALLBACK;
39 
40 typedef M4sprite Sprite;
41 //struct Sprite {};
42 
43 struct menuItem {
44  menuItem *next;
45  menuItem *prev;
46 
47  void *myMenu;
48  int32 tag;
49 
50  int32 x1, y1, x2, y2;
51 
52  bool transparent;
53  GrBuff *background;
54 
55  void *itemInfo;
56 
57  CALLBACK callback;
58  DrawFunction redraw;
59  DestroyFunction destroy;
60  ItemHandlerFunction itemEventHandler;
61 };
62 
63 struct menuItemMsg {
64  int32 itemFlags;
65 };
66 
68  int32 itemFlags;
69  int32 buttonType;
70  const char *prompt;
71  menuItem *assocItem;
72  int32 specialTag;
73 };
74 
76  int32 itemFlags;
77 
78  int32 thumbW, thumbH;
79  int32 thumbX, maxThumbX;
80 
81  int32 percent;
82 };
83 
85  int32 itemFlags;
86 
87  int32 thumbW, thumbH;
88  int32 thumbY, minThumbY, maxThumbY;
89 
90  int32 percent;
91 };
92 
94  int32 itemFlags;
95 
96  int32 specialTag;
97  int32 pixWidth;
98 
99  char prompt[80];
100  char *promptEnd;
101 
102  char *cursor;
103 };
104 
105 struct guiMenu {
106  GrBuff *menuBuffer;
107  menuItem *itemList;
108  CALLBACK cb_return;
109  CALLBACK cb_esc;
110  EventHandler menuEventHandler;
111 };
112 
113 // GENERAL MENU FUNCTIONS
114 bool menu_Initialize(RGB8 *myPalette);
115 guiMenu *menu_Create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFlags);
116 void menu_Destroy(guiMenu *myMenu);
117 void menu_Configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc);
118 GrBuff *menu_CopyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h);
119 menuItem *menu_GetItem(int32 tag, guiMenu *myMenu);
120 void menu_ItemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu);
121 void menu_ItemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu);
122 
123 // SPECIFIC ITEM FUNCTIONS
124 
125 // Messages
126 menuItem *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, bool transparent = false);
127 void menu_DisableMsg(menuItem *myItem, int32 tag, guiMenu *myMenu);
128 void menu_EnableMsg(menuItem *myItem, int32 tag, guiMenu *myMenu);
129 
130 // Buttons
131 bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
132 menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback = nullptr,
133  int32 buttonType = 0, bool ghosted = false, bool transparent = false,
134  const char *prompt = nullptr, ItemHandlerFunction i_handler = button_Handler);
135 void menu_DisableButton(menuItem *myItem, int32 tag, guiMenu *myMenu);
136 void menu_EnableButton(menuItem *myItem, int32 tag, guiMenu *myMenu);
137 
138 // Horizontal sliders
139 menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
140  int32 initPercent = 0, CALLBACK callback = nullptr, bool transparent = false);
141 
142 // Vertical sliders
143 menuItem *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
144  int32 initPercent = 0, CALLBACK callback = nullptr, bool transparent = false);
145 void menu_DisableVSlider(menuItem *myItem, int32 tag, guiMenu *myMenu);
146 void menu_EnableVSlider(menuItem *myItem, int32 tag, guiMenu *myMenu);
147 
148 // Textfields
149 menuItem *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, int32 initFlags,
150  const char *prompt = nullptr, int32 specialtag = 0, CALLBACK callback = nullptr, bool transparent = false);
151 
152 //GAME MENU FUNCTIONS
153 extern void CreateGameMenu(RGB8 *myPalette);
154 extern void CreateOptionsMenu(RGB8 *myPalette);
155 extern void CreateF2SaveMenu(RGB8 *myPalette);
156 extern void CreateLoadMenu(RGB8 *myPalette);
157 extern void CreateF3LoadMenu(RGB8 *myPalette);
158 
159 //routines used by the main menu
160 void CreateLoadMenuFromMain(RGB8 *myPalette);
161 void CreateGameMenuFromMain(RGB8 *myPalette);
162 
163 
164 //======================================
165 //
166 // gamemenu module defines
167 //
168 #define MEMORY_NEEDED 0 // bytes needed for menus to work
169 #define MENU_DEPTH 9 // video depth for menu popup boxes
170 #define MAX_SLOTS 99 // number of save games you can have
171 #define MAX_SLOTS_SHOWN 8 // number of slots in the scrolling field
172 
173 // 128 very light green
174 // 129 light green
175 // 130 medium green
176 // 131 dark green
177 // 133 light red
178 // 136 red
179 // 142 dark red
180 // 186 purple
181 // 206 dark grey
182 // 236 very dark purple
183 
184 #define TEXT_COLOR_GREY_HILITE 192
185 #define TEXT_COLOR_GREY_FOREGROUND 210
186 #define TEXT_COLOR_GREY_SHADOW 229
187 
188 #define TEXT_COLOR_NORM_HILITE 3
189 #define TEXT_COLOR_NORM_FOREGROUND 2
190 #define TEXT_COLOR_NORM_SHADOW 1
191 
192 #define TEXT_COLOR_OVER_HILITE 3
193 #define TEXT_COLOR_OVER_FOREGROUND 2
194 #define TEXT_COLOR_OVER_SHADOW 1
195 
196 #define TEXT_COLOR_PRESS_HILITE 3
197 #define TEXT_COLOR_PRESS_FOREGROUND 2
198 #define TEXT_COLOR_PRESS_SHADOW 1
199 
200 #define SLIDER_BAR_COLOR 129
201 
202 
203 
204 //======================================
205 //
206 // Game menu enums and defines
207 //
208 #define GAME_MENU_X 190
209 #define GAME_MENU_Y 100
210 #define GAME_MENU_W 260
211 #define GAME_MENU_H 198
212 
213 enum game_menu_sprites {
214  GM_DIALOG_BOX,
215 
216  GM_BUTTON_GREY,
217  GM_BUTTON_NORM,
218  GM_BUTTON_OVER,
219  GM_BUTTON_PRESS,
220 
221  GM_TOTAL_SPRITES
222 };
223 
224 enum game_menu_button_tags {
225  GM_TAG_QUIT = 1,
226  GM_TAG_OPTIONS = 2,
227  GM_TAG_RESUME = 3,
228  GM_TAG_SAVE = 4,
229  GM_TAG_LOAD = 5,
230  GM_TAG_MAIN = 6
231 };
232 
233 #define GM_MAIN_X 45
234 #define GM_MAIN_Y 53
235 #define GM_MAIN_W 24
236 #define GM_MAIN_H 24
237 
238 #define GM_OPTIONS_X 45
239 #define GM_OPTIONS_Y 94
240 #define GM_OPTIONS_W 24
241 #define GM_OPTIONS_H 24
242 
243 #define GM_RESUME_X 45
244 #define GM_RESUME_Y 135
245 #define GM_RESUME_W 24
246 #define GM_RESUME_H 24
247 
248 #define GM_QUIT_X 141
249 #define GM_QUIT_Y 135
250 #define GM_QUIT_W 24
251 #define GM_QUIT_H 24
252 
253 #define GM_SAVE_X 141
254 #define GM_SAVE_Y 53
255 #define GM_SAVE_W 24
256 #define GM_SAVE_H 24
257 
258 #define GM_LOAD_X 141
259 #define GM_LOAD_Y 94
260 #define GM_LOAD_W 24
261 #define GM_LOAD_H 24
262 
263 //======================================
264 //
265 // Save/Load menu enums and defines
266 //
267 #define SAVE_LOAD_MENU_X 145
268 #define SAVE_LOAD_MENU_Y 10
269 #define SAVE_LOAD_MENU_W 344
270 #define SAVE_LOAD_MENU_H 460
271 
272 enum save_load_menu_sprites {
273 
274  SL_DIALOG_BOX,
275  SL_EMPTY_THUMB,
276 
277  SL_SAVE_BTN_GREY,
278  SL_SAVE_BTN_NORM,
279  SL_SAVE_BTN_OVER,
280  SL_SAVE_BTN_PRESS,
281 
282  SL_LOAD_BTN_GREY,
283  SL_LOAD_BTN_NORM,
284  SL_LOAD_BTN_OVER,
285  SL_LOAD_BTN_PRESS,
286 
287  SL_CANCEL_BTN_NORM,
288  SL_CANCEL_BTN_OVER,
289  SL_CANCEL_BTN_PRESS,
290 
291  SL_UP_BTN_GREY,
292  SL_UP_BTN_NORM,
293  SL_UP_BTN_OVER,
294  SL_UP_BTN_PRESS,
295 
296  SL_DOWN_BTN_GREY,
297  SL_DOWN_BTN_NORM,
298  SL_DOWN_BTN_OVER,
299  SL_DOWN_BTN_PRESS,
300 
301  SL_SAVE_LABEL,
302  SL_LOAD_LABEL,
303 
304  SL_SLIDER_BTN_NORM,
305  SL_SLIDER_BTN_OVER,
306  SL_SLIDER_BTN_PRESS,
307 
308  SL_LINE_NORM,
309  SL_LINE_OVER,
310  SL_LINE_PRESS,
311 
312  SL_SCROLL_BAR,
313 
314  SL_TOTAL_SPRITES
315 };
316 
317 enum save_load_menu_item_tags {
318  SL_TAG_SAVE = 100,
319  SL_TAG_SAVE_LABEL,
320  SL_TAG_LOAD,
321  SL_TAG_LOAD_LABEL,
322  SL_TAG_CANCEL,
323  SL_TAG_VSLIDER,
324  SL_TAG_THUMBNAIL
325 };
326 
327 #define SL_SAVE_X 214
328 #define SL_SAVE_Y 384
329 #define SL_SAVE_W 74
330 #define SL_SAVE_H 43
331 
332 #define SL_LOAD_X 214
333 #define SL_LOAD_Y 384
334 #define SL_LOAD_W 74
335 #define SL_LOAD_H 43
336 
337 #define SL_UP_X 292
338 #define SL_UP_Y 255
339 #define SL_UP_W 20
340 #define SL_UP_H 17
341 
342 #define SL_DOWN_X 293
343 #define SL_DOWN_Y 363
344 #define SL_DOWN_W 20
345 #define SL_DOWN_H 17
346 
347 #define SL_SLIDER_X 291
348 #define SL_SLIDER_Y 255
349 #define SL_SLIDER_W 23
350 #define SL_SLIDER_H 127
351 
352 #define SL_CANCEL_X 139
353 #define SL_CANCEL_Y 384
354 #define SL_CANCEL_W 74
355 #define SL_CANCEL_H 43
356 
357 #define SL_SAVE_LABEL_X 50
358 #define SL_SAVE_LABEL_Y 241
359 #define SL_SAVE_LABEL_W 70
360 #define SL_SAVE_LABEL_H 16
361 
362 #define SL_LOAD_LABEL_X 50
363 #define SL_LOAD_LABEL_Y 241
364 #define SL_LOAD_LABEL_W 70
365 #define SL_LOAD_LABEL_H 16
366 
367 #define SL_SCROLL_FIELD_X 50
368 #define SL_SCROLL_FIELD_Y 256
369 #define SL_SCROLL_FIELD_W 238
370 #define SL_SCROLL_FIELD_H 121
371 
372 #define SL_SCROLL_LINE_W 238
373 #define SL_SCROLL_LINE_H 15 //was 16
374 
375 #define SL_THUMBNAIL_X 66
376 #define SL_THUMBNAIL_Y 28
377 #define SL_THUMBNAIL_W 215
378 #define SL_THUMBNAIL_H 162
379 
383 enum options_menu_sprites {
384 
385  OM_DIALOG_BOX,
386 
387  OM_SLIDER_BTN_NORM,
388  OM_SLIDER_BTN_OVER,
389  OM_SLIDER_BTN_PRESS,
390 
391  OM_SLIDER_BAR,
392 
393  OM_DONE_BTN_GREY,
394  OM_DONE_BTN_NORM,
395  OM_DONE_BTN_OVER,
396  OM_DONE_BTN_PRESS,
397 
398  OM_CANCEL_BTN_NORM,
399  OM_CANCEL_BTN_OVER,
400  OM_CANCEL_BTN_PRESS,
401 
402  OM_TOTAL_SPRITES
403 };
404 
405 #define OPTIONS_MENU_X 175
406 #define OPTIONS_MENU_Y 100
407 #define OPTIONS_MENU_W 298
408 #define OPTIONS_MENU_H 218
409 
410 enum option_menu_item_tags {
411  OM_TAG_DONE = 1,
412  OM_TAG_CANCEL,
413  OM_TAG_DIGI,
414  OM_TAG_DIGESTABILITY,
415 };
416 
417 #define OM_DONE_X 168
418 #define OM_DONE_Y 141
419 #define OM_DONE_W 74
420 #define OM_DONE_H 43
421 
422 #define OM_CANCEL_X 93
423 #define OM_CANCEL_Y 141
424 #define OM_CANCEL_W 74
425 #define OM_CANCEL_H 43
426 
427 #define OM_DIGI_X 47
428 #define OM_DIGI_Y 64
429 #define OM_DIGI_W 212
430 #define OM_DIGI_H 24
431 
432 #define OM_DIGESTABILITY_X 47
433 #define OM_DIGESTABILITY_Y 104
434 #define OM_DIGESTABILITY_W 212
435 #define OM_DIGESTABILITY_H 24
436 
440 enum error_menu_sprites {
441  EM_DIALOG_BOX,
442 
443  EM_RETURN_BTN_NORM,
444  EM_RETURN_BTN_OVER,
445  EM_RETURN_BTN_PRESS,
446 
447  EM_TOTAL_SPRITES
448 };
449 
450 enum error_menu_tags {
451  EM_TAG_RETURN = 1
452 };
453 #define ERROR_MENU_X 100
454 #define ERROR_MENU_Y 100
455 #define ERROR_MENU_W 100
456 #define ERROR_MENU_H 100
457 
458 #define EM_RETURN_X 15
459 #define EM_RETURN_Y 15
460 #define EM_RETURN_W 15
461 #define EM_RETURN_H 15
462 
463 
464 struct MenuGlobals {
465  //GLOBAL VARS
466  bool menuSystemInitialized = false;
467  bool interfaceWasVisible = false;
468  RGB8 *menuPalette = nullptr;
469  bool dumpedCodes = false;
470  bool dumpedBackground = false;
471 
472  menuItem *menuCurrItem = nullptr;
473 
474  guiMenu *gameMenu = nullptr;
475  guiMenu *opMenu = nullptr;
476  guiMenu *slMenu = nullptr;
477  guiMenu *errMenu = nullptr;
478 
479  //menu sprite series vars
480  char *menuSeriesResource = nullptr;
481  MemHandle menuSeriesHandle = nullptr;
482  int32 menuSeriesOffset = 0;
483  int32 menuSeriesPalOffset = 0;
484 
485  Font *menuFont = nullptr;
486 
487  // menu sprites array (used to hold all the sprites for the current menu, spriteCount is set tot he number of sprites in the series)
488  int32 spriteCount = 0;
489  Sprite **menuSprites = nullptr;
490 
491  // VARS SPECIFIC TO THE GAME MENUS SYSTEM
492  // An array of slot titles used by the save/load menus
493  char **slotTitles = nullptr;
494  bool *slotInUse = nullptr;
495  int32 firstSlotIndex = 0; // Slot at the top of the list on menu
496  int32 slotSelected = -1; // Slot currently selected
497  bool deleteSaveDesc = false;
498 
499  Sprite **thumbNails = nullptr;
500  Sprite *saveLoadThumbNail = nullptr; // Original used for menu display
501  Graphics::Surface _thumbnail; // ScummVM version used for savegame
502  int32 sizeofThumbData = -1;
503  int32 thumbIndex = 0;
504 
505  bool currMenuIsSave = true; // Used to determine load or save menu
506  bool saveLoadFromHotkey = false; // Come from hotkey, not through game menu
507  bool gameMenuFromMain = false; // Come from main menu, not through escape
508 
509  int32 remember_digi_volume = 0; // For cancelling out of the options menu
510  int32 remember_digestability = 0; // For cancelling out of the options menu
511 
512  ~MenuGlobals() {
513  _thumbnail.free();
514  }
515 };
516 
517 void CreateGameMenuMain(RGB8 *myPalette);
518 
519 } // namespace GUI
520 } // namespace Burger
521 } // namespace M4
522 
523 #endif
Definition: game_menu.h:43
Definition: surface.h:67
Definition: gr_font.h:30
Definition: game_menu.h:75
Definition: game_menu.h:464
Definition: game_menu.h:93
Definition: system.h:46
Definition: game_menu.h:63
Definition: m4_types.h:88
Definition: game_menu.h:67
Definition: database.h:28
Definition: game_menu.h:84
Definition: gr_buff.h:30
Definition: game_menu.h:105