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 /* skip images and messages (fonts!) when using forced custom graphics */
752 if (setup.override_level_graphics && !initial)
757 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
760 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
762 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
763 char *filename = getLevelSetTitleMessageFilename(i, initial);
764 int sort_priority = tmi->sort_priority;
767 /* skip images and messages (fonts!) when using forced custom graphics */
768 if (setup.override_level_graphics)
772 if (filename != NULL)
773 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
777 static void InitializeTitleControls(boolean show_title_initial)
779 num_title_screens = 0;
782 if (show_title_initial)
783 InitializeTitleControls_CheckTitleInfo(TRUE);
786 InitializeTitleControls_CheckTitleInfo(FALSE);
788 /* sort title screens according to sort_priority and title number */
789 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
790 compareTitleControlInfo);
793 static boolean visibleMenuPos(struct MenuPosInfo *pos)
795 return (pos != NULL && pos->x != -1 && pos->y != -1);
798 static boolean visibleTextPos(struct TextPosInfo *pos)
800 return (pos != NULL && pos->x != -1 && pos->y != -1);
803 static void InitializeMainControls()
805 boolean local_team_mode = (!options.network && setup.team_mode);
808 /* set main control text values to dynamically determined values */
809 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
811 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
812 menu.main.text.first_level.size));
813 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
814 menu.main.text.last_level.size));
815 strcpy(main_text_level_number, int2str(level_nr,
816 menu.main.text.level_number.size));
818 main_text_level_year = leveldir_current->year;
819 main_text_level_imported_from = leveldir_current->imported_from;
820 main_text_level_imported_by = leveldir_current->imported_by;
821 main_text_level_tested_by = leveldir_current->tested_by;
823 /* set main control screen positions to dynamically determined values */
824 for (i = 0; main_controls[i].nr != -1; i++)
826 struct MainControlInfo *mci = &main_controls[i];
828 struct MenuPosInfo *pos_button = mci->pos_button;
829 struct TextPosInfo *pos_text = mci->pos_text;
830 struct TextPosInfo *pos_input = mci->pos_input;
831 char *text = (mci->text ? *mci->text : NULL);
832 char *input = (mci->input ? *mci->input : NULL);
833 int button_graphic = mci->button_graphic;
835 int font_text = (pos_text ? pos_text->font : -1);
836 int font_input = (pos_input ? pos_input->font : -1);
838 int font_text = mci->font_text;
839 int font_input = mci->font_input;
842 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
843 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
844 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
845 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
846 int text_chars = (text != NULL ? strlen(text) : 0);
847 int input_chars = (input != NULL ? strlen(input) : 0);
850 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
852 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
853 int text_width = font_text_width * text_chars;
854 int text_height = font_text_height;
855 int input_width = font_input_width * input_chars;
856 int input_height = font_input_height;
858 if (nr == MAIN_CONTROL_NAME)
861 if (menu.main.input.name.x == -1)
862 menu.main.input.name.x = menu.main.text.name.x + text_width;
863 if (menu.main.input.name.y == -1)
864 menu.main.input.name.y = menu.main.text.name.y;
868 menu.main.input.name.width = input_width;
869 menu.main.input.name.height = input_height;
871 menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
872 menu.main.input.name.height = font_input_height;
876 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
878 if (pos_button->width == 0)
879 pos_button->width = button_width;
880 if (pos_button->height == 0)
881 pos_button->height = button_height;
884 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
886 /* calculate width for non-clickable text -- needed for text alignment */
887 boolean calculate_text_width = (pos_button == NULL && text != NULL);
889 if (visibleMenuPos(pos_button))
891 if (pos_text->x == -1)
892 pos_text->x = pos_button->x + pos_button->width;
893 if (pos_text->y == -1)
894 pos_text->y = pos_button->y;
897 if (pos_text->width == -1 || calculate_text_width)
898 pos_text->width = text_width;
899 if (pos_text->height == -1)
900 pos_text->height = text_height;
903 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
905 if (visibleTextPos(pos_text))
907 if (pos_input->x == -1)
908 pos_input->x = pos_text->x + pos_text->width;
909 if (pos_input->y == -1)
910 pos_input->y = pos_text->y;
913 if (pos_input->width == -1)
914 pos_input->width = input_width;
915 if (pos_input->height == -1)
916 pos_input->height = input_height;
921 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
922 boolean active_input)
926 for (i = 0; main_controls[i].nr != -1; i++)
928 struct MainControlInfo *mci = &main_controls[i];
930 if (mci->nr == nr || nr == -1)
932 struct MenuPosInfo *pos_button = mci->pos_button;
933 struct TextPosInfo *pos_text = mci->pos_text;
934 struct TextPosInfo *pos_input = mci->pos_input;
935 char *text = (mci->text ? *mci->text : NULL);
936 char *input = (mci->input ? *mci->input : NULL);
937 int button_graphic = mci->button_graphic;
939 int font_text = (pos_text ? pos_text->font : -1);
940 int font_input = (pos_input ? pos_input->font : -1);
942 int font_text = mci->font_text;
943 int font_input = mci->font_input;
948 button_graphic = BUTTON_ACTIVE(button_graphic);
949 font_text = FONT_ACTIVE(font_text);
954 font_input = FONT_ACTIVE(font_input);
957 if (visibleMenuPos(pos_button))
959 struct MenuPosInfo *pos = pos_button;
960 int x = mSX + pos->x;
961 int y = mSY + pos->y;
963 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
964 DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
967 if (visibleTextPos(pos_text) && text != NULL)
969 struct TextPosInfo *pos = pos_text;
970 int x = mSX + ALIGNED_TEXT_XPOS(pos);
971 int y = mSY + ALIGNED_TEXT_YPOS(pos);
974 /* (check why/if this is needed) */
975 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
977 DrawText(x, y, text, font_text);
980 if (visibleTextPos(pos_input) && input != NULL)
982 struct TextPosInfo *pos = pos_input;
983 int x = mSX + ALIGNED_TEXT_XPOS(pos);
984 int y = mSY + ALIGNED_TEXT_YPOS(pos);
987 /* (check why/if this is needed) */
988 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
990 DrawText(x, y, input, font_input);
996 static void DrawCursorAndText_Main(int nr, boolean active_text)
998 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1002 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1004 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1008 static struct MainControlInfo *getMainControlInfo(int nr)
1012 for (i = 0; main_controls[i].nr != -1; i++)
1013 if (main_controls[i].nr == nr)
1014 return &main_controls[i];
1019 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1024 int rect_x = ALIGNED_TEXT_XPOS(rect);
1025 int rect_y = ALIGNED_TEXT_YPOS(rect);
1027 return (x >= rect_x && x < rect_x + rect->width &&
1028 y >= rect_y && y < rect_y + rect->height);
1031 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1036 int rect_x = ALIGNED_TEXT_XPOS(rect);
1037 int rect_y = ALIGNED_TEXT_YPOS(rect);
1039 return (x >= rect_x && x < rect_x + rect->width &&
1040 y >= rect_y && y < rect_y + rect->height);
1043 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1045 static int cursor_array[SCR_FIELDY];
1046 int x = mSX + TILEX * xpos;
1047 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1052 cursor_array[ypos] = graphic;
1054 graphic = cursor_array[ypos];
1058 graphic = BUTTON_ACTIVE(graphic);
1060 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1061 DrawGraphicThruMaskExt(drawto, x, y, graphic, 0);
1064 static void initCursor(int ypos, int graphic)
1066 drawCursorExt(0, ypos, FALSE, graphic);
1069 static void drawCursor(int ypos, boolean active)
1071 drawCursorExt(0, ypos, active, -1);
1074 static void drawCursorXY(int xpos, int ypos, int graphic)
1076 drawCursorExt(xpos, ypos, FALSE, graphic);
1079 static void drawChooseTreeCursor(int ypos, boolean active)
1081 int last_game_status = game_status; /* save current game status */
1084 /* force LEVELS draw offset on artwork setup screen */
1085 game_status = GAME_MODE_LEVELS;
1088 drawCursorExt(0, ypos, active, -1);
1090 game_status = last_game_status; /* restore current game status */
1095 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1096 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1100 static int getPrevlevelButtonPos()
1105 static int getCurrentLevelTextPos()
1107 return (getPrevlevelButtonPos() + 1);
1110 static int getNextLevelButtonPos()
1112 return getPrevlevelButtonPos() + 3 + 1;
1115 static int getLevelRangeTextPos()
1117 return getNextLevelButtonPos() + 1;
1121 int effectiveGameStatus()
1123 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1124 return GAME_MODE_TITLE;
1129 void DrawTitleScreenImage(int nr, boolean initial)
1131 int graphic = getTitleScreenGraphic(nr, initial);
1132 Bitmap *bitmap = graphic_info[graphic].bitmap;
1134 int width = graphic_info[graphic].width;
1135 int height = graphic_info[graphic].height;
1136 int src_x = graphic_info[graphic].src_x;
1137 int src_y = graphic_info[graphic].src_y;
1139 int width = graphic_info[graphic].src_image_width;
1140 int height = graphic_info[graphic].src_image_height;
1141 int src_x = 0, src_y = 0;
1148 if (width > WIN_XSIZE)
1150 /* image width too large for window => center image horizontally */
1151 src_x = (width - WIN_XSIZE) / 2;
1155 if (height > WIN_YSIZE)
1157 /* image height too large for window => center image vertically */
1158 src_y = (height - WIN_YSIZE) / 2;
1162 /* always display title screens centered */
1163 dst_x = (WIN_XSIZE - width) / 2;
1164 dst_y = (WIN_YSIZE - height) / 2;
1166 SetDrawBackgroundMask(REDRAW_ALL);
1167 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1169 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1171 if (DrawingOnBackground(dst_x, dst_y))
1172 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1174 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1176 redraw_mask = REDRAW_ALL;
1178 /* reset fading control values to default config settings */
1182 title = getTitleFading(nr, initial, TRUE);
1187 title.fade_delay_final = title.fade_delay;
1188 title.post_delay_final = title.post_delay;
1189 title.auto_delay_final = title.auto_delay;
1191 /* override default settings with image config settings, if defined */
1192 if (graphic_info[graphic].anim_mode != ANIM_DEFAULT)
1193 title.anim_mode = graphic_info[graphic].anim_mode;
1194 if (graphic_info[graphic].fade_delay > -1)
1195 title.fade_delay = graphic_info[graphic].fade_delay;
1196 if (graphic_info[graphic].post_delay > -1)
1197 title.post_delay = graphic_info[graphic].post_delay;
1198 if (graphic_info[graphic].auto_delay > -1)
1199 title.auto_delay = graphic_info[graphic].auto_delay;
1203 void DrawTitleScreenMessage(int nr, boolean initial)
1205 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1206 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1208 int font_nr = FONT_TEXT_1;
1212 int pad_y = 32 + 14;
1215 int max_chars_per_line;
1216 int max_lines_per_screen;
1218 int last_game_status = game_status; /* save current game status */
1220 if (filename == NULL)
1223 /* force TITLE font on title message screen */
1224 game_status = getTitleMessageGameMode(initial);
1226 /* if chars set to "-1", automatically determine by text and font width */
1227 if (tmi->chars == -1)
1228 tmi->chars = tmi->width / getFontWidth(tmi->font);
1230 tmi->width = tmi->chars * getFontWidth(tmi->font);
1232 /* if lines set to "-1", automatically determine by text and font height */
1233 if (tmi->lines == -1)
1234 tmi->lines = tmi->height / getFontHeight(tmi->font);
1236 tmi->height = tmi->lines * getFontHeight(tmi->font);
1238 SetDrawBackgroundMask(REDRAW_ALL);
1239 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1241 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1244 font_width = getFontWidth(font_nr);
1245 font_height = getFontHeight(font_nr);
1246 max_chars_per_line = (WIN_XSIZE - 2 * pad_x) / font_width;
1247 max_lines_per_screen = (WIN_YSIZE - pad_y) / font_height - 1;
1251 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1252 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
1253 tmi->autowrap, tmi->centered, tmi->parse_comments);
1255 DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
1256 max_lines_per_screen, -1, tmi->autowrap, tmi->centered,
1257 tmi->parse_comments);
1260 game_status = last_game_status; /* restore current game status */
1263 void DrawTitleScreen()
1265 KeyboardAutoRepeatOff();
1268 SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
1271 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1276 boolean CheckTitleScreen(boolean levelset_has_changed)
1278 static boolean show_title_initial = TRUE;
1279 boolean show_titlescreen = FALSE;
1281 /* needed to be able to skip title screen, if no image or message defined */
1282 InitializeTitleControls(show_title_initial);
1284 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1285 show_titlescreen = TRUE;
1287 /* show initial title images and messages only once at program start */
1288 show_title_initial = FALSE;
1290 return (show_titlescreen && num_title_screens > 0);
1293 void DrawMainMenuExt(int redraw_mask, boolean do_fading)
1295 static LevelDirTree *leveldir_last_valid = NULL;
1296 boolean levelset_has_changed = FALSE;
1297 boolean redraw_all = FALSE;
1299 FadeSetLeaveScreen();
1301 /* (does not work well when changing to editor, which fades out itself) */
1303 FadeOut(redraw_mask);
1307 FadeSoundsAndMusic();
1309 KeyboardAutoRepeatOn();
1312 SetDrawDeactivationMask(REDRAW_NONE);
1313 SetDrawBackgroundMask(REDRAW_FIELD);
1315 audio.sound_deactivated = FALSE;
1319 /* needed if last screen was the playing screen, invoked from level editor */
1320 if (level_editor_test_game)
1322 game_status = GAME_MODE_EDITOR;
1329 FadeOut(redraw_mask);
1331 /* needed if last screen was the editor screen */
1332 UndrawSpecialEditorDoor();
1335 /* needed if last screen was the setup screen and fullscreen state changed */
1336 ToggleFullscreenIfNeeded();
1338 /* leveldir_current may be invalid (level group, parent link) */
1339 if (!validLevelSeries(leveldir_current))
1340 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1342 if (leveldir_current != leveldir_last_valid)
1343 levelset_has_changed = TRUE;
1345 /* store valid level series information */
1346 leveldir_last_valid = leveldir_current;
1348 /* needed if last screen (level choice) changed graphics, sounds or music */
1349 ReloadCustomArtwork(0);
1351 if (redraw_mask & REDRAW_ALL)
1356 printf("::: FadeOut @ DrawMainMenuExt ...\n");
1358 FadeOut(redraw_mask);
1360 printf("::: FadeOut @ DrawMainMenuExt done\n");
1363 /* needed if last screen was the editor screen */
1364 UndrawSpecialEditorDoor();
1367 #if defined(TARGET_SDL)
1368 SetDrawtoField(DRAW_BACKBUFFER);
1371 if (CheckTitleScreen(levelset_has_changed))
1373 game_status = GAME_MODE_TITLE;
1380 /* level_nr may have been set to value over handicap with level editor */
1381 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1382 level_nr = leveldir_current->handicap_level;
1384 LoadLevel(level_nr);
1386 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1389 FadeOut(redraw_mask);
1393 if (redraw_mask == REDRAW_ALL)
1395 // int door_state = GetDoorState();
1399 // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1405 InitializeMainControls();
1407 DrawCursorAndText_Main(-1, FALSE);
1408 DrawPreviewLevel(TRUE);
1410 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1413 if (TAPE_IS_EMPTY(tape))
1415 DrawCompleteVideoDisplay();
1420 /* create gadgets for main menu screen */
1421 FreeScreenGadgets();
1422 CreateScreenGadgets();
1424 /* map gadgets for main menu screen */
1426 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1429 DrawMaskedBorder(REDRAW_ALL);
1433 if (redraw_mask == REDRAW_ALL)
1435 int door_state = GetDoorState();
1437 // RedrawBackground();
1439 OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1444 DrawMaskedBorder(REDRAW_ALL);
1449 redraw_mask = REDRAW_ALL;
1452 FadeIn(redraw_mask);
1456 SetMouseCursor(CURSOR_DEFAULT);
1460 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1463 void DrawAndFadeInMainMenu(int redraw_mask)
1465 DrawMainMenuExt(redraw_mask, TRUE);
1470 DrawMainMenuExt(REDRAW_ALL, FALSE);
1474 static void gotoTopLevelDir()
1476 /* move upwards to top level directory */
1477 while (leveldir_current->node_parent)
1479 /* write a "path" into level tree for easy navigation to last level */
1480 if (leveldir_current->node_parent->node_group->cl_first == -1)
1482 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1483 int leveldir_pos = posTreeInfo(leveldir_current);
1484 int num_page_entries;
1485 int cl_first, cl_cursor;
1487 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1488 num_page_entries = num_leveldirs;
1490 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1492 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1493 cl_cursor = leveldir_pos - cl_first;
1495 leveldir_current->node_parent->node_group->cl_first = cl_first;
1496 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1499 leveldir_current = leveldir_current->node_parent;
1504 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1506 static unsigned long title_delay = 0;
1507 static int title_screen_nr = 0;
1508 static int last_sound = -1, last_music = -1;
1509 boolean return_to_main_menu = FALSE;
1510 boolean use_fading_main_menu = TRUE;
1513 boolean use_cross_fading = FALSE;
1515 boolean use_cross_fading = !show_title_initial; /* default */
1518 struct TitleControlInfo *tci;
1519 struct TitleFadingInfo fading_default;
1520 struct TitleFadingInfo fading_last = fading;
1521 struct TitleFadingInfo fading_next;
1524 if (button == MB_MENU_INITIALIZE)
1527 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1531 int last_game_status = game_status; /* save current game status */
1535 title_screen_nr = 0;
1536 tci = &title_controls[title_screen_nr];
1538 last_sound = SND_UNDEFINED;
1539 last_music = MUS_UNDEFINED;
1542 /* determine number of title screens to display (images and messages) */
1543 InitializeTitleControls();
1546 if (game_status == GAME_MODE_INFO)
1548 if (num_title_screens == 0)
1550 DrawInfoScreen_NotAvailable("Title screen information:",
1551 "No title screen for this level set.");
1554 /* use default settings for fading, but always disable auto delay */
1555 fading = title_default;
1556 fading.auto_delay = -1;
1562 FadeSoundsAndMusic();
1565 FadeOut(REDRAW_ALL);
1570 DrawTitleScreenImage(tci->local_nr, tci->initial);
1572 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1574 fading_default = (tci->initial ? title_initial_default : title_default);
1576 fading = fading_next = getTitleFading(tci);
1580 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1581 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1583 fading.fade_mode = FADE_MODE_FADE;
1584 fading.fade_delay = fading_default.fade_delay;
1587 if (fading_last.fade_mode != FADE_MODE_CROSSFADE &&
1588 fading_next.fade_mode == FADE_MODE_CROSSFADE)
1589 fading.fade_mode = FADE_MODE_FADE;
1594 sound = getTitleSound(tci);
1595 music = getTitleMusic(tci);
1597 if (sound != last_sound)
1598 PlayMenuSoundExt(sound);
1599 if (music != last_music)
1600 PlayMenuMusicExt(music);
1606 SetMouseCursor(CURSOR_NONE);
1608 // printf("::: mode: %d, delay: %d\n", fading.fade_mode, fading.fade_delay);
1614 fading = fading_next;
1616 DelayReached(&title_delay, 0); /* reset delay counter */
1622 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1623 button = MB_MENU_CHOICE;
1625 if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
1626 button = MB_MENU_CHOICE;
1629 if (button == MB_MENU_LEAVE)
1631 return_to_main_menu = TRUE;
1632 use_fading_main_menu = FALSE;
1634 else if (button == MB_MENU_CHOICE)
1637 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1640 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1643 FadeOut(REDRAW_FIELD);
1646 FadeSetEnterScreen();
1648 info_mode = INFO_MODE_MAIN;
1649 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1655 tci = &title_controls[title_screen_nr];
1657 if (title_screen_nr < num_title_screens)
1661 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1668 graphic_info[getTitleScreenGraphic(tci->local_nr,
1669 tci->initial)].anim_mode;
1671 anim_mode = ANIM_FADE; /* ??? */
1673 use_cross_fading = (anim_mode == ANIM_FADE ? FALSE :
1674 anim_mode == ANIM_CROSSFADE ? TRUE :
1678 sound = getTitleSound(tci);
1679 music = getTitleMusic(tci);
1681 if (sound == SND_UNDEFINED || sound != last_sound)
1683 if (music == MUS_UNDEFINED || music != last_music)
1687 FadeOut(REDRAW_ALL);
1691 DrawTitleScreenImage(tci->local_nr, tci->initial);
1693 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1695 fading_next = getTitleFading(tci);
1698 sound = getTitleSound(tci);
1699 music = getTitleMusic(tci);
1701 if (sound != last_sound)
1702 PlayMenuSoundExt(sound);
1703 if (music != last_music)
1704 PlayMenuMusicExt(music);
1711 printf("::: %d -> %d\n", fading.fade_mode, fading_next.fade_mode);
1715 /* last screen already faded out, next screen has no animation */
1716 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1717 fading_next.fade_mode == FADE_MODE_NONE)
1718 fading = fading_next;
1720 /* last screen already faded out, next screen has no animation */
1721 if (fading.fade_mode != FADE_MODE_CROSSFADE &&
1722 fading_next.fade_mode == FADE_MODE_NONE)
1723 fading = fading_next;
1730 fading = fading_next;
1732 DelayReached(&title_delay, 0); /* reset delay counter */
1736 FadeSoundsAndMusic();
1742 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1746 FadeOut(REDRAW_ALL);
1750 FadeOut(REDRAW_ALL);
1754 return_to_main_menu = TRUE;
1758 if (return_to_main_menu)
1764 SetMouseCursor(CURSOR_DEFAULT);
1766 if (game_status == GAME_MODE_INFO)
1769 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1772 info_mode = INFO_MODE_MAIN;
1773 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1775 else /* default: return to main menu */
1778 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1781 game_status = GAME_MODE_MAIN;
1782 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1787 void HandleMainMenu_SelectLevel(int step, int direction)
1789 int old_level_nr = level_nr;
1792 new_level_nr = old_level_nr + step * direction;
1793 if (new_level_nr < leveldir_current->first_level)
1794 new_level_nr = leveldir_current->first_level;
1795 if (new_level_nr > leveldir_current->last_level)
1796 new_level_nr = leveldir_current->last_level;
1798 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1800 /* skipping levels is only allowed when trying to skip single level */
1801 if (setup.skip_levels && step == 1 &&
1802 Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK))
1804 leveldir_current->handicap_level++;
1805 SaveLevelSetup_SeriesInfo();
1808 new_level_nr = leveldir_current->handicap_level;
1811 if (new_level_nr != old_level_nr)
1813 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1815 PlaySound(SND_MENU_ITEM_SELECTING);
1817 level_nr = new_level_nr;
1820 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1821 int2str(level_nr, menu.main.text.level_number.size),
1822 mci->pos_text->font);
1824 DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
1827 LoadLevel(level_nr);
1828 DrawPreviewLevel(TRUE);
1832 DrawCompleteVideoDisplay();
1834 /* needed because DrawPreviewLevel() takes some time */
1842 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1844 static int choice = MAIN_CONTROL_GAME;
1848 if (button == MB_MENU_INITIALIZE)
1850 DrawCursorAndText_Main(choice, TRUE);
1855 if (mx || my) /* mouse input */
1859 for (i = 0; main_controls[i].nr != -1; i++)
1861 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1862 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1863 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1865 pos = main_controls[i].nr;
1871 else if (dx || dy) /* keyboard input */
1873 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1874 choice == MAIN_CONTROL_SETUP))
1875 button = MB_MENU_CHOICE;
1880 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1882 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1884 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1890 PlaySound(SND_MENU_ITEM_ACTIVATING);
1892 DrawCursorAndText_Main(choice, FALSE);
1893 DrawCursorAndText_Main(pos, TRUE);
1900 PlaySound(SND_MENU_ITEM_SELECTING);
1902 if (pos == MAIN_CONTROL_NAME)
1904 game_status = GAME_MODE_PSEUDO_TYPENAME;
1906 HandleTypeName(strlen(setup.player_name), 0);
1908 else if (pos == MAIN_CONTROL_LEVELS)
1912 game_status = GAME_MODE_LEVELS;
1914 SaveLevelSetup_LastSeries();
1915 SaveLevelSetup_SeriesInfo();
1924 else if (pos == MAIN_CONTROL_SCORES)
1926 game_status = GAME_MODE_SCORES;
1930 else if (pos == MAIN_CONTROL_EDITOR)
1932 if (leveldir_current->readonly &&
1933 !strEqual(setup.player_name, "Artsoft"))
1934 Request("This level is read only !", REQ_CONFIRM);
1936 game_status = GAME_MODE_EDITOR;
1938 FadeSetEnterScreen();
1942 else if (pos == MAIN_CONTROL_INFO)
1944 game_status = GAME_MODE_INFO;
1945 info_mode = INFO_MODE_MAIN;
1948 fading = menu.navigation;
1953 else if (pos == MAIN_CONTROL_GAME)
1955 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
1957 else if (pos == MAIN_CONTROL_SETUP)
1959 game_status = GAME_MODE_SETUP;
1960 setup_mode = SETUP_MODE_MAIN;
1964 else if (pos == MAIN_CONTROL_QUIT)
1966 SaveLevelSetup_LastSeries();
1967 SaveLevelSetup_SeriesInfo();
1969 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
1970 game_status = GAME_MODE_QUIT;
1975 if (game_status == GAME_MODE_MAIN)
1977 DrawPreviewLevel(FALSE);
1984 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1986 static int choice = 5;
1990 if (button == MB_MENU_INITIALIZE)
1992 drawCursor(choice, TRUE);
1997 if (mx || my) /* mouse input */
1999 x = (mx - mSX) / 32;
2000 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2002 else if (dx || dy) /* keyboard input */
2004 if (dx && choice == 1)
2005 x = (dx < 0 ? 10 : 14);
2008 if (choice == 4 || choice == 6)
2009 button = MB_MENU_CHOICE;
2015 if (y == 1 && dx != 0 && button)
2017 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
2019 else if (IN_VIS_FIELD(x, y) &&
2020 y >= 0 && y <= 7 && (y != 1 || x < 10))
2026 drawCursor(choice, FALSE);
2027 drawCursor(y, TRUE);
2036 game_status = GAME_MODE_PSEUDO_TYPENAME;
2037 HandleTypeName(strlen(setup.player_name), 0);
2043 game_status = GAME_MODE_LEVELS;
2045 SaveLevelSetup_LastSeries();
2046 SaveLevelSetup_SeriesInfo();
2057 game_status = GAME_MODE_SCORES;
2062 if (leveldir_current->readonly &&
2063 !strEqual(setup.player_name, "Artsoft"))
2064 Request("This level is read only !", REQ_CONFIRM);
2065 game_status = GAME_MODE_EDITOR;
2070 game_status = GAME_MODE_INFO;
2071 info_mode = INFO_MODE_MAIN;
2076 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
2080 game_status = GAME_MODE_SETUP;
2081 setup_mode = SETUP_MODE_MAIN;
2087 SaveLevelSetup_LastSeries();
2088 SaveLevelSetup_SeriesInfo();
2090 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
2091 game_status = GAME_MODE_QUIT;
2096 if (game_status == GAME_MODE_MAIN)
2098 DrawPreviewLevel(FALSE);
2106 /* ========================================================================= */
2107 /* info screen functions */
2108 /* ========================================================================= */
2110 static struct TokenInfo *info_info;
2111 static int num_info_info;
2113 static void execInfoTitleScreen()
2116 FadeSetEnterScreen();
2119 info_mode = INFO_MODE_TITLE;
2123 static void execInfoElements()
2126 FadeSetEnterScreen();
2129 info_mode = INFO_MODE_ELEMENTS;
2133 static void execInfoMusic()
2136 FadeSetEnterScreen();
2139 info_mode = INFO_MODE_MUSIC;
2143 static void execInfoCredits()
2146 FadeSetEnterScreen();
2149 info_mode = INFO_MODE_CREDITS;
2153 static void execInfoProgram()
2156 FadeSetEnterScreen();
2159 info_mode = INFO_MODE_PROGRAM;
2163 static void execInfoVersion()
2166 FadeSetEnterScreen();
2169 info_mode = INFO_MODE_VERSION;
2173 static void execInfoLevelSet()
2176 FadeSetEnterScreen();
2179 info_mode = INFO_MODE_LEVELSET;
2183 static void execExitInfo()
2189 game_status = GAME_MODE_MAIN;
2191 DrawMainMenuExt(REDRAW_FIELD, FALSE);
2197 static struct TokenInfo info_info_main[] =
2199 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2200 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2201 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2202 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2203 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2204 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2205 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2206 { TYPE_EMPTY, NULL, "" },
2207 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2212 static void DrawCursorAndText_Info(int pos, boolean active)
2214 int xpos = MENU_SCREEN_START_XPOS;
2215 int ypos = MENU_SCREEN_START_YPOS + pos;
2216 int font_nr = FONT_MENU_1;
2219 font_nr = FONT_ACTIVE(font_nr);
2221 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
2223 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
2224 drawCursor(pos, active);
2227 static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading)
2232 CloseDoor(DOOR_CLOSE_2);
2234 /* (needed after displaying title screens which disable auto repeat) */
2235 KeyboardAutoRepeatOn();
2237 FadeSetLeaveScreen();
2240 FadeOut(redraw_mask);
2244 if (redraw_mask == REDRAW_ALL)
2248 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2254 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2256 info_info = info_info_main;
2260 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
2262 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2265 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2266 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2267 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2268 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2269 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
2270 initCursor(i, IMG_MENU_BUTTON);
2272 DrawCursorAndText_Info(i, FALSE);
2277 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2282 DrawMaskedBorder(redraw_mask);
2284 FadeIn(redraw_mask);
2289 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2291 static int choice_store[MAX_INFO_MODES];
2292 int choice = choice_store[info_mode]; /* always starts with 0 */
2296 if (button == MB_MENU_INITIALIZE)
2298 /* advance to first valid menu entry */
2299 while (choice < num_info_info &&
2300 info_info[choice].type & TYPE_SKIP_ENTRY)
2302 choice_store[info_mode] = choice;
2304 DrawCursorAndText_Info(choice, TRUE);
2308 else if (button == MB_MENU_LEAVE)
2310 for (y = 0; y < num_info_info; y++)
2312 if (info_info[y].type & TYPE_LEAVE_MENU)
2314 void (*menu_callback_function)(void) = info_info[y].value;
2318 menu_callback_function();
2320 break; /* absolutely needed because function changes 'info_info'! */
2327 if (mx || my) /* mouse input */
2329 x = (mx - mSX) / 32;
2330 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2332 else if (dx || dy) /* keyboard input */
2336 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2338 if (info_info[choice].type & menu_navigation_type ||
2339 info_info[choice].type & TYPE_ENTER_SCREEN ||
2340 info_info[choice].type & TYPE_BOOLEAN_STYLE)
2341 button = MB_MENU_CHOICE;
2346 /* jump to next non-empty menu entry (up or down) */
2347 while (y > 0 && y < num_info_info - 1 &&
2348 info_info[y].type & TYPE_SKIP_ENTRY)
2352 if (IN_VIS_FIELD(x, y) &&
2353 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2359 PlaySound(SND_MENU_ITEM_ACTIVATING);
2361 DrawCursorAndText_Info(choice, FALSE);
2362 DrawCursorAndText_Info(y, TRUE);
2364 choice = choice_store[info_mode] = y;
2367 else if (!(info_info[y].type & TYPE_GHOSTED))
2369 PlaySound(SND_MENU_ITEM_SELECTING);
2371 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2373 void (*menu_callback_function)(void) = info_info[choice].value;
2375 FadeSetFromType(info_info[y].type);
2377 menu_callback_function();
2383 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2385 int ystart1 = mSY - SY + 100;
2386 int ystart2 = mSY - SY + 150;
2387 int ybottom = mSY - SY + SYSIZE - 20;
2389 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2391 FadeOut(REDRAW_FIELD);
2396 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2397 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2399 DrawTextSCentered(ybottom, FONT_TEXT_4,
2400 "Press any key or button for info menu");
2402 FadeIn(REDRAW_FIELD);
2405 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2407 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2408 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2409 int xstart = mSX + 16;
2410 int ystart1 = mSY - SY + 100;
2411 int ystart2 = mSY + 64 + 2 * 32;
2412 int ybottom = mSY - SY + SYSIZE - 20;
2413 int ystep = TILEY + 4;
2414 int element, action, direction;
2422 for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++)
2423 infoscreen_step[i] = infoscreen_frame[i] = 0;
2428 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2430 DrawTextSCentered(ybottom, FONT_TEXT_4,
2431 "Press any key or button for next page");
2437 while (helpanim_info[j].element != HELPANIM_LIST_END)
2439 if (i >= start + MAX_INFO_ELEMENTS_ON_SCREEN ||
2444 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2453 j += infoscreen_step[i - start];
2455 element = helpanim_info[j].element;
2456 action = helpanim_info[j].action;
2457 direction = helpanim_info[j].direction;
2460 element = EL_UNKNOWN;
2462 if (action != -1 && direction != -1)
2463 graphic = el_act_dir2img(element, action, direction);
2464 else if (action != -1)
2465 graphic = el_act2img(element, action);
2466 else if (direction != -1)
2467 graphic = el_dir2img(element, direction);
2469 graphic = el2img(element);
2471 delay = helpanim_info[j++].delay;
2476 if (infoscreen_frame[i - start] == 0)
2479 infoscreen_frame[i - start] = delay - 1;
2483 sync_frame = delay - infoscreen_frame[i - start];
2484 infoscreen_frame[i - start]--;
2487 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2489 if (!infoscreen_frame[i - start])
2490 infoscreen_step[i - start] = 0;
2494 if (!infoscreen_frame[i - start])
2495 infoscreen_step[i - start]++;
2496 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2502 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2504 DrawGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2505 graphic, sync_frame, USE_MASKING);
2508 DrawInfoScreen_HelpText(element, action, direction, i - start);
2513 redraw_mask |= REDRAW_FIELD;
2518 static char *getHelpText(int element, int action, int direction)
2520 char token[MAX_LINE_LEN];
2522 strcpy(token, element_info[element].token_name);
2525 strcat(token, element_action_info[action].suffix);
2527 if (direction != -1)
2528 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2530 return getHashEntry(helptext_info, token);
2533 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2535 int font_nr = FONT_INFO_ELEMENTS;
2536 int font_width = getFontWidth(font_nr);
2537 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2538 int sy = mSY + 65 + 2 * 32 + 1;
2539 int ystep = TILEY + 4;
2540 int pad_x = sx - SX;
2541 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2542 int max_lines_per_text = 2;
2545 if (action != -1 && direction != -1) /* element.action.direction */
2546 text = getHelpText(element, action, direction);
2548 if (text == NULL && action != -1) /* element.action */
2549 text = getHelpText(element, action, -1);
2551 if (text == NULL && direction != -1) /* element.direction */
2552 text = getHelpText(element, -1, direction);
2554 if (text == NULL) /* base element */
2555 text = getHelpText(element, -1, -1);
2557 if (text == NULL) /* not found */
2558 text = "No description available";
2560 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2561 sy += getFontHeight(font_nr) / 2;
2563 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2564 max_chars_per_line, -1, max_lines_per_text, -1,
2565 TRUE, FALSE, FALSE);
2568 void DrawInfoScreen_TitleScreen()
2573 void HandleInfoScreen_TitleScreen(int button)
2575 HandleTitleScreen(0, 0, 0, 0, button);
2578 void DrawInfoScreen_Elements()
2580 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2582 FadeOut(REDRAW_FIELD);
2587 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2589 FadeIn(REDRAW_FIELD);
2594 void HandleInfoScreen_Elements(int button)
2596 static unsigned long info_delay = 0;
2597 static int num_anims;
2598 static int num_pages;
2600 int anims_per_page = MAX_INFO_ELEMENTS_ON_SCREEN;
2603 if (button == MB_MENU_INITIALIZE)
2605 boolean new_element = TRUE;
2609 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2611 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2613 else if (new_element)
2616 new_element = FALSE;
2620 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2624 if (button == MB_MENU_LEAVE)
2626 PlaySound(SND_MENU_ITEM_SELECTING);
2628 info_mode = INFO_MODE_MAIN;
2633 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2635 if (button != MB_MENU_INITIALIZE)
2637 PlaySound(SND_MENU_ITEM_SELECTING);
2642 if (page >= num_pages)
2644 FadeSoundsAndMusic();
2646 info_mode = INFO_MODE_MAIN;
2647 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2654 FadeSetNextScreen();
2658 if (button != MB_MENU_INITIALIZE)
2659 FadeOut(REDRAW_FIELD);
2661 if (button != MB_MENU_INITIALIZE)
2662 FadeCrossSaveBackbuffer();
2665 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2668 if (button != MB_MENU_INITIALIZE)
2669 FadeIn(REDRAW_FIELD);
2671 if (button != MB_MENU_INITIALIZE)
2672 FadeCross(REDRAW_FIELD);
2677 if (DelayReached(&info_delay, GameFrameDelay))
2678 if (page < num_pages)
2679 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2681 PlayMenuSoundIfLoop();
2685 void DrawInfoScreen_Music()
2687 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2690 FadeOut(REDRAW_FIELD);
2698 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2701 FadeIn(REDRAW_FIELD);
2705 void HandleInfoScreen_Music(int button)
2707 static struct MusicFileInfo *list = NULL;
2708 int ystart1 = mSY - SY + 100;
2709 int ystart2 = mSY - SY + 150;
2710 int ybottom = mSY - SY + SYSIZE - 20;
2713 if (button == MB_MENU_INITIALIZE)
2715 list = music_file_info;
2719 FadeSoundsAndMusic();
2724 DrawTextSCentered(ystart1, FONT_TEXT_1,
2725 "No music info for this level set.");
2727 DrawTextSCentered(ybottom, FONT_TEXT_4,
2728 "Press any key or button for info menu");
2734 if (button == MB_MENU_LEAVE)
2736 PlaySound(SND_MENU_ITEM_SELECTING);
2738 FadeSoundsAndMusic();
2740 info_mode = INFO_MODE_MAIN;
2745 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2749 if (button != MB_MENU_INITIALIZE)
2751 PlaySound(SND_MENU_ITEM_SELECTING);
2759 FadeSoundsAndMusic();
2761 info_mode = INFO_MODE_MAIN;
2762 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2767 FadeSoundsAndMusic();
2770 if (list != music_file_info)
2771 FadeSetNextScreen();
2775 if (button != MB_MENU_INITIALIZE)
2776 FadeOut(REDRAW_FIELD);
2778 if (button != MB_MENU_INITIALIZE)
2779 FadeCrossSaveBackbuffer();
2787 int sound = list->music;
2789 if (sound_info[sound].loop)
2790 PlaySoundLoop(sound);
2794 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2798 PlayMusic(list->music);
2800 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2803 if (!strEqual(list->title, UNKNOWN_NAME))
2805 if (!strEqual(list->title_header, UNKNOWN_NAME))
2806 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2808 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2811 if (!strEqual(list->artist, UNKNOWN_NAME))
2813 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2814 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2816 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2818 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2821 if (!strEqual(list->album, UNKNOWN_NAME))
2823 if (!strEqual(list->album_header, UNKNOWN_NAME))
2824 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2826 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2828 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2831 if (!strEqual(list->year, UNKNOWN_NAME))
2833 if (!strEqual(list->year_header, UNKNOWN_NAME))
2834 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2836 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2838 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2841 DrawTextSCentered(ybottom, FONT_TEXT_4,
2842 "Press any key or button for next page");
2845 if (button != MB_MENU_INITIALIZE)
2846 FadeIn(REDRAW_FIELD);
2848 if (button != MB_MENU_INITIALIZE)
2849 FadeCross(REDRAW_FIELD);
2853 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2854 PlaySoundLoop(list->music);
2857 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2859 int ystart1 = mSY - SY + 100;
2860 int ystart2 = mSY - SY + 150;
2861 int ybottom = mSY - SY + SYSIZE - 20;
2867 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2871 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2872 "Special thanks to");
2873 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2875 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2877 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2878 "\"Boulder Dash\"");
2879 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2881 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2883 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2885 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2886 "First Star Software");
2888 else if (screen_nr == 1)
2890 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2891 "Special thanks to");
2892 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2893 "Klaus Heinz & Volker Wertich");
2894 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2896 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2897 "\"Emerald Mine\"");
2898 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2900 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2902 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2904 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2907 else if (screen_nr == 2)
2909 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2910 "Special thanks to");
2911 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2912 "Michael Stopp & Philip Jespersen");
2913 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2915 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2917 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2919 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2921 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2923 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2924 "Digital Integration");
2926 else if (screen_nr == 3)
2928 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2929 "Special thanks to");
2930 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2931 "Hiroyuki Imabayashi");
2932 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2934 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2936 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2938 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2940 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2942 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2945 else if (screen_nr == 4)
2947 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2948 "Special thanks to");
2949 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2951 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2953 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2954 "Jürgen Bonhagen");
2955 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2956 "for the continuous creation");
2957 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2958 "of outstanding level sets");
2960 else if (screen_nr == 5)
2962 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2964 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2966 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2967 "for ideas and inspiration by");
2968 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2971 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2973 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2975 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2976 "for ideas and inspiration by");
2977 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2980 else if (screen_nr == 6)
2982 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2984 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2986 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2987 "for the new Emerald Mine engine");
2989 else if (screen_nr == 7)
2991 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2993 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2995 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2996 "for the initial DOS port");
2998 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3000 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3002 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3003 "for some additional toons");
3005 else if (screen_nr == 8)
3007 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3008 "And not to forget:");
3009 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3011 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3012 "All those who contributed");
3013 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3014 "levels to this game");
3015 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
3019 DrawTextSCentered(ybottom, FONT_TEXT_4,
3020 "Press any key or button for next page");
3023 void DrawInfoScreen_Credits()
3025 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
3027 FadeSoundsAndMusic();
3030 FadeOut(REDRAW_FIELD);
3033 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3036 FadeIn(REDRAW_FIELD);
3040 void HandleInfoScreen_Credits(int button)
3042 static int screen_nr = 0;
3043 int num_screens = 9;
3045 if (button == MB_MENU_INITIALIZE)
3049 // DrawInfoScreen_CreditsScreen(screen_nr);
3052 if (button == MB_MENU_LEAVE)
3054 PlaySound(SND_MENU_ITEM_SELECTING);
3056 info_mode = INFO_MODE_MAIN;
3061 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
3063 if (button != MB_MENU_INITIALIZE)
3065 PlaySound(SND_MENU_ITEM_SELECTING);
3070 if (screen_nr >= num_screens)
3072 FadeSoundsAndMusic();
3074 info_mode = INFO_MODE_MAIN;
3075 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3082 FadeSetNextScreen();
3086 if (button != MB_MENU_INITIALIZE)
3087 FadeOut(REDRAW_FIELD);
3089 if (button != MB_MENU_INITIALIZE)
3090 FadeCrossSaveBackbuffer();
3093 DrawInfoScreen_CreditsScreen(screen_nr);
3096 if (button != MB_MENU_INITIALIZE)
3097 FadeIn(REDRAW_FIELD);
3099 if (button != MB_MENU_INITIALIZE)
3100 FadeCross(REDRAW_FIELD);
3105 PlayMenuSoundIfLoop();
3109 void DrawInfoScreen_Program()
3111 int ystart1 = mSY - SY + 100;
3112 int ystart2 = mSY - SY + 150;
3113 int ybottom = mSY - SY + SYSIZE - 20;
3116 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3119 FadeOut(REDRAW_FIELD);
3125 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
3127 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3128 "This game is Freeware!");
3129 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3130 "If you like it, send e-mail to:");
3131 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3132 PROGRAM_EMAIL_STRING);
3133 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
3134 "or SnailMail to:");
3135 DrawTextSCentered(ystart2 + 4 * ystep + 0, FONT_TEXT_3,
3137 DrawTextSCentered(ystart2 + 4 * ystep + 20, FONT_TEXT_3,
3138 "Detmolder Strasse 189");
3139 DrawTextSCentered(ystart2 + 4 * ystep + 40, FONT_TEXT_3,
3141 DrawTextSCentered(ystart2 + 4 * ystep + 60, FONT_TEXT_3,
3143 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3144 "More information and levels:");
3145 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3146 PROGRAM_WEBSITE_STRING);
3147 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3148 "If you have created new levels,");
3149 DrawTextSCentered(ystart2 + 10 * ystep, FONT_TEXT_2,
3150 "send them to me to include them!");
3151 DrawTextSCentered(ystart2 + 11 * ystep, FONT_TEXT_2,
3154 DrawTextSCentered(ybottom, FONT_TEXT_4,
3155 "Press any key or button for info menu");
3158 FadeIn(REDRAW_FIELD);
3162 void HandleInfoScreen_Program(int button)
3164 if (button == MB_MENU_LEAVE)
3166 PlaySound(SND_MENU_ITEM_SELECTING);
3168 info_mode = INFO_MODE_MAIN;
3173 else if (button == MB_MENU_CHOICE)
3175 PlaySound(SND_MENU_ITEM_SELECTING);
3177 FadeSoundsAndMusic();
3180 FadeOut(REDRAW_FIELD);
3183 info_mode = INFO_MODE_MAIN;
3184 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3188 PlayMenuSoundIfLoop();
3192 void DrawInfoScreen_Version()
3194 int font_header = FONT_TEXT_3;
3195 int font_text = FONT_TEXT_2;
3196 int xstep = getFontWidth(font_text);
3197 int ystep = getFontHeight(font_text);
3198 int ystart1 = mSY - SY + 100;
3199 int ystart2 = mSY - SY + 150;
3200 int ybottom = mSY - SY + SYSIZE - 20;
3201 int xstart1 = mSX + 2 * xstep;
3202 int xstart2 = mSX + 19 * xstep;
3203 #if defined(TARGET_SDL)
3204 int xstart3 = mSX + 29 * xstep;
3205 SDL_version sdl_version_compiled;
3206 const SDL_version *sdl_version_linked;
3207 int driver_name_len = 8;
3208 char driver_name[driver_name_len];
3211 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3214 FadeOut(REDRAW_FIELD);
3220 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
3222 DrawTextF(xstart1, ystart2, font_header, "Name");
3223 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
3226 DrawTextF(xstart1, ystart2, font_header, "Version");
3227 DrawTextF(xstart2, ystart2, font_text, getProgramFullVersionString());
3230 DrawTextF(xstart1, ystart2, font_header, "Platform");
3231 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
3234 DrawTextF(xstart1, ystart2, font_header, "Target");
3235 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
3238 DrawTextF(xstart1, ystart2, font_header, "Compile time");
3239 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
3241 #if defined(TARGET_SDL)
3242 ystart2 += 3 * ystep;
3243 DrawTextF(xstart1, ystart2, font_header, "Library");
3244 DrawTextF(xstart2, ystart2, font_header, "compiled");
3245 DrawTextF(xstart3, ystart2, font_header, "linked");
3247 SDL_VERSION(&sdl_version_compiled);
3248 sdl_version_linked = SDL_Linked_Version();
3250 ystart2 += 2 * ystep;
3251 DrawTextF(xstart1, ystart2, font_text, "SDL");
3252 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3253 sdl_version_compiled.major,
3254 sdl_version_compiled.minor,
3255 sdl_version_compiled.patch);
3256 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3257 sdl_version_linked->major,
3258 sdl_version_linked->minor,
3259 sdl_version_linked->patch);
3261 SDL_IMAGE_VERSION(&sdl_version_compiled);
3262 sdl_version_linked = IMG_Linked_Version();
3265 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
3266 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3267 sdl_version_compiled.major,
3268 sdl_version_compiled.minor,
3269 sdl_version_compiled.patch);
3270 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3271 sdl_version_linked->major,
3272 sdl_version_linked->minor,
3273 sdl_version_linked->patch);
3275 SDL_MIXER_VERSION(&sdl_version_compiled);
3276 sdl_version_linked = Mix_Linked_Version();
3279 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
3280 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3281 sdl_version_compiled.major,
3282 sdl_version_compiled.minor,
3283 sdl_version_compiled.patch);
3284 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3285 sdl_version_linked->major,
3286 sdl_version_linked->minor,
3287 sdl_version_linked->patch);
3289 SDL_NET_VERSION(&sdl_version_compiled);
3290 sdl_version_linked = SDLNet_Linked_Version();
3293 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
3294 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3295 sdl_version_compiled.major,
3296 sdl_version_compiled.minor,
3297 sdl_version_compiled.patch);
3298 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3299 sdl_version_linked->major,
3300 sdl_version_linked->minor,
3301 sdl_version_linked->patch);
3303 ystart2 += 3 * ystep;
3304 DrawTextF(xstart1, ystart2, font_header, "Driver");
3305 DrawTextF(xstart2, ystart2, font_header, "Requested");
3306 DrawTextF(xstart3, ystart2, font_header, "Used");
3308 SDL_VideoDriverName(driver_name, driver_name_len);
3310 ystart2 += 2 * ystep;
3311 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
3312 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
3313 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3315 SDL_AudioDriverName(driver_name, driver_name_len);
3318 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
3319 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
3320 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3323 DrawTextSCentered(ybottom, FONT_TEXT_4,
3324 "Press any key or button for info menu");
3327 FadeIn(REDRAW_FIELD);
3331 void HandleInfoScreen_Version(int button)
3333 if (button == MB_MENU_LEAVE)
3335 PlaySound(SND_MENU_ITEM_SELECTING);
3337 info_mode = INFO_MODE_MAIN;
3342 else if (button == MB_MENU_CHOICE)
3344 PlaySound(SND_MENU_ITEM_SELECTING);
3346 FadeSoundsAndMusic();
3349 FadeOut(REDRAW_FIELD);
3352 info_mode = INFO_MODE_MAIN;
3353 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3357 PlayMenuSoundIfLoop();
3361 void DrawInfoScreen_LevelSet()
3363 struct TitleMessageInfo *tmi = &readme;
3364 char *filename = getLevelSetInfoFilename();
3366 /* if chars set to "-1", automatically determine by text and font width */
3367 if (tmi->chars == -1)
3368 tmi->chars = tmi->width / getFontWidth(tmi->font);
3370 tmi->width = tmi->chars * getFontWidth(tmi->font);
3372 /* if lines set to "-1", automatically determine by text and font height */
3373 if (tmi->lines == -1)
3374 tmi->lines = tmi->height / getFontHeight(tmi->font);
3376 tmi->height = tmi->lines * getFontHeight(tmi->font);
3378 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3381 FadeOut(REDRAW_FIELD);
3387 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3389 if (filename != NULL)
3390 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3391 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
3392 tmi->autowrap, tmi->centered, tmi->parse_comments);
3394 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3395 "No information for this level set.");
3397 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3398 "Press any key or button for info menu");
3401 FadeIn(REDRAW_FIELD);
3405 void HandleInfoScreen_LevelSet(int button)
3407 if (button == MB_MENU_LEAVE)
3409 PlaySound(SND_MENU_ITEM_SELECTING);
3411 info_mode = INFO_MODE_MAIN;
3416 else if (button == MB_MENU_CHOICE)
3418 PlaySound(SND_MENU_ITEM_SELECTING);
3420 FadeSoundsAndMusic();
3423 FadeOut(REDRAW_FIELD);
3426 info_mode = INFO_MODE_MAIN;
3427 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3431 PlayMenuSoundIfLoop();
3435 static void DrawInfoScreenExt(int redraw_mask, boolean do_fading)
3437 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3439 if (info_mode == INFO_MODE_TITLE)
3440 DrawInfoScreen_TitleScreen();
3441 else if (info_mode == INFO_MODE_ELEMENTS)
3442 DrawInfoScreen_Elements();
3443 else if (info_mode == INFO_MODE_MUSIC)
3444 DrawInfoScreen_Music();
3445 else if (info_mode == INFO_MODE_CREDITS)
3446 DrawInfoScreen_Credits();
3447 else if (info_mode == INFO_MODE_PROGRAM)
3448 DrawInfoScreen_Program();
3449 else if (info_mode == INFO_MODE_VERSION)
3450 DrawInfoScreen_Version();
3451 else if (info_mode == INFO_MODE_LEVELSET)
3452 DrawInfoScreen_LevelSet();
3454 DrawInfoScreen_Main(redraw_mask, do_fading);
3456 if (info_mode != INFO_MODE_MAIN &&
3457 info_mode != INFO_MODE_TITLE &&
3458 info_mode != INFO_MODE_MUSIC)
3465 void DrawAndFadeInInfoScreen(int redraw_mask)
3467 DrawInfoScreenExt(redraw_mask, TRUE);
3470 void DrawInfoScreen()
3472 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3475 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3477 if (info_mode == INFO_MODE_TITLE)
3478 HandleInfoScreen_TitleScreen(button);
3479 else if (info_mode == INFO_MODE_ELEMENTS)
3480 HandleInfoScreen_Elements(button);
3481 else if (info_mode == INFO_MODE_MUSIC)
3482 HandleInfoScreen_Music(button);
3483 else if (info_mode == INFO_MODE_CREDITS)
3484 HandleInfoScreen_Credits(button);
3485 else if (info_mode == INFO_MODE_PROGRAM)
3486 HandleInfoScreen_Program(button);
3487 else if (info_mode == INFO_MODE_VERSION)
3488 HandleInfoScreen_Version(button);
3489 else if (info_mode == INFO_MODE_LEVELSET)
3490 HandleInfoScreen_LevelSet(button);
3492 HandleInfoScreen_Main(mx, my, dx, dy, button);
3498 /* ========================================================================= */
3499 /* type name functions */
3500 /* ========================================================================= */
3502 void HandleTypeName(int newxpos, Key key)
3504 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3505 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3507 struct TextPosInfo *pos = mci->pos_input;
3508 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3509 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3512 static int xpos = 0;
3514 static int xpos = 0, ypos = 2;
3516 int font_nr = pos->font;
3517 int font_active_nr = FONT_ACTIVE(font_nr);
3518 int font_width = getFontWidth(font_active_nr);
3521 int startx = mSX + mci->pos_input->x;
3522 int starty = mSY + mci->pos_input->y;
3525 int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
3526 int startx = mSX + 32 + name_width;
3527 int starty = mSY + ypos * 32;
3529 char key_char = getValidConfigValueChar(getCharFromKey(key));
3530 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3531 boolean is_active = TRUE;
3533 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3537 strcpy(last_player_name, setup.player_name);
3542 /* add one character width for added cursor character */
3543 pos->width += font_width;
3544 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3546 DrawText(startx, starty, setup.player_name, font_active_nr);
3547 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3550 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3552 setup.player_name[xpos] = key_char;
3553 setup.player_name[xpos + 1] = 0;
3558 /* add one character width for added name text character */
3559 pos->width += font_width;
3560 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3562 DrawText(startx, starty, setup.player_name, font_active_nr);
3563 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3566 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3570 setup.player_name[xpos] = 0;
3573 /* remove one character width for removed name text character */
3574 pos->width -= 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);
3581 else if (key == KSYM_Return && xpos > 0)
3584 /* remove one character width for removed cursor text character */
3585 pos->width -= font_width;
3586 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3588 DrawText(startx, starty, setup.player_name, font_nr);
3589 DrawText(startx + xpos * font_width, starty, " ", font_active_nr);
3596 game_status = GAME_MODE_MAIN;
3598 else if (key == KSYM_Escape)
3600 strcpy(setup.player_name, last_player_name);
3604 game_status = GAME_MODE_MAIN;
3609 pos->width = (strlen(setup.player_name) + 1) * font_width;
3610 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3612 DrawText(startx, starty, setup.player_name, font_active_nr);
3613 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3617 pos->width = strlen(setup.player_name) * font_width;
3618 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3620 DrawText(startx, starty, setup.player_name, font_nr);
3625 /* ========================================================================= */
3626 /* tree menu functions */
3627 /* ========================================================================= */
3629 static void DrawChooseTree(TreeInfo **ti_ptr)
3633 FreeScreenGadgets();
3634 CreateScreenGadgets();
3636 CloseDoor(DOOR_CLOSE_2);
3639 FadeOut(REDRAW_FIELD);
3644 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3645 MapScreenTreeGadgets(*ti_ptr);
3648 FadeIn(REDRAW_FIELD);
3654 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3656 struct GadgetInfo *gi = screen_gadget[id];
3657 int items_max, items_visible, item_position;
3659 items_max = numTreeInfoInGroup(ti);
3660 items_visible = NUM_MENU_ENTRIES_ON_SCREEN;
3661 item_position = first_entry;
3663 if (item_position > items_max - items_visible)
3664 item_position = items_max - items_visible;
3666 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3667 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3668 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3671 static void drawChooseTreeList(int first_entry, int num_page_entries,
3675 char *title_string = NULL;
3676 int yoffset_sets = MENU_TITLE1_YPOS;
3677 int yoffset_setup = 16;
3678 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? yoffset_sets :
3680 int last_game_status = game_status; /* save current game status */
3682 title_string = ti->infotext;
3684 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3687 /* force LEVELS font on artwork setup screen */
3688 game_status = GAME_MODE_LEVELS;
3692 /* clear tree list area, but not title or scrollbar */
3693 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3694 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3695 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3697 /* clear tree list area, but not title or scrollbar */
3698 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3699 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3700 MAX_MENU_ENTRIES_ON_SCREEN * 32);
3703 for (i = 0; i < num_page_entries; i++)
3705 TreeInfo *node, *node_first;
3706 int entry_pos = first_entry + i;
3707 int xpos = MENU_SCREEN_START_XPOS;
3708 int ypos = MENU_SCREEN_START_YPOS + i;
3709 int startx = mSX + xpos * 32;
3710 int starty = mSY + ypos * 32;
3711 int font_nr = FONT_TEXT_1;
3712 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3713 int startx_text = startx + font_xoffset;
3714 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3715 int text_size = startx_scrollbar - startx_text;
3716 int max_buffer_len = text_size / getFontWidth(font_nr);
3717 char buffer[max_buffer_len + 1];
3719 node_first = getTreeInfoFirstGroupEntry(ti);
3720 node = getTreeInfoFromPos(node_first, entry_pos);
3722 strncpy(buffer, node->name, max_buffer_len);
3723 buffer[max_buffer_len] = '\0';
3725 DrawText(startx, starty, buffer, font_nr + node->color);
3727 if (node->parent_link)
3728 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3729 else if (node->level_group)
3730 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3732 initCursor(i, IMG_MENU_BUTTON);
3735 game_status = last_game_status; /* restore current game status */
3737 redraw_mask |= REDRAW_FIELD;
3740 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3742 TreeInfo *node, *node_first;
3743 int x, last_redraw_mask = redraw_mask;
3744 int ypos = MENU_TITLE2_YPOS;
3745 int font_nr = FONT_TITLE_2;
3747 if (ti->type != TREE_TYPE_LEVEL_DIR)
3750 node_first = getTreeInfoFirstGroupEntry(ti);
3751 node = getTreeInfoFromPos(node_first, entry_pos);
3753 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3755 if (node->parent_link)
3756 DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
3758 else if (node->level_group)
3759 DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
3761 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3762 DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
3763 node->levels, node->class_desc);
3765 /* let BackToFront() redraw only what is needed */
3766 redraw_mask = last_redraw_mask | REDRAW_TILES;
3767 for (x = 0; x < SCR_FIELDX; x++)
3768 MarkTileDirty(x, 1);
3771 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3774 TreeInfo *ti = *ti_ptr;
3776 int y = ti->cl_cursor;
3777 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3778 int num_entries = numTreeInfoInGroup(ti);
3779 int num_page_entries;
3780 int last_game_status = game_status; /* save current game status */
3781 boolean position_set_by_scrollbar = (dx == 999);
3784 /* force LEVELS draw offset on choose level and artwork setup screen */
3785 game_status = GAME_MODE_LEVELS;
3788 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3789 num_page_entries = num_entries;
3791 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3793 game_status = last_game_status; /* restore current game status */
3795 if (button == MB_MENU_INITIALIZE)
3797 int num_entries = numTreeInfoInGroup(ti);
3798 int entry_pos = posTreeInfo(ti);
3800 if (ti->cl_first == -1)
3802 /* only on initialization */
3803 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3804 ti->cl_cursor = entry_pos - ti->cl_first;
3806 else if (ti->cl_cursor >= num_page_entries ||
3807 (num_entries > num_page_entries &&
3808 num_entries - ti->cl_first < num_page_entries))
3810 /* only after change of list size (by custom graphic configuration) */
3811 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3812 ti->cl_cursor = entry_pos - ti->cl_first;
3815 if (position_set_by_scrollbar)
3818 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3821 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3822 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3823 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3827 else if (button == MB_MENU_LEAVE)
3831 PlaySound(SND_MENU_ITEM_SELECTING);
3833 if (ti->node_parent)
3835 *ti_ptr = ti->node_parent;
3836 DrawChooseTree(ti_ptr);
3838 else if (game_status == GAME_MODE_SETUP)
3840 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
3842 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3843 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3844 execSetupGraphics();
3850 game_status = GAME_MODE_MAIN;
3852 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3861 if (mx || my) /* mouse input */
3863 int last_game_status = game_status; /* save current game status */
3866 /* force LEVELS draw offset on artwork setup screen */
3867 game_status = GAME_MODE_LEVELS;
3870 x = (mx - mSX) / 32;
3871 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3873 game_status = last_game_status; /* restore current game status */
3875 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3877 /* move cursor instead of scrolling when already at start/end of list */
3878 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3880 else if (dy == +1 * SCROLL_LINE &&
3881 ti->cl_first + num_page_entries == num_entries)
3884 /* handle scrolling screen one line or page */
3885 if (ti->cl_cursor + dy < 0 ||
3886 ti->cl_cursor + dy > num_page_entries - 1)
3888 if (ABS(dy) == SCROLL_PAGE)
3889 step = num_page_entries - 1;
3891 if (dy < 0 && ti->cl_first > 0)
3893 /* scroll page/line up */
3895 ti->cl_first -= step;
3896 if (ti->cl_first < 0)
3899 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3900 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3901 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3903 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3906 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3908 /* scroll page/line down */
3910 ti->cl_first += step;
3911 if (ti->cl_first + num_page_entries > num_entries)
3912 ti->cl_first = MAX(0, num_entries - num_page_entries);
3914 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3915 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3916 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3918 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3925 /* handle moving cursor one line */
3926 y = ti->cl_cursor + dy;
3931 TreeInfo *node_first, *node_cursor;
3932 int entry_pos = ti->cl_first + y;
3934 node_first = getTreeInfoFirstGroupEntry(ti);
3935 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3937 if (node_cursor->node_group)
3941 PlaySound(SND_MENU_ITEM_SELECTING);
3943 node_cursor->cl_first = ti->cl_first;
3944 node_cursor->cl_cursor = ti->cl_cursor;
3945 *ti_ptr = node_cursor->node_group;
3946 DrawChooseTree(ti_ptr);
3951 else if (dx == -1 && ti->node_parent)
3955 PlaySound(SND_MENU_ITEM_SELECTING);
3957 *ti_ptr = ti->node_parent;
3958 DrawChooseTree(ti_ptr);
3963 if (!anyScrollbarGadgetActive() &&
3964 IN_VIS_FIELD(x, y) &&
3965 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3966 y >= 0 && y < num_page_entries)
3970 if (y != ti->cl_cursor)
3972 PlaySound(SND_MENU_ITEM_ACTIVATING);
3974 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3975 drawChooseTreeCursor(y, TRUE);
3976 drawChooseTreeInfo(ti->cl_first + y, ti);
3983 TreeInfo *node_first, *node_cursor;
3984 int entry_pos = ti->cl_first + y;
3986 PlaySound(SND_MENU_ITEM_SELECTING);
3988 node_first = getTreeInfoFirstGroupEntry(ti);
3989 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3991 if (node_cursor->node_group)
3995 node_cursor->cl_first = ti->cl_first;
3996 node_cursor->cl_cursor = ti->cl_cursor;
3997 *ti_ptr = node_cursor->node_group;
3998 DrawChooseTree(ti_ptr);
4000 else if (node_cursor->parent_link)
4004 *ti_ptr = node_cursor->node_parent;
4005 DrawChooseTree(ti_ptr);
4009 FadeSetEnterScreen();
4011 node_cursor->cl_first = ti->cl_first;
4012 node_cursor->cl_cursor = ti->cl_cursor;
4013 *ti_ptr = node_cursor;
4015 if (ti->type == TREE_TYPE_LEVEL_DIR)
4017 LoadLevelSetup_SeriesInfo();
4019 SaveLevelSetup_LastSeries();
4020 SaveLevelSetup_SeriesInfo();
4024 if (game_status == GAME_MODE_SETUP)
4026 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
4028 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
4029 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
4030 execSetupGraphics();
4036 game_status = GAME_MODE_MAIN;
4044 void DrawChooseLevel()
4046 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
4048 DrawChooseTree(&leveldir_current);
4054 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
4056 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4061 void DrawHallOfFame(int highlight_position)
4064 FadeSoundsAndMusic();
4066 /* (this is needed when called from GameEnd() after winning a game) */
4067 KeyboardAutoRepeatOn();
4070 /* (this is needed when called from GameEnd() after winning a game) */
4071 SetDrawDeactivationMask(REDRAW_NONE);
4072 SetDrawBackgroundMask(REDRAW_FIELD);
4074 CloseDoor(DOOR_CLOSE_2);
4076 if (highlight_position < 0)
4077 LoadScore(level_nr);
4079 FadeSetEnterScreen();
4081 // printf("::: %d: %d\n", game_status, menu.enter_screen[game_status]);
4084 FadeOut(REDRAW_FIELD);
4092 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4095 FadeIn(REDRAW_FIELD);
4099 static void drawHallOfFameList(int first_entry, int highlight_position)
4103 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4106 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4107 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4108 "HighScores of Level %d", level_nr);
4110 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4112 int entry = first_entry + i;
4113 boolean active = (entry == highlight_position);
4114 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4115 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4116 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4117 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4118 int dx1 = 3 * getFontWidth(font_nr1);
4119 int dx2 = dx1 + getFontWidth(font_nr1);
4120 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
4121 int sy = mSY + 64 + i * 32;
4123 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4124 DrawText(mSX + dx1, sy, ".", font_nr1);
4125 DrawText(mSX + dx2, sy, ".........................", font_nr3);
4127 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4128 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4130 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4133 redraw_mask |= REDRAW_FIELD;
4136 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4138 static int first_entry = 0;
4139 static int highlight_position = 0;
4140 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4142 if (button == MB_MENU_INITIALIZE)
4145 highlight_position = mx;
4146 drawHallOfFameList(first_entry, highlight_position);
4151 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4152 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4156 if (first_entry > 0)
4158 first_entry -= step;
4159 if (first_entry < 0)
4162 drawHallOfFameList(first_entry, highlight_position);
4167 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4169 first_entry += step;
4170 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4171 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4173 drawHallOfFameList(first_entry, highlight_position);
4176 else if (button == MB_MENU_LEAVE)
4178 PlaySound(SND_MENU_ITEM_SELECTING);
4180 FadeSound(SND_BACKGROUND_SCORES);
4182 game_status = GAME_MODE_MAIN;
4186 else if (button == MB_MENU_CHOICE)
4188 PlaySound(SND_MENU_ITEM_SELECTING);
4190 FadeSound(SND_BACKGROUND_SCORES);
4193 FadeOut(REDRAW_FIELD);
4196 game_status = GAME_MODE_MAIN;
4198 DrawAndFadeInMainMenu(REDRAW_FIELD);
4201 if (game_status == GAME_MODE_SCORES)
4202 PlayMenuSoundIfLoop();
4208 /* ========================================================================= */
4209 /* setup screen functions */
4210 /* ========================================================================= */
4212 static struct TokenInfo *setup_info;
4213 static int num_setup_info;
4215 static char *screen_mode_text;
4216 static char *scroll_delay_text;
4217 static char *game_speed_text;
4218 static char *graphics_set_name;
4219 static char *sounds_set_name;
4220 static char *music_set_name;
4222 static void execSetupMain()
4228 setup_mode = SETUP_MODE_MAIN;
4232 static void execSetupGame()
4238 if (game_speeds == NULL)
4242 for (i = 0; game_speeds_list[i].value != -1; i++)
4244 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4245 char identifier[32], name[32];
4246 int value = game_speeds_list[i].value;
4247 char *text = game_speeds_list[i].text;
4249 ti->node_top = &game_speeds;
4250 ti->sort_priority = 10000 - value;
4252 sprintf(identifier, "%d", value);
4253 sprintf(name, "%s", text);
4255 setString(&ti->identifier, identifier);
4256 setString(&ti->name, name);
4257 setString(&ti->name_sorting, name);
4258 setString(&ti->infotext, "Game Speed");
4260 pushTreeInfo(&game_speeds, ti);
4263 /* sort game speed values to start with slowest game speed */
4264 sortTreeInfo(&game_speeds);
4266 /* set current game speed to configured game speed value */
4267 game_speed_current =
4268 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4270 /* if that fails, set current game speed to reliable default value */
4271 if (game_speed_current == NULL)
4272 game_speed_current =
4273 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4275 /* if that also fails, set current game speed to first available speed */
4276 if (game_speed_current == NULL)
4277 game_speed_current = game_speeds;
4280 setup.game_frame_delay = atoi(game_speed_current->identifier);
4282 /* needed for displaying game speed text instead of identifier */
4283 game_speed_text = game_speed_current->name;
4285 setup_mode = SETUP_MODE_GAME;
4289 static void execSetupChooseGameSpeed()
4295 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4299 static void execSetupEditor()
4305 setup_mode = SETUP_MODE_EDITOR;
4309 static void execSetupGraphics()
4315 if (video.fullscreen_available && screen_modes == NULL)
4319 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4321 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4322 char identifier[32], name[32];
4323 int x = video.fullscreen_modes[i].width;
4324 int y = video.fullscreen_modes[i].height;
4327 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4329 ti->node_top = &screen_modes;
4330 ti->sort_priority = x * 10000 + y;
4332 sprintf(identifier, "%dx%d", x, y);
4333 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4335 setString(&ti->identifier, identifier);
4336 setString(&ti->name, name);
4337 setString(&ti->name_sorting, name);
4338 setString(&ti->infotext, "Fullscreen Mode");
4340 pushTreeInfo(&screen_modes, ti);
4343 /* sort fullscreen modes to start with lowest available screen resolution */
4344 sortTreeInfo(&screen_modes);
4346 /* set current screen mode for fullscreen mode to configured setup value */
4347 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4348 setup.fullscreen_mode);
4350 /* if that fails, set current screen mode to reliable default value */
4351 if (screen_mode_current == NULL)
4352 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4353 DEFAULT_FULLSCREEN_MODE);
4355 /* if that also fails, set current screen mode to first available mode */
4356 if (screen_mode_current == NULL)
4357 screen_mode_current = screen_modes;
4359 if (screen_mode_current == NULL)
4360 video.fullscreen_available = FALSE;
4363 if (video.fullscreen_available)
4365 setup.fullscreen_mode = screen_mode_current->identifier;
4367 /* needed for displaying screen mode name instead of identifier */
4368 screen_mode_text = screen_mode_current->name;
4372 if (scroll_delays == NULL)
4376 for (i = 0; scroll_delays_list[i].value != -1; i++)
4378 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4379 char identifier[32], name[32];
4380 int value = scroll_delays_list[i].value;
4381 char *text = scroll_delays_list[i].text;
4383 ti->node_top = &scroll_delays;
4384 ti->sort_priority = value;
4386 sprintf(identifier, "%d", value);
4387 sprintf(name, "%s", text);
4389 setString(&ti->identifier, identifier);
4390 setString(&ti->name, name);
4391 setString(&ti->name_sorting, name);
4392 setString(&ti->infotext, "Scroll Delay");
4394 pushTreeInfo(&scroll_delays, ti);
4397 /* sort scroll delay values to start with lowest scroll delay value */
4398 sortTreeInfo(&scroll_delays);
4400 /* set current scroll delay value to configured scroll delay value */
4401 scroll_delay_current =
4402 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4404 /* if that fails, set current scroll delay to reliable default value */
4405 if (scroll_delay_current == NULL)
4406 scroll_delay_current =
4407 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4409 /* if that also fails, set current scroll delay to first available value */
4410 if (scroll_delay_current == NULL)
4411 scroll_delay_current = scroll_delays;
4414 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4416 /* needed for displaying scroll delay text instead of identifier */
4417 scroll_delay_text = scroll_delay_current->name;
4420 setup_mode = SETUP_MODE_GRAPHICS;
4424 static void execSetupChooseScreenMode()
4430 if (!video.fullscreen_available)
4433 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4437 static void execSetupChooseScrollDelay()
4443 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4447 static void execSetupSound()
4453 setup_mode = SETUP_MODE_SOUND;
4457 static void execSetupArtwork()
4463 setup.graphics_set = artwork.gfx_current->identifier;
4464 setup.sounds_set = artwork.snd_current->identifier;
4465 setup.music_set = artwork.mus_current->identifier;
4467 /* needed if last screen (setup choice) changed graphics, sounds or music */
4468 ReloadCustomArtwork(0);
4470 /* needed for displaying artwork name instead of artwork identifier */
4471 graphics_set_name = artwork.gfx_current->name;
4472 sounds_set_name = artwork.snd_current->name;
4473 music_set_name = artwork.mus_current->name;
4475 setup_mode = SETUP_MODE_ARTWORK;
4479 static void execSetupChooseGraphics()
4485 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4489 static void execSetupChooseSounds()
4495 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4499 static void execSetupChooseMusic()
4505 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4509 static void execSetupInput()
4515 setup_mode = SETUP_MODE_INPUT;
4519 static void execSetupShortcuts1()
4525 setup_mode = SETUP_MODE_SHORTCUTS_1;
4529 static void execSetupShortcuts2()
4535 setup_mode = SETUP_MODE_SHORTCUTS_2;
4539 static void execExitSetup()
4545 game_status = GAME_MODE_MAIN;
4547 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4553 static void execSaveAndExitSetup()
4559 static struct TokenInfo setup_info_main[] =
4561 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4562 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4563 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4564 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4565 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4566 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4567 { TYPE_ENTER_MENU, execSetupShortcuts1, "Key Shortcuts 1" },
4568 { TYPE_ENTER_MENU, execSetupShortcuts2, "Key Shortcuts 2" },
4569 { TYPE_EMPTY, NULL, "" },
4570 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4571 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4576 static struct TokenInfo setup_info_game[] =
4578 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4579 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4580 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4581 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4582 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4583 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4584 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4585 { TYPE_STRING, &game_speed_text, "" },
4586 { TYPE_EMPTY, NULL, "" },
4587 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4592 static struct TokenInfo setup_info_editor[] =
4595 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4596 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4597 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4598 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4599 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4600 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4601 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4602 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4604 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4605 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4606 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4608 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4610 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4611 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4612 { TYPE_EMPTY, NULL, "" },
4614 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4615 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4616 { TYPE_EMPTY, NULL, "" },
4618 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4619 { TYPE_EMPTY, NULL, "" },
4620 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4625 static struct TokenInfo setup_info_graphics[] =
4627 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4628 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4629 { TYPE_STRING, &screen_mode_text, "" },
4631 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
4633 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay Value:" },
4634 { TYPE_STRING, &scroll_delay_text, "" },
4636 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" },
4637 { TYPE_SWITCH, &setup.double_buffering,"Double-Buffering:" },
4639 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4640 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4641 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4642 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4643 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4644 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4645 { TYPE_EMPTY, NULL, "" },
4646 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4651 static struct TokenInfo setup_info_sound[] =
4653 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4654 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4655 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4656 { TYPE_EMPTY, NULL, "" },
4657 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4662 static struct TokenInfo setup_info_artwork[] =
4664 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4665 { TYPE_STRING, &graphics_set_name, "" },
4666 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4667 { TYPE_STRING, &sounds_set_name, "" },
4668 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4669 { TYPE_STRING, &music_set_name, "" },
4670 { TYPE_EMPTY, NULL, "" },
4672 { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
4673 { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:" },
4674 { TYPE_YES_NO, &setup.override_level_music, "Override Level Music:" },
4676 { TYPE_STRING, NULL, "Override Level Artwork:"},
4677 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
4678 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
4679 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
4681 { TYPE_EMPTY, NULL, "" },
4682 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4687 static struct TokenInfo setup_info_input[] =
4689 { TYPE_SWITCH, NULL, "Player:" },
4690 { TYPE_SWITCH, NULL, "Device:" },
4691 { TYPE_ENTER_MENU, NULL, "" },
4692 { TYPE_EMPTY, NULL, "" },
4693 { TYPE_EMPTY, NULL, "" },
4694 { TYPE_EMPTY, NULL, "" },
4695 { TYPE_EMPTY, NULL, "" },
4696 { TYPE_EMPTY, NULL, "" },
4697 { TYPE_EMPTY, NULL, "" },
4698 { TYPE_EMPTY, NULL, "" },
4699 { TYPE_EMPTY, NULL, "" },
4700 { TYPE_EMPTY, NULL, "" },
4701 { TYPE_EMPTY, NULL, "" },
4702 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4707 static struct TokenInfo setup_info_shortcuts_1[] =
4709 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4710 { TYPE_KEY, &setup.shortcut.save_game, "" },
4711 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4712 { TYPE_KEY, &setup.shortcut.load_game, "" },
4713 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4714 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4715 { TYPE_EMPTY, NULL, "" },
4716 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4717 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4718 { TYPE_EMPTY, NULL, "" },
4719 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4724 static struct TokenInfo setup_info_shortcuts_2[] =
4726 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4727 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4728 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4729 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4730 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4731 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4732 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4733 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4734 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4735 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4736 { TYPE_EMPTY, NULL, "" },
4737 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4742 static Key getSetupKey()
4744 Key key = KSYM_UNDEFINED;
4745 boolean got_key_event = FALSE;
4747 while (!got_key_event)
4749 if (PendingEvent()) /* got event */
4757 case EVENT_KEYPRESS:
4759 key = GetEventKey((KeyEvent *)&event, TRUE);
4761 /* press 'Escape' or 'Enter' to keep the existing key binding */
4762 if (key == KSYM_Escape || key == KSYM_Return)
4763 key = KSYM_UNDEFINED; /* keep old value */
4765 got_key_event = TRUE;
4769 case EVENT_KEYRELEASE:
4770 key_joystick_mapping = 0;
4774 HandleOtherEvents(&event);
4782 /* don't eat all CPU time */
4789 static int getSetupTextFont(int type)
4791 if (type & (TYPE_SWITCH |
4802 static int getSetupValueFont(int type, void *value)
4804 if (type & TYPE_KEY)
4805 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
4806 else if (type & TYPE_STRING)
4807 return FONT_VALUE_2;
4808 else if (type & TYPE_ECS_AGA)
4809 return FONT_VALUE_1;
4810 else if (type & TYPE_BOOLEAN_STYLE)
4811 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
4813 return FONT_VALUE_1;
4816 static void drawSetupValue(int pos)
4818 boolean font_draw_xoffset_modified = FALSE;
4819 int font_draw_xoffset_old = -1;
4820 int xpos = MENU_SCREEN_VALUE_XPOS;
4821 int ypos = MENU_SCREEN_START_YPOS + pos;
4822 int startx = mSX + xpos * 32;
4823 int starty = mSY + ypos * 32;
4824 int font_nr, font_width;
4825 int type = setup_info[pos].type;
4826 void *value = setup_info[pos].value;
4827 char *value_string = getSetupValue(type, value);
4830 if (value_string == NULL)
4833 if (type & TYPE_KEY)
4835 xpos = MENU_SCREEN_START_XPOS;
4837 if (type & TYPE_QUERY)
4839 value_string = "<press key>";
4842 else if (type & TYPE_STRING)
4844 int max_value_len = (SCR_FIELDX - 2) * 2;
4846 xpos = MENU_SCREEN_START_XPOS;
4848 if (strlen(value_string) > max_value_len)
4849 value_string[max_value_len] = '\0';
4852 startx = mSX + xpos * 32;
4853 starty = mSY + ypos * 32;
4854 font_nr = getSetupValueFont(type, value);
4855 font_width = getFontWidth(font_nr);
4857 /* downward compatibility correction for Juergen Bonhagen's menu settings */
4858 if (setup_mode != SETUP_MODE_INPUT)
4860 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
4861 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
4862 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
4863 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
4864 int text_font_nr = getSetupTextFont(FONT_MENU_2);
4865 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
4866 int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr);
4867 boolean correct_font_draw_xoffset = FALSE;
4869 if (xpos == MENU_SCREEN_START_XPOS &&
4870 startx + font1_xoffset < text_startx + text_font_xoffset)
4871 correct_font_draw_xoffset = TRUE;
4873 if (xpos == MENU_SCREEN_VALUE_XPOS &&
4874 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
4875 correct_font_draw_xoffset = TRUE;
4877 /* check if setup value would overlap with setup text when printed */
4878 /* (this can happen for extreme/wrong values for font draw offset) */
4879 if (correct_font_draw_xoffset)
4881 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
4882 font_draw_xoffset_modified = TRUE;
4884 if (type & TYPE_KEY)
4885 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
4886 else if (!(type & TYPE_STRING))
4887 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
4888 MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
4892 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
4893 DrawText(startx + i * font_width, starty, " ", font_nr);
4895 DrawText(startx, starty, value_string, font_nr);
4897 if (font_draw_xoffset_modified)
4898 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
4901 static void changeSetupValue(int pos)
4903 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
4905 *(boolean *)setup_info[pos].value ^= TRUE;
4907 else if (setup_info[pos].type & TYPE_KEY)
4911 setup_info[pos].type |= TYPE_QUERY;
4912 drawSetupValue(pos);
4913 setup_info[pos].type &= ~TYPE_QUERY;
4915 key = getSetupKey();
4916 if (key != KSYM_UNDEFINED)
4917 *(Key *)setup_info[pos].value = key;
4920 drawSetupValue(pos);
4923 static void DrawCursorAndText_Setup(int pos, boolean active)
4925 int xpos = MENU_SCREEN_START_XPOS;
4926 int ypos = MENU_SCREEN_START_YPOS + pos;
4927 int font_nr = getSetupTextFont(setup_info[pos].type);
4929 if (setup_info == setup_info_input)
4930 font_nr = FONT_MENU_1;
4933 font_nr = FONT_ACTIVE(font_nr);
4935 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
4937 if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
4938 drawCursor(pos, active);
4941 static void DrawSetupScreen_Generic()
4943 boolean redraw_all = FALSE;
4944 char *title_string = NULL;
4948 CloseDoor(DOOR_CLOSE_2);
4950 if (redraw_mask & REDRAW_ALL)
4954 printf("::: %s\n", (redraw_mask & REDRAW_FIELD ? "REDRAW_FIELD" :
4955 redraw_mask & REDRAW_ALL ? "REDRAW_ALL" :
4956 int2str(0, redraw_mask)));
4960 FadeOut(redraw_mask);
4962 FadeOut(REDRAW_FIELD);
4967 if (setup_mode == SETUP_MODE_MAIN)
4969 setup_info = setup_info_main;
4970 title_string = "Setup";
4972 else if (setup_mode == SETUP_MODE_GAME)
4974 setup_info = setup_info_game;
4975 title_string = "Setup Game";
4977 else if (setup_mode == SETUP_MODE_EDITOR)
4979 setup_info = setup_info_editor;
4980 title_string = "Setup Editor";
4982 else if (setup_mode == SETUP_MODE_GRAPHICS)
4984 setup_info = setup_info_graphics;
4985 title_string = "Setup Graphics";
4987 else if (setup_mode == SETUP_MODE_SOUND)
4989 setup_info = setup_info_sound;
4990 title_string = "Setup Sound";
4992 else if (setup_mode == SETUP_MODE_ARTWORK)
4994 setup_info = setup_info_artwork;
4995 title_string = "Custom Artwork";
4997 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
4999 setup_info = setup_info_shortcuts_1;
5000 title_string = "Setup Shortcuts";
5002 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5004 setup_info = setup_info_shortcuts_2;
5005 title_string = "Setup Shortcuts";
5008 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5012 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5014 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5017 void *value_ptr = setup_info[i].value;
5020 int xpos = MENU_SCREEN_START_XPOS;
5021 int ypos = MENU_SCREEN_START_YPOS + i;
5025 /* set some entries to "unchangeable" according to other variables */
5026 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5027 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5028 (value_ptr == &setup.sound_music && !audio.music_available) ||
5029 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5030 (value_ptr == &screen_mode_text && !video.fullscreen_available))
5031 setup_info[i].type |= TYPE_GHOSTED;
5033 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5034 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5035 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5036 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5037 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5038 initCursor(i, IMG_MENU_BUTTON);
5041 DrawCursorAndText_Setup(i, FALSE);
5043 font_nr = getSetupTextFont(setup_info[i].type);
5045 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr);
5048 if (setup_info[i].type & TYPE_VALUE)
5055 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5056 "Joysticks deactivated in setup menu");
5060 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5064 redraw_mask = REDRAW_ALL;
5067 FadeIn(redraw_mask);
5069 FadeIn(REDRAW_FIELD);
5074 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5078 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5080 static int choice_store[MAX_SETUP_MODES];
5081 int choice = choice_store[setup_mode]; /* always starts with 0 */
5085 if (button == MB_MENU_INITIALIZE)
5087 /* advance to first valid menu entry */
5088 while (choice < num_setup_info &&
5089 setup_info[choice].type & TYPE_SKIP_ENTRY)
5091 choice_store[setup_mode] = choice;
5094 DrawCursorAndText_Setup(choice, TRUE);
5096 drawCursor(choice, TRUE);
5101 else if (button == MB_MENU_LEAVE)
5103 PlaySound(SND_MENU_ITEM_SELECTING);
5105 for (y = 0; y < num_setup_info; y++)
5107 if (setup_info[y].type & TYPE_LEAVE_MENU)
5109 void (*menu_callback_function)(void) = setup_info[y].value;
5113 menu_callback_function();
5115 break; /* absolutely needed because function changes 'setup_info'! */
5122 if (mx || my) /* mouse input */
5124 x = (mx - mSX) / 32;
5125 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5127 else if (dx || dy) /* keyboard input */
5131 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5133 if (setup_info[choice].type & menu_navigation_type ||
5134 setup_info[choice].type & TYPE_BOOLEAN_STYLE)
5135 button = MB_MENU_CHOICE;
5140 /* jump to next non-empty menu entry (up or down) */
5141 while (y > 0 && y < num_setup_info - 1 &&
5142 setup_info[y].type & TYPE_SKIP_ENTRY)
5146 if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
5150 if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
5152 PlaySound(SND_MENU_ITEM_ACTIVATING);
5155 DrawCursorAndText_Setup(choice, FALSE);
5156 DrawCursorAndText_Setup(y, TRUE);
5158 drawCursor(choice, FALSE);
5159 drawCursor(y, TRUE);
5162 choice = choice_store[setup_mode] = y;
5165 else if (!(setup_info[y].type & TYPE_GHOSTED))
5167 PlaySound(SND_MENU_ITEM_SELECTING);
5169 /* when selecting key headline, execute function for key value change */
5170 if (setup_info[y].type & TYPE_KEYTEXT &&
5171 setup_info[y + 1].type & TYPE_KEY)
5174 /* when selecting string value, execute function for list selection */
5175 if (setup_info[y].type & TYPE_STRING && y > 0 &&
5176 setup_info[y - 1].type & TYPE_ENTER_LIST)
5179 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
5181 void (*menu_callback_function)(void) = setup_info[y].value;
5183 FadeSetFromType(setup_info[y].type);
5185 menu_callback_function();
5189 if (setup_info[y].type & TYPE_VALUE)
5190 changeSetupValue(y);
5196 void DrawSetupScreen_Input()
5203 FadeOut(REDRAW_FIELD);
5209 setup_info = setup_info_input;
5212 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5216 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5217 "Joysticks deactivated on this screen");
5219 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5220 "Joysticks deactivated on this screen");
5226 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5228 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5231 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5232 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5233 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5234 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5235 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5236 initCursor(i, IMG_MENU_BUTTON);
5238 DrawCursorAndText_Setup(i, FALSE);
5241 initCursor(0, IMG_MENU_BUTTON);
5242 initCursor(1, IMG_MENU_BUTTON);
5243 initCursor(2, IMG_MENU_BUTTON_ENTER_MENU);
5244 initCursor(13, IMG_MENU_BUTTON_LEAVE_MENU);
5246 DrawText(mSX + 32, mSY + 2 * 32, "Player:", FONT_MENU_1);
5247 DrawText(mSX + 32, mSY + 3 * 32, "Device:", FONT_MENU_1);
5248 DrawText(mSX + 32, mSY + 15 * 32, "Back", FONT_MENU_1);
5252 DeactivateJoystickForCalibration();
5257 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5258 "Joysticks deactivated on this screen");
5260 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5261 "Joysticks deactivated on this screen");
5265 /* create gadgets for setup input menu screen */
5266 FreeScreenGadgets();
5267 CreateScreenGadgets();
5269 /* map gadgets for setup input menu screen */
5270 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5272 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5275 FadeIn(REDRAW_FIELD);
5281 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5283 if (device_name == NULL)
5286 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5289 if (strlen(device_name) > 1)
5291 char c1 = device_name[strlen(device_name) - 1];
5292 char c2 = device_name[strlen(device_name) - 2];
5294 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5295 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5298 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5299 strlen(device_name));
5302 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5305 static struct SetupKeyboardInfo custom_key;
5312 { &custom_key.left, "Joystick Left" },
5313 { &custom_key.right, "Joystick Right" },
5314 { &custom_key.up, "Joystick Up" },
5315 { &custom_key.down, "Joystick Down" },
5316 { &custom_key.snap, "Button 1" },
5317 { &custom_key.drop, "Button 2" }
5319 static char *joystick_name[MAX_PLAYERS] =
5326 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5330 custom_key = setup.input[player_nr].key;
5332 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5333 FONT_INPUT_1_ACTIVE);
5335 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5337 DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5338 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5340 if (setup.input[player_nr].use_joystick)
5342 char *device_name = setup.input[player_nr].joy.device_name;
5343 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5344 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5346 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5347 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5351 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5352 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5355 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5357 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5358 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5359 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5360 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5362 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5363 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5364 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5365 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5366 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5367 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5369 for (i = 0; i < 6; i++)
5371 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5373 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5375 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5376 (setup.input[player_nr].use_joystick ?
5378 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5382 static int input_player_nr = 0;
5384 void HandleSetupScreen_Input_Player(int step, int direction)
5386 int old_player_nr = input_player_nr;
5389 new_player_nr = old_player_nr + step * direction;
5390 if (new_player_nr < 0)
5392 if (new_player_nr > MAX_PLAYERS - 1)
5393 new_player_nr = MAX_PLAYERS - 1;
5395 if (new_player_nr != old_player_nr)
5397 input_player_nr = new_player_nr;
5399 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5403 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5405 static int choice = 0;
5408 int pos_start = SETUPINPUT_SCREEN_POS_START;
5409 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5410 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5411 int pos_end = SETUPINPUT_SCREEN_POS_END;
5413 if (button == MB_MENU_INITIALIZE)
5415 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5418 DrawCursorAndText_Setup(choice, TRUE);
5420 drawCursor(choice, TRUE);
5425 else if (button == MB_MENU_LEAVE)
5427 setup_mode = SETUP_MODE_MAIN;
5434 if (mx || my) /* mouse input */
5436 x = (mx - mSX) / 32;
5437 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5439 else if (dx || dy) /* keyboard input */
5441 if (dx && choice == 0)
5442 x = (dx < 0 ? 10 : 12);
5443 else if ((dx && choice == 1) ||
5444 (dx == +1 && choice == 2) ||
5445 (dx == -1 && choice == pos_end))
5446 button = MB_MENU_CHOICE;
5450 if (y >= pos_empty1 && y <= pos_empty2)
5451 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5454 if (y == 0 && dx != 0 && button)
5456 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5458 else if (IN_VIS_FIELD(x, y) &&
5459 y >= pos_start && y <= pos_end &&
5460 !(y >= pos_empty1 && y <= pos_empty2))
5467 DrawCursorAndText_Setup(choice, FALSE);
5468 DrawCursorAndText_Setup(y, TRUE);
5470 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5472 drawCursor(choice, FALSE);
5473 drawCursor(y, TRUE);
5483 char *device_name = setup.input[input_player_nr].joy.device_name;
5485 if (!setup.input[input_player_nr].use_joystick)
5487 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5489 setJoystickDeviceToNr(device_name, new_device_nr);
5490 setup.input[input_player_nr].use_joystick = TRUE;
5494 int device_nr = getJoystickNrFromDeviceName(device_name);
5495 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5497 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5498 setup.input[input_player_nr].use_joystick = FALSE;
5500 setJoystickDeviceToNr(device_name, new_device_nr);
5503 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5507 if (setup.input[input_player_nr].use_joystick)
5510 CalibrateJoystick(input_player_nr);
5513 CustomizeKeyboard(input_player_nr);
5515 else if (y == pos_end)
5521 setup_mode = SETUP_MODE_MAIN;
5528 void CustomizeKeyboard(int player_nr)
5532 boolean finished = FALSE;
5533 static struct SetupKeyboardInfo custom_key;
5538 } customize_step[] =
5540 { &custom_key.left, "Move Left" },
5541 { &custom_key.right, "Move Right" },
5542 { &custom_key.up, "Move Up" },
5543 { &custom_key.down, "Move Down" },
5544 { &custom_key.snap, "Snap Field" },
5545 { &custom_key.drop, "Drop Element" }
5548 /* read existing key bindings from player setup */
5549 custom_key = setup.input[player_nr].key;
5552 FadeOut(REDRAW_FIELD);
5556 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5564 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5565 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5566 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5567 "Key:", FONT_INPUT_1_ACTIVE);
5568 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5569 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5572 FadeIn(REDRAW_FIELD);
5579 if (PendingEvent()) /* got event */
5587 case EVENT_KEYPRESS:
5589 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5591 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5593 if (key == KSYM_Escape)
5594 FadeSkipNextFadeIn();
5600 /* all keys configured -- wait for "Escape" or "Return" key */
5604 /* press 'Enter' to keep the existing key binding */
5605 if (key == KSYM_Return)
5606 key = *customize_step[step_nr].key;
5608 /* check if key already used */
5609 for (i = 0; i < step_nr; i++)
5610 if (*customize_step[i].key == key)
5615 /* got new key binding */
5616 *customize_step[step_nr].key = key;
5617 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5619 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5620 getKeyNameFromKey(key), FONT_VALUE_1);
5623 /* un-highlight last query */
5624 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
5625 customize_step[step_nr - 1].text, FONT_MENU_1);
5626 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
5627 "Key:", FONT_MENU_1);
5629 /* press 'Enter' to leave */
5632 DrawText(mSX + 16, mSY + 15 * 32 + 16,
5633 "Press Enter", FONT_TITLE_1);
5637 /* query next key binding */
5638 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5639 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5640 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5641 "Key:", FONT_INPUT_1_ACTIVE);
5642 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5643 getKeyNameFromKey(*customize_step[step_nr].key),
5648 case EVENT_KEYRELEASE:
5649 key_joystick_mapping = 0;
5653 HandleOtherEvents(&event);
5661 /* don't eat all CPU time */
5665 /* write new key bindings back to player setup */
5666 setup.input[player_nr].key = custom_key;
5669 DrawSetupScreen_Input();
5672 static boolean CalibrateJoystickMain(int player_nr)
5674 int new_joystick_xleft = JOYSTICK_XMIDDLE;
5675 int new_joystick_xright = JOYSTICK_XMIDDLE;
5676 int new_joystick_yupper = JOYSTICK_YMIDDLE;
5677 int new_joystick_ylower = JOYSTICK_YMIDDLE;
5678 int new_joystick_xmiddle, new_joystick_ymiddle;
5680 int joystick_fd = joystick.fd[player_nr];
5681 int x, y, last_x, last_y, xpos = 8, ypos = 3;
5682 boolean check[3][3];
5683 int check_remaining = 3 * 3;
5688 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
5691 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
5695 FadeOut(REDRAW_FIELD);
5699 for (y = 0; y < 3; y++)
5701 for (x = 0; x < 3; x++)
5703 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
5704 check[x][y] = FALSE;
5708 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
5709 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
5710 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
5711 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
5712 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
5713 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
5714 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
5716 joy_value = Joystick(player_nr);
5717 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5718 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5720 /* eventually uncalibrated center position (joystick could be uncentered) */
5721 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5724 new_joystick_xmiddle = joy_x;
5725 new_joystick_ymiddle = joy_y;
5727 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
5730 FadeIn(REDRAW_FIELD);
5735 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
5740 if (PendingEvent()) /* got event */
5748 case EVENT_KEYPRESS:
5749 switch (GetEventKey((KeyEvent *)&event, TRUE))
5752 if (check_remaining == 0)
5757 FadeSkipNextFadeIn();
5766 case EVENT_KEYRELEASE:
5767 key_joystick_mapping = 0;
5771 HandleOtherEvents(&event);
5776 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5779 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
5780 new_joystick_xright = MAX(new_joystick_xright, joy_x);
5781 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
5782 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
5784 setup.input[player_nr].joy.xleft = new_joystick_xleft;
5785 setup.input[player_nr].joy.yupper = new_joystick_yupper;
5786 setup.input[player_nr].joy.xright = new_joystick_xright;
5787 setup.input[player_nr].joy.ylower = new_joystick_ylower;
5788 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
5789 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
5791 CheckJoystickData();
5793 joy_value = Joystick(player_nr);
5795 if (joy_value & JOY_BUTTON && check_remaining == 0)
5798 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5799 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5801 if (x != last_x || y != last_y)
5803 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0);
5804 DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0);
5809 if (check_remaining > 0 && !check[x+1][y+1])
5811 check[x+1][y+1] = TRUE;
5817 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
5818 setup.input[player_nr].joy.xleft,
5819 setup.input[player_nr].joy.xmiddle,
5820 setup.input[player_nr].joy.xright);
5821 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
5822 setup.input[player_nr].joy.yupper,
5823 setup.input[player_nr].joy.ymiddle,
5824 setup.input[player_nr].joy.ylower);
5833 /* don't eat all CPU time */
5837 /* calibrated center position (joystick should now be centered) */
5838 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5841 new_joystick_xmiddle = joy_x;
5842 new_joystick_ymiddle = joy_y;
5847 DrawSetupScreen_Input();
5850 /* wait until the last pressed button was released */
5851 while (Joystick(player_nr) & JOY_BUTTON)
5853 if (PendingEvent()) /* got event */
5858 HandleOtherEvents(&event);
5867 void CalibrateJoystick(int player_nr)
5869 if (!CalibrateJoystickMain(player_nr))
5871 char *device_name = setup.input[player_nr].joy.device_name;
5872 int nr = getJoystickNrFromDeviceName(device_name) + 1;
5873 int xpos = mSX - SX;
5874 int ypos = mSY - SY;
5878 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
5879 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
5882 Delay(2000); /* show error message for a short time */
5888 DrawSetupScreen_Input();
5892 void DrawSetupScreen()
5894 DeactivateJoystick();
5896 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
5898 if (setup_mode == SETUP_MODE_INPUT)
5899 DrawSetupScreen_Input();
5900 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5901 DrawChooseTree(&game_speed_current);
5902 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5903 DrawChooseTree(&screen_mode_current);
5904 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5905 DrawChooseTree(&scroll_delay_current);
5906 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5907 DrawChooseTree(&artwork.gfx_current);
5908 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5909 DrawChooseTree(&artwork.snd_current);
5910 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5911 DrawChooseTree(&artwork.mus_current);
5913 DrawSetupScreen_Generic();
5919 void RedrawSetupScreenAfterFullscreenToggle()
5921 if (setup_mode == SETUP_MODE_GRAPHICS)
5925 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
5927 if (setup_mode == SETUP_MODE_INPUT)
5928 HandleSetupScreen_Input(mx, my, dx, dy, button);
5929 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5930 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
5931 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5932 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
5933 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5934 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
5935 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5936 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
5937 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5938 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
5939 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5940 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
5942 HandleSetupScreen_Generic(mx, my, dx, dy, button);
5947 void HandleGameActions()
5949 if (game_status != GAME_MODE_PLAYING)
5952 GameActions(); /* main game loop */
5954 if (tape.auto_play && !tape.playing)
5955 AutoPlayTape(); /* continue automatically playing next tape */
5959 /* ---------- new screen button stuff -------------------------------------- */
5961 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
5966 case SCREEN_CTRL_ID_PREV_LEVEL:
5967 *x = mSX + menu.main.button.prev_level.x;
5968 *y = mSY + menu.main.button.prev_level.y;
5971 case SCREEN_CTRL_ID_NEXT_LEVEL:
5972 *x = mSX + menu.main.button.next_level.x;
5973 *y = mSY + menu.main.button.next_level.y;
5976 case SCREEN_CTRL_ID_PREV_LEVEL:
5977 *x = mSX + TILEX * getPrevlevelButtonPos();
5978 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5981 case SCREEN_CTRL_ID_NEXT_LEVEL:
5982 *x = mSX + TILEX * getNextLevelButtonPos();
5983 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5987 case SCREEN_CTRL_ID_PREV_PLAYER:
5988 *x = mSX + TILEX * 10;
5989 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5992 case SCREEN_CTRL_ID_NEXT_PLAYER:
5993 *x = mSX + TILEX * 12;
5994 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5998 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6004 int gfx_unpressed, gfx_pressed;
6005 void (*get_gadget_position)(int *, int *, int);
6009 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6012 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6013 getScreenMenuButtonPos,
6014 SCREEN_CTRL_ID_PREV_LEVEL,
6019 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6020 getScreenMenuButtonPos,
6021 SCREEN_CTRL_ID_NEXT_LEVEL,
6026 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6027 getScreenMenuButtonPos,
6028 SCREEN_CTRL_ID_PREV_PLAYER,
6033 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6034 getScreenMenuButtonPos,
6035 SCREEN_CTRL_ID_NEXT_PLAYER,
6043 int gfx_unpressed, gfx_pressed;
6047 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6050 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6051 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
6052 SCREEN_CTRL_ID_SCROLL_UP,
6056 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6057 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
6058 SCREEN_CTRL_ID_SCROLL_DOWN,
6065 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6066 Bitmap **gfx_unpressed, **gfx_pressed;
6068 int gfx_unpressed, gfx_pressed;
6075 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6078 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6079 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
6081 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6083 SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
6084 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
6085 GD_TYPE_SCROLLBAR_VERTICAL,
6086 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6087 "scroll level series vertically"
6091 static void CreateScreenMenubuttons()
6093 struct GadgetInfo *gi;
6094 unsigned long event_mask;
6097 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6099 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6100 int gfx_unpressed, gfx_pressed;
6101 int x, y, width, height;
6102 int gd_x1, gd_x2, gd_y1, gd_y2;
6103 int id = menubutton_info[i].gadget_id;
6105 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6107 menubutton_info[i].get_gadget_position(&x, &y, id);
6109 width = SC_MENUBUTTON_XSIZE;
6110 height = SC_MENUBUTTON_YSIZE;
6112 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6113 gfx_pressed = menubutton_info[i].gfx_pressed;
6114 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6115 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6116 gd_x1 = graphic_info[gfx_unpressed].src_x;
6117 gd_y1 = graphic_info[gfx_unpressed].src_y;
6118 gd_x2 = graphic_info[gfx_pressed].src_x;
6119 gd_y2 = graphic_info[gfx_pressed].src_y;
6121 gi = CreateGadget(GDI_CUSTOM_ID, id,
6122 GDI_CUSTOM_TYPE_ID, i,
6123 GDI_INFO_TEXT, menubutton_info[i].infotext,
6128 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6129 GDI_STATE, GD_BUTTON_UNPRESSED,
6130 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6131 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6132 GDI_DIRECT_DRAW, FALSE,
6133 GDI_EVENT_MASK, event_mask,
6134 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6138 Error(ERR_EXIT, "cannot create gadget");
6140 screen_gadget[id] = gi;
6144 static void CreateScreenScrollbuttons()
6146 struct GadgetInfo *gi;
6147 unsigned long event_mask;
6150 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6152 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6153 int gfx_unpressed, gfx_pressed;
6154 int x, y, width, height;
6155 int gd_x1, gd_x2, gd_y1, gd_y2;
6156 int id = scrollbutton_info[i].gadget_id;
6158 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6160 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6161 y = mSY + scrollbutton_info[i].y;
6162 width = SC_SCROLLBUTTON_XSIZE;
6163 height = SC_SCROLLBUTTON_YSIZE;
6165 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6166 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6167 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6169 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6170 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6171 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6172 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6173 gd_x1 = graphic_info[gfx_unpressed].src_x;
6174 gd_y1 = graphic_info[gfx_unpressed].src_y;
6175 gd_x2 = graphic_info[gfx_pressed].src_x;
6176 gd_y2 = graphic_info[gfx_pressed].src_y;
6178 gi = CreateGadget(GDI_CUSTOM_ID, id,
6179 GDI_CUSTOM_TYPE_ID, i,
6180 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6185 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6186 GDI_STATE, GD_BUTTON_UNPRESSED,
6187 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6188 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6189 GDI_DIRECT_DRAW, FALSE,
6190 GDI_EVENT_MASK, event_mask,
6191 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6195 Error(ERR_EXIT, "cannot create gadget");
6197 screen_gadget[id] = gi;
6201 static void CreateScreenScrollbars()
6205 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6207 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6208 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6209 int gfx_unpressed, gfx_pressed;
6211 int x, y, width, height;
6212 int gd_x1, gd_x2, gd_y1, gd_y2;
6213 struct GadgetInfo *gi;
6214 int items_max, items_visible, item_position;
6215 unsigned long event_mask;
6216 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6217 int id = scrollbar_info[i].gadget_id;
6219 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6221 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6222 y = mSY + scrollbar_info[i].y;
6223 width = scrollbar_info[i].width;
6224 height = scrollbar_info[i].height;
6226 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6227 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6229 items_max = num_page_entries;
6230 items_visible = num_page_entries;
6233 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6234 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
6235 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
6241 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6242 gfx_pressed = scrollbar_info[i].gfx_pressed;
6243 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6244 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6245 gd_x1 = graphic_info[gfx_unpressed].src_x;
6246 gd_y1 = graphic_info[gfx_unpressed].src_y;
6247 gd_x2 = graphic_info[gfx_pressed].src_x;
6248 gd_y2 = graphic_info[gfx_pressed].src_y;
6251 gi = CreateGadget(GDI_CUSTOM_ID, id,
6252 GDI_CUSTOM_TYPE_ID, i,
6253 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6258 GDI_TYPE, scrollbar_info[i].type,
6259 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6260 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6261 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6263 GDI_WHEEL_AREA_X, SX,
6264 GDI_WHEEL_AREA_Y, SY,
6265 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6266 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6268 GDI_WHEEL_AREA_X, 0,
6269 GDI_WHEEL_AREA_Y, 0,
6270 GDI_WHEEL_AREA_WIDTH, WIN_XSIZE,
6271 GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE,
6273 GDI_STATE, GD_BUTTON_UNPRESSED,
6274 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6275 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6276 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6277 GDI_DIRECT_DRAW, FALSE,
6278 GDI_EVENT_MASK, event_mask,
6279 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6283 Error(ERR_EXIT, "cannot create gadget");
6285 screen_gadget[id] = gi;
6289 void CreateScreenGadgets()
6291 int last_game_status = game_status; /* save current game status */
6293 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6296 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6298 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
6300 /* copy pointers to clip mask and GC */
6301 scrollbar_bitmap[i]->clip_mask =
6302 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
6303 scrollbar_bitmap[i]->stored_clip_gc =
6304 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
6306 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
6307 scrollbar_bitmap[i],
6308 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
6309 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
6310 TILEX, TILEY, 0, 0);
6314 CreateScreenMenubuttons();
6317 /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */
6318 game_status = GAME_MODE_LEVELS;
6321 CreateScreenScrollbuttons();
6322 CreateScreenScrollbars();
6324 game_status = last_game_status; /* restore current game status */
6327 void FreeScreenGadgets()
6331 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6332 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6334 /* prevent freeing clip mask and GC twice */
6335 scrollbar_bitmap[i]->clip_mask = None;
6336 scrollbar_bitmap[i]->stored_clip_gc = None;
6338 FreeBitmap(scrollbar_bitmap[i]);
6342 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6343 FreeGadget(screen_gadget[i]);
6346 void MapScreenMenuGadgets(int screen_mask)
6350 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6351 if (screen_mask & menubutton_info[i].screen_mask)
6352 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6355 void MapScreenTreeGadgets(TreeInfo *ti)
6357 int num_entries = numTreeInfoInGroup(ti);
6360 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6363 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6364 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6366 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6367 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6370 static void HandleScreenGadgets(struct GadgetInfo *gi)
6372 int id = gi->custom_id;
6373 int button = gi->event.button;
6374 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6378 case SCREEN_CTRL_ID_PREV_LEVEL:
6379 HandleMainMenu_SelectLevel(step, -1);
6382 case SCREEN_CTRL_ID_NEXT_LEVEL:
6383 HandleMainMenu_SelectLevel(step, +1);
6386 case SCREEN_CTRL_ID_PREV_PLAYER:
6387 HandleSetupScreen_Input_Player(step, -1);
6390 case SCREEN_CTRL_ID_NEXT_PLAYER:
6391 HandleSetupScreen_Input_Player(step, +1);
6394 case SCREEN_CTRL_ID_SCROLL_UP:
6395 if (game_status == GAME_MODE_LEVELS)
6396 HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6397 else if (game_status == GAME_MODE_SETUP)
6398 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6401 case SCREEN_CTRL_ID_SCROLL_DOWN:
6402 if (game_status == GAME_MODE_LEVELS)
6403 HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6404 else if (game_status == GAME_MODE_SETUP)
6405 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6408 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6409 if (game_status == GAME_MODE_LEVELS)
6410 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
6411 else if (game_status == GAME_MODE_SETUP)
6412 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);