1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
28 /* screens on the info screen */
29 #define INFO_MODE_MAIN 0
30 #define INFO_MODE_TITLE 1
31 #define INFO_MODE_ELEMENTS 2
32 #define INFO_MODE_MUSIC 3
33 #define INFO_MODE_CREDITS 4
34 #define INFO_MODE_PROGRAM 5
35 #define INFO_MODE_VERSION 6
36 #define INFO_MODE_LEVELSET 7
38 #define MAX_INFO_MODES 8
40 /* screens on the setup screen */
41 #define SETUP_MODE_MAIN 0
42 #define SETUP_MODE_GAME 1
43 #define SETUP_MODE_EDITOR 2
44 #define SETUP_MODE_GRAPHICS 3
45 #define SETUP_MODE_SOUND 4
46 #define SETUP_MODE_ARTWORK 5
47 #define SETUP_MODE_INPUT 6
48 #define SETUP_MODE_SHORTCUTS_1 7
49 #define SETUP_MODE_SHORTCUTS_2 8
51 /* sub-screens on the setup screen (generic) */
52 #define SETUP_MODE_CHOOSE_ARTWORK 9
53 #define SETUP_MODE_CHOOSE_OTHER 10
55 /* sub-screens on the setup screen (specific) */
56 #define SETUP_MODE_CHOOSE_GAME_SPEED 11
57 #define SETUP_MODE_CHOOSE_SCREEN_MODE 12
58 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 13
59 #define SETUP_MODE_CHOOSE_GRAPHICS 14
60 #define SETUP_MODE_CHOOSE_SOUNDS 15
61 #define SETUP_MODE_CHOOSE_MUSIC 16
63 #define MAX_SETUP_MODES 17
65 /* for input setup functions */
66 #define SETUPINPUT_SCREEN_POS_START 0
67 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
68 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
69 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
71 /* for various menu stuff */
72 #define MENU_SCREEN_START_XPOS 1
73 #define MENU_SCREEN_START_YPOS 2
74 #define MENU_SCREEN_VALUE_XPOS 14
75 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
76 #define MENU_TITLE1_YPOS 8
77 #define MENU_TITLE2_YPOS 46
78 #define MAX_INFO_ELEMENTS_ON_SCREEN 10
79 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
80 #define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \
81 MENU_SCREEN_START_XPOS)
82 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
84 /* buttons and scrollbars identifiers */
85 #define SCREEN_CTRL_ID_PREV_LEVEL 0
86 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
87 #define SCREEN_CTRL_ID_PREV_PLAYER 2
88 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
89 #define SCREEN_CTRL_ID_SCROLL_UP 4
90 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
91 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
93 #define NUM_SCREEN_GADGETS 7
95 #define NUM_SCREEN_MENUBUTTONS 4
96 #define NUM_SCREEN_SCROLLBUTTONS 2
97 #define NUM_SCREEN_SCROLLBARS 1
99 #define SCREEN_MASK_MAIN (1 << 0)
100 #define SCREEN_MASK_INPUT (1 << 1)
102 /* graphic position and size values for buttons and scrollbars */
103 #define SC_MENUBUTTON_XSIZE TILEX
104 #define SC_MENUBUTTON_YSIZE TILEY
106 #define SC_SCROLLBUTTON_XSIZE TILEX
107 #define SC_SCROLLBUTTON_YSIZE TILEY
109 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
111 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
112 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
113 SC_SCROLLBUTTON_YSIZE)
115 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
116 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
118 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
119 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
120 SC_SCROLLBUTTON_YSIZE)
122 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
123 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
124 SC_SCROLL_VERTICAL_YSIZE)
126 #define SC_BORDER_SIZE 14
129 /* other useful macro definitions */
130 #define BUTTON_GRAPHIC_ACTIVE(g) \
131 (g == IMG_MENU_BUTTON_LEFT ? IMG_MENU_BUTTON_LEFT_ACTIVE : \
132 g == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE : \
133 g == IMG_MENU_BUTTON_UP ? IMG_MENU_BUTTON_UP_ACTIVE : \
134 g == IMG_MENU_BUTTON_DOWN ? IMG_MENU_BUTTON_DOWN_ACTIVE : \
135 g == IMG_MENU_BUTTON_LEAVE_MENU ? IMG_MENU_BUTTON_LEAVE_MENU_ACTIVE : \
136 g == IMG_MENU_BUTTON_ENTER_MENU ? IMG_MENU_BUTTON_ENTER_MENU_ACTIVE : \
137 g == IMG_MENU_BUTTON_PREV_LEVEL ? IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE : \
138 g == IMG_MENU_BUTTON_NEXT_LEVEL ? IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE : \
139 g == IMG_MENU_BUTTON_NAME ? IMG_MENU_BUTTON_NAME_ACTIVE : \
140 g == IMG_MENU_BUTTON_LEVELS ? IMG_MENU_BUTTON_LEVELS_ACTIVE : \
141 g == IMG_MENU_BUTTON_SCORES ? IMG_MENU_BUTTON_SCORES_ACTIVE : \
142 g == IMG_MENU_BUTTON_EDITOR ? IMG_MENU_BUTTON_EDITOR_ACTIVE : \
143 g == IMG_MENU_BUTTON_INFO ? IMG_MENU_BUTTON_INFO_ACTIVE : \
144 g == IMG_MENU_BUTTON_GAME ? IMG_MENU_BUTTON_GAME_ACTIVE : \
145 g == IMG_MENU_BUTTON_SETUP ? IMG_MENU_BUTTON_SETUP_ACTIVE : \
146 g == IMG_MENU_BUTTON_QUIT ? IMG_MENU_BUTTON_QUIT_ACTIVE : \
147 IMG_MENU_BUTTON_ACTIVE)
151 /* forward declarations of internal functions */
152 static void HandleScreenGadgets(struct GadgetInfo *);
153 static void HandleSetupScreen_Generic(int, int, int, int, int);
154 static void HandleSetupScreen_Input(int, int, int, int, int);
155 static void CustomizeKeyboard(int);
156 static void CalibrateJoystick(int);
157 static void execSetupGame(void);
158 static void execSetupGraphics(void);
159 static void execSetupArtwork(void);
160 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
162 static void DrawChooseLevel(void);
163 static void DrawInfoScreen(void);
164 static void DrawAndFadeInInfoScreen(int);
165 static void DrawSetupScreen(void);
167 static void DrawInfoScreenExt(int, int);
168 static void DrawInfoScreen_NotAvailable(char *, char *);
169 static void DrawInfoScreen_HelpAnim(int, int, boolean);
170 static void DrawInfoScreen_HelpText(int, int, int, int);
171 static void HandleInfoScreen_Main(int, int, int, int, int);
172 static void HandleInfoScreen_TitleScreen(int);
173 static void HandleInfoScreen_Elements(int);
174 static void HandleInfoScreen_Music(int);
175 static void HandleInfoScreen_Credits(int);
176 static void HandleInfoScreen_Program(int);
177 static void HandleInfoScreen_Version(int);
179 static void MapScreenMenuGadgets(int);
180 static void MapScreenTreeGadgets(TreeInfo *);
182 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
184 static int info_mode = INFO_MODE_MAIN;
185 static int setup_mode = SETUP_MODE_MAIN;
187 static TreeInfo *screen_modes = NULL;
188 static TreeInfo *screen_mode_current = NULL;
190 static TreeInfo *scroll_delays = NULL;
191 static TreeInfo *scroll_delay_current = NULL;
193 static TreeInfo *game_speeds = NULL;
194 static TreeInfo *game_speed_current = NULL;
200 } game_speeds_list[] =
209 { 1000, "1/1s (Extremely Slow)" },
214 { 29, "1/35s (Original Supaplex)" },
216 { 20, "1/50s (Normal Speed)" },
217 { 14, "1/70s (Maximum Supaplex)" },
221 { 1, "1/1000s (Extremely Fast)" },
231 } scroll_delays_list[] =
233 { 0, "0 Tiles (No Scroll Delay)" },
236 { 3, "3 Tiles (Default)" },
241 { 8, "8 Tiles (Maximum Scroll Delay)"},
246 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
247 (s) <= GAME_MODE_SETUP ? (s) : \
248 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
249 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
251 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
252 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
253 (i) <= INFO_MODE_LEVELSET ? (i) : \
256 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
257 (i) <= SETUP_MODE_SHORTCUTS_2 ? (i) : \
258 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
259 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
260 SETUP_MODE_CHOOSE_ARTWORK : \
261 SETUP_MODE_CHOOSE_OTHER)
263 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
264 menu.draw_xoffset[GAME_MODE_INFO] : \
265 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
266 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
267 menu.draw_yoffset[GAME_MODE_INFO] : \
268 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
270 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
271 menu.draw_xoffset[GAME_MODE_SETUP] : \
272 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
273 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
274 menu.draw_yoffset[GAME_MODE_SETUP] : \
275 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
277 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
278 DRAW_XOFFSET_INFO(info_mode) : \
279 (s) == GAME_MODE_SETUP ? \
280 DRAW_XOFFSET_SETUP(setup_mode) : \
281 menu.draw_xoffset[DRAW_MODE(s)])
282 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
283 DRAW_YOFFSET_INFO(info_mode) : \
284 (s) == GAME_MODE_SETUP ? \
285 DRAW_YOFFSET_SETUP(setup_mode) : \
286 menu.draw_yoffset[DRAW_MODE(s)])
288 #define mSX (SX + DRAW_XOFFSET(game_status))
289 #define mSY (SY + DRAW_YOFFSET(game_status))
291 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
292 menu.list_size[game_status] : \
293 MAX_MENU_ENTRIES_ON_SCREEN)
295 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
296 #define NUM_SCROLLBAR_BITMAPS 2
297 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS];
301 /* title display and control definitions */
303 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
304 2 * MAX_NUM_TITLE_MESSAGES)
306 static int num_title_screens = 0;
308 struct TitleControlInfo
316 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
318 /* main menu display and control definitions */
320 #define MAIN_CONTROL_NAME 0
321 #define MAIN_CONTROL_LEVELS 1
322 #define MAIN_CONTROL_SCORES 2
323 #define MAIN_CONTROL_EDITOR 3
324 #define MAIN_CONTROL_INFO 4
325 #define MAIN_CONTROL_GAME 5
326 #define MAIN_CONTROL_SETUP 6
327 #define MAIN_CONTROL_QUIT 7
328 #define MAIN_CONTROL_PREV_LEVEL 8
329 #define MAIN_CONTROL_NEXT_LEVEL 9
330 #define MAIN_CONTROL_FIRST_LEVEL 10
331 #define MAIN_CONTROL_LAST_LEVEL 11
332 #define MAIN_CONTROL_LEVEL_NUMBER 12
333 #define MAIN_CONTROL_LEVEL_INFO_1 13
334 #define MAIN_CONTROL_LEVEL_INFO_2 14
335 #define MAIN_CONTROL_LEVEL_NAME 15
336 #define MAIN_CONTROL_LEVEL_AUTHOR 16
337 #define MAIN_CONTROL_LEVEL_YEAR 17
338 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
339 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
340 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
341 #define MAIN_CONTROL_TITLE_1 21
342 #define MAIN_CONTROL_TITLE_2 22
343 #define MAIN_CONTROL_TITLE_3 23
345 static char str_main_text_name[10];
346 static char str_main_text_first_level[10];
347 static char str_main_text_last_level[10];
348 static char str_main_text_level_number[10];
350 static char *main_text_name = str_main_text_name;
351 static char *main_text_first_level = str_main_text_first_level;
352 static char *main_text_last_level = str_main_text_last_level;
353 static char *main_text_level_number = str_main_text_level_number;
354 static char *main_text_levels = "Levelset";
355 static char *main_text_scores = "Hall Of Fame";
356 static char *main_text_editor = "Level Creator";
357 static char *main_text_info = "Info Screen";
358 static char *main_text_game = "Start Game";
359 static char *main_text_setup = "Setup";
360 static char *main_text_quit = "Quit";
361 static char *main_text_level_name = level.name;
362 static char *main_text_level_author = level.author;
363 static char *main_text_level_year = NULL;
364 static char *main_text_level_imported_from = NULL;
365 static char *main_text_level_imported_by = NULL;
366 static char *main_text_level_tested_by = NULL;
367 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
368 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
369 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
371 struct MainControlInfo
375 struct MenuPosInfo *pos_button;
378 struct TextPosInfo *pos_text;
381 struct TextPosInfo *pos_input;
385 static struct MainControlInfo main_controls[] =
389 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
390 &menu.main.text.name, &main_text_name,
391 &menu.main.input.name, &setup.player_name,
395 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
396 &menu.main.text.levels, &main_text_levels,
401 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
402 &menu.main.text.scores, &main_text_scores,
407 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
408 &menu.main.text.editor, &main_text_editor,
413 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
414 &menu.main.text.info, &main_text_info,
419 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
420 &menu.main.text.game, &main_text_game,
425 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
426 &menu.main.text.setup, &main_text_setup,
431 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
432 &menu.main.text.quit, &main_text_quit,
436 /* (these two buttons are real gadgets) */
438 MAIN_CONTROL_PREV_LEVEL,
439 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
444 MAIN_CONTROL_NEXT_LEVEL,
445 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
451 MAIN_CONTROL_FIRST_LEVEL,
453 &menu.main.text.first_level, &main_text_first_level,
457 MAIN_CONTROL_LAST_LEVEL,
459 &menu.main.text.last_level, &main_text_last_level,
463 MAIN_CONTROL_LEVEL_NUMBER,
465 &menu.main.text.level_number, &main_text_level_number,
469 MAIN_CONTROL_LEVEL_INFO_1,
471 &menu.main.text.level_info_1, NULL,
475 MAIN_CONTROL_LEVEL_INFO_2,
477 &menu.main.text.level_info_2, NULL,
481 MAIN_CONTROL_LEVEL_NAME,
483 &menu.main.text.level_name, &main_text_level_name,
487 MAIN_CONTROL_LEVEL_AUTHOR,
489 &menu.main.text.level_author, &main_text_level_author,
493 MAIN_CONTROL_LEVEL_YEAR,
495 &menu.main.text.level_year, &main_text_level_year,
499 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
501 &menu.main.text.level_imported_from, &main_text_level_imported_from,
505 MAIN_CONTROL_LEVEL_IMPORTED_BY,
507 &menu.main.text.level_imported_by, &main_text_level_imported_by,
511 MAIN_CONTROL_LEVEL_TESTED_BY,
513 &menu.main.text.level_tested_by, &main_text_level_tested_by,
517 MAIN_CONTROL_TITLE_1,
519 &menu.main.text.title_1, &main_text_title_1,
523 MAIN_CONTROL_TITLE_2,
525 &menu.main.text.title_2, &main_text_title_2,
529 MAIN_CONTROL_TITLE_3,
531 &menu.main.text.title_3, &main_text_title_3,
544 static int getTitleScreenGraphic(int nr, boolean initial)
546 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
549 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
551 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
555 static int getTitleScreenGameMode(boolean initial)
557 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
561 static int getTitleMessageGameMode(boolean initial)
563 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
567 static int getTitleScreenBackground(boolean initial)
569 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
574 static int getTitleMessageBackground(int nr, boolean initial)
576 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
580 static int getTitleBackground(int nr, boolean initial, boolean is_image)
582 int base = (is_image ?
583 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
584 IMG_BACKGROUND_TITLESCREEN_1) :
585 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
586 IMG_BACKGROUND_TITLEMESSAGE_1));
587 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
588 IMG_BACKGROUND_TITLE);
589 int graphic_local = base + nr;
591 if (graphic_info[graphic_local].bitmap != NULL)
592 return graphic_local;
594 if (graphic_info[graphic_global].bitmap != NULL)
595 return graphic_global;
597 return IMG_UNDEFINED;
600 static int getTitleSound(struct TitleControlInfo *tci)
602 boolean is_image = tci->is_image;
603 int initial = tci->initial;
604 int nr = tci->local_nr;
605 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
606 int base = (is_image ?
607 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
608 SND_BACKGROUND_TITLESCREEN_1) :
609 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
610 SND_BACKGROUND_TITLEMESSAGE_1));
611 int sound_global = menu.sound[mode];
612 int sound_local = base + nr;
615 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
616 nr, initial, is_image,
617 sound_global, getSoundListEntry(sound_global)->filename,
618 sound_local, getSoundListEntry(sound_local)->filename);
621 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
624 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
627 return SND_UNDEFINED;
630 static int getTitleMusic(struct TitleControlInfo *tci)
632 boolean is_image = tci->is_image;
633 int initial = tci->initial;
634 int nr = tci->local_nr;
635 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
636 int base = (is_image ?
637 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
638 MUS_BACKGROUND_TITLESCREEN_1) :
639 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
640 MUS_BACKGROUND_TITLEMESSAGE_1));
641 int music_global = menu.music[mode];
642 int music_local = base + nr;
645 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
646 nr, initial, is_image,
647 music_global, getMusicListEntry(music_global)->filename,
648 music_local, getMusicListEntry(music_local)->filename);
651 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
654 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
657 return MUS_UNDEFINED;
660 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
662 boolean is_image = tci->is_image;
663 int initial = tci->initial;
664 int nr = tci->local_nr;
665 struct TitleFadingInfo ti;
669 int graphic = getTitleScreenGraphic(nr, initial);
671 /* initialize fading control values to default title config settings */
672 ti = (initial ? title_initial_default : title_default);
674 /* override default settings with image config settings, if defined */
675 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
676 ti.fade_mode = graphic_info[graphic].fade_mode;
677 if (graphic_info[graphic].fade_delay > -1)
678 ti.fade_delay = graphic_info[graphic].fade_delay;
679 if (graphic_info[graphic].post_delay > -1)
680 ti.post_delay = graphic_info[graphic].post_delay;
681 if (graphic_info[graphic].auto_delay > -1)
682 ti.auto_delay = graphic_info[graphic].auto_delay;
688 ti.fade_mode = titlemessage_initial[nr].fade_mode;
689 ti.fade_delay = titlemessage_initial[nr].fade_delay;
690 ti.post_delay = titlemessage_initial[nr].post_delay;
691 ti.auto_delay = titlemessage_initial[nr].auto_delay;
695 ti.fade_mode = titlemessage[nr].fade_mode;
696 ti.fade_delay = titlemessage[nr].fade_delay;
697 ti.post_delay = titlemessage[nr].post_delay;
698 ti.auto_delay = titlemessage[nr].auto_delay;
703 if (ti.anim_mode == ANIM_NONE)
704 ti.fade_delay = ti.post_delay = 0;
710 static int compareTitleControlInfo(const void *object1, const void *object2)
712 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
713 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
716 if (tci1->initial != tci2->initial)
717 compare_result = (tci1->initial ? -1 : +1);
718 else if (tci1->sort_priority != tci2->sort_priority)
719 compare_result = tci1->sort_priority - tci2->sort_priority;
720 else if (tci1->is_image != tci2->is_image)
721 compare_result = (tci1->is_image ? -1 : +1);
723 compare_result = tci1->local_nr - tci2->local_nr;
725 return compare_result;
728 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
730 int nr, int sort_priority)
732 title_controls[num_title_screens].is_image = is_image;
733 title_controls[num_title_screens].initial = initial;
734 title_controls[num_title_screens].local_nr = nr;
735 title_controls[num_title_screens].sort_priority = sort_priority;
740 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
744 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
746 int graphic = getTitleScreenGraphic(i, initial);
747 Bitmap *bitmap = graphic_info[graphic].bitmap;
748 int sort_priority = graphic_info[graphic].sort_priority;
751 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
754 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
756 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
757 char *filename = getLevelSetTitleMessageFilename(i, initial);
758 int sort_priority = tmi->sort_priority;
760 if (filename != NULL)
761 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
765 static void InitializeTitleControls(boolean show_title_initial)
767 num_title_screens = 0;
769 if (show_title_initial)
770 InitializeTitleControls_CheckTitleInfo(TRUE);
772 InitializeTitleControls_CheckTitleInfo(FALSE);
774 /* sort title screens according to sort_priority and title number */
775 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
776 compareTitleControlInfo);
779 static boolean visibleMenuPos(struct MenuPosInfo *pos)
781 return (pos != NULL && pos->x != -1 && pos->y != -1);
784 static boolean visibleTextPos(struct TextPosInfo *pos)
786 return (pos != NULL && pos->x != -1 && pos->y != -1);
789 static void InitializeMainControls()
791 boolean local_team_mode = (!options.network && setup.team_mode);
794 /* set main control text values to dynamically determined values */
795 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
797 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
798 menu.main.text.first_level.size));
799 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
800 menu.main.text.last_level.size));
801 strcpy(main_text_level_number, int2str(level_nr,
802 menu.main.text.level_number.size));
804 main_text_level_year = leveldir_current->year;
805 main_text_level_imported_from = leveldir_current->imported_from;
806 main_text_level_imported_by = leveldir_current->imported_by;
807 main_text_level_tested_by = leveldir_current->tested_by;
809 /* set main control screen positions to dynamically determined values */
810 for (i = 0; main_controls[i].nr != -1; i++)
812 struct MainControlInfo *mci = &main_controls[i];
814 struct MenuPosInfo *pos_button = mci->pos_button;
815 struct TextPosInfo *pos_text = mci->pos_text;
816 struct TextPosInfo *pos_input = mci->pos_input;
817 char *text = (mci->text ? *mci->text : NULL);
818 char *input = (mci->input ? *mci->input : NULL);
819 int button_graphic = mci->button_graphic;
821 int font_text = (pos_text ? pos_text->font : -1);
822 int font_input = (pos_input ? pos_input->font : -1);
824 int font_text = mci->font_text;
825 int font_input = mci->font_input;
828 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
829 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
830 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
831 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
832 int text_chars = (text != NULL ? strlen(text) : 0);
833 int input_chars = (input != NULL ? strlen(input) : 0);
836 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
838 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
839 int text_width = font_text_width * text_chars;
840 int text_height = font_text_height;
841 int input_width = font_input_width * input_chars;
842 int input_height = font_input_height;
844 if (nr == MAIN_CONTROL_NAME)
847 if (menu.main.input.name.x == -1)
848 menu.main.input.name.x = menu.main.text.name.x + text_width;
849 if (menu.main.input.name.y == -1)
850 menu.main.input.name.y = menu.main.text.name.y;
854 menu.main.input.name.width = input_width;
855 menu.main.input.name.height = input_height;
857 menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
858 menu.main.input.name.height = font_input_height;
862 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
864 if (pos_button->width == 0)
865 pos_button->width = button_width;
866 if (pos_button->height == 0)
867 pos_button->height = button_height;
870 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
872 /* calculate width for non-clickable text -- needed for text alignment */
873 boolean calculate_text_width = (pos_button == NULL && text != NULL);
875 if (visibleMenuPos(pos_button))
877 if (pos_text->x == -1)
878 pos_text->x = pos_button->x + pos_button->width;
879 if (pos_text->y == -1)
880 pos_text->y = pos_button->y;
883 if (pos_text->width == -1 || calculate_text_width)
884 pos_text->width = text_width;
885 if (pos_text->height == -1)
886 pos_text->height = text_height;
889 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
891 if (visibleTextPos(pos_text))
893 if (pos_input->x == -1)
894 pos_input->x = pos_text->x + pos_text->width;
895 if (pos_input->y == -1)
896 pos_input->y = pos_text->y;
899 if (pos_input->width == -1)
900 pos_input->width = input_width;
901 if (pos_input->height == -1)
902 pos_input->height = input_height;
907 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
908 boolean active_input)
912 for (i = 0; main_controls[i].nr != -1; i++)
914 struct MainControlInfo *mci = &main_controls[i];
916 if (mci->nr == nr || nr == -1)
918 struct MenuPosInfo *pos_button = mci->pos_button;
919 struct TextPosInfo *pos_text = mci->pos_text;
920 struct TextPosInfo *pos_input = mci->pos_input;
921 char *text = (mci->text ? *mci->text : NULL);
922 char *input = (mci->input ? *mci->input : NULL);
923 int button_graphic = mci->button_graphic;
925 int font_text = (pos_text ? pos_text->font : -1);
926 int font_input = (pos_input ? pos_input->font : -1);
928 int font_text = mci->font_text;
929 int font_input = mci->font_input;
934 button_graphic = BUTTON_ACTIVE(button_graphic);
935 font_text = FONT_ACTIVE(font_text);
940 font_input = FONT_ACTIVE(font_input);
943 if (visibleMenuPos(pos_button))
945 struct MenuPosInfo *pos = pos_button;
946 int x = mSX + pos->x;
947 int y = mSY + pos->y;
949 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
950 DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
953 if (visibleTextPos(pos_text) && text != NULL)
955 struct TextPosInfo *pos = pos_text;
956 int x = mSX + ALIGNED_TEXT_XPOS(pos);
957 int y = mSY + ALIGNED_TEXT_YPOS(pos);
960 /* (check why/if this is needed) */
961 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
963 DrawText(x, y, text, font_text);
966 if (visibleTextPos(pos_input) && input != NULL)
968 struct TextPosInfo *pos = pos_input;
969 int x = mSX + ALIGNED_TEXT_XPOS(pos);
970 int y = mSY + ALIGNED_TEXT_YPOS(pos);
973 /* (check why/if this is needed) */
974 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
976 DrawText(x, y, input, font_input);
982 static void DrawCursorAndText_Main(int nr, boolean active_text)
984 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
988 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
990 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
994 static struct MainControlInfo *getMainControlInfo(int nr)
998 for (i = 0; main_controls[i].nr != -1; i++)
999 if (main_controls[i].nr == nr)
1000 return &main_controls[i];
1005 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1010 int rect_x = ALIGNED_TEXT_XPOS(rect);
1011 int rect_y = ALIGNED_TEXT_YPOS(rect);
1013 return (x >= rect_x && x < rect_x + rect->width &&
1014 y >= rect_y && y < rect_y + rect->height);
1017 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1022 int rect_x = ALIGNED_TEXT_XPOS(rect);
1023 int rect_y = ALIGNED_TEXT_YPOS(rect);
1025 return (x >= rect_x && x < rect_x + rect->width &&
1026 y >= rect_y && y < rect_y + rect->height);
1029 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1031 static int cursor_array[SCR_FIELDY];
1032 int x = mSX + TILEX * xpos;
1033 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1038 cursor_array[ypos] = graphic;
1040 graphic = cursor_array[ypos];
1044 graphic = BUTTON_ACTIVE(graphic);
1046 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1047 DrawGraphicThruMaskExt(drawto, x, y, graphic, 0);
1050 static void initCursor(int ypos, int graphic)
1052 drawCursorExt(0, ypos, FALSE, graphic);
1055 static void drawCursor(int ypos, boolean active)
1057 drawCursorExt(0, ypos, active, -1);
1060 static void drawCursorXY(int xpos, int ypos, int graphic)
1062 drawCursorExt(xpos, ypos, FALSE, graphic);
1065 static void drawChooseTreeCursor(int ypos, boolean active)
1067 int last_game_status = game_status; /* save current game status */
1070 /* force LEVELS draw offset on artwork setup screen */
1071 game_status = GAME_MODE_LEVELS;
1074 drawCursorExt(0, ypos, active, -1);
1076 game_status = last_game_status; /* restore current game status */
1081 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1082 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1086 static int getPrevlevelButtonPos()
1091 static int getCurrentLevelTextPos()
1093 return (getPrevlevelButtonPos() + 1);
1096 static int getNextLevelButtonPos()
1098 return getPrevlevelButtonPos() + 3 + 1;
1101 static int getLevelRangeTextPos()
1103 return getNextLevelButtonPos() + 1;
1107 int effectiveGameStatus()
1109 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1110 return GAME_MODE_TITLE;
1115 void DrawTitleScreenImage(int nr, boolean initial)
1117 int graphic = getTitleScreenGraphic(nr, initial);
1118 Bitmap *bitmap = graphic_info[graphic].bitmap;
1120 int width = graphic_info[graphic].width;
1121 int height = graphic_info[graphic].height;
1122 int src_x = graphic_info[graphic].src_x;
1123 int src_y = graphic_info[graphic].src_y;
1125 int width = graphic_info[graphic].src_image_width;
1126 int height = graphic_info[graphic].src_image_height;
1127 int src_x = 0, src_y = 0;
1134 if (width > WIN_XSIZE)
1136 /* image width too large for window => center image horizontally */
1137 src_x = (width - WIN_XSIZE) / 2;
1141 if (height > WIN_YSIZE)
1143 /* image height too large for window => center image vertically */
1144 src_y = (height - WIN_YSIZE) / 2;
1148 /* always display title screens centered */
1149 dst_x = (WIN_XSIZE - width) / 2;
1150 dst_y = (WIN_YSIZE - height) / 2;
1152 SetDrawBackgroundMask(REDRAW_ALL);
1153 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1155 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1157 if (DrawingOnBackground(dst_x, dst_y))
1158 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1160 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1162 redraw_mask = REDRAW_ALL;
1164 /* reset fading control values to default config settings */
1168 title = getTitleFading(nr, initial, TRUE);
1173 title.fade_delay_final = title.fade_delay;
1174 title.post_delay_final = title.post_delay;
1175 title.auto_delay_final = title.auto_delay;
1177 /* override default settings with image config settings, if defined */
1178 if (graphic_info[graphic].anim_mode != ANIM_DEFAULT)
1179 title.anim_mode = graphic_info[graphic].anim_mode;
1180 if (graphic_info[graphic].fade_delay > -1)
1181 title.fade_delay = graphic_info[graphic].fade_delay;
1182 if (graphic_info[graphic].post_delay > -1)
1183 title.post_delay = graphic_info[graphic].post_delay;
1184 if (graphic_info[graphic].auto_delay > -1)
1185 title.auto_delay = graphic_info[graphic].auto_delay;
1189 void DrawTitleScreenMessage(int nr, boolean initial)
1191 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1192 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1194 int font_nr = FONT_TEXT_1;
1198 int pad_y = 32 + 14;
1201 int max_chars_per_line;
1202 int max_lines_per_screen;
1204 int last_game_status = game_status; /* save current game status */
1206 if (filename == NULL)
1209 /* force TITLE font on title message screen */
1210 game_status = getTitleMessageGameMode(initial);
1212 /* if chars set to "-1", automatically determine by text and font width */
1213 if (tmi->chars == -1)
1214 tmi->chars = tmi->width / getFontWidth(tmi->font);
1216 tmi->width = tmi->chars * getFontWidth(tmi->font);
1218 /* if lines set to "-1", automatically determine by text and font height */
1219 if (tmi->lines == -1)
1220 tmi->lines = tmi->height / getFontHeight(tmi->font);
1222 tmi->height = tmi->lines * getFontHeight(tmi->font);
1224 SetDrawBackgroundMask(REDRAW_ALL);
1225 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1227 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1230 font_width = getFontWidth(font_nr);
1231 font_height = getFontHeight(font_nr);
1232 max_chars_per_line = (WIN_XSIZE - 2 * pad_x) / font_width;
1233 max_lines_per_screen = (WIN_YSIZE - pad_y) / font_height - 1;
1237 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1238 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
1239 tmi->autowrap, tmi->centered, tmi->parse_comments);
1241 DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
1242 max_lines_per_screen, -1, tmi->autowrap, tmi->centered,
1243 tmi->parse_comments);
1246 game_status = last_game_status; /* restore current game status */
1249 void DrawTitleScreen()
1251 KeyboardAutoRepeatOff();
1254 SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
1257 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1262 boolean CheckTitleScreen(boolean levelset_has_changed)
1264 static boolean show_title_initial = TRUE;
1265 boolean show_titlescreen = FALSE;
1267 /* needed to be able to skip title screen, if no image or message defined */
1268 InitializeTitleControls(show_title_initial);
1270 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1271 show_titlescreen = TRUE;
1273 /* show initial title images and messages only once at program start */
1274 show_title_initial = FALSE;
1276 return (show_titlescreen && num_title_screens > 0);
1279 void DrawMainMenuExt(int redraw_mask, boolean do_fading)
1281 static LevelDirTree *leveldir_last_valid = NULL;
1282 boolean levelset_has_changed = FALSE;
1284 FadeSetLeaveScreen();
1286 /* (does not work well when changing to editor, which fades out itself) */
1288 FadeOut(redraw_mask);
1292 FadeSoundsAndMusic();
1294 KeyboardAutoRepeatOn();
1297 SetDrawDeactivationMask(REDRAW_NONE);
1298 SetDrawBackgroundMask(REDRAW_FIELD);
1300 audio.sound_deactivated = FALSE;
1304 /* needed if last screen was the playing screen, invoked from level editor */
1305 if (level_editor_test_game)
1307 game_status = GAME_MODE_EDITOR;
1314 FadeOut(redraw_mask);
1316 /* needed if last screen was the editor screen */
1317 UndrawSpecialEditorDoor();
1320 /* needed if last screen was the setup screen and fullscreen state changed */
1321 ToggleFullscreenIfNeeded();
1323 /* leveldir_current may be invalid (level group, parent link) */
1324 if (!validLevelSeries(leveldir_current))
1325 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1327 if (leveldir_current != leveldir_last_valid)
1328 levelset_has_changed = TRUE;
1330 /* store valid level series information */
1331 leveldir_last_valid = leveldir_current;
1333 /* needed if last screen (level choice) changed graphics, sounds or music */
1334 ReloadCustomArtwork(0);
1337 printf("::: FadeOut @ DrawMainMenuExt ...\n");
1338 FadeOut(redraw_mask);
1339 printf("::: FadeOut @ DrawMainMenuExt done\n");
1341 /* needed if last screen was the editor screen */
1342 UndrawSpecialEditorDoor();
1345 #if defined(TARGET_SDL)
1346 SetDrawtoField(DRAW_BACKBUFFER);
1349 if (CheckTitleScreen(levelset_has_changed))
1351 game_status = GAME_MODE_TITLE;
1358 /* level_nr may have been set to value over handicap with level editor */
1359 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1360 level_nr = leveldir_current->handicap_level;
1362 LoadLevel(level_nr);
1364 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1367 FadeOut(redraw_mask);
1371 if (redraw_mask == REDRAW_ALL)
1373 // int door_state = GetDoorState();
1377 // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1383 InitializeMainControls();
1385 DrawCursorAndText_Main(-1, FALSE);
1386 DrawPreviewLevel(TRUE);
1388 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1391 if (TAPE_IS_EMPTY(tape))
1393 DrawCompleteVideoDisplay();
1398 /* create gadgets for main menu screen */
1399 FreeScreenGadgets();
1400 CreateScreenGadgets();
1402 /* map gadgets for main menu screen */
1404 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1407 DrawMaskedBorder(REDRAW_ALL);
1411 if (redraw_mask == REDRAW_ALL)
1413 int door_state = GetDoorState();
1415 // RedrawBackground();
1417 OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1421 FadeIn(redraw_mask);
1425 SetMouseCursor(CURSOR_DEFAULT);
1429 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1432 void DrawAndFadeInMainMenu(int redraw_mask)
1434 DrawMainMenuExt(redraw_mask, TRUE);
1439 DrawMainMenuExt(REDRAW_ALL, FALSE);
1443 static void gotoTopLevelDir()
1445 /* move upwards to top level directory */
1446 while (leveldir_current->node_parent)
1448 /* write a "path" into level tree for easy navigation to last level */
1449 if (leveldir_current->node_parent->node_group->cl_first == -1)
1451 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1452 int leveldir_pos = posTreeInfo(leveldir_current);
1453 int num_page_entries;
1454 int cl_first, cl_cursor;
1456 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1457 num_page_entries = num_leveldirs;
1459 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1461 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1462 cl_cursor = leveldir_pos - cl_first;
1464 leveldir_current->node_parent->node_group->cl_first = cl_first;
1465 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1468 leveldir_current = leveldir_current->node_parent;
1473 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1475 static unsigned long title_delay = 0;
1476 static int title_screen_nr = 0;
1477 static int last_sound = -1, last_music = -1;
1478 boolean return_to_main_menu = FALSE;
1479 boolean use_fading_main_menu = TRUE;
1482 boolean use_cross_fading = FALSE;
1484 boolean use_cross_fading = !show_title_initial; /* default */
1487 struct TitleControlInfo *tci;
1488 struct TitleFadingInfo fading_default;
1489 struct TitleFadingInfo fading_last = fading;
1490 struct TitleFadingInfo fading_next;
1493 if (button == MB_MENU_INITIALIZE)
1496 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1500 int last_game_status = game_status; /* save current game status */
1504 title_screen_nr = 0;
1505 tci = &title_controls[title_screen_nr];
1507 last_sound = SND_UNDEFINED;
1508 last_music = MUS_UNDEFINED;
1511 /* determine number of title screens to display (images and messages) */
1512 InitializeTitleControls();
1515 if (game_status == GAME_MODE_INFO)
1517 if (num_title_screens == 0)
1519 DrawInfoScreen_NotAvailable("Title screen information:",
1520 "No title screen for this level set.");
1523 /* use default settings for fading, but always disable auto delay */
1524 fading = title_default;
1525 fading.auto_delay = -1;
1531 FadeSoundsAndMusic();
1534 FadeOut(REDRAW_ALL);
1539 DrawTitleScreenImage(tci->local_nr, tci->initial);
1541 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1543 fading_default = (tci->initial ? title_initial_default : title_default);
1545 fading = fading_next = getTitleFading(tci);
1549 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1550 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1552 fading.fade_mode = FADE_MODE_FADE;
1553 fading.fade_delay = fading_default.fade_delay;
1556 if (fading_last.fade_mode != FADE_MODE_CROSSFADE &&
1557 fading_next.fade_mode == FADE_MODE_CROSSFADE)
1558 fading.fade_mode = FADE_MODE_FADE;
1563 sound = getTitleSound(tci);
1564 music = getTitleMusic(tci);
1566 if (sound != last_sound)
1567 PlayMenuSoundExt(sound);
1568 if (music != last_music)
1569 PlayMenuMusicExt(music);
1575 SetMouseCursor(CURSOR_NONE);
1577 // printf("::: mode: %d, delay: %d\n", fading.fade_mode, fading.fade_delay);
1583 fading = fading_next;
1585 DelayReached(&title_delay, 0); /* reset delay counter */
1591 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1592 button = MB_MENU_CHOICE;
1594 if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
1595 button = MB_MENU_CHOICE;
1598 if (button == MB_MENU_LEAVE)
1600 return_to_main_menu = TRUE;
1601 use_fading_main_menu = FALSE;
1603 else if (button == MB_MENU_CHOICE)
1606 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1609 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1612 FadeOut(REDRAW_FIELD);
1615 FadeSetEnterScreen();
1617 info_mode = INFO_MODE_MAIN;
1618 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1624 tci = &title_controls[title_screen_nr];
1626 if (title_screen_nr < num_title_screens)
1630 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1637 graphic_info[getTitleScreenGraphic(tci->local_nr,
1638 tci->initial)].anim_mode;
1640 anim_mode = ANIM_FADE; /* ??? */
1642 use_cross_fading = (anim_mode == ANIM_FADE ? FALSE :
1643 anim_mode == ANIM_CROSSFADE ? TRUE :
1647 sound = getTitleSound(tci);
1648 music = getTitleMusic(tci);
1650 if (sound == SND_UNDEFINED || sound != last_sound)
1652 if (music == MUS_UNDEFINED || music != last_music)
1656 FadeOut(REDRAW_ALL);
1660 DrawTitleScreenImage(tci->local_nr, tci->initial);
1662 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1664 fading_next = getTitleFading(tci);
1667 sound = getTitleSound(tci);
1668 music = getTitleMusic(tci);
1670 if (sound != last_sound)
1671 PlayMenuSoundExt(sound);
1672 if (music != last_music)
1673 PlayMenuMusicExt(music);
1680 printf("::: %d -> %d\n", fading.fade_mode, fading_next.fade_mode);
1684 /* last screen already faded out, next screen has no animation */
1685 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1686 fading_next.fade_mode == FADE_MODE_NONE)
1687 fading = fading_next;
1689 /* last screen already faded out, next screen has no animation */
1690 if (fading.fade_mode != FADE_MODE_CROSSFADE &&
1691 fading_next.fade_mode == FADE_MODE_NONE)
1692 fading = fading_next;
1699 fading = fading_next;
1701 DelayReached(&title_delay, 0); /* reset delay counter */
1705 FadeSoundsAndMusic();
1711 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1715 FadeOut(REDRAW_ALL);
1719 FadeOut(REDRAW_ALL);
1723 return_to_main_menu = TRUE;
1727 if (return_to_main_menu)
1733 SetMouseCursor(CURSOR_DEFAULT);
1735 if (game_status == GAME_MODE_INFO)
1738 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1741 info_mode = INFO_MODE_MAIN;
1742 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1744 else /* default: return to main menu */
1747 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1750 game_status = GAME_MODE_MAIN;
1751 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1756 void HandleMainMenu_SelectLevel(int step, int direction)
1758 int old_level_nr = level_nr;
1761 new_level_nr = old_level_nr + step * direction;
1762 if (new_level_nr < leveldir_current->first_level)
1763 new_level_nr = leveldir_current->first_level;
1764 if (new_level_nr > leveldir_current->last_level)
1765 new_level_nr = leveldir_current->last_level;
1767 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1769 /* skipping levels is only allowed when trying to skip single level */
1770 if (setup.skip_levels && step == 1 &&
1771 Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK))
1773 leveldir_current->handicap_level++;
1774 SaveLevelSetup_SeriesInfo();
1777 new_level_nr = leveldir_current->handicap_level;
1780 if (new_level_nr != old_level_nr)
1782 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1784 PlaySound(SND_MENU_ITEM_SELECTING);
1786 level_nr = new_level_nr;
1789 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1790 int2str(level_nr, menu.main.text.level_number.size),
1791 mci->pos_text->font);
1793 DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
1796 LoadLevel(level_nr);
1797 DrawPreviewLevel(TRUE);
1801 DrawCompleteVideoDisplay();
1803 /* needed because DrawPreviewLevel() takes some time */
1811 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1813 static int choice = MAIN_CONTROL_GAME;
1817 if (button == MB_MENU_INITIALIZE)
1819 DrawCursorAndText_Main(choice, TRUE);
1824 if (mx || my) /* mouse input */
1828 for (i = 0; main_controls[i].nr != -1; i++)
1830 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1831 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1832 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1834 pos = main_controls[i].nr;
1840 else if (dx || dy) /* keyboard input */
1842 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1843 choice == MAIN_CONTROL_SETUP))
1844 button = MB_MENU_CHOICE;
1849 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1851 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1853 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1859 PlaySound(SND_MENU_ITEM_ACTIVATING);
1861 DrawCursorAndText_Main(choice, FALSE);
1862 DrawCursorAndText_Main(pos, TRUE);
1869 PlaySound(SND_MENU_ITEM_SELECTING);
1871 if (pos == MAIN_CONTROL_NAME)
1873 game_status = GAME_MODE_PSEUDO_TYPENAME;
1875 HandleTypeName(strlen(setup.player_name), 0);
1877 else if (pos == MAIN_CONTROL_LEVELS)
1881 game_status = GAME_MODE_LEVELS;
1883 SaveLevelSetup_LastSeries();
1884 SaveLevelSetup_SeriesInfo();
1893 else if (pos == MAIN_CONTROL_SCORES)
1895 game_status = GAME_MODE_SCORES;
1899 else if (pos == MAIN_CONTROL_EDITOR)
1901 if (leveldir_current->readonly &&
1902 !strEqual(setup.player_name, "Artsoft"))
1903 Request("This level is read only !", REQ_CONFIRM);
1905 game_status = GAME_MODE_EDITOR;
1907 FadeSetEnterScreen();
1911 else if (pos == MAIN_CONTROL_INFO)
1913 game_status = GAME_MODE_INFO;
1914 info_mode = INFO_MODE_MAIN;
1917 fading = menu.navigation;
1922 else if (pos == MAIN_CONTROL_GAME)
1924 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
1926 else if (pos == MAIN_CONTROL_SETUP)
1928 game_status = GAME_MODE_SETUP;
1929 setup_mode = SETUP_MODE_MAIN;
1933 else if (pos == MAIN_CONTROL_QUIT)
1935 SaveLevelSetup_LastSeries();
1936 SaveLevelSetup_SeriesInfo();
1938 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
1939 game_status = GAME_MODE_QUIT;
1944 if (game_status == GAME_MODE_MAIN)
1946 DrawPreviewLevel(FALSE);
1953 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1955 static int choice = 5;
1959 if (button == MB_MENU_INITIALIZE)
1961 drawCursor(choice, TRUE);
1966 if (mx || my) /* mouse input */
1968 x = (mx - mSX) / 32;
1969 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
1971 else if (dx || dy) /* keyboard input */
1973 if (dx && choice == 1)
1974 x = (dx < 0 ? 10 : 14);
1977 if (choice == 4 || choice == 6)
1978 button = MB_MENU_CHOICE;
1984 if (y == 1 && dx != 0 && button)
1986 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1988 else if (IN_VIS_FIELD(x, y) &&
1989 y >= 0 && y <= 7 && (y != 1 || x < 10))
1995 drawCursor(choice, FALSE);
1996 drawCursor(y, TRUE);
2005 game_status = GAME_MODE_PSEUDO_TYPENAME;
2006 HandleTypeName(strlen(setup.player_name), 0);
2012 game_status = GAME_MODE_LEVELS;
2014 SaveLevelSetup_LastSeries();
2015 SaveLevelSetup_SeriesInfo();
2026 game_status = GAME_MODE_SCORES;
2031 if (leveldir_current->readonly &&
2032 !strEqual(setup.player_name, "Artsoft"))
2033 Request("This level is read only !", REQ_CONFIRM);
2034 game_status = GAME_MODE_EDITOR;
2039 game_status = GAME_MODE_INFO;
2040 info_mode = INFO_MODE_MAIN;
2045 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
2049 game_status = GAME_MODE_SETUP;
2050 setup_mode = SETUP_MODE_MAIN;
2056 SaveLevelSetup_LastSeries();
2057 SaveLevelSetup_SeriesInfo();
2059 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
2060 game_status = GAME_MODE_QUIT;
2065 if (game_status == GAME_MODE_MAIN)
2067 DrawPreviewLevel(FALSE);
2075 /* ========================================================================= */
2076 /* info screen functions */
2077 /* ========================================================================= */
2079 static struct TokenInfo *info_info;
2080 static int num_info_info;
2082 static void execInfoTitleScreen()
2085 FadeSetEnterScreen();
2088 info_mode = INFO_MODE_TITLE;
2092 static void execInfoElements()
2095 FadeSetEnterScreen();
2098 info_mode = INFO_MODE_ELEMENTS;
2102 static void execInfoMusic()
2105 FadeSetEnterScreen();
2108 info_mode = INFO_MODE_MUSIC;
2112 static void execInfoCredits()
2115 FadeSetEnterScreen();
2118 info_mode = INFO_MODE_CREDITS;
2122 static void execInfoProgram()
2125 FadeSetEnterScreen();
2128 info_mode = INFO_MODE_PROGRAM;
2132 static void execInfoVersion()
2135 FadeSetEnterScreen();
2138 info_mode = INFO_MODE_VERSION;
2142 static void execInfoLevelSet()
2145 FadeSetEnterScreen();
2148 info_mode = INFO_MODE_LEVELSET;
2152 static void execExitInfo()
2158 game_status = GAME_MODE_MAIN;
2160 DrawMainMenuExt(REDRAW_FIELD, FALSE);
2166 static struct TokenInfo info_info_main[] =
2168 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2169 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2170 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2171 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2172 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2173 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2174 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2175 { TYPE_EMPTY, NULL, "" },
2176 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2181 static void DrawCursorAndText_Info(int pos, boolean active)
2183 int xpos = MENU_SCREEN_START_XPOS;
2184 int ypos = MENU_SCREEN_START_YPOS + pos;
2185 int font_nr = FONT_MENU_1;
2188 font_nr = FONT_ACTIVE(font_nr);
2190 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
2192 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
2193 drawCursor(pos, active);
2196 static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading)
2201 CloseDoor(DOOR_CLOSE_2);
2203 /* (needed after displaying title screens which disable auto repeat) */
2204 KeyboardAutoRepeatOn();
2206 FadeSetLeaveScreen();
2209 FadeOut(redraw_mask);
2213 if (redraw_mask == REDRAW_ALL)
2217 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2223 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2225 info_info = info_info_main;
2228 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2230 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2231 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2232 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2233 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2234 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
2235 initCursor(i, IMG_MENU_BUTTON);
2237 DrawCursorAndText_Info(i, FALSE);
2242 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2247 DrawMaskedBorder(redraw_mask);
2249 FadeIn(redraw_mask);
2254 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2256 static int choice_store[MAX_INFO_MODES];
2257 int choice = choice_store[info_mode]; /* always starts with 0 */
2261 if (button == MB_MENU_INITIALIZE)
2263 /* advance to first valid menu entry */
2264 while (choice < num_info_info &&
2265 info_info[choice].type & TYPE_SKIP_ENTRY)
2267 choice_store[info_mode] = choice;
2269 DrawCursorAndText_Info(choice, TRUE);
2273 else if (button == MB_MENU_LEAVE)
2275 for (y = 0; y < num_info_info; y++)
2277 if (info_info[y].type & TYPE_LEAVE_MENU)
2279 void (*menu_callback_function)(void) = info_info[y].value;
2283 menu_callback_function();
2285 break; /* absolutely needed because function changes 'info_info'! */
2292 if (mx || my) /* mouse input */
2294 x = (mx - mSX) / 32;
2295 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2297 else if (dx || dy) /* keyboard input */
2301 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2303 if (info_info[choice].type & menu_navigation_type ||
2304 info_info[choice].type & TYPE_ENTER_SCREEN ||
2305 info_info[choice].type & TYPE_BOOLEAN_STYLE)
2306 button = MB_MENU_CHOICE;
2311 /* jump to next non-empty menu entry (up or down) */
2312 while (y > 0 && y < num_info_info - 1 &&
2313 info_info[y].type & TYPE_SKIP_ENTRY)
2317 if (IN_VIS_FIELD(x, y) &&
2318 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2324 PlaySound(SND_MENU_ITEM_ACTIVATING);
2326 DrawCursorAndText_Info(choice, FALSE);
2327 DrawCursorAndText_Info(y, TRUE);
2329 choice = choice_store[info_mode] = y;
2332 else if (!(info_info[y].type & TYPE_GHOSTED))
2334 PlaySound(SND_MENU_ITEM_SELECTING);
2336 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2338 void (*menu_callback_function)(void) = info_info[choice].value;
2340 FadeSetFromType(info_info[y].type);
2342 menu_callback_function();
2348 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2350 int ystart1 = mSY - SY + 100;
2351 int ystart2 = mSY - SY + 150;
2352 int ybottom = mSY - SY + SYSIZE - 20;
2354 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2356 FadeOut(REDRAW_FIELD);
2361 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2362 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2364 DrawTextSCentered(ybottom, FONT_TEXT_4,
2365 "Press any key or button for info menu");
2367 FadeIn(REDRAW_FIELD);
2370 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2372 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2373 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2374 int xstart = mSX + 16;
2375 int ystart1 = mSY - SY + 100;
2376 int ystart2 = mSY + 64 + 2 * 32;
2377 int ybottom = mSY - SY + SYSIZE - 20;
2378 int ystep = TILEY + 4;
2379 int element, action, direction;
2387 for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++)
2388 infoscreen_step[i] = infoscreen_frame[i] = 0;
2393 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2395 DrawTextSCentered(ybottom, FONT_TEXT_4,
2396 "Press any key or button for next page");
2402 while (helpanim_info[j].element != HELPANIM_LIST_END)
2404 if (i >= start + MAX_INFO_ELEMENTS_ON_SCREEN ||
2409 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2418 j += infoscreen_step[i - start];
2420 element = helpanim_info[j].element;
2421 action = helpanim_info[j].action;
2422 direction = helpanim_info[j].direction;
2425 element = EL_UNKNOWN;
2427 if (action != -1 && direction != -1)
2428 graphic = el_act_dir2img(element, action, direction);
2429 else if (action != -1)
2430 graphic = el_act2img(element, action);
2431 else if (direction != -1)
2432 graphic = el_dir2img(element, direction);
2434 graphic = el2img(element);
2436 delay = helpanim_info[j++].delay;
2441 if (infoscreen_frame[i - start] == 0)
2444 infoscreen_frame[i - start] = delay - 1;
2448 sync_frame = delay - infoscreen_frame[i - start];
2449 infoscreen_frame[i - start]--;
2452 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2454 if (!infoscreen_frame[i - start])
2455 infoscreen_step[i - start] = 0;
2459 if (!infoscreen_frame[i - start])
2460 infoscreen_step[i - start]++;
2461 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2467 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2469 DrawGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2470 graphic, sync_frame, USE_MASKING);
2473 DrawInfoScreen_HelpText(element, action, direction, i - start);
2478 redraw_mask |= REDRAW_FIELD;
2483 static char *getHelpText(int element, int action, int direction)
2485 char token[MAX_LINE_LEN];
2487 strcpy(token, element_info[element].token_name);
2490 strcat(token, element_action_info[action].suffix);
2492 if (direction != -1)
2493 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2495 return getHashEntry(helptext_info, token);
2498 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2500 int font_nr = FONT_INFO_ELEMENTS;
2501 int font_width = getFontWidth(font_nr);
2502 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2503 int sy = mSY + 65 + 2 * 32 + 1;
2504 int ystep = TILEY + 4;
2505 int pad_x = sx - SX;
2506 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2507 int max_lines_per_text = 2;
2510 if (action != -1 && direction != -1) /* element.action.direction */
2511 text = getHelpText(element, action, direction);
2513 if (text == NULL && action != -1) /* element.action */
2514 text = getHelpText(element, action, -1);
2516 if (text == NULL && direction != -1) /* element.direction */
2517 text = getHelpText(element, -1, direction);
2519 if (text == NULL) /* base element */
2520 text = getHelpText(element, -1, -1);
2522 if (text == NULL) /* not found */
2523 text = "No description available";
2525 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2526 sy += getFontHeight(font_nr) / 2;
2528 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2529 max_chars_per_line, -1, max_lines_per_text, -1,
2530 TRUE, FALSE, FALSE);
2533 void DrawInfoScreen_TitleScreen()
2538 void HandleInfoScreen_TitleScreen(int button)
2540 HandleTitleScreen(0, 0, 0, 0, button);
2543 void DrawInfoScreen_Elements()
2545 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2547 FadeOut(REDRAW_FIELD);
2552 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2554 FadeIn(REDRAW_FIELD);
2559 void HandleInfoScreen_Elements(int button)
2561 static unsigned long info_delay = 0;
2562 static int num_anims;
2563 static int num_pages;
2565 int anims_per_page = MAX_INFO_ELEMENTS_ON_SCREEN;
2568 if (button == MB_MENU_INITIALIZE)
2570 boolean new_element = TRUE;
2574 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2576 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2578 else if (new_element)
2581 new_element = FALSE;
2585 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2589 if (button == MB_MENU_LEAVE)
2591 PlaySound(SND_MENU_ITEM_SELECTING);
2593 info_mode = INFO_MODE_MAIN;
2598 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2600 if (button != MB_MENU_INITIALIZE)
2602 PlaySound(SND_MENU_ITEM_SELECTING);
2607 if (page >= num_pages)
2609 FadeSoundsAndMusic();
2611 info_mode = INFO_MODE_MAIN;
2612 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2619 FadeSetNextScreen();
2623 if (button != MB_MENU_INITIALIZE)
2624 FadeOut(REDRAW_FIELD);
2626 if (button != MB_MENU_INITIALIZE)
2627 FadeCrossSaveBackbuffer();
2630 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2633 if (button != MB_MENU_INITIALIZE)
2634 FadeIn(REDRAW_FIELD);
2636 if (button != MB_MENU_INITIALIZE)
2637 FadeCross(REDRAW_FIELD);
2642 if (DelayReached(&info_delay, GameFrameDelay))
2643 if (page < num_pages)
2644 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2646 PlayMenuSoundIfLoop();
2650 void DrawInfoScreen_Music()
2652 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2655 FadeOut(REDRAW_FIELD);
2663 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2666 FadeIn(REDRAW_FIELD);
2670 void HandleInfoScreen_Music(int button)
2672 static struct MusicFileInfo *list = NULL;
2673 int ystart1 = mSY - SY + 100;
2674 int ystart2 = mSY - SY + 150;
2675 int ybottom = mSY - SY + SYSIZE - 20;
2678 if (button == MB_MENU_INITIALIZE)
2680 list = music_file_info;
2684 FadeSoundsAndMusic();
2689 DrawTextSCentered(ystart1, FONT_TEXT_1,
2690 "No music info for this level set.");
2692 DrawTextSCentered(ybottom, FONT_TEXT_4,
2693 "Press any key or button for info menu");
2699 if (button == MB_MENU_LEAVE)
2701 PlaySound(SND_MENU_ITEM_SELECTING);
2703 FadeSoundsAndMusic();
2705 info_mode = INFO_MODE_MAIN;
2710 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2714 if (button != MB_MENU_INITIALIZE)
2716 PlaySound(SND_MENU_ITEM_SELECTING);
2724 FadeSoundsAndMusic();
2726 info_mode = INFO_MODE_MAIN;
2727 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2732 FadeSoundsAndMusic();
2735 if (list != music_file_info)
2736 FadeSetNextScreen();
2740 if (button != MB_MENU_INITIALIZE)
2741 FadeOut(REDRAW_FIELD);
2743 if (button != MB_MENU_INITIALIZE)
2744 FadeCrossSaveBackbuffer();
2752 int sound = list->music;
2754 if (sound_info[sound].loop)
2755 PlaySoundLoop(sound);
2759 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2763 PlayMusic(list->music);
2765 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2768 if (!strEqual(list->title, UNKNOWN_NAME))
2770 if (!strEqual(list->title_header, UNKNOWN_NAME))
2771 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2773 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2776 if (!strEqual(list->artist, UNKNOWN_NAME))
2778 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2779 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2781 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2783 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2786 if (!strEqual(list->album, UNKNOWN_NAME))
2788 if (!strEqual(list->album_header, UNKNOWN_NAME))
2789 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2791 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2793 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2796 if (!strEqual(list->year, UNKNOWN_NAME))
2798 if (!strEqual(list->year_header, UNKNOWN_NAME))
2799 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2801 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2803 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2806 DrawTextSCentered(ybottom, FONT_TEXT_4,
2807 "Press any key or button for next page");
2810 if (button != MB_MENU_INITIALIZE)
2811 FadeIn(REDRAW_FIELD);
2813 if (button != MB_MENU_INITIALIZE)
2814 FadeCross(REDRAW_FIELD);
2818 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2819 PlaySoundLoop(list->music);
2822 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2824 int ystart1 = mSY - SY + 100;
2825 int ystart2 = mSY - SY + 150;
2826 int ybottom = mSY - SY + SYSIZE - 20;
2832 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2836 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2837 "Special thanks to");
2838 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2840 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2842 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2843 "\"Boulder Dash\"");
2844 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2846 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2848 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2850 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2851 "First Star Software");
2853 else if (screen_nr == 1)
2855 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2856 "Special thanks to");
2857 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2858 "Klaus Heinz & Volker Wertich");
2859 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2861 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2862 "\"Emerald Mine\"");
2863 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2865 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2867 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2869 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2872 else if (screen_nr == 2)
2874 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2875 "Special thanks to");
2876 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2877 "Michael Stopp & Philip Jespersen");
2878 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2880 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2882 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2884 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2886 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2888 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2889 "Digital Integration");
2891 else if (screen_nr == 3)
2893 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2894 "Special thanks to");
2895 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2896 "Hiroyuki Imabayashi");
2897 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2899 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2901 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2903 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2905 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2907 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2910 else if (screen_nr == 4)
2912 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2913 "Special thanks to");
2914 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2916 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2918 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2919 "Jürgen Bonhagen");
2920 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2921 "for the continuous creation");
2922 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2923 "of outstanding level sets");
2925 else if (screen_nr == 5)
2927 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2929 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2931 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2932 "for ideas and inspiration by");
2933 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2936 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2938 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2940 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2941 "for ideas and inspiration by");
2942 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2945 else if (screen_nr == 6)
2947 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2949 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2951 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2952 "for the new Emerald Mine engine");
2954 else if (screen_nr == 7)
2956 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2958 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2960 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2961 "for the initial DOS port");
2963 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2965 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2967 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2968 "for some additional toons");
2970 else if (screen_nr == 8)
2972 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2973 "And not to forget:");
2974 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2976 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2977 "All those who contributed");
2978 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2979 "levels to this game");
2980 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2984 DrawTextSCentered(ybottom, FONT_TEXT_4,
2985 "Press any key or button for next page");
2988 void DrawInfoScreen_Credits()
2990 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2992 FadeSoundsAndMusic();
2995 FadeOut(REDRAW_FIELD);
2998 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3001 FadeIn(REDRAW_FIELD);
3005 void HandleInfoScreen_Credits(int button)
3007 static int screen_nr = 0;
3008 int num_screens = 9;
3010 if (button == MB_MENU_INITIALIZE)
3014 // DrawInfoScreen_CreditsScreen(screen_nr);
3017 if (button == MB_MENU_LEAVE)
3019 PlaySound(SND_MENU_ITEM_SELECTING);
3021 info_mode = INFO_MODE_MAIN;
3026 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
3028 if (button != MB_MENU_INITIALIZE)
3030 PlaySound(SND_MENU_ITEM_SELECTING);
3035 if (screen_nr >= num_screens)
3037 FadeSoundsAndMusic();
3039 info_mode = INFO_MODE_MAIN;
3040 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3047 FadeSetNextScreen();
3051 if (button != MB_MENU_INITIALIZE)
3052 FadeOut(REDRAW_FIELD);
3054 if (button != MB_MENU_INITIALIZE)
3055 FadeCrossSaveBackbuffer();
3058 DrawInfoScreen_CreditsScreen(screen_nr);
3061 if (button != MB_MENU_INITIALIZE)
3062 FadeIn(REDRAW_FIELD);
3064 if (button != MB_MENU_INITIALIZE)
3065 FadeCross(REDRAW_FIELD);
3070 PlayMenuSoundIfLoop();
3074 void DrawInfoScreen_Program()
3076 int ystart1 = mSY - SY + 100;
3077 int ystart2 = mSY - SY + 150;
3078 int ybottom = mSY - SY + SYSIZE - 20;
3081 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3084 FadeOut(REDRAW_FIELD);
3090 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
3092 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3093 "This game is Freeware!");
3094 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3095 "If you like it, send e-mail to:");
3096 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3097 PROGRAM_EMAIL_STRING);
3098 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
3099 "or SnailMail to:");
3100 DrawTextSCentered(ystart2 + 4 * ystep + 0, FONT_TEXT_3,
3102 DrawTextSCentered(ystart2 + 4 * ystep + 20, FONT_TEXT_3,
3103 "Detmolder Strasse 189");
3104 DrawTextSCentered(ystart2 + 4 * ystep + 40, FONT_TEXT_3,
3106 DrawTextSCentered(ystart2 + 4 * ystep + 60, FONT_TEXT_3,
3108 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3109 "More information and levels:");
3110 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3111 PROGRAM_WEBSITE_STRING);
3112 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3113 "If you have created new levels,");
3114 DrawTextSCentered(ystart2 + 10 * ystep, FONT_TEXT_2,
3115 "send them to me to include them!");
3116 DrawTextSCentered(ystart2 + 11 * ystep, FONT_TEXT_2,
3119 DrawTextSCentered(ybottom, FONT_TEXT_4,
3120 "Press any key or button for info menu");
3123 FadeIn(REDRAW_FIELD);
3127 void HandleInfoScreen_Program(int button)
3129 if (button == MB_MENU_LEAVE)
3131 PlaySound(SND_MENU_ITEM_SELECTING);
3133 info_mode = INFO_MODE_MAIN;
3138 else if (button == MB_MENU_CHOICE)
3140 PlaySound(SND_MENU_ITEM_SELECTING);
3142 FadeSoundsAndMusic();
3145 FadeOut(REDRAW_FIELD);
3148 info_mode = INFO_MODE_MAIN;
3149 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3153 PlayMenuSoundIfLoop();
3157 void DrawInfoScreen_Version()
3159 int font_header = FONT_TEXT_3;
3160 int font_text = FONT_TEXT_2;
3161 int xstep = getFontWidth(font_text);
3162 int ystep = getFontHeight(font_text);
3163 int ystart1 = mSY - SY + 100;
3164 int ystart2 = mSY - SY + 150;
3165 int ybottom = mSY - SY + SYSIZE - 20;
3166 int xstart1 = mSX + 2 * xstep;
3167 int xstart2 = mSX + 19 * xstep;
3168 #if defined(TARGET_SDL)
3169 int xstart3 = mSX + 29 * xstep;
3170 SDL_version sdl_version_compiled;
3171 const SDL_version *sdl_version_linked;
3172 int driver_name_len = 8;
3173 char driver_name[driver_name_len];
3176 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3179 FadeOut(REDRAW_FIELD);
3185 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
3187 DrawTextF(xstart1, ystart2, font_header, "Name");
3188 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
3191 DrawTextF(xstart1, ystart2, font_header, "Version");
3192 DrawTextF(xstart2, ystart2, font_text, getProgramFullVersionString());
3195 DrawTextF(xstart1, ystart2, font_header, "Platform");
3196 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
3199 DrawTextF(xstart1, ystart2, font_header, "Target");
3200 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
3203 DrawTextF(xstart1, ystart2, font_header, "Compile time");
3204 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
3206 #if defined(TARGET_SDL)
3207 ystart2 += 3 * ystep;
3208 DrawTextF(xstart1, ystart2, font_header, "Library");
3209 DrawTextF(xstart2, ystart2, font_header, "compiled");
3210 DrawTextF(xstart3, ystart2, font_header, "linked");
3212 SDL_VERSION(&sdl_version_compiled);
3213 sdl_version_linked = SDL_Linked_Version();
3215 ystart2 += 2 * ystep;
3216 DrawTextF(xstart1, ystart2, font_text, "SDL");
3217 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3218 sdl_version_compiled.major,
3219 sdl_version_compiled.minor,
3220 sdl_version_compiled.patch);
3221 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3222 sdl_version_linked->major,
3223 sdl_version_linked->minor,
3224 sdl_version_linked->patch);
3226 SDL_IMAGE_VERSION(&sdl_version_compiled);
3227 sdl_version_linked = IMG_Linked_Version();
3230 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
3231 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3232 sdl_version_compiled.major,
3233 sdl_version_compiled.minor,
3234 sdl_version_compiled.patch);
3235 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3236 sdl_version_linked->major,
3237 sdl_version_linked->minor,
3238 sdl_version_linked->patch);
3240 SDL_MIXER_VERSION(&sdl_version_compiled);
3241 sdl_version_linked = Mix_Linked_Version();
3244 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
3245 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3246 sdl_version_compiled.major,
3247 sdl_version_compiled.minor,
3248 sdl_version_compiled.patch);
3249 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3250 sdl_version_linked->major,
3251 sdl_version_linked->minor,
3252 sdl_version_linked->patch);
3254 SDL_NET_VERSION(&sdl_version_compiled);
3255 sdl_version_linked = SDLNet_Linked_Version();
3258 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
3259 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3260 sdl_version_compiled.major,
3261 sdl_version_compiled.minor,
3262 sdl_version_compiled.patch);
3263 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3264 sdl_version_linked->major,
3265 sdl_version_linked->minor,
3266 sdl_version_linked->patch);
3268 ystart2 += 3 * ystep;
3269 DrawTextF(xstart1, ystart2, font_header, "Driver");
3270 DrawTextF(xstart2, ystart2, font_header, "Requested");
3271 DrawTextF(xstart3, ystart2, font_header, "Used");
3273 SDL_VideoDriverName(driver_name, driver_name_len);
3275 ystart2 += 2 * ystep;
3276 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
3277 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
3278 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3280 SDL_AudioDriverName(driver_name, driver_name_len);
3283 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
3284 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
3285 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3288 DrawTextSCentered(ybottom, FONT_TEXT_4,
3289 "Press any key or button for info menu");
3292 FadeIn(REDRAW_FIELD);
3296 void HandleInfoScreen_Version(int button)
3298 if (button == MB_MENU_LEAVE)
3300 PlaySound(SND_MENU_ITEM_SELECTING);
3302 info_mode = INFO_MODE_MAIN;
3307 else if (button == MB_MENU_CHOICE)
3309 PlaySound(SND_MENU_ITEM_SELECTING);
3311 FadeSoundsAndMusic();
3314 FadeOut(REDRAW_FIELD);
3317 info_mode = INFO_MODE_MAIN;
3318 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3322 PlayMenuSoundIfLoop();
3326 void DrawInfoScreen_LevelSet()
3328 struct TitleMessageInfo *tmi = &readme;
3329 char *filename = getLevelSetInfoFilename();
3331 /* if chars set to "-1", automatically determine by text and font width */
3332 if (tmi->chars == -1)
3333 tmi->chars = tmi->width / getFontWidth(tmi->font);
3335 tmi->width = tmi->chars * getFontWidth(tmi->font);
3337 /* if lines set to "-1", automatically determine by text and font height */
3338 if (tmi->lines == -1)
3339 tmi->lines = tmi->height / getFontHeight(tmi->font);
3341 tmi->height = tmi->lines * getFontHeight(tmi->font);
3343 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3346 FadeOut(REDRAW_FIELD);
3352 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3354 if (filename != NULL)
3355 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3356 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
3357 tmi->autowrap, tmi->centered, tmi->parse_comments);
3359 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3360 "No information for this level set.");
3362 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3363 "Press any key or button for info menu");
3366 FadeIn(REDRAW_FIELD);
3370 void HandleInfoScreen_LevelSet(int button)
3372 if (button == MB_MENU_LEAVE)
3374 PlaySound(SND_MENU_ITEM_SELECTING);
3376 info_mode = INFO_MODE_MAIN;
3381 else if (button == MB_MENU_CHOICE)
3383 PlaySound(SND_MENU_ITEM_SELECTING);
3385 FadeSoundsAndMusic();
3388 FadeOut(REDRAW_FIELD);
3391 info_mode = INFO_MODE_MAIN;
3392 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3396 PlayMenuSoundIfLoop();
3400 static void DrawInfoScreenExt(int redraw_mask, boolean do_fading)
3402 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3404 if (info_mode == INFO_MODE_TITLE)
3405 DrawInfoScreen_TitleScreen();
3406 else if (info_mode == INFO_MODE_ELEMENTS)
3407 DrawInfoScreen_Elements();
3408 else if (info_mode == INFO_MODE_MUSIC)
3409 DrawInfoScreen_Music();
3410 else if (info_mode == INFO_MODE_CREDITS)
3411 DrawInfoScreen_Credits();
3412 else if (info_mode == INFO_MODE_PROGRAM)
3413 DrawInfoScreen_Program();
3414 else if (info_mode == INFO_MODE_VERSION)
3415 DrawInfoScreen_Version();
3416 else if (info_mode == INFO_MODE_LEVELSET)
3417 DrawInfoScreen_LevelSet();
3419 DrawInfoScreen_Main(redraw_mask, do_fading);
3421 if (info_mode != INFO_MODE_MAIN &&
3422 info_mode != INFO_MODE_TITLE &&
3423 info_mode != INFO_MODE_MUSIC)
3430 void DrawAndFadeInInfoScreen(int redraw_mask)
3432 DrawInfoScreenExt(redraw_mask, TRUE);
3435 void DrawInfoScreen()
3437 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3440 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3442 if (info_mode == INFO_MODE_TITLE)
3443 HandleInfoScreen_TitleScreen(button);
3444 else if (info_mode == INFO_MODE_ELEMENTS)
3445 HandleInfoScreen_Elements(button);
3446 else if (info_mode == INFO_MODE_MUSIC)
3447 HandleInfoScreen_Music(button);
3448 else if (info_mode == INFO_MODE_CREDITS)
3449 HandleInfoScreen_Credits(button);
3450 else if (info_mode == INFO_MODE_PROGRAM)
3451 HandleInfoScreen_Program(button);
3452 else if (info_mode == INFO_MODE_VERSION)
3453 HandleInfoScreen_Version(button);
3454 else if (info_mode == INFO_MODE_LEVELSET)
3455 HandleInfoScreen_LevelSet(button);
3457 HandleInfoScreen_Main(mx, my, dx, dy, button);
3463 /* ========================================================================= */
3464 /* type name functions */
3465 /* ========================================================================= */
3467 void HandleTypeName(int newxpos, Key key)
3469 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3470 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3472 struct TextPosInfo *pos = mci->pos_input;
3473 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3474 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3477 static int xpos = 0;
3479 static int xpos = 0, ypos = 2;
3481 int font_nr = pos->font;
3482 int font_active_nr = FONT_ACTIVE(font_nr);
3483 int font_width = getFontWidth(font_active_nr);
3486 int startx = mSX + mci->pos_input->x;
3487 int starty = mSY + mci->pos_input->y;
3490 int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
3491 int startx = mSX + 32 + name_width;
3492 int starty = mSY + ypos * 32;
3494 char key_char = getValidConfigValueChar(getCharFromKey(key));
3495 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3496 boolean is_active = TRUE;
3498 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3502 strcpy(last_player_name, setup.player_name);
3507 /* add one character width for added cursor character */
3508 pos->width += font_width;
3509 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3511 DrawText(startx, starty, setup.player_name, font_active_nr);
3512 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3515 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3517 setup.player_name[xpos] = key_char;
3518 setup.player_name[xpos + 1] = 0;
3523 /* add one character width for added name text character */
3524 pos->width += font_width;
3525 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3527 DrawText(startx, starty, setup.player_name, font_active_nr);
3528 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3531 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3535 setup.player_name[xpos] = 0;
3538 /* remove one character width for removed name text character */
3539 pos->width -= font_width;
3540 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3542 DrawText(startx, starty, setup.player_name, font_active_nr);
3543 DrawText(startx + xpos * font_width, starty, "_ ", font_active_nr);
3546 else if (key == KSYM_Return && xpos > 0)
3549 /* remove one character width for removed cursor text character */
3550 pos->width -= font_width;
3551 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3553 DrawText(startx, starty, setup.player_name, font_nr);
3554 DrawText(startx + xpos * font_width, starty, " ", font_active_nr);
3561 game_status = GAME_MODE_MAIN;
3563 else if (key == KSYM_Escape)
3565 strcpy(setup.player_name, last_player_name);
3569 game_status = GAME_MODE_MAIN;
3574 pos->width = (strlen(setup.player_name) + 1) * font_width;
3575 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3577 DrawText(startx, starty, setup.player_name, font_active_nr);
3578 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3582 pos->width = strlen(setup.player_name) * font_width;
3583 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3585 DrawText(startx, starty, setup.player_name, font_nr);
3590 /* ========================================================================= */
3591 /* tree menu functions */
3592 /* ========================================================================= */
3594 static void DrawChooseTree(TreeInfo **ti_ptr)
3598 FreeScreenGadgets();
3599 CreateScreenGadgets();
3601 CloseDoor(DOOR_CLOSE_2);
3604 FadeOut(REDRAW_FIELD);
3609 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3610 MapScreenTreeGadgets(*ti_ptr);
3613 FadeIn(REDRAW_FIELD);
3619 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3621 struct GadgetInfo *gi = screen_gadget[id];
3622 int items_max, items_visible, item_position;
3624 items_max = numTreeInfoInGroup(ti);
3625 items_visible = NUM_MENU_ENTRIES_ON_SCREEN;
3626 item_position = first_entry;
3628 if (item_position > items_max - items_visible)
3629 item_position = items_max - items_visible;
3631 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3632 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3633 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3636 static void drawChooseTreeList(int first_entry, int num_page_entries,
3640 char *title_string = NULL;
3641 int yoffset_sets = MENU_TITLE1_YPOS;
3642 int yoffset_setup = 16;
3643 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? yoffset_sets :
3645 int last_game_status = game_status; /* save current game status */
3647 title_string = ti->infotext;
3649 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3652 /* force LEVELS font on artwork setup screen */
3653 game_status = GAME_MODE_LEVELS;
3657 /* clear tree list area, but not title or scrollbar */
3658 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3659 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3660 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3662 /* clear tree list area, but not title or scrollbar */
3663 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3664 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3665 MAX_MENU_ENTRIES_ON_SCREEN * 32);
3668 for (i = 0; i < num_page_entries; i++)
3670 TreeInfo *node, *node_first;
3671 int entry_pos = first_entry + i;
3672 int xpos = MENU_SCREEN_START_XPOS;
3673 int ypos = MENU_SCREEN_START_YPOS + i;
3674 int startx = mSX + xpos * 32;
3675 int starty = mSY + ypos * 32;
3676 int font_nr = FONT_TEXT_1;
3677 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3678 int startx_text = startx + font_xoffset;
3679 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3680 int text_size = startx_scrollbar - startx_text;
3681 int max_buffer_len = text_size / getFontWidth(font_nr);
3682 char buffer[max_buffer_len + 1];
3684 node_first = getTreeInfoFirstGroupEntry(ti);
3685 node = getTreeInfoFromPos(node_first, entry_pos);
3687 strncpy(buffer, node->name, max_buffer_len);
3688 buffer[max_buffer_len] = '\0';
3690 DrawText(startx, starty, buffer, font_nr + node->color);
3692 if (node->parent_link)
3693 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3694 else if (node->level_group)
3695 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3697 initCursor(i, IMG_MENU_BUTTON);
3700 game_status = last_game_status; /* restore current game status */
3702 redraw_mask |= REDRAW_FIELD;
3705 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3707 TreeInfo *node, *node_first;
3708 int x, last_redraw_mask = redraw_mask;
3709 int ypos = MENU_TITLE2_YPOS;
3710 int font_nr = FONT_TITLE_2;
3712 if (ti->type != TREE_TYPE_LEVEL_DIR)
3715 node_first = getTreeInfoFirstGroupEntry(ti);
3716 node = getTreeInfoFromPos(node_first, entry_pos);
3718 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3720 if (node->parent_link)
3721 DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
3723 else if (node->level_group)
3724 DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
3726 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3727 DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
3728 node->levels, node->class_desc);
3730 /* let BackToFront() redraw only what is needed */
3731 redraw_mask = last_redraw_mask | REDRAW_TILES;
3732 for (x = 0; x < SCR_FIELDX; x++)
3733 MarkTileDirty(x, 1);
3736 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3739 TreeInfo *ti = *ti_ptr;
3741 int y = ti->cl_cursor;
3742 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3743 int num_entries = numTreeInfoInGroup(ti);
3744 int num_page_entries;
3745 int last_game_status = game_status; /* save current game status */
3746 boolean position_set_by_scrollbar = (dx == 999);
3749 /* force LEVELS draw offset on choose level and artwork setup screen */
3750 game_status = GAME_MODE_LEVELS;
3753 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3754 num_page_entries = num_entries;
3756 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3758 game_status = last_game_status; /* restore current game status */
3760 if (button == MB_MENU_INITIALIZE)
3762 int num_entries = numTreeInfoInGroup(ti);
3763 int entry_pos = posTreeInfo(ti);
3765 if (ti->cl_first == -1)
3767 /* only on initialization */
3768 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3769 ti->cl_cursor = entry_pos - ti->cl_first;
3771 else if (ti->cl_cursor >= num_page_entries ||
3772 (num_entries > num_page_entries &&
3773 num_entries - ti->cl_first < num_page_entries))
3775 /* only after change of list size (by custom graphic configuration) */
3776 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3777 ti->cl_cursor = entry_pos - ti->cl_first;
3780 if (position_set_by_scrollbar)
3783 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3786 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3787 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3788 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3792 else if (button == MB_MENU_LEAVE)
3796 PlaySound(SND_MENU_ITEM_SELECTING);
3798 if (ti->node_parent)
3800 *ti_ptr = ti->node_parent;
3801 DrawChooseTree(ti_ptr);
3803 else if (game_status == GAME_MODE_SETUP)
3805 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
3807 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3808 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3809 execSetupGraphics();
3815 game_status = GAME_MODE_MAIN;
3817 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3826 if (mx || my) /* mouse input */
3828 int last_game_status = game_status; /* save current game status */
3831 /* force LEVELS draw offset on artwork setup screen */
3832 game_status = GAME_MODE_LEVELS;
3835 x = (mx - mSX) / 32;
3836 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3838 game_status = last_game_status; /* restore current game status */
3840 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3842 /* move cursor instead of scrolling when already at start/end of list */
3843 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3845 else if (dy == +1 * SCROLL_LINE &&
3846 ti->cl_first + num_page_entries == num_entries)
3849 /* handle scrolling screen one line or page */
3850 if (ti->cl_cursor + dy < 0 ||
3851 ti->cl_cursor + dy > num_page_entries - 1)
3853 if (ABS(dy) == SCROLL_PAGE)
3854 step = num_page_entries - 1;
3856 if (dy < 0 && ti->cl_first > 0)
3858 /* scroll page/line up */
3860 ti->cl_first -= step;
3861 if (ti->cl_first < 0)
3864 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3865 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3866 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3868 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3871 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3873 /* scroll page/line down */
3875 ti->cl_first += step;
3876 if (ti->cl_first + num_page_entries > num_entries)
3877 ti->cl_first = MAX(0, num_entries - num_page_entries);
3879 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3880 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3881 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3883 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3890 /* handle moving cursor one line */
3891 y = ti->cl_cursor + dy;
3896 TreeInfo *node_first, *node_cursor;
3897 int entry_pos = ti->cl_first + y;
3899 node_first = getTreeInfoFirstGroupEntry(ti);
3900 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3902 if (node_cursor->node_group)
3906 PlaySound(SND_MENU_ITEM_SELECTING);
3908 node_cursor->cl_first = ti->cl_first;
3909 node_cursor->cl_cursor = ti->cl_cursor;
3910 *ti_ptr = node_cursor->node_group;
3911 DrawChooseTree(ti_ptr);
3916 else if (dx == -1 && ti->node_parent)
3920 PlaySound(SND_MENU_ITEM_SELECTING);
3922 *ti_ptr = ti->node_parent;
3923 DrawChooseTree(ti_ptr);
3928 if (!anyScrollbarGadgetActive() &&
3929 IN_VIS_FIELD(x, y) &&
3930 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3931 y >= 0 && y < num_page_entries)
3935 if (y != ti->cl_cursor)
3937 PlaySound(SND_MENU_ITEM_ACTIVATING);
3939 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3940 drawChooseTreeCursor(y, TRUE);
3941 drawChooseTreeInfo(ti->cl_first + y, ti);
3948 TreeInfo *node_first, *node_cursor;
3949 int entry_pos = ti->cl_first + y;
3951 PlaySound(SND_MENU_ITEM_SELECTING);
3953 node_first = getTreeInfoFirstGroupEntry(ti);
3954 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3956 if (node_cursor->node_group)
3960 node_cursor->cl_first = ti->cl_first;
3961 node_cursor->cl_cursor = ti->cl_cursor;
3962 *ti_ptr = node_cursor->node_group;
3963 DrawChooseTree(ti_ptr);
3965 else if (node_cursor->parent_link)
3969 *ti_ptr = node_cursor->node_parent;
3970 DrawChooseTree(ti_ptr);
3974 FadeSetEnterScreen();
3976 node_cursor->cl_first = ti->cl_first;
3977 node_cursor->cl_cursor = ti->cl_cursor;
3978 *ti_ptr = node_cursor;
3980 if (ti->type == TREE_TYPE_LEVEL_DIR)
3982 LoadLevelSetup_SeriesInfo();
3984 SaveLevelSetup_LastSeries();
3985 SaveLevelSetup_SeriesInfo();
3989 if (game_status == GAME_MODE_SETUP)
3991 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
3993 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3994 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3995 execSetupGraphics();
4001 game_status = GAME_MODE_MAIN;
4009 void DrawChooseLevel()
4011 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
4013 DrawChooseTree(&leveldir_current);
4019 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
4021 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4026 void DrawHallOfFame(int highlight_position)
4029 FadeSoundsAndMusic();
4031 /* (this is needed when called from GameEnd() after winning a game) */
4032 KeyboardAutoRepeatOn();
4035 /* (this is needed when called from GameEnd() after winning a game) */
4036 SetDrawDeactivationMask(REDRAW_NONE);
4037 SetDrawBackgroundMask(REDRAW_FIELD);
4039 CloseDoor(DOOR_CLOSE_2);
4041 if (highlight_position < 0)
4042 LoadScore(level_nr);
4044 FadeSetEnterScreen();
4046 // printf("::: %d: %d\n", game_status, menu.enter_screen[game_status]);
4049 FadeOut(REDRAW_FIELD);
4057 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4060 FadeIn(REDRAW_FIELD);
4064 static void drawHallOfFameList(int first_entry, int highlight_position)
4068 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4071 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4072 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4073 "HighScores of Level %d", level_nr);
4075 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4077 int entry = first_entry + i;
4078 boolean active = (entry == highlight_position);
4079 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4080 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4081 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4082 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4083 int dx1 = 3 * getFontWidth(font_nr1);
4084 int dx2 = dx1 + getFontWidth(font_nr1);
4085 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
4086 int sy = mSY + 64 + i * 32;
4088 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4089 DrawText(mSX + dx1, sy, ".", font_nr1);
4090 DrawText(mSX + dx2, sy, ".........................", font_nr3);
4092 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4093 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4095 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4098 redraw_mask |= REDRAW_FIELD;
4101 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4103 static int first_entry = 0;
4104 static int highlight_position = 0;
4105 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4107 if (button == MB_MENU_INITIALIZE)
4110 highlight_position = mx;
4111 drawHallOfFameList(first_entry, highlight_position);
4116 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4117 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4121 if (first_entry > 0)
4123 first_entry -= step;
4124 if (first_entry < 0)
4127 drawHallOfFameList(first_entry, highlight_position);
4132 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4134 first_entry += step;
4135 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4136 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4138 drawHallOfFameList(first_entry, highlight_position);
4141 else if (button == MB_MENU_LEAVE)
4143 PlaySound(SND_MENU_ITEM_SELECTING);
4145 FadeSound(SND_BACKGROUND_SCORES);
4147 game_status = GAME_MODE_MAIN;
4151 else if (button == MB_MENU_CHOICE)
4153 PlaySound(SND_MENU_ITEM_SELECTING);
4155 FadeSound(SND_BACKGROUND_SCORES);
4158 FadeOut(REDRAW_FIELD);
4161 game_status = GAME_MODE_MAIN;
4163 DrawAndFadeInMainMenu(REDRAW_FIELD);
4166 if (game_status == GAME_MODE_SCORES)
4167 PlayMenuSoundIfLoop();
4173 /* ========================================================================= */
4174 /* setup screen functions */
4175 /* ========================================================================= */
4177 static struct TokenInfo *setup_info;
4178 static int num_setup_info;
4180 static char *screen_mode_text;
4181 static char *scroll_delay_text;
4182 static char *game_speed_text;
4183 static char *graphics_set_name;
4184 static char *sounds_set_name;
4185 static char *music_set_name;
4187 static void execSetupMain()
4193 setup_mode = SETUP_MODE_MAIN;
4197 static void execSetupGame()
4203 if (game_speeds == NULL)
4207 for (i = 0; game_speeds_list[i].value != -1; i++)
4209 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4210 char identifier[32], name[32];
4211 int value = game_speeds_list[i].value;
4212 char *text = game_speeds_list[i].text;
4214 ti->node_top = &game_speeds;
4215 ti->sort_priority = 10000 - value;
4217 sprintf(identifier, "%d", value);
4218 sprintf(name, "%s", text);
4220 setString(&ti->identifier, identifier);
4221 setString(&ti->name, name);
4222 setString(&ti->name_sorting, name);
4223 setString(&ti->infotext, "Game Speed");
4225 pushTreeInfo(&game_speeds, ti);
4228 /* sort game speed values to start with slowest game speed */
4229 sortTreeInfo(&game_speeds);
4231 /* set current game speed to configured game speed value */
4232 game_speed_current =
4233 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4235 /* if that fails, set current game speed to reliable default value */
4236 if (game_speed_current == NULL)
4237 game_speed_current =
4238 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4240 /* if that also fails, set current game speed to first available speed */
4241 if (game_speed_current == NULL)
4242 game_speed_current = game_speeds;
4245 setup.game_frame_delay = atoi(game_speed_current->identifier);
4247 /* needed for displaying game speed text instead of identifier */
4248 game_speed_text = game_speed_current->name;
4250 setup_mode = SETUP_MODE_GAME;
4254 static void execSetupChooseGameSpeed()
4260 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4264 static void execSetupEditor()
4270 setup_mode = SETUP_MODE_EDITOR;
4274 static void execSetupGraphics()
4280 if (video.fullscreen_available && screen_modes == NULL)
4284 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4286 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4287 char identifier[32], name[32];
4288 int x = video.fullscreen_modes[i].width;
4289 int y = video.fullscreen_modes[i].height;
4292 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4294 ti->node_top = &screen_modes;
4295 ti->sort_priority = x * 10000 + y;
4297 sprintf(identifier, "%dx%d", x, y);
4298 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4300 setString(&ti->identifier, identifier);
4301 setString(&ti->name, name);
4302 setString(&ti->name_sorting, name);
4303 setString(&ti->infotext, "Fullscreen Mode");
4305 pushTreeInfo(&screen_modes, ti);
4308 /* sort fullscreen modes to start with lowest available screen resolution */
4309 sortTreeInfo(&screen_modes);
4311 /* set current screen mode for fullscreen mode to configured setup value */
4312 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4313 setup.fullscreen_mode);
4315 /* if that fails, set current screen mode to reliable default value */
4316 if (screen_mode_current == NULL)
4317 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4318 DEFAULT_FULLSCREEN_MODE);
4320 /* if that also fails, set current screen mode to first available mode */
4321 if (screen_mode_current == NULL)
4322 screen_mode_current = screen_modes;
4324 if (screen_mode_current == NULL)
4325 video.fullscreen_available = FALSE;
4328 if (video.fullscreen_available)
4330 setup.fullscreen_mode = screen_mode_current->identifier;
4332 /* needed for displaying screen mode name instead of identifier */
4333 screen_mode_text = screen_mode_current->name;
4337 if (scroll_delays == NULL)
4341 for (i = 0; scroll_delays_list[i].value != -1; i++)
4343 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4344 char identifier[32], name[32];
4345 int value = scroll_delays_list[i].value;
4346 char *text = scroll_delays_list[i].text;
4348 ti->node_top = &scroll_delays;
4349 ti->sort_priority = value;
4351 sprintf(identifier, "%d", value);
4352 sprintf(name, "%s", text);
4354 setString(&ti->identifier, identifier);
4355 setString(&ti->name, name);
4356 setString(&ti->name_sorting, name);
4357 setString(&ti->infotext, "Scroll Delay");
4359 pushTreeInfo(&scroll_delays, ti);
4362 /* sort scroll delay values to start with lowest scroll delay value */
4363 sortTreeInfo(&scroll_delays);
4365 /* set current scroll delay value to configured scroll delay value */
4366 scroll_delay_current =
4367 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4369 /* if that fails, set current scroll delay to reliable default value */
4370 if (scroll_delay_current == NULL)
4371 scroll_delay_current =
4372 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4374 /* if that also fails, set current scroll delay to first available value */
4375 if (scroll_delay_current == NULL)
4376 scroll_delay_current = scroll_delays;
4379 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4381 /* needed for displaying scroll delay text instead of identifier */
4382 scroll_delay_text = scroll_delay_current->name;
4385 setup_mode = SETUP_MODE_GRAPHICS;
4389 static void execSetupChooseScreenMode()
4395 if (!video.fullscreen_available)
4398 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4402 static void execSetupChooseScrollDelay()
4408 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4412 static void execSetupSound()
4418 setup_mode = SETUP_MODE_SOUND;
4422 static void execSetupArtwork()
4428 setup.graphics_set = artwork.gfx_current->identifier;
4429 setup.sounds_set = artwork.snd_current->identifier;
4430 setup.music_set = artwork.mus_current->identifier;
4432 /* needed if last screen (setup choice) changed graphics, sounds or music */
4433 ReloadCustomArtwork(0);
4435 /* needed for displaying artwork name instead of artwork identifier */
4436 graphics_set_name = artwork.gfx_current->name;
4437 sounds_set_name = artwork.snd_current->name;
4438 music_set_name = artwork.mus_current->name;
4440 setup_mode = SETUP_MODE_ARTWORK;
4444 static void execSetupChooseGraphics()
4450 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4454 static void execSetupChooseSounds()
4460 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4464 static void execSetupChooseMusic()
4470 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4474 static void execSetupInput()
4480 setup_mode = SETUP_MODE_INPUT;
4484 static void execSetupShortcuts1()
4490 setup_mode = SETUP_MODE_SHORTCUTS_1;
4494 static void execSetupShortcuts2()
4500 setup_mode = SETUP_MODE_SHORTCUTS_2;
4504 static void execExitSetup()
4510 game_status = GAME_MODE_MAIN;
4512 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4518 static void execSaveAndExitSetup()
4524 static struct TokenInfo setup_info_main[] =
4526 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4527 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4528 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4529 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4530 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4531 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4532 { TYPE_ENTER_MENU, execSetupShortcuts1, "Key Shortcuts 1" },
4533 { TYPE_ENTER_MENU, execSetupShortcuts2, "Key Shortcuts 2" },
4534 { TYPE_EMPTY, NULL, "" },
4535 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4536 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4541 static struct TokenInfo setup_info_game[] =
4543 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4544 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4545 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4546 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4547 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4548 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4549 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4550 { TYPE_STRING, &game_speed_text, "" },
4551 { TYPE_EMPTY, NULL, "" },
4552 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4557 static struct TokenInfo setup_info_editor[] =
4560 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4561 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4562 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4563 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4564 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4565 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4566 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4567 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4569 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4570 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4571 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4573 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4575 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4576 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4577 { TYPE_EMPTY, NULL, "" },
4579 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4580 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4581 { TYPE_EMPTY, NULL, "" },
4583 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4584 { TYPE_EMPTY, NULL, "" },
4585 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4590 static struct TokenInfo setup_info_graphics[] =
4592 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4593 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4594 { TYPE_STRING, &screen_mode_text, "" },
4596 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
4598 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay Value:" },
4599 { TYPE_STRING, &scroll_delay_text, "" },
4601 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" },
4602 { TYPE_SWITCH, &setup.double_buffering,"Double-Buffering:" },
4604 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4605 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4606 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4607 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4608 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4609 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4610 { TYPE_EMPTY, NULL, "" },
4611 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4616 static struct TokenInfo setup_info_sound[] =
4618 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4619 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4620 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4621 { TYPE_EMPTY, NULL, "" },
4622 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4627 static struct TokenInfo setup_info_artwork[] =
4629 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4630 { TYPE_STRING, &graphics_set_name, "" },
4631 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4632 { TYPE_STRING, &sounds_set_name, "" },
4633 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4634 { TYPE_STRING, &music_set_name, "" },
4635 { TYPE_EMPTY, NULL, "" },
4637 { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
4638 { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:" },
4639 { TYPE_YES_NO, &setup.override_level_music, "Override Level Music:" },
4641 { TYPE_STRING, NULL, "Override Level Artwork:"},
4642 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
4643 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
4644 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
4646 { TYPE_EMPTY, NULL, "" },
4647 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4652 static struct TokenInfo setup_info_input[] =
4654 { TYPE_SWITCH, NULL, "Player:" },
4655 { TYPE_SWITCH, NULL, "Device:" },
4656 { TYPE_ENTER_MENU, NULL, "" },
4657 { TYPE_EMPTY, NULL, "" },
4658 { TYPE_EMPTY, NULL, "" },
4659 { TYPE_EMPTY, NULL, "" },
4660 { TYPE_EMPTY, NULL, "" },
4661 { TYPE_EMPTY, NULL, "" },
4662 { TYPE_EMPTY, NULL, "" },
4663 { TYPE_EMPTY, NULL, "" },
4664 { TYPE_EMPTY, NULL, "" },
4665 { TYPE_EMPTY, NULL, "" },
4666 { TYPE_EMPTY, NULL, "" },
4667 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4672 static struct TokenInfo setup_info_shortcuts_1[] =
4674 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4675 { TYPE_KEY, &setup.shortcut.save_game, "" },
4676 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4677 { TYPE_KEY, &setup.shortcut.load_game, "" },
4678 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4679 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4680 { TYPE_EMPTY, NULL, "" },
4681 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4682 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4683 { TYPE_EMPTY, NULL, "" },
4684 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4689 static struct TokenInfo setup_info_shortcuts_2[] =
4691 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4692 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4693 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4694 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4695 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4696 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4697 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4698 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4699 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4700 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4701 { TYPE_EMPTY, NULL, "" },
4702 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4707 static Key getSetupKey()
4709 Key key = KSYM_UNDEFINED;
4710 boolean got_key_event = FALSE;
4712 while (!got_key_event)
4714 if (PendingEvent()) /* got event */
4722 case EVENT_KEYPRESS:
4724 key = GetEventKey((KeyEvent *)&event, TRUE);
4726 /* press 'Escape' or 'Enter' to keep the existing key binding */
4727 if (key == KSYM_Escape || key == KSYM_Return)
4728 key = KSYM_UNDEFINED; /* keep old value */
4730 got_key_event = TRUE;
4734 case EVENT_KEYRELEASE:
4735 key_joystick_mapping = 0;
4739 HandleOtherEvents(&event);
4747 /* don't eat all CPU time */
4754 static int getSetupTextFont(int type)
4756 if (type & (TYPE_SWITCH |
4767 static int getSetupValueFont(int type, void *value)
4769 if (type & TYPE_KEY)
4770 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
4771 else if (type & TYPE_STRING)
4772 return FONT_VALUE_2;
4773 else if (type & TYPE_ECS_AGA)
4774 return FONT_VALUE_1;
4775 else if (type & TYPE_BOOLEAN_STYLE)
4776 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
4778 return FONT_VALUE_1;
4781 static void drawSetupValue(int pos)
4783 boolean font_draw_xoffset_modified = FALSE;
4784 int font_draw_xoffset_old = -1;
4785 int xpos = MENU_SCREEN_VALUE_XPOS;
4786 int ypos = MENU_SCREEN_START_YPOS + pos;
4787 int startx = mSX + xpos * 32;
4788 int starty = mSY + ypos * 32;
4789 int font_nr, font_width;
4790 int type = setup_info[pos].type;
4791 void *value = setup_info[pos].value;
4792 char *value_string = getSetupValue(type, value);
4795 if (value_string == NULL)
4798 if (type & TYPE_KEY)
4800 xpos = MENU_SCREEN_START_XPOS;
4802 if (type & TYPE_QUERY)
4804 value_string = "<press key>";
4807 else if (type & TYPE_STRING)
4809 int max_value_len = (SCR_FIELDX - 2) * 2;
4811 xpos = MENU_SCREEN_START_XPOS;
4813 if (strlen(value_string) > max_value_len)
4814 value_string[max_value_len] = '\0';
4817 startx = mSX + xpos * 32;
4818 starty = mSY + ypos * 32;
4819 font_nr = getSetupValueFont(type, value);
4820 font_width = getFontWidth(font_nr);
4822 /* downward compatibility correction for Juergen Bonhagen's menu settings */
4823 if (setup_mode != SETUP_MODE_INPUT)
4825 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
4826 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
4827 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
4828 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
4829 int text_font_nr = getSetupTextFont(FONT_MENU_2);
4830 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
4831 int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr);
4832 boolean correct_font_draw_xoffset = FALSE;
4834 if (xpos == MENU_SCREEN_START_XPOS &&
4835 startx + font1_xoffset < text_startx + text_font_xoffset)
4836 correct_font_draw_xoffset = TRUE;
4838 if (xpos == MENU_SCREEN_VALUE_XPOS &&
4839 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
4840 correct_font_draw_xoffset = TRUE;
4842 /* check if setup value would overlap with setup text when printed */
4843 /* (this can happen for extreme/wrong values for font draw offset) */
4844 if (correct_font_draw_xoffset)
4846 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
4847 font_draw_xoffset_modified = TRUE;
4849 if (type & TYPE_KEY)
4850 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
4851 else if (!(type & TYPE_STRING))
4852 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
4853 MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
4857 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
4858 DrawText(startx + i * font_width, starty, " ", font_nr);
4860 DrawText(startx, starty, value_string, font_nr);
4862 if (font_draw_xoffset_modified)
4863 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
4866 static void changeSetupValue(int pos)
4868 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
4870 *(boolean *)setup_info[pos].value ^= TRUE;
4872 else if (setup_info[pos].type & TYPE_KEY)
4876 setup_info[pos].type |= TYPE_QUERY;
4877 drawSetupValue(pos);
4878 setup_info[pos].type &= ~TYPE_QUERY;
4880 key = getSetupKey();
4881 if (key != KSYM_UNDEFINED)
4882 *(Key *)setup_info[pos].value = key;
4885 drawSetupValue(pos);
4888 static void DrawCursorAndText_Setup(int pos, boolean active)
4890 int xpos = MENU_SCREEN_START_XPOS;
4891 int ypos = MENU_SCREEN_START_YPOS + pos;
4892 int font_nr = getSetupTextFont(setup_info[pos].type);
4894 if (setup_info == setup_info_input)
4895 font_nr = FONT_MENU_1;
4898 font_nr = FONT_ACTIVE(font_nr);
4900 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
4902 if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
4903 drawCursor(pos, active);
4906 static void DrawSetupScreen_Generic()
4908 boolean redraw_all = FALSE;
4909 char *title_string = NULL;
4913 CloseDoor(DOOR_CLOSE_2);
4915 if (redraw_mask & REDRAW_ALL)
4918 printf("::: %s\n", (redraw_mask & REDRAW_FIELD ? "REDRAW_FIELD" :
4919 redraw_mask & REDRAW_ALL ? "REDRAW_ALL" :
4920 int2str(0, redraw_mask)));
4923 FadeOut(redraw_mask);
4925 FadeOut(REDRAW_FIELD);
4930 if (setup_mode == SETUP_MODE_MAIN)
4932 setup_info = setup_info_main;
4933 title_string = "Setup";
4935 else if (setup_mode == SETUP_MODE_GAME)
4937 setup_info = setup_info_game;
4938 title_string = "Setup Game";
4940 else if (setup_mode == SETUP_MODE_EDITOR)
4942 setup_info = setup_info_editor;
4943 title_string = "Setup Editor";
4945 else if (setup_mode == SETUP_MODE_GRAPHICS)
4947 setup_info = setup_info_graphics;
4948 title_string = "Setup Graphics";
4950 else if (setup_mode == SETUP_MODE_SOUND)
4952 setup_info = setup_info_sound;
4953 title_string = "Setup Sound";
4955 else if (setup_mode == SETUP_MODE_ARTWORK)
4957 setup_info = setup_info_artwork;
4958 title_string = "Custom Artwork";
4960 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
4962 setup_info = setup_info_shortcuts_1;
4963 title_string = "Setup Shortcuts";
4965 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
4967 setup_info = setup_info_shortcuts_2;
4968 title_string = "Setup Shortcuts";
4971 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
4974 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4976 void *value_ptr = setup_info[i].value;
4979 int xpos = MENU_SCREEN_START_XPOS;
4980 int ypos = MENU_SCREEN_START_YPOS + i;
4984 /* set some entries to "unchangeable" according to other variables */
4985 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
4986 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
4987 (value_ptr == &setup.sound_music && !audio.music_available) ||
4988 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
4989 (value_ptr == &screen_mode_text && !video.fullscreen_available))
4990 setup_info[i].type |= TYPE_GHOSTED;
4992 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
4993 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
4994 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
4995 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
4996 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
4997 initCursor(i, IMG_MENU_BUTTON);
5000 DrawCursorAndText_Setup(i, FALSE);
5002 font_nr = getSetupTextFont(setup_info[i].type);
5004 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr);
5007 if (setup_info[i].type & TYPE_VALUE)
5014 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5015 "Joysticks deactivated in setup menu");
5019 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5023 redraw_mask = REDRAW_ALL;
5026 FadeIn(redraw_mask);
5028 FadeIn(REDRAW_FIELD);
5033 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5037 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5039 static int choice_store[MAX_SETUP_MODES];
5040 int choice = choice_store[setup_mode]; /* always starts with 0 */
5044 if (button == MB_MENU_INITIALIZE)
5046 /* advance to first valid menu entry */
5047 while (choice < num_setup_info &&
5048 setup_info[choice].type & TYPE_SKIP_ENTRY)
5050 choice_store[setup_mode] = choice;
5053 DrawCursorAndText_Setup(choice, TRUE);
5055 drawCursor(choice, TRUE);
5060 else if (button == MB_MENU_LEAVE)
5062 PlaySound(SND_MENU_ITEM_SELECTING);
5064 for (y = 0; y < num_setup_info; y++)
5066 if (setup_info[y].type & TYPE_LEAVE_MENU)
5068 void (*menu_callback_function)(void) = setup_info[y].value;
5072 menu_callback_function();
5074 break; /* absolutely needed because function changes 'setup_info'! */
5081 if (mx || my) /* mouse input */
5083 x = (mx - mSX) / 32;
5084 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5086 else if (dx || dy) /* keyboard input */
5090 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5092 if (setup_info[choice].type & menu_navigation_type ||
5093 setup_info[choice].type & TYPE_BOOLEAN_STYLE)
5094 button = MB_MENU_CHOICE;
5099 /* jump to next non-empty menu entry (up or down) */
5100 while (y > 0 && y < num_setup_info - 1 &&
5101 setup_info[y].type & TYPE_SKIP_ENTRY)
5105 if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
5109 if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
5111 PlaySound(SND_MENU_ITEM_ACTIVATING);
5114 DrawCursorAndText_Setup(choice, FALSE);
5115 DrawCursorAndText_Setup(y, TRUE);
5117 drawCursor(choice, FALSE);
5118 drawCursor(y, TRUE);
5121 choice = choice_store[setup_mode] = y;
5124 else if (!(setup_info[y].type & TYPE_GHOSTED))
5126 PlaySound(SND_MENU_ITEM_SELECTING);
5128 /* when selecting key headline, execute function for key value change */
5129 if (setup_info[y].type & TYPE_KEYTEXT &&
5130 setup_info[y + 1].type & TYPE_KEY)
5133 /* when selecting string value, execute function for list selection */
5134 if (setup_info[y].type & TYPE_STRING && y > 0 &&
5135 setup_info[y - 1].type & TYPE_ENTER_LIST)
5138 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
5140 void (*menu_callback_function)(void) = setup_info[y].value;
5142 FadeSetFromType(setup_info[y].type);
5144 menu_callback_function();
5148 if (setup_info[y].type & TYPE_VALUE)
5149 changeSetupValue(y);
5155 void DrawSetupScreen_Input()
5162 FadeOut(REDRAW_FIELD);
5168 setup_info = setup_info_input;
5171 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5174 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5176 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5177 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5178 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5179 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5180 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5181 initCursor(i, IMG_MENU_BUTTON);
5183 DrawCursorAndText_Setup(i, FALSE);
5186 initCursor(0, IMG_MENU_BUTTON);
5187 initCursor(1, IMG_MENU_BUTTON);
5188 initCursor(2, IMG_MENU_BUTTON_ENTER_MENU);
5189 initCursor(13, IMG_MENU_BUTTON_LEAVE_MENU);
5191 DrawText(mSX + 32, mSY + 2 * 32, "Player:", FONT_MENU_1);
5192 DrawText(mSX + 32, mSY + 3 * 32, "Device:", FONT_MENU_1);
5193 DrawText(mSX + 32, mSY + 15 * 32, "Back", FONT_MENU_1);
5197 DeactivateJoystickForCalibration();
5200 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5201 "Joysticks deactivated on this screen");
5204 /* create gadgets for setup input menu screen */
5205 FreeScreenGadgets();
5206 CreateScreenGadgets();
5208 /* map gadgets for setup input menu screen */
5209 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5211 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5214 FadeIn(REDRAW_FIELD);
5220 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5222 if (device_name == NULL)
5225 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5228 if (strlen(device_name) > 1)
5230 char c1 = device_name[strlen(device_name) - 1];
5231 char c2 = device_name[strlen(device_name) - 2];
5233 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5234 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5237 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5238 strlen(device_name));
5241 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5244 static struct SetupKeyboardInfo custom_key;
5251 { &custom_key.left, "Joystick Left" },
5252 { &custom_key.right, "Joystick Right" },
5253 { &custom_key.up, "Joystick Up" },
5254 { &custom_key.down, "Joystick Down" },
5255 { &custom_key.snap, "Button 1" },
5256 { &custom_key.drop, "Button 2" }
5258 static char *joystick_name[MAX_PLAYERS] =
5265 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5269 custom_key = setup.input[player_nr].key;
5271 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5272 FONT_INPUT_1_ACTIVE);
5274 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5276 DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5277 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5279 if (setup.input[player_nr].use_joystick)
5281 char *device_name = setup.input[player_nr].joy.device_name;
5282 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5283 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5285 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5286 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5290 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5291 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5294 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5296 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5297 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5298 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5299 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5301 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5302 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5303 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5304 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5305 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5306 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5308 for (i = 0; i < 6; i++)
5310 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5312 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5314 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5315 (setup.input[player_nr].use_joystick ?
5317 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5321 static int input_player_nr = 0;
5323 void HandleSetupScreen_Input_Player(int step, int direction)
5325 int old_player_nr = input_player_nr;
5328 new_player_nr = old_player_nr + step * direction;
5329 if (new_player_nr < 0)
5331 if (new_player_nr > MAX_PLAYERS - 1)
5332 new_player_nr = MAX_PLAYERS - 1;
5334 if (new_player_nr != old_player_nr)
5336 input_player_nr = new_player_nr;
5338 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5342 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5344 static int choice = 0;
5347 int pos_start = SETUPINPUT_SCREEN_POS_START;
5348 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5349 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5350 int pos_end = SETUPINPUT_SCREEN_POS_END;
5352 if (button == MB_MENU_INITIALIZE)
5354 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5357 DrawCursorAndText_Setup(choice, TRUE);
5359 drawCursor(choice, TRUE);
5364 else if (button == MB_MENU_LEAVE)
5366 setup_mode = SETUP_MODE_MAIN;
5373 if (mx || my) /* mouse input */
5375 x = (mx - mSX) / 32;
5376 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5378 else if (dx || dy) /* keyboard input */
5380 if (dx && choice == 0)
5381 x = (dx < 0 ? 10 : 12);
5382 else if ((dx && choice == 1) ||
5383 (dx == +1 && choice == 2) ||
5384 (dx == -1 && choice == pos_end))
5385 button = MB_MENU_CHOICE;
5389 if (y >= pos_empty1 && y <= pos_empty2)
5390 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5393 if (y == 0 && dx != 0 && button)
5395 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5397 else if (IN_VIS_FIELD(x, y) &&
5398 y >= pos_start && y <= pos_end &&
5399 !(y >= pos_empty1 && y <= pos_empty2))
5406 DrawCursorAndText_Setup(choice, FALSE);
5407 DrawCursorAndText_Setup(y, TRUE);
5409 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5411 drawCursor(choice, FALSE);
5412 drawCursor(y, TRUE);
5422 char *device_name = setup.input[input_player_nr].joy.device_name;
5424 if (!setup.input[input_player_nr].use_joystick)
5426 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5428 setJoystickDeviceToNr(device_name, new_device_nr);
5429 setup.input[input_player_nr].use_joystick = TRUE;
5433 int device_nr = getJoystickNrFromDeviceName(device_name);
5434 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5436 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5437 setup.input[input_player_nr].use_joystick = FALSE;
5439 setJoystickDeviceToNr(device_name, new_device_nr);
5442 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5446 if (setup.input[input_player_nr].use_joystick)
5449 CalibrateJoystick(input_player_nr);
5452 CustomizeKeyboard(input_player_nr);
5454 else if (y == pos_end)
5460 setup_mode = SETUP_MODE_MAIN;
5467 void CustomizeKeyboard(int player_nr)
5471 boolean finished = FALSE;
5472 static struct SetupKeyboardInfo custom_key;
5477 } customize_step[] =
5479 { &custom_key.left, "Move Left" },
5480 { &custom_key.right, "Move Right" },
5481 { &custom_key.up, "Move Up" },
5482 { &custom_key.down, "Move Down" },
5483 { &custom_key.snap, "Snap Field" },
5484 { &custom_key.drop, "Drop Element" }
5487 /* read existing key bindings from player setup */
5488 custom_key = setup.input[player_nr].key;
5491 FadeOut(REDRAW_FIELD);
5495 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5503 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5504 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5505 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5506 "Key:", FONT_INPUT_1_ACTIVE);
5507 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5508 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5511 FadeIn(REDRAW_FIELD);
5518 if (PendingEvent()) /* got event */
5526 case EVENT_KEYPRESS:
5528 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5530 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5532 if (key == KSYM_Escape)
5533 FadeSkipNextFadeIn();
5539 /* all keys configured -- wait for "Escape" or "Return" key */
5543 /* press 'Enter' to keep the existing key binding */
5544 if (key == KSYM_Return)
5545 key = *customize_step[step_nr].key;
5547 /* check if key already used */
5548 for (i = 0; i < step_nr; i++)
5549 if (*customize_step[i].key == key)
5554 /* got new key binding */
5555 *customize_step[step_nr].key = key;
5556 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5558 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5559 getKeyNameFromKey(key), FONT_VALUE_1);
5562 /* un-highlight last query */
5563 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
5564 customize_step[step_nr - 1].text, FONT_MENU_1);
5565 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
5566 "Key:", FONT_MENU_1);
5568 /* press 'Enter' to leave */
5571 DrawText(mSX + 16, mSY + 15 * 32 + 16,
5572 "Press Enter", FONT_TITLE_1);
5576 /* query next key binding */
5577 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5578 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5579 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5580 "Key:", FONT_INPUT_1_ACTIVE);
5581 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5582 getKeyNameFromKey(*customize_step[step_nr].key),
5587 case EVENT_KEYRELEASE:
5588 key_joystick_mapping = 0;
5592 HandleOtherEvents(&event);
5600 /* don't eat all CPU time */
5604 /* write new key bindings back to player setup */
5605 setup.input[player_nr].key = custom_key;
5608 DrawSetupScreen_Input();
5611 static boolean CalibrateJoystickMain(int player_nr)
5613 int new_joystick_xleft = JOYSTICK_XMIDDLE;
5614 int new_joystick_xright = JOYSTICK_XMIDDLE;
5615 int new_joystick_yupper = JOYSTICK_YMIDDLE;
5616 int new_joystick_ylower = JOYSTICK_YMIDDLE;
5617 int new_joystick_xmiddle, new_joystick_ymiddle;
5619 int joystick_fd = joystick.fd[player_nr];
5620 int x, y, last_x, last_y, xpos = 8, ypos = 3;
5621 boolean check[3][3];
5622 int check_remaining = 3 * 3;
5627 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
5630 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
5634 FadeOut(REDRAW_FIELD);
5638 for (y = 0; y < 3; y++)
5640 for (x = 0; x < 3; x++)
5642 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
5643 check[x][y] = FALSE;
5647 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
5648 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
5649 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
5650 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
5651 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
5652 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
5653 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
5655 joy_value = Joystick(player_nr);
5656 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5657 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5659 /* eventually uncalibrated center position (joystick could be uncentered) */
5660 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5663 new_joystick_xmiddle = joy_x;
5664 new_joystick_ymiddle = joy_y;
5666 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
5669 FadeIn(REDRAW_FIELD);
5674 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
5679 if (PendingEvent()) /* got event */
5687 case EVENT_KEYPRESS:
5688 switch (GetEventKey((KeyEvent *)&event, TRUE))
5691 if (check_remaining == 0)
5696 FadeSkipNextFadeIn();
5705 case EVENT_KEYRELEASE:
5706 key_joystick_mapping = 0;
5710 HandleOtherEvents(&event);
5715 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5718 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
5719 new_joystick_xright = MAX(new_joystick_xright, joy_x);
5720 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
5721 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
5723 setup.input[player_nr].joy.xleft = new_joystick_xleft;
5724 setup.input[player_nr].joy.yupper = new_joystick_yupper;
5725 setup.input[player_nr].joy.xright = new_joystick_xright;
5726 setup.input[player_nr].joy.ylower = new_joystick_ylower;
5727 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
5728 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
5730 CheckJoystickData();
5732 joy_value = Joystick(player_nr);
5734 if (joy_value & JOY_BUTTON && check_remaining == 0)
5737 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5738 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5740 if (x != last_x || y != last_y)
5742 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0);
5743 DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0);
5748 if (check_remaining > 0 && !check[x+1][y+1])
5750 check[x+1][y+1] = TRUE;
5756 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
5757 setup.input[player_nr].joy.xleft,
5758 setup.input[player_nr].joy.xmiddle,
5759 setup.input[player_nr].joy.xright);
5760 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
5761 setup.input[player_nr].joy.yupper,
5762 setup.input[player_nr].joy.ymiddle,
5763 setup.input[player_nr].joy.ylower);
5772 /* don't eat all CPU time */
5776 /* calibrated center position (joystick should now be centered) */
5777 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5780 new_joystick_xmiddle = joy_x;
5781 new_joystick_ymiddle = joy_y;
5786 DrawSetupScreen_Input();
5789 /* wait until the last pressed button was released */
5790 while (Joystick(player_nr) & JOY_BUTTON)
5792 if (PendingEvent()) /* got event */
5797 HandleOtherEvents(&event);
5806 void CalibrateJoystick(int player_nr)
5808 if (!CalibrateJoystickMain(player_nr))
5810 char *device_name = setup.input[player_nr].joy.device_name;
5811 int nr = getJoystickNrFromDeviceName(device_name) + 1;
5812 int xpos = mSX - SX;
5813 int ypos = mSY - SY;
5817 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
5818 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
5821 Delay(2000); /* show error message for a short time */
5827 DrawSetupScreen_Input();
5831 void DrawSetupScreen()
5833 DeactivateJoystick();
5835 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
5837 if (setup_mode == SETUP_MODE_INPUT)
5838 DrawSetupScreen_Input();
5839 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5840 DrawChooseTree(&game_speed_current);
5841 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5842 DrawChooseTree(&screen_mode_current);
5843 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5844 DrawChooseTree(&scroll_delay_current);
5845 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5846 DrawChooseTree(&artwork.gfx_current);
5847 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5848 DrawChooseTree(&artwork.snd_current);
5849 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5850 DrawChooseTree(&artwork.mus_current);
5852 DrawSetupScreen_Generic();
5858 void RedrawSetupScreenAfterFullscreenToggle()
5860 if (setup_mode == SETUP_MODE_GRAPHICS)
5864 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
5866 if (setup_mode == SETUP_MODE_INPUT)
5867 HandleSetupScreen_Input(mx, my, dx, dy, button);
5868 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5869 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
5870 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5871 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
5872 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5873 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
5874 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5875 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
5876 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5877 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
5878 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5879 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
5881 HandleSetupScreen_Generic(mx, my, dx, dy, button);
5886 void HandleGameActions()
5888 if (game_status != GAME_MODE_PLAYING)
5891 GameActions(); /* main game loop */
5893 if (tape.auto_play && !tape.playing)
5894 AutoPlayTape(); /* continue automatically playing next tape */
5898 /* ---------- new screen button stuff -------------------------------------- */
5900 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
5905 case SCREEN_CTRL_ID_PREV_LEVEL:
5906 *x = mSX + menu.main.button.prev_level.x;
5907 *y = mSY + menu.main.button.prev_level.y;
5910 case SCREEN_CTRL_ID_NEXT_LEVEL:
5911 *x = mSX + menu.main.button.next_level.x;
5912 *y = mSY + menu.main.button.next_level.y;
5915 case SCREEN_CTRL_ID_PREV_LEVEL:
5916 *x = mSX + TILEX * getPrevlevelButtonPos();
5917 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5920 case SCREEN_CTRL_ID_NEXT_LEVEL:
5921 *x = mSX + TILEX * getNextLevelButtonPos();
5922 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5926 case SCREEN_CTRL_ID_PREV_PLAYER:
5927 *x = mSX + TILEX * 10;
5928 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5931 case SCREEN_CTRL_ID_NEXT_PLAYER:
5932 *x = mSX + TILEX * 12;
5933 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5937 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
5943 int gfx_unpressed, gfx_pressed;
5944 void (*get_gadget_position)(int *, int *, int);
5948 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
5951 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
5952 getScreenMenuButtonPos,
5953 SCREEN_CTRL_ID_PREV_LEVEL,
5958 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
5959 getScreenMenuButtonPos,
5960 SCREEN_CTRL_ID_NEXT_LEVEL,
5965 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
5966 getScreenMenuButtonPos,
5967 SCREEN_CTRL_ID_PREV_PLAYER,
5972 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
5973 getScreenMenuButtonPos,
5974 SCREEN_CTRL_ID_NEXT_PLAYER,
5982 int gfx_unpressed, gfx_pressed;
5986 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
5989 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
5990 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
5991 SCREEN_CTRL_ID_SCROLL_UP,
5995 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
5996 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
5997 SCREEN_CTRL_ID_SCROLL_DOWN,
6004 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6005 Bitmap **gfx_unpressed, **gfx_pressed;
6007 int gfx_unpressed, gfx_pressed;
6014 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6017 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6018 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
6020 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6022 SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
6023 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
6024 GD_TYPE_SCROLLBAR_VERTICAL,
6025 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6026 "scroll level series vertically"
6030 static void CreateScreenMenubuttons()
6032 struct GadgetInfo *gi;
6033 unsigned long event_mask;
6036 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6038 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6039 int gfx_unpressed, gfx_pressed;
6040 int x, y, width, height;
6041 int gd_x1, gd_x2, gd_y1, gd_y2;
6042 int id = menubutton_info[i].gadget_id;
6044 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6046 menubutton_info[i].get_gadget_position(&x, &y, id);
6048 width = SC_MENUBUTTON_XSIZE;
6049 height = SC_MENUBUTTON_YSIZE;
6051 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6052 gfx_pressed = menubutton_info[i].gfx_pressed;
6053 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6054 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6055 gd_x1 = graphic_info[gfx_unpressed].src_x;
6056 gd_y1 = graphic_info[gfx_unpressed].src_y;
6057 gd_x2 = graphic_info[gfx_pressed].src_x;
6058 gd_y2 = graphic_info[gfx_pressed].src_y;
6060 gi = CreateGadget(GDI_CUSTOM_ID, id,
6061 GDI_CUSTOM_TYPE_ID, i,
6062 GDI_INFO_TEXT, menubutton_info[i].infotext,
6067 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6068 GDI_STATE, GD_BUTTON_UNPRESSED,
6069 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6070 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6071 GDI_DIRECT_DRAW, FALSE,
6072 GDI_EVENT_MASK, event_mask,
6073 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6077 Error(ERR_EXIT, "cannot create gadget");
6079 screen_gadget[id] = gi;
6083 static void CreateScreenScrollbuttons()
6085 struct GadgetInfo *gi;
6086 unsigned long event_mask;
6089 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6091 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6092 int gfx_unpressed, gfx_pressed;
6093 int x, y, width, height;
6094 int gd_x1, gd_x2, gd_y1, gd_y2;
6095 int id = scrollbutton_info[i].gadget_id;
6097 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6099 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6100 y = mSY + scrollbutton_info[i].y;
6101 width = SC_SCROLLBUTTON_XSIZE;
6102 height = SC_SCROLLBUTTON_YSIZE;
6104 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6105 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6106 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6108 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6109 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6110 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6111 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6112 gd_x1 = graphic_info[gfx_unpressed].src_x;
6113 gd_y1 = graphic_info[gfx_unpressed].src_y;
6114 gd_x2 = graphic_info[gfx_pressed].src_x;
6115 gd_y2 = graphic_info[gfx_pressed].src_y;
6117 gi = CreateGadget(GDI_CUSTOM_ID, id,
6118 GDI_CUSTOM_TYPE_ID, i,
6119 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6124 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6125 GDI_STATE, GD_BUTTON_UNPRESSED,
6126 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6127 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6128 GDI_DIRECT_DRAW, FALSE,
6129 GDI_EVENT_MASK, event_mask,
6130 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6134 Error(ERR_EXIT, "cannot create gadget");
6136 screen_gadget[id] = gi;
6140 static void CreateScreenScrollbars()
6144 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6146 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6147 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6148 int gfx_unpressed, gfx_pressed;
6150 int x, y, width, height;
6151 int gd_x1, gd_x2, gd_y1, gd_y2;
6152 struct GadgetInfo *gi;
6153 int items_max, items_visible, item_position;
6154 unsigned long event_mask;
6155 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6156 int id = scrollbar_info[i].gadget_id;
6158 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6160 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6161 y = mSY + scrollbar_info[i].y;
6162 width = scrollbar_info[i].width;
6163 height = scrollbar_info[i].height;
6165 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6166 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6168 items_max = num_page_entries;
6169 items_visible = num_page_entries;
6172 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6173 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
6174 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
6180 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6181 gfx_pressed = scrollbar_info[i].gfx_pressed;
6182 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6183 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6184 gd_x1 = graphic_info[gfx_unpressed].src_x;
6185 gd_y1 = graphic_info[gfx_unpressed].src_y;
6186 gd_x2 = graphic_info[gfx_pressed].src_x;
6187 gd_y2 = graphic_info[gfx_pressed].src_y;
6190 gi = CreateGadget(GDI_CUSTOM_ID, id,
6191 GDI_CUSTOM_TYPE_ID, i,
6192 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6197 GDI_TYPE, scrollbar_info[i].type,
6198 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6199 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6200 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6202 GDI_WHEEL_AREA_X, SX,
6203 GDI_WHEEL_AREA_Y, SY,
6204 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6205 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6207 GDI_WHEEL_AREA_X, 0,
6208 GDI_WHEEL_AREA_Y, 0,
6209 GDI_WHEEL_AREA_WIDTH, WIN_XSIZE,
6210 GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE,
6212 GDI_STATE, GD_BUTTON_UNPRESSED,
6213 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6214 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6215 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6216 GDI_DIRECT_DRAW, FALSE,
6217 GDI_EVENT_MASK, event_mask,
6218 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6222 Error(ERR_EXIT, "cannot create gadget");
6224 screen_gadget[id] = gi;
6228 void CreateScreenGadgets()
6230 int last_game_status = game_status; /* save current game status */
6232 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6235 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6237 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
6239 /* copy pointers to clip mask and GC */
6240 scrollbar_bitmap[i]->clip_mask =
6241 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
6242 scrollbar_bitmap[i]->stored_clip_gc =
6243 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
6245 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
6246 scrollbar_bitmap[i],
6247 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
6248 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
6249 TILEX, TILEY, 0, 0);
6253 CreateScreenMenubuttons();
6256 /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */
6257 game_status = GAME_MODE_LEVELS;
6260 CreateScreenScrollbuttons();
6261 CreateScreenScrollbars();
6263 game_status = last_game_status; /* restore current game status */
6266 void FreeScreenGadgets()
6270 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6271 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6273 /* prevent freeing clip mask and GC twice */
6274 scrollbar_bitmap[i]->clip_mask = None;
6275 scrollbar_bitmap[i]->stored_clip_gc = None;
6277 FreeBitmap(scrollbar_bitmap[i]);
6281 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6282 FreeGadget(screen_gadget[i]);
6285 void MapScreenMenuGadgets(int screen_mask)
6289 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6290 if (screen_mask & menubutton_info[i].screen_mask)
6291 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6294 void MapScreenTreeGadgets(TreeInfo *ti)
6296 int num_entries = numTreeInfoInGroup(ti);
6299 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6302 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6303 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6305 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6306 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6309 static void HandleScreenGadgets(struct GadgetInfo *gi)
6311 int id = gi->custom_id;
6312 int button = gi->event.button;
6313 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6317 case SCREEN_CTRL_ID_PREV_LEVEL:
6318 HandleMainMenu_SelectLevel(step, -1);
6321 case SCREEN_CTRL_ID_NEXT_LEVEL:
6322 HandleMainMenu_SelectLevel(step, +1);
6325 case SCREEN_CTRL_ID_PREV_PLAYER:
6326 HandleSetupScreen_Input_Player(step, -1);
6329 case SCREEN_CTRL_ID_NEXT_PLAYER:
6330 HandleSetupScreen_Input_Player(step, +1);
6333 case SCREEN_CTRL_ID_SCROLL_UP:
6334 if (game_status == GAME_MODE_LEVELS)
6335 HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6336 else if (game_status == GAME_MODE_SETUP)
6337 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6340 case SCREEN_CTRL_ID_SCROLL_DOWN:
6341 if (game_status == GAME_MODE_LEVELS)
6342 HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6343 else if (game_status == GAME_MODE_SETUP)
6344 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6347 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6348 if (game_status == GAME_MODE_LEVELS)
6349 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
6350 else if (game_status == GAME_MODE_SETUP)
6351 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);