1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
28 /* screens on the info screen */
29 #define INFO_MODE_MAIN 0
30 #define INFO_MODE_TITLE 1
31 #define INFO_MODE_ELEMENTS 2
32 #define INFO_MODE_MUSIC 3
33 #define INFO_MODE_CREDITS 4
34 #define INFO_MODE_PROGRAM 5
35 #define INFO_MODE_VERSION 6
36 #define INFO_MODE_LEVELSET 7
38 #define MAX_INFO_MODES 8
40 /* screens on the setup screen */
41 #define SETUP_MODE_MAIN 0
42 #define SETUP_MODE_GAME 1
43 #define SETUP_MODE_EDITOR 2
44 #define SETUP_MODE_GRAPHICS 3
45 #define SETUP_MODE_SOUND 4
46 #define SETUP_MODE_ARTWORK 5
47 #define SETUP_MODE_INPUT 6
48 #define SETUP_MODE_SHORTCUTS_1 7
49 #define SETUP_MODE_SHORTCUTS_2 8
51 /* sub-screens on the setup screen (generic) */
52 #define SETUP_MODE_CHOOSE_ARTWORK 9
53 #define SETUP_MODE_CHOOSE_OTHER 10
55 /* sub-screens on the setup screen (specific) */
56 #define SETUP_MODE_CHOOSE_GAME_SPEED 11
57 #define SETUP_MODE_CHOOSE_SCREEN_MODE 12
58 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 13
59 #define SETUP_MODE_CHOOSE_GRAPHICS 14
60 #define SETUP_MODE_CHOOSE_SOUNDS 15
61 #define SETUP_MODE_CHOOSE_MUSIC 16
63 #define MAX_SETUP_MODES 17
65 /* for input setup functions */
66 #define SETUPINPUT_SCREEN_POS_START 0
67 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
68 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
69 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
71 /* for various menu stuff */
72 #define MENU_SCREEN_START_XPOS 1
73 #define MENU_SCREEN_START_YPOS 2
74 #define MENU_SCREEN_VALUE_XPOS 14
75 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
76 #define MENU_TITLE1_YPOS 8
77 #define MENU_TITLE2_YPOS 46
78 #define MAX_INFO_ELEMENTS_ON_SCREEN 10
79 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
80 #define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \
81 MENU_SCREEN_START_XPOS)
82 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
84 /* buttons and scrollbars identifiers */
85 #define SCREEN_CTRL_ID_PREV_LEVEL 0
86 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
87 #define SCREEN_CTRL_ID_PREV_PLAYER 2
88 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
89 #define SCREEN_CTRL_ID_SCROLL_UP 4
90 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
91 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
93 #define NUM_SCREEN_GADGETS 7
95 #define NUM_SCREEN_MENUBUTTONS 4
96 #define NUM_SCREEN_SCROLLBUTTONS 2
97 #define NUM_SCREEN_SCROLLBARS 1
99 #define SCREEN_MASK_MAIN (1 << 0)
100 #define SCREEN_MASK_INPUT (1 << 1)
102 /* graphic position and size values for buttons and scrollbars */
103 #define SC_MENUBUTTON_XSIZE TILEX
104 #define SC_MENUBUTTON_YSIZE TILEY
106 #define SC_SCROLLBUTTON_XSIZE TILEX
107 #define SC_SCROLLBUTTON_YSIZE TILEY
109 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
111 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
112 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
113 SC_SCROLLBUTTON_YSIZE)
115 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
116 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
118 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
119 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
120 SC_SCROLLBUTTON_YSIZE)
122 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
123 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
124 SC_SCROLL_VERTICAL_YSIZE)
126 #define SC_BORDER_SIZE 14
129 /* other useful macro definitions */
130 #define BUTTON_GRAPHIC_ACTIVE(g) \
131 (g == IMG_MENU_BUTTON_LEFT ? IMG_MENU_BUTTON_LEFT_ACTIVE : \
132 g == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE : \
133 g == IMG_MENU_BUTTON_UP ? IMG_MENU_BUTTON_UP_ACTIVE : \
134 g == IMG_MENU_BUTTON_DOWN ? IMG_MENU_BUTTON_DOWN_ACTIVE : \
135 g == IMG_MENU_BUTTON_LEAVE_MENU ? IMG_MENU_BUTTON_LEAVE_MENU_ACTIVE : \
136 g == IMG_MENU_BUTTON_ENTER_MENU ? IMG_MENU_BUTTON_ENTER_MENU_ACTIVE : \
137 g == IMG_MENU_BUTTON_PREV_LEVEL ? IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE : \
138 g == IMG_MENU_BUTTON_NEXT_LEVEL ? IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE : \
139 g == IMG_MENU_BUTTON_NAME ? IMG_MENU_BUTTON_NAME_ACTIVE : \
140 g == IMG_MENU_BUTTON_LEVELS ? IMG_MENU_BUTTON_LEVELS_ACTIVE : \
141 g == IMG_MENU_BUTTON_SCORES ? IMG_MENU_BUTTON_SCORES_ACTIVE : \
142 g == IMG_MENU_BUTTON_EDITOR ? IMG_MENU_BUTTON_EDITOR_ACTIVE : \
143 g == IMG_MENU_BUTTON_INFO ? IMG_MENU_BUTTON_INFO_ACTIVE : \
144 g == IMG_MENU_BUTTON_GAME ? IMG_MENU_BUTTON_GAME_ACTIVE : \
145 g == IMG_MENU_BUTTON_SETUP ? IMG_MENU_BUTTON_SETUP_ACTIVE : \
146 g == IMG_MENU_BUTTON_QUIT ? IMG_MENU_BUTTON_QUIT_ACTIVE : \
147 IMG_MENU_BUTTON_ACTIVE)
151 /* forward declarations of internal functions */
152 static void HandleScreenGadgets(struct GadgetInfo *);
153 static void HandleSetupScreen_Generic(int, int, int, int, int);
154 static void HandleSetupScreen_Input(int, int, int, int, int);
155 static void CustomizeKeyboard(int);
156 static void CalibrateJoystick(int);
157 static void execSetupGame(void);
158 static void execSetupGraphics(void);
159 static void execSetupArtwork(void);
160 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
162 static void DrawChooseLevel(void);
163 static void DrawInfoScreen(void);
164 static void DrawAndFadeInInfoScreen(int);
165 static void DrawSetupScreen(void);
167 static void DrawInfoScreenExt(int, int);
168 static void DrawInfoScreen_NotAvailable(char *, char *);
169 static void DrawInfoScreen_HelpAnim(int, int, boolean);
170 static void DrawInfoScreen_HelpText(int, int, int, int);
171 static void HandleInfoScreen_Main(int, int, int, int, int);
172 static void HandleInfoScreen_TitleScreen(int);
173 static void HandleInfoScreen_Elements(int);
174 static void HandleInfoScreen_Music(int);
175 static void HandleInfoScreen_Credits(int);
176 static void HandleInfoScreen_Program(int);
177 static void HandleInfoScreen_Version(int);
179 static void MapScreenMenuGadgets(int);
180 static void MapScreenTreeGadgets(TreeInfo *);
182 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
184 static int info_mode = INFO_MODE_MAIN;
185 static int setup_mode = SETUP_MODE_MAIN;
187 static TreeInfo *screen_modes = NULL;
188 static TreeInfo *screen_mode_current = NULL;
190 static TreeInfo *scroll_delays = NULL;
191 static TreeInfo *scroll_delay_current = NULL;
193 static TreeInfo *game_speeds = NULL;
194 static TreeInfo *game_speed_current = NULL;
200 } game_speeds_list[] =
209 { 1000, "1/1s (Extremely Slow)" },
214 { 29, "1/35s (Original Supaplex)" },
216 { 20, "1/50s (Normal Speed)" },
217 { 14, "1/70s (Maximum Supaplex)" },
221 { 1, "1/1000s (Extremely Fast)" },
231 } scroll_delays_list[] =
233 { 0, "0 Tiles (No Scroll Delay)" },
236 { 3, "3 Tiles (Default)" },
241 { 8, "8 Tiles (Maximum Scroll Delay)"},
246 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
247 (s) <= GAME_MODE_SETUP ? (s) : \
248 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
249 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
251 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
252 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
253 (i) <= INFO_MODE_LEVELSET ? (i) : \
256 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
257 (i) <= SETUP_MODE_SHORTCUTS_2 ? (i) : \
258 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
259 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
260 SETUP_MODE_CHOOSE_ARTWORK : \
261 SETUP_MODE_CHOOSE_OTHER)
263 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
264 menu.draw_xoffset[GAME_MODE_INFO] : \
265 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
266 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
267 menu.draw_yoffset[GAME_MODE_INFO] : \
268 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
270 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
271 menu.draw_xoffset[GAME_MODE_SETUP] : \
272 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
273 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
274 menu.draw_yoffset[GAME_MODE_SETUP] : \
275 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
277 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
278 DRAW_XOFFSET_INFO(info_mode) : \
279 (s) == GAME_MODE_SETUP ? \
280 DRAW_XOFFSET_SETUP(setup_mode) : \
281 menu.draw_xoffset[DRAW_MODE(s)])
282 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
283 DRAW_YOFFSET_INFO(info_mode) : \
284 (s) == GAME_MODE_SETUP ? \
285 DRAW_YOFFSET_SETUP(setup_mode) : \
286 menu.draw_yoffset[DRAW_MODE(s)])
288 #define mSX (SX + DRAW_XOFFSET(game_status))
289 #define mSY (SY + DRAW_YOFFSET(game_status))
291 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
292 menu.list_size[game_status] : \
293 MAX_MENU_ENTRIES_ON_SCREEN)
295 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
296 #define NUM_SCROLLBAR_BITMAPS 2
297 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS];
301 /* title display and control definitions */
303 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
304 2 * MAX_NUM_TITLE_MESSAGES)
306 static int num_title_screens = 0;
308 struct TitleControlInfo
316 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
318 /* main menu display and control definitions */
320 #define MAIN_CONTROL_NAME 0
321 #define MAIN_CONTROL_LEVELS 1
322 #define MAIN_CONTROL_SCORES 2
323 #define MAIN_CONTROL_EDITOR 3
324 #define MAIN_CONTROL_INFO 4
325 #define MAIN_CONTROL_GAME 5
326 #define MAIN_CONTROL_SETUP 6
327 #define MAIN_CONTROL_QUIT 7
328 #define MAIN_CONTROL_PREV_LEVEL 8
329 #define MAIN_CONTROL_NEXT_LEVEL 9
330 #define MAIN_CONTROL_FIRST_LEVEL 10
331 #define MAIN_CONTROL_LAST_LEVEL 11
332 #define MAIN_CONTROL_LEVEL_NUMBER 12
333 #define MAIN_CONTROL_LEVEL_INFO_1 13
334 #define MAIN_CONTROL_LEVEL_INFO_2 14
335 #define MAIN_CONTROL_LEVEL_NAME 15
336 #define MAIN_CONTROL_LEVEL_AUTHOR 16
337 #define MAIN_CONTROL_LEVEL_YEAR 17
338 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
339 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
340 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
341 #define MAIN_CONTROL_TITLE_1 21
342 #define MAIN_CONTROL_TITLE_2 22
343 #define MAIN_CONTROL_TITLE_3 23
345 static char str_main_text_name[10];
346 static char str_main_text_first_level[10];
347 static char str_main_text_last_level[10];
348 static char str_main_text_level_number[10];
350 static char *main_text_name = str_main_text_name;
351 static char *main_text_first_level = str_main_text_first_level;
352 static char *main_text_last_level = str_main_text_last_level;
353 static char *main_text_level_number = str_main_text_level_number;
354 static char *main_text_levels = "Levelset";
355 static char *main_text_scores = "Hall Of Fame";
356 static char *main_text_editor = "Level Creator";
357 static char *main_text_info = "Info Screen";
358 static char *main_text_game = "Start Game";
359 static char *main_text_setup = "Setup";
360 static char *main_text_quit = "Quit";
361 static char *main_text_level_name = level.name;
362 static char *main_text_level_author = level.author;
363 static char *main_text_level_year = NULL;
364 static char *main_text_level_imported_from = NULL;
365 static char *main_text_level_imported_by = NULL;
366 static char *main_text_level_tested_by = NULL;
367 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
368 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
369 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
371 struct MainControlInfo
375 struct MenuPosInfo *pos_button;
378 struct TextPosInfo *pos_text;
381 struct TextPosInfo *pos_input;
385 static struct MainControlInfo main_controls[] =
389 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
390 &menu.main.text.name, &main_text_name,
391 &menu.main.input.name, &setup.player_name,
395 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
396 &menu.main.text.levels, &main_text_levels,
401 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
402 &menu.main.text.scores, &main_text_scores,
407 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
408 &menu.main.text.editor, &main_text_editor,
413 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
414 &menu.main.text.info, &main_text_info,
419 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
420 &menu.main.text.game, &main_text_game,
425 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
426 &menu.main.text.setup, &main_text_setup,
431 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
432 &menu.main.text.quit, &main_text_quit,
436 /* (these two buttons are real gadgets) */
438 MAIN_CONTROL_PREV_LEVEL,
439 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
444 MAIN_CONTROL_NEXT_LEVEL,
445 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
451 MAIN_CONTROL_FIRST_LEVEL,
453 &menu.main.text.first_level, &main_text_first_level,
457 MAIN_CONTROL_LAST_LEVEL,
459 &menu.main.text.last_level, &main_text_last_level,
463 MAIN_CONTROL_LEVEL_NUMBER,
465 &menu.main.text.level_number, &main_text_level_number,
469 MAIN_CONTROL_LEVEL_INFO_1,
471 &menu.main.text.level_info_1, NULL,
475 MAIN_CONTROL_LEVEL_INFO_2,
477 &menu.main.text.level_info_2, NULL,
481 MAIN_CONTROL_LEVEL_NAME,
483 &menu.main.text.level_name, &main_text_level_name,
487 MAIN_CONTROL_LEVEL_AUTHOR,
489 &menu.main.text.level_author, &main_text_level_author,
493 MAIN_CONTROL_LEVEL_YEAR,
495 &menu.main.text.level_year, &main_text_level_year,
499 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
501 &menu.main.text.level_imported_from, &main_text_level_imported_from,
505 MAIN_CONTROL_LEVEL_IMPORTED_BY,
507 &menu.main.text.level_imported_by, &main_text_level_imported_by,
511 MAIN_CONTROL_LEVEL_TESTED_BY,
513 &menu.main.text.level_tested_by, &main_text_level_tested_by,
517 MAIN_CONTROL_TITLE_1,
519 &menu.main.text.title_1, &main_text_title_1,
523 MAIN_CONTROL_TITLE_2,
525 &menu.main.text.title_2, &main_text_title_2,
529 MAIN_CONTROL_TITLE_3,
531 &menu.main.text.title_3, &main_text_title_3,
544 static int getTitleScreenGraphic(int nr, boolean initial)
546 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
549 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
551 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
555 static int getTitleScreenGameMode(boolean initial)
557 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
561 static int getTitleMessageGameMode(boolean initial)
563 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
567 static int getTitleScreenBackground(boolean initial)
569 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
574 static int getTitleMessageBackground(int nr, boolean initial)
576 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
580 static int getTitleBackground(int nr, boolean initial, boolean is_image)
582 int base = (is_image ?
583 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
584 IMG_BACKGROUND_TITLESCREEN_1) :
585 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
586 IMG_BACKGROUND_TITLEMESSAGE_1));
587 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
588 IMG_BACKGROUND_TITLE);
589 int graphic_local = base + nr;
591 if (graphic_info[graphic_local].bitmap != NULL)
592 return graphic_local;
594 if (graphic_info[graphic_global].bitmap != NULL)
595 return graphic_global;
597 return IMG_UNDEFINED;
600 static int getTitleSound(struct TitleControlInfo *tci)
602 boolean is_image = tci->is_image;
603 int initial = tci->initial;
604 int nr = tci->local_nr;
605 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
606 int base = (is_image ?
607 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
608 SND_BACKGROUND_TITLESCREEN_1) :
609 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
610 SND_BACKGROUND_TITLEMESSAGE_1));
611 int sound_global = menu.sound[mode];
612 int sound_local = base + nr;
615 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
616 nr, initial, is_image,
617 sound_global, getSoundListEntry(sound_global)->filename,
618 sound_local, getSoundListEntry(sound_local)->filename);
621 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
624 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
627 return SND_UNDEFINED;
630 static int getTitleMusic(struct TitleControlInfo *tci)
632 boolean is_image = tci->is_image;
633 int initial = tci->initial;
634 int nr = tci->local_nr;
635 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
636 int base = (is_image ?
637 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
638 MUS_BACKGROUND_TITLESCREEN_1) :
639 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
640 MUS_BACKGROUND_TITLEMESSAGE_1));
641 int music_global = menu.music[mode];
642 int music_local = base + nr;
645 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
646 nr, initial, is_image,
647 music_global, getMusicListEntry(music_global)->filename,
648 music_local, getMusicListEntry(music_local)->filename);
651 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
654 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
657 return MUS_UNDEFINED;
660 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
662 boolean is_image = tci->is_image;
663 int initial = tci->initial;
664 int nr = tci->local_nr;
665 struct TitleFadingInfo ti;
669 int graphic = getTitleScreenGraphic(nr, initial);
671 /* initialize fading control values to default title config settings */
672 ti = (initial ? title_initial_default : title_default);
674 /* override default settings with image config settings, if defined */
675 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
676 ti.fade_mode = graphic_info[graphic].fade_mode;
677 if (graphic_info[graphic].fade_delay > -1)
678 ti.fade_delay = graphic_info[graphic].fade_delay;
679 if (graphic_info[graphic].post_delay > -1)
680 ti.post_delay = graphic_info[graphic].post_delay;
681 if (graphic_info[graphic].auto_delay > -1)
682 ti.auto_delay = graphic_info[graphic].auto_delay;
688 ti.fade_mode = titlemessage_initial[nr].fade_mode;
689 ti.fade_delay = titlemessage_initial[nr].fade_delay;
690 ti.post_delay = titlemessage_initial[nr].post_delay;
691 ti.auto_delay = titlemessage_initial[nr].auto_delay;
695 ti.fade_mode = titlemessage[nr].fade_mode;
696 ti.fade_delay = titlemessage[nr].fade_delay;
697 ti.post_delay = titlemessage[nr].post_delay;
698 ti.auto_delay = titlemessage[nr].auto_delay;
703 if (ti.anim_mode == ANIM_NONE)
704 ti.fade_delay = ti.post_delay = 0;
710 static int compareTitleControlInfo(const void *object1, const void *object2)
712 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
713 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
716 if (tci1->initial != tci2->initial)
717 compare_result = (tci1->initial ? -1 : +1);
718 else if (tci1->sort_priority != tci2->sort_priority)
719 compare_result = tci1->sort_priority - tci2->sort_priority;
720 else if (tci1->is_image != tci2->is_image)
721 compare_result = (tci1->is_image ? -1 : +1);
723 compare_result = tci1->local_nr - tci2->local_nr;
725 return compare_result;
728 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
730 int nr, int sort_priority)
732 title_controls[num_title_screens].is_image = is_image;
733 title_controls[num_title_screens].initial = initial;
734 title_controls[num_title_screens].local_nr = nr;
735 title_controls[num_title_screens].sort_priority = sort_priority;
740 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
744 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
746 int graphic = getTitleScreenGraphic(i, initial);
747 Bitmap *bitmap = graphic_info[graphic].bitmap;
748 int sort_priority = graphic_info[graphic].sort_priority;
751 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
754 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
756 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
757 char *filename = getLevelSetTitleMessageFilename(i, initial);
758 int sort_priority = tmi->sort_priority;
760 if (filename != NULL)
761 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
765 static void InitializeTitleControls(boolean show_title_initial)
767 num_title_screens = 0;
769 if (show_title_initial)
770 InitializeTitleControls_CheckTitleInfo(TRUE);
772 InitializeTitleControls_CheckTitleInfo(FALSE);
774 /* sort title screens according to sort_priority and title number */
775 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
776 compareTitleControlInfo);
779 static boolean visibleMenuPos(struct MenuPosInfo *pos)
781 return (pos != NULL && pos->x != -1 && pos->y != -1);
784 static boolean visibleTextPos(struct TextPosInfo *pos)
786 return (pos != NULL && pos->x != -1 && pos->y != -1);
789 static void InitializeMainControls()
791 boolean local_team_mode = (!options.network && setup.team_mode);
794 /* set main control text values to dynamically determined values */
795 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
797 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
798 menu.main.text.first_level.size));
799 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
800 menu.main.text.last_level.size));
801 strcpy(main_text_level_number, int2str(level_nr,
802 menu.main.text.level_number.size));
804 main_text_level_year = leveldir_current->year;
805 main_text_level_imported_from = leveldir_current->imported_from;
806 main_text_level_imported_by = leveldir_current->imported_by;
807 main_text_level_tested_by = leveldir_current->tested_by;
809 /* set main control screen positions to dynamically determined values */
810 for (i = 0; main_controls[i].nr != -1; i++)
812 struct MainControlInfo *mci = &main_controls[i];
814 struct MenuPosInfo *pos_button = mci->pos_button;
815 struct TextPosInfo *pos_text = mci->pos_text;
816 struct TextPosInfo *pos_input = mci->pos_input;
817 char *text = (mci->text ? *mci->text : NULL);
818 char *input = (mci->input ? *mci->input : NULL);
819 int button_graphic = mci->button_graphic;
821 int font_text = (pos_text ? pos_text->font : -1);
822 int font_input = (pos_input ? pos_input->font : -1);
824 int font_text = mci->font_text;
825 int font_input = mci->font_input;
828 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
829 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
830 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
831 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
832 int text_chars = (text != NULL ? strlen(text) : 0);
833 int input_chars = (input != NULL ? strlen(input) : 0);
836 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
838 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
839 int text_width = font_text_width * text_chars;
840 int text_height = font_text_height;
841 int input_width = font_input_width * input_chars;
842 int input_height = font_input_height;
844 if (nr == MAIN_CONTROL_NAME)
847 if (menu.main.input.name.x == -1)
848 menu.main.input.name.x = menu.main.text.name.x + text_width;
849 if (menu.main.input.name.y == -1)
850 menu.main.input.name.y = menu.main.text.name.y;
854 menu.main.input.name.width = input_width;
855 menu.main.input.name.height = input_height;
857 menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
858 menu.main.input.name.height = font_input_height;
862 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
864 if (pos_button->width == 0)
865 pos_button->width = button_width;
866 if (pos_button->height == 0)
867 pos_button->height = button_height;
870 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
872 /* calculate width for non-clickable text -- needed for text alignment */
873 boolean calculate_text_width = (pos_button == NULL && text != NULL);
875 if (visibleMenuPos(pos_button))
877 if (pos_text->x == -1)
878 pos_text->x = pos_button->x + pos_button->width;
879 if (pos_text->y == -1)
880 pos_text->y = pos_button->y;
883 if (pos_text->width == -1 || calculate_text_width)
884 pos_text->width = text_width;
885 if (pos_text->height == -1)
886 pos_text->height = text_height;
889 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
891 if (visibleTextPos(pos_text))
893 if (pos_input->x == -1)
894 pos_input->x = pos_text->x + pos_text->width;
895 if (pos_input->y == -1)
896 pos_input->y = pos_text->y;
899 if (pos_input->width == -1)
900 pos_input->width = input_width;
901 if (pos_input->height == -1)
902 pos_input->height = input_height;
907 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
908 boolean active_input)
912 for (i = 0; main_controls[i].nr != -1; i++)
914 struct MainControlInfo *mci = &main_controls[i];
916 if (mci->nr == nr || nr == -1)
918 struct MenuPosInfo *pos_button = mci->pos_button;
919 struct TextPosInfo *pos_text = mci->pos_text;
920 struct TextPosInfo *pos_input = mci->pos_input;
921 char *text = (mci->text ? *mci->text : NULL);
922 char *input = (mci->input ? *mci->input : NULL);
923 int button_graphic = mci->button_graphic;
925 int font_text = (pos_text ? pos_text->font : -1);
926 int font_input = (pos_input ? pos_input->font : -1);
928 int font_text = mci->font_text;
929 int font_input = mci->font_input;
934 button_graphic = BUTTON_ACTIVE(button_graphic);
935 font_text = FONT_ACTIVE(font_text);
940 font_input = FONT_ACTIVE(font_input);
943 if (visibleMenuPos(pos_button))
945 struct MenuPosInfo *pos = pos_button;
946 int x = mSX + pos->x;
947 int y = mSY + pos->y;
949 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
950 DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
953 if (visibleTextPos(pos_text) && text != NULL)
955 struct TextPosInfo *pos = pos_text;
956 int x = mSX + ALIGNED_TEXT_XPOS(pos);
957 int y = mSY + ALIGNED_TEXT_YPOS(pos);
960 /* (check why/if this is needed) */
961 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
963 DrawText(x, y, text, font_text);
966 if (visibleTextPos(pos_input) && input != NULL)
968 struct TextPosInfo *pos = pos_input;
969 int x = mSX + ALIGNED_TEXT_XPOS(pos);
970 int y = mSY + ALIGNED_TEXT_YPOS(pos);
973 /* (check why/if this is needed) */
974 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
976 DrawText(x, y, input, font_input);
982 static void DrawCursorAndText_Main(int nr, boolean active_text)
984 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
988 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
990 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
994 static struct MainControlInfo *getMainControlInfo(int nr)
998 for (i = 0; main_controls[i].nr != -1; i++)
999 if (main_controls[i].nr == nr)
1000 return &main_controls[i];
1005 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1010 int rect_x = ALIGNED_TEXT_XPOS(rect);
1011 int rect_y = ALIGNED_TEXT_YPOS(rect);
1013 return (x >= rect_x && x < rect_x + rect->width &&
1014 y >= rect_y && y < rect_y + rect->height);
1017 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1022 int rect_x = ALIGNED_TEXT_XPOS(rect);
1023 int rect_y = ALIGNED_TEXT_YPOS(rect);
1025 return (x >= rect_x && x < rect_x + rect->width &&
1026 y >= rect_y && y < rect_y + rect->height);
1029 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1031 static int cursor_array[SCR_FIELDY];
1032 int x = mSX + TILEX * xpos;
1033 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1038 cursor_array[ypos] = graphic;
1040 graphic = cursor_array[ypos];
1044 graphic = BUTTON_ACTIVE(graphic);
1046 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1047 DrawGraphicThruMaskExt(drawto, x, y, graphic, 0);
1050 static void initCursor(int ypos, int graphic)
1052 drawCursorExt(0, ypos, FALSE, graphic);
1055 static void drawCursor(int ypos, boolean active)
1057 drawCursorExt(0, ypos, active, -1);
1060 static void drawCursorXY(int xpos, int ypos, int graphic)
1062 drawCursorExt(xpos, ypos, FALSE, graphic);
1065 static void drawChooseTreeCursor(int ypos, boolean active)
1067 int last_game_status = game_status; /* save current game status */
1070 /* force LEVELS draw offset on artwork setup screen */
1071 game_status = GAME_MODE_LEVELS;
1074 drawCursorExt(0, ypos, active, -1);
1076 game_status = last_game_status; /* restore current game status */
1081 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1082 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1086 static int getPrevlevelButtonPos()
1091 static int getCurrentLevelTextPos()
1093 return (getPrevlevelButtonPos() + 1);
1096 static int getNextLevelButtonPos()
1098 return getPrevlevelButtonPos() + 3 + 1;
1101 static int getLevelRangeTextPos()
1103 return getNextLevelButtonPos() + 1;
1107 int effectiveGameStatus()
1109 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1110 return GAME_MODE_TITLE;
1115 void DrawTitleScreenImage(int nr, boolean initial)
1117 int graphic = getTitleScreenGraphic(nr, initial);
1118 Bitmap *bitmap = graphic_info[graphic].bitmap;
1120 int width = graphic_info[graphic].width;
1121 int height = graphic_info[graphic].height;
1122 int src_x = graphic_info[graphic].src_x;
1123 int src_y = graphic_info[graphic].src_y;
1125 int width = graphic_info[graphic].src_image_width;
1126 int height = graphic_info[graphic].src_image_height;
1127 int src_x = 0, src_y = 0;
1134 if (width > WIN_XSIZE)
1136 /* image width too large for window => center image horizontally */
1137 src_x = (width - WIN_XSIZE) / 2;
1141 if (height > WIN_YSIZE)
1143 /* image height too large for window => center image vertically */
1144 src_y = (height - WIN_YSIZE) / 2;
1148 /* always display title screens centered */
1149 dst_x = (WIN_XSIZE - width) / 2;
1150 dst_y = (WIN_YSIZE - height) / 2;
1152 SetDrawBackgroundMask(REDRAW_ALL);
1153 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1155 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1157 if (DrawingOnBackground(dst_x, dst_y))
1158 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1160 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1162 redraw_mask = REDRAW_ALL;
1164 /* reset fading control values to default config settings */
1168 title = getTitleFading(nr, initial, TRUE);
1173 title.fade_delay_final = title.fade_delay;
1174 title.post_delay_final = title.post_delay;
1175 title.auto_delay_final = title.auto_delay;
1177 /* override default settings with image config settings, if defined */
1178 if (graphic_info[graphic].anim_mode != ANIM_DEFAULT)
1179 title.anim_mode = graphic_info[graphic].anim_mode;
1180 if (graphic_info[graphic].fade_delay > -1)
1181 title.fade_delay = graphic_info[graphic].fade_delay;
1182 if (graphic_info[graphic].post_delay > -1)
1183 title.post_delay = graphic_info[graphic].post_delay;
1184 if (graphic_info[graphic].auto_delay > -1)
1185 title.auto_delay = graphic_info[graphic].auto_delay;
1189 void DrawTitleScreenMessage(int nr, boolean initial)
1191 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1192 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1194 int font_nr = FONT_TEXT_1;
1198 int pad_y = 32 + 14;
1201 int max_chars_per_line;
1202 int max_lines_per_screen;
1204 int last_game_status = game_status; /* save current game status */
1206 if (filename == NULL)
1209 /* force TITLE font on title message screen */
1210 game_status = getTitleMessageGameMode(initial);
1212 /* if chars set to "-1", automatically determine by text and font width */
1213 if (tmi->chars == -1)
1214 tmi->chars = tmi->width / getFontWidth(tmi->font);
1216 tmi->width = tmi->chars * getFontWidth(tmi->font);
1218 /* if lines set to "-1", automatically determine by text and font height */
1219 if (tmi->lines == -1)
1220 tmi->lines = tmi->height / getFontHeight(tmi->font);
1222 tmi->height = tmi->lines * getFontHeight(tmi->font);
1224 SetDrawBackgroundMask(REDRAW_ALL);
1225 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1227 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1230 font_width = getFontWidth(font_nr);
1231 font_height = getFontHeight(font_nr);
1232 max_chars_per_line = (WIN_XSIZE - 2 * pad_x) / font_width;
1233 max_lines_per_screen = (WIN_YSIZE - pad_y) / font_height - 1;
1237 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1238 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
1239 tmi->autowrap, tmi->centered, tmi->parse_comments);
1241 DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
1242 max_lines_per_screen, -1, tmi->autowrap, tmi->centered,
1243 tmi->parse_comments);
1246 game_status = last_game_status; /* restore current game status */
1249 void DrawTitleScreen()
1251 KeyboardAutoRepeatOff();
1254 SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
1257 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1262 boolean CheckTitleScreen(boolean levelset_has_changed)
1264 static boolean show_title_initial = TRUE;
1265 boolean show_titlescreen = FALSE;
1267 /* needed to be able to skip title screen, if no image or message defined */
1268 InitializeTitleControls(show_title_initial);
1270 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1271 show_titlescreen = TRUE;
1273 /* show initial title images and messages only once at program start */
1274 show_title_initial = FALSE;
1276 return (show_titlescreen && num_title_screens > 0);
1279 void DrawMainMenuExt(int redraw_mask, boolean do_fading)
1281 static LevelDirTree *leveldir_last_valid = NULL;
1282 boolean levelset_has_changed = FALSE;
1283 boolean redraw_all = FALSE;
1285 FadeSetLeaveScreen();
1287 /* (does not work well when changing to editor, which fades out itself) */
1289 FadeOut(redraw_mask);
1293 FadeSoundsAndMusic();
1295 KeyboardAutoRepeatOn();
1298 SetDrawDeactivationMask(REDRAW_NONE);
1299 SetDrawBackgroundMask(REDRAW_FIELD);
1301 audio.sound_deactivated = FALSE;
1305 /* needed if last screen was the playing screen, invoked from level editor */
1306 if (level_editor_test_game)
1308 game_status = GAME_MODE_EDITOR;
1315 FadeOut(redraw_mask);
1317 /* needed if last screen was the editor screen */
1318 UndrawSpecialEditorDoor();
1321 /* needed if last screen was the setup screen and fullscreen state changed */
1322 ToggleFullscreenIfNeeded();
1324 /* leveldir_current may be invalid (level group, parent link) */
1325 if (!validLevelSeries(leveldir_current))
1326 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1328 if (leveldir_current != leveldir_last_valid)
1329 levelset_has_changed = TRUE;
1331 /* store valid level series information */
1332 leveldir_last_valid = leveldir_current;
1334 /* needed if last screen (level choice) changed graphics, sounds or music */
1335 ReloadCustomArtwork(0);
1337 if (redraw_mask & REDRAW_ALL)
1342 printf("::: FadeOut @ DrawMainMenuExt ...\n");
1344 FadeOut(redraw_mask);
1346 printf("::: FadeOut @ DrawMainMenuExt done\n");
1349 /* needed if last screen was the editor screen */
1350 UndrawSpecialEditorDoor();
1353 #if defined(TARGET_SDL)
1354 SetDrawtoField(DRAW_BACKBUFFER);
1357 if (CheckTitleScreen(levelset_has_changed))
1359 game_status = GAME_MODE_TITLE;
1366 /* level_nr may have been set to value over handicap with level editor */
1367 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1368 level_nr = leveldir_current->handicap_level;
1370 LoadLevel(level_nr);
1372 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1375 FadeOut(redraw_mask);
1379 if (redraw_mask == REDRAW_ALL)
1381 // int door_state = GetDoorState();
1385 // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1391 InitializeMainControls();
1393 DrawCursorAndText_Main(-1, FALSE);
1394 DrawPreviewLevel(TRUE);
1396 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1399 if (TAPE_IS_EMPTY(tape))
1401 DrawCompleteVideoDisplay();
1406 /* create gadgets for main menu screen */
1407 FreeScreenGadgets();
1408 CreateScreenGadgets();
1410 /* map gadgets for main menu screen */
1412 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1415 DrawMaskedBorder(REDRAW_ALL);
1419 if (redraw_mask == REDRAW_ALL)
1421 int door_state = GetDoorState();
1423 // RedrawBackground();
1425 OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1431 redraw_mask = REDRAW_ALL;
1434 FadeIn(redraw_mask);
1438 SetMouseCursor(CURSOR_DEFAULT);
1442 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1445 void DrawAndFadeInMainMenu(int redraw_mask)
1447 DrawMainMenuExt(redraw_mask, TRUE);
1452 DrawMainMenuExt(REDRAW_ALL, FALSE);
1456 static void gotoTopLevelDir()
1458 /* move upwards to top level directory */
1459 while (leveldir_current->node_parent)
1461 /* write a "path" into level tree for easy navigation to last level */
1462 if (leveldir_current->node_parent->node_group->cl_first == -1)
1464 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1465 int leveldir_pos = posTreeInfo(leveldir_current);
1466 int num_page_entries;
1467 int cl_first, cl_cursor;
1469 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1470 num_page_entries = num_leveldirs;
1472 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1474 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1475 cl_cursor = leveldir_pos - cl_first;
1477 leveldir_current->node_parent->node_group->cl_first = cl_first;
1478 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1481 leveldir_current = leveldir_current->node_parent;
1486 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1488 static unsigned long title_delay = 0;
1489 static int title_screen_nr = 0;
1490 static int last_sound = -1, last_music = -1;
1491 boolean return_to_main_menu = FALSE;
1492 boolean use_fading_main_menu = TRUE;
1495 boolean use_cross_fading = FALSE;
1497 boolean use_cross_fading = !show_title_initial; /* default */
1500 struct TitleControlInfo *tci;
1501 struct TitleFadingInfo fading_default;
1502 struct TitleFadingInfo fading_last = fading;
1503 struct TitleFadingInfo fading_next;
1506 if (button == MB_MENU_INITIALIZE)
1509 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1513 int last_game_status = game_status; /* save current game status */
1517 title_screen_nr = 0;
1518 tci = &title_controls[title_screen_nr];
1520 last_sound = SND_UNDEFINED;
1521 last_music = MUS_UNDEFINED;
1524 /* determine number of title screens to display (images and messages) */
1525 InitializeTitleControls();
1528 if (game_status == GAME_MODE_INFO)
1530 if (num_title_screens == 0)
1532 DrawInfoScreen_NotAvailable("Title screen information:",
1533 "No title screen for this level set.");
1536 /* use default settings for fading, but always disable auto delay */
1537 fading = title_default;
1538 fading.auto_delay = -1;
1544 FadeSoundsAndMusic();
1547 FadeOut(REDRAW_ALL);
1552 DrawTitleScreenImage(tci->local_nr, tci->initial);
1554 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1556 fading_default = (tci->initial ? title_initial_default : title_default);
1558 fading = fading_next = getTitleFading(tci);
1562 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1563 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1565 fading.fade_mode = FADE_MODE_FADE;
1566 fading.fade_delay = fading_default.fade_delay;
1569 if (fading_last.fade_mode != FADE_MODE_CROSSFADE &&
1570 fading_next.fade_mode == FADE_MODE_CROSSFADE)
1571 fading.fade_mode = FADE_MODE_FADE;
1576 sound = getTitleSound(tci);
1577 music = getTitleMusic(tci);
1579 if (sound != last_sound)
1580 PlayMenuSoundExt(sound);
1581 if (music != last_music)
1582 PlayMenuMusicExt(music);
1588 SetMouseCursor(CURSOR_NONE);
1590 // printf("::: mode: %d, delay: %d\n", fading.fade_mode, fading.fade_delay);
1596 fading = fading_next;
1598 DelayReached(&title_delay, 0); /* reset delay counter */
1604 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1605 button = MB_MENU_CHOICE;
1607 if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
1608 button = MB_MENU_CHOICE;
1611 if (button == MB_MENU_LEAVE)
1613 return_to_main_menu = TRUE;
1614 use_fading_main_menu = FALSE;
1616 else if (button == MB_MENU_CHOICE)
1619 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1622 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1625 FadeOut(REDRAW_FIELD);
1628 FadeSetEnterScreen();
1630 info_mode = INFO_MODE_MAIN;
1631 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1637 tci = &title_controls[title_screen_nr];
1639 if (title_screen_nr < num_title_screens)
1643 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1650 graphic_info[getTitleScreenGraphic(tci->local_nr,
1651 tci->initial)].anim_mode;
1653 anim_mode = ANIM_FADE; /* ??? */
1655 use_cross_fading = (anim_mode == ANIM_FADE ? FALSE :
1656 anim_mode == ANIM_CROSSFADE ? TRUE :
1660 sound = getTitleSound(tci);
1661 music = getTitleMusic(tci);
1663 if (sound == SND_UNDEFINED || sound != last_sound)
1665 if (music == MUS_UNDEFINED || music != last_music)
1669 FadeOut(REDRAW_ALL);
1673 DrawTitleScreenImage(tci->local_nr, tci->initial);
1675 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1677 fading_next = getTitleFading(tci);
1680 sound = getTitleSound(tci);
1681 music = getTitleMusic(tci);
1683 if (sound != last_sound)
1684 PlayMenuSoundExt(sound);
1685 if (music != last_music)
1686 PlayMenuMusicExt(music);
1693 printf("::: %d -> %d\n", fading.fade_mode, fading_next.fade_mode);
1697 /* last screen already faded out, next screen has no animation */
1698 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1699 fading_next.fade_mode == FADE_MODE_NONE)
1700 fading = fading_next;
1702 /* last screen already faded out, next screen has no animation */
1703 if (fading.fade_mode != FADE_MODE_CROSSFADE &&
1704 fading_next.fade_mode == FADE_MODE_NONE)
1705 fading = fading_next;
1712 fading = fading_next;
1714 DelayReached(&title_delay, 0); /* reset delay counter */
1718 FadeSoundsAndMusic();
1724 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1728 FadeOut(REDRAW_ALL);
1732 FadeOut(REDRAW_ALL);
1736 return_to_main_menu = TRUE;
1740 if (return_to_main_menu)
1746 SetMouseCursor(CURSOR_DEFAULT);
1748 if (game_status == GAME_MODE_INFO)
1751 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1754 info_mode = INFO_MODE_MAIN;
1755 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1757 else /* default: return to main menu */
1760 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1763 game_status = GAME_MODE_MAIN;
1764 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1769 void HandleMainMenu_SelectLevel(int step, int direction)
1771 int old_level_nr = level_nr;
1774 new_level_nr = old_level_nr + step * direction;
1775 if (new_level_nr < leveldir_current->first_level)
1776 new_level_nr = leveldir_current->first_level;
1777 if (new_level_nr > leveldir_current->last_level)
1778 new_level_nr = leveldir_current->last_level;
1780 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1782 /* skipping levels is only allowed when trying to skip single level */
1783 if (setup.skip_levels && step == 1 &&
1784 Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK))
1786 leveldir_current->handicap_level++;
1787 SaveLevelSetup_SeriesInfo();
1790 new_level_nr = leveldir_current->handicap_level;
1793 if (new_level_nr != old_level_nr)
1795 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1797 PlaySound(SND_MENU_ITEM_SELECTING);
1799 level_nr = new_level_nr;
1802 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1803 int2str(level_nr, menu.main.text.level_number.size),
1804 mci->pos_text->font);
1806 DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
1809 LoadLevel(level_nr);
1810 DrawPreviewLevel(TRUE);
1814 DrawCompleteVideoDisplay();
1816 /* needed because DrawPreviewLevel() takes some time */
1824 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1826 static int choice = MAIN_CONTROL_GAME;
1830 if (button == MB_MENU_INITIALIZE)
1832 DrawCursorAndText_Main(choice, TRUE);
1837 if (mx || my) /* mouse input */
1841 for (i = 0; main_controls[i].nr != -1; i++)
1843 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1844 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1845 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1847 pos = main_controls[i].nr;
1853 else if (dx || dy) /* keyboard input */
1855 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1856 choice == MAIN_CONTROL_SETUP))
1857 button = MB_MENU_CHOICE;
1862 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1864 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1866 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1872 PlaySound(SND_MENU_ITEM_ACTIVATING);
1874 DrawCursorAndText_Main(choice, FALSE);
1875 DrawCursorAndText_Main(pos, TRUE);
1882 PlaySound(SND_MENU_ITEM_SELECTING);
1884 if (pos == MAIN_CONTROL_NAME)
1886 game_status = GAME_MODE_PSEUDO_TYPENAME;
1888 HandleTypeName(strlen(setup.player_name), 0);
1890 else if (pos == MAIN_CONTROL_LEVELS)
1894 game_status = GAME_MODE_LEVELS;
1896 SaveLevelSetup_LastSeries();
1897 SaveLevelSetup_SeriesInfo();
1906 else if (pos == MAIN_CONTROL_SCORES)
1908 game_status = GAME_MODE_SCORES;
1912 else if (pos == MAIN_CONTROL_EDITOR)
1914 if (leveldir_current->readonly &&
1915 !strEqual(setup.player_name, "Artsoft"))
1916 Request("This level is read only !", REQ_CONFIRM);
1918 game_status = GAME_MODE_EDITOR;
1920 FadeSetEnterScreen();
1924 else if (pos == MAIN_CONTROL_INFO)
1926 game_status = GAME_MODE_INFO;
1927 info_mode = INFO_MODE_MAIN;
1930 fading = menu.navigation;
1935 else if (pos == MAIN_CONTROL_GAME)
1937 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
1939 else if (pos == MAIN_CONTROL_SETUP)
1941 game_status = GAME_MODE_SETUP;
1942 setup_mode = SETUP_MODE_MAIN;
1946 else if (pos == MAIN_CONTROL_QUIT)
1948 SaveLevelSetup_LastSeries();
1949 SaveLevelSetup_SeriesInfo();
1951 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
1952 game_status = GAME_MODE_QUIT;
1957 if (game_status == GAME_MODE_MAIN)
1959 DrawPreviewLevel(FALSE);
1966 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1968 static int choice = 5;
1972 if (button == MB_MENU_INITIALIZE)
1974 drawCursor(choice, TRUE);
1979 if (mx || my) /* mouse input */
1981 x = (mx - mSX) / 32;
1982 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
1984 else if (dx || dy) /* keyboard input */
1986 if (dx && choice == 1)
1987 x = (dx < 0 ? 10 : 14);
1990 if (choice == 4 || choice == 6)
1991 button = MB_MENU_CHOICE;
1997 if (y == 1 && dx != 0 && button)
1999 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
2001 else if (IN_VIS_FIELD(x, y) &&
2002 y >= 0 && y <= 7 && (y != 1 || x < 10))
2008 drawCursor(choice, FALSE);
2009 drawCursor(y, TRUE);
2018 game_status = GAME_MODE_PSEUDO_TYPENAME;
2019 HandleTypeName(strlen(setup.player_name), 0);
2025 game_status = GAME_MODE_LEVELS;
2027 SaveLevelSetup_LastSeries();
2028 SaveLevelSetup_SeriesInfo();
2039 game_status = GAME_MODE_SCORES;
2044 if (leveldir_current->readonly &&
2045 !strEqual(setup.player_name, "Artsoft"))
2046 Request("This level is read only !", REQ_CONFIRM);
2047 game_status = GAME_MODE_EDITOR;
2052 game_status = GAME_MODE_INFO;
2053 info_mode = INFO_MODE_MAIN;
2058 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
2062 game_status = GAME_MODE_SETUP;
2063 setup_mode = SETUP_MODE_MAIN;
2069 SaveLevelSetup_LastSeries();
2070 SaveLevelSetup_SeriesInfo();
2072 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
2073 game_status = GAME_MODE_QUIT;
2078 if (game_status == GAME_MODE_MAIN)
2080 DrawPreviewLevel(FALSE);
2088 /* ========================================================================= */
2089 /* info screen functions */
2090 /* ========================================================================= */
2092 static struct TokenInfo *info_info;
2093 static int num_info_info;
2095 static void execInfoTitleScreen()
2098 FadeSetEnterScreen();
2101 info_mode = INFO_MODE_TITLE;
2105 static void execInfoElements()
2108 FadeSetEnterScreen();
2111 info_mode = INFO_MODE_ELEMENTS;
2115 static void execInfoMusic()
2118 FadeSetEnterScreen();
2121 info_mode = INFO_MODE_MUSIC;
2125 static void execInfoCredits()
2128 FadeSetEnterScreen();
2131 info_mode = INFO_MODE_CREDITS;
2135 static void execInfoProgram()
2138 FadeSetEnterScreen();
2141 info_mode = INFO_MODE_PROGRAM;
2145 static void execInfoVersion()
2148 FadeSetEnterScreen();
2151 info_mode = INFO_MODE_VERSION;
2155 static void execInfoLevelSet()
2158 FadeSetEnterScreen();
2161 info_mode = INFO_MODE_LEVELSET;
2165 static void execExitInfo()
2171 game_status = GAME_MODE_MAIN;
2173 DrawMainMenuExt(REDRAW_FIELD, FALSE);
2179 static struct TokenInfo info_info_main[] =
2181 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2182 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2183 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2184 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2185 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2186 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2187 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2188 { TYPE_EMPTY, NULL, "" },
2189 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2194 static void DrawCursorAndText_Info(int pos, boolean active)
2196 int xpos = MENU_SCREEN_START_XPOS;
2197 int ypos = MENU_SCREEN_START_YPOS + pos;
2198 int font_nr = FONT_MENU_1;
2201 font_nr = FONT_ACTIVE(font_nr);
2203 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
2205 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
2206 drawCursor(pos, active);
2209 static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading)
2214 CloseDoor(DOOR_CLOSE_2);
2216 /* (needed after displaying title screens which disable auto repeat) */
2217 KeyboardAutoRepeatOn();
2219 FadeSetLeaveScreen();
2222 FadeOut(redraw_mask);
2226 if (redraw_mask == REDRAW_ALL)
2230 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2236 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2238 info_info = info_info_main;
2242 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
2244 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2247 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2248 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2249 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2250 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2251 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
2252 initCursor(i, IMG_MENU_BUTTON);
2254 DrawCursorAndText_Info(i, FALSE);
2259 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2264 DrawMaskedBorder(redraw_mask);
2266 FadeIn(redraw_mask);
2271 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2273 static int choice_store[MAX_INFO_MODES];
2274 int choice = choice_store[info_mode]; /* always starts with 0 */
2278 if (button == MB_MENU_INITIALIZE)
2280 /* advance to first valid menu entry */
2281 while (choice < num_info_info &&
2282 info_info[choice].type & TYPE_SKIP_ENTRY)
2284 choice_store[info_mode] = choice;
2286 DrawCursorAndText_Info(choice, TRUE);
2290 else if (button == MB_MENU_LEAVE)
2292 for (y = 0; y < num_info_info; y++)
2294 if (info_info[y].type & TYPE_LEAVE_MENU)
2296 void (*menu_callback_function)(void) = info_info[y].value;
2300 menu_callback_function();
2302 break; /* absolutely needed because function changes 'info_info'! */
2309 if (mx || my) /* mouse input */
2311 x = (mx - mSX) / 32;
2312 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2314 else if (dx || dy) /* keyboard input */
2318 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2320 if (info_info[choice].type & menu_navigation_type ||
2321 info_info[choice].type & TYPE_ENTER_SCREEN ||
2322 info_info[choice].type & TYPE_BOOLEAN_STYLE)
2323 button = MB_MENU_CHOICE;
2328 /* jump to next non-empty menu entry (up or down) */
2329 while (y > 0 && y < num_info_info - 1 &&
2330 info_info[y].type & TYPE_SKIP_ENTRY)
2334 if (IN_VIS_FIELD(x, y) &&
2335 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2341 PlaySound(SND_MENU_ITEM_ACTIVATING);
2343 DrawCursorAndText_Info(choice, FALSE);
2344 DrawCursorAndText_Info(y, TRUE);
2346 choice = choice_store[info_mode] = y;
2349 else if (!(info_info[y].type & TYPE_GHOSTED))
2351 PlaySound(SND_MENU_ITEM_SELECTING);
2353 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2355 void (*menu_callback_function)(void) = info_info[choice].value;
2357 FadeSetFromType(info_info[y].type);
2359 menu_callback_function();
2365 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2367 int ystart1 = mSY - SY + 100;
2368 int ystart2 = mSY - SY + 150;
2369 int ybottom = mSY - SY + SYSIZE - 20;
2371 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2373 FadeOut(REDRAW_FIELD);
2378 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2379 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2381 DrawTextSCentered(ybottom, FONT_TEXT_4,
2382 "Press any key or button for info menu");
2384 FadeIn(REDRAW_FIELD);
2387 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2389 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2390 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2391 int xstart = mSX + 16;
2392 int ystart1 = mSY - SY + 100;
2393 int ystart2 = mSY + 64 + 2 * 32;
2394 int ybottom = mSY - SY + SYSIZE - 20;
2395 int ystep = TILEY + 4;
2396 int element, action, direction;
2404 for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++)
2405 infoscreen_step[i] = infoscreen_frame[i] = 0;
2410 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2412 DrawTextSCentered(ybottom, FONT_TEXT_4,
2413 "Press any key or button for next page");
2419 while (helpanim_info[j].element != HELPANIM_LIST_END)
2421 if (i >= start + MAX_INFO_ELEMENTS_ON_SCREEN ||
2426 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2435 j += infoscreen_step[i - start];
2437 element = helpanim_info[j].element;
2438 action = helpanim_info[j].action;
2439 direction = helpanim_info[j].direction;
2442 element = EL_UNKNOWN;
2444 if (action != -1 && direction != -1)
2445 graphic = el_act_dir2img(element, action, direction);
2446 else if (action != -1)
2447 graphic = el_act2img(element, action);
2448 else if (direction != -1)
2449 graphic = el_dir2img(element, direction);
2451 graphic = el2img(element);
2453 delay = helpanim_info[j++].delay;
2458 if (infoscreen_frame[i - start] == 0)
2461 infoscreen_frame[i - start] = delay - 1;
2465 sync_frame = delay - infoscreen_frame[i - start];
2466 infoscreen_frame[i - start]--;
2469 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2471 if (!infoscreen_frame[i - start])
2472 infoscreen_step[i - start] = 0;
2476 if (!infoscreen_frame[i - start])
2477 infoscreen_step[i - start]++;
2478 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2484 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2486 DrawGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2487 graphic, sync_frame, USE_MASKING);
2490 DrawInfoScreen_HelpText(element, action, direction, i - start);
2495 redraw_mask |= REDRAW_FIELD;
2500 static char *getHelpText(int element, int action, int direction)
2502 char token[MAX_LINE_LEN];
2504 strcpy(token, element_info[element].token_name);
2507 strcat(token, element_action_info[action].suffix);
2509 if (direction != -1)
2510 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2512 return getHashEntry(helptext_info, token);
2515 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2517 int font_nr = FONT_INFO_ELEMENTS;
2518 int font_width = getFontWidth(font_nr);
2519 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2520 int sy = mSY + 65 + 2 * 32 + 1;
2521 int ystep = TILEY + 4;
2522 int pad_x = sx - SX;
2523 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2524 int max_lines_per_text = 2;
2527 if (action != -1 && direction != -1) /* element.action.direction */
2528 text = getHelpText(element, action, direction);
2530 if (text == NULL && action != -1) /* element.action */
2531 text = getHelpText(element, action, -1);
2533 if (text == NULL && direction != -1) /* element.direction */
2534 text = getHelpText(element, -1, direction);
2536 if (text == NULL) /* base element */
2537 text = getHelpText(element, -1, -1);
2539 if (text == NULL) /* not found */
2540 text = "No description available";
2542 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2543 sy += getFontHeight(font_nr) / 2;
2545 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2546 max_chars_per_line, -1, max_lines_per_text, -1,
2547 TRUE, FALSE, FALSE);
2550 void DrawInfoScreen_TitleScreen()
2555 void HandleInfoScreen_TitleScreen(int button)
2557 HandleTitleScreen(0, 0, 0, 0, button);
2560 void DrawInfoScreen_Elements()
2562 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2564 FadeOut(REDRAW_FIELD);
2569 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2571 FadeIn(REDRAW_FIELD);
2576 void HandleInfoScreen_Elements(int button)
2578 static unsigned long info_delay = 0;
2579 static int num_anims;
2580 static int num_pages;
2582 int anims_per_page = MAX_INFO_ELEMENTS_ON_SCREEN;
2585 if (button == MB_MENU_INITIALIZE)
2587 boolean new_element = TRUE;
2591 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2593 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2595 else if (new_element)
2598 new_element = FALSE;
2602 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2606 if (button == MB_MENU_LEAVE)
2608 PlaySound(SND_MENU_ITEM_SELECTING);
2610 info_mode = INFO_MODE_MAIN;
2615 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2617 if (button != MB_MENU_INITIALIZE)
2619 PlaySound(SND_MENU_ITEM_SELECTING);
2624 if (page >= num_pages)
2626 FadeSoundsAndMusic();
2628 info_mode = INFO_MODE_MAIN;
2629 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2636 FadeSetNextScreen();
2640 if (button != MB_MENU_INITIALIZE)
2641 FadeOut(REDRAW_FIELD);
2643 if (button != MB_MENU_INITIALIZE)
2644 FadeCrossSaveBackbuffer();
2647 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2650 if (button != MB_MENU_INITIALIZE)
2651 FadeIn(REDRAW_FIELD);
2653 if (button != MB_MENU_INITIALIZE)
2654 FadeCross(REDRAW_FIELD);
2659 if (DelayReached(&info_delay, GameFrameDelay))
2660 if (page < num_pages)
2661 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2663 PlayMenuSoundIfLoop();
2667 void DrawInfoScreen_Music()
2669 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2672 FadeOut(REDRAW_FIELD);
2680 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2683 FadeIn(REDRAW_FIELD);
2687 void HandleInfoScreen_Music(int button)
2689 static struct MusicFileInfo *list = NULL;
2690 int ystart1 = mSY - SY + 100;
2691 int ystart2 = mSY - SY + 150;
2692 int ybottom = mSY - SY + SYSIZE - 20;
2695 if (button == MB_MENU_INITIALIZE)
2697 list = music_file_info;
2701 FadeSoundsAndMusic();
2706 DrawTextSCentered(ystart1, FONT_TEXT_1,
2707 "No music info for this level set.");
2709 DrawTextSCentered(ybottom, FONT_TEXT_4,
2710 "Press any key or button for info menu");
2716 if (button == MB_MENU_LEAVE)
2718 PlaySound(SND_MENU_ITEM_SELECTING);
2720 FadeSoundsAndMusic();
2722 info_mode = INFO_MODE_MAIN;
2727 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2731 if (button != MB_MENU_INITIALIZE)
2733 PlaySound(SND_MENU_ITEM_SELECTING);
2741 FadeSoundsAndMusic();
2743 info_mode = INFO_MODE_MAIN;
2744 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2749 FadeSoundsAndMusic();
2752 if (list != music_file_info)
2753 FadeSetNextScreen();
2757 if (button != MB_MENU_INITIALIZE)
2758 FadeOut(REDRAW_FIELD);
2760 if (button != MB_MENU_INITIALIZE)
2761 FadeCrossSaveBackbuffer();
2769 int sound = list->music;
2771 if (sound_info[sound].loop)
2772 PlaySoundLoop(sound);
2776 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2780 PlayMusic(list->music);
2782 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2785 if (!strEqual(list->title, UNKNOWN_NAME))
2787 if (!strEqual(list->title_header, UNKNOWN_NAME))
2788 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2790 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2793 if (!strEqual(list->artist, UNKNOWN_NAME))
2795 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2796 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2798 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2800 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2803 if (!strEqual(list->album, UNKNOWN_NAME))
2805 if (!strEqual(list->album_header, UNKNOWN_NAME))
2806 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2808 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2810 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2813 if (!strEqual(list->year, UNKNOWN_NAME))
2815 if (!strEqual(list->year_header, UNKNOWN_NAME))
2816 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2818 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2820 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2823 DrawTextSCentered(ybottom, FONT_TEXT_4,
2824 "Press any key or button for next page");
2827 if (button != MB_MENU_INITIALIZE)
2828 FadeIn(REDRAW_FIELD);
2830 if (button != MB_MENU_INITIALIZE)
2831 FadeCross(REDRAW_FIELD);
2835 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2836 PlaySoundLoop(list->music);
2839 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2841 int ystart1 = mSY - SY + 100;
2842 int ystart2 = mSY - SY + 150;
2843 int ybottom = mSY - SY + SYSIZE - 20;
2849 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2853 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2854 "Special thanks to");
2855 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2857 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2859 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2860 "\"Boulder Dash\"");
2861 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2863 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2865 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2867 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2868 "First Star Software");
2870 else if (screen_nr == 1)
2872 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2873 "Special thanks to");
2874 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2875 "Klaus Heinz & Volker Wertich");
2876 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2878 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2879 "\"Emerald Mine\"");
2880 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2882 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2884 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2886 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2889 else if (screen_nr == 2)
2891 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2892 "Special thanks to");
2893 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2894 "Michael Stopp & Philip Jespersen");
2895 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2897 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2899 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2901 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2903 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2905 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2906 "Digital Integration");
2908 else if (screen_nr == 3)
2910 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2911 "Special thanks to");
2912 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2913 "Hiroyuki Imabayashi");
2914 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2916 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2918 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2920 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2922 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2924 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2927 else if (screen_nr == 4)
2929 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2930 "Special thanks to");
2931 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2933 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2935 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2936 "Jürgen Bonhagen");
2937 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2938 "for the continuous creation");
2939 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2940 "of outstanding level sets");
2942 else if (screen_nr == 5)
2944 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2946 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2948 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2949 "for ideas and inspiration by");
2950 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2953 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2955 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2957 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2958 "for ideas and inspiration by");
2959 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2962 else if (screen_nr == 6)
2964 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2966 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2968 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2969 "for the new Emerald Mine engine");
2971 else if (screen_nr == 7)
2973 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2975 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2977 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2978 "for the initial DOS port");
2980 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2982 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2984 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2985 "for some additional toons");
2987 else if (screen_nr == 8)
2989 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2990 "And not to forget:");
2991 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2993 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2994 "All those who contributed");
2995 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2996 "levels to this game");
2997 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
3001 DrawTextSCentered(ybottom, FONT_TEXT_4,
3002 "Press any key or button for next page");
3005 void DrawInfoScreen_Credits()
3007 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
3009 FadeSoundsAndMusic();
3012 FadeOut(REDRAW_FIELD);
3015 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3018 FadeIn(REDRAW_FIELD);
3022 void HandleInfoScreen_Credits(int button)
3024 static int screen_nr = 0;
3025 int num_screens = 9;
3027 if (button == MB_MENU_INITIALIZE)
3031 // DrawInfoScreen_CreditsScreen(screen_nr);
3034 if (button == MB_MENU_LEAVE)
3036 PlaySound(SND_MENU_ITEM_SELECTING);
3038 info_mode = INFO_MODE_MAIN;
3043 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
3045 if (button != MB_MENU_INITIALIZE)
3047 PlaySound(SND_MENU_ITEM_SELECTING);
3052 if (screen_nr >= num_screens)
3054 FadeSoundsAndMusic();
3056 info_mode = INFO_MODE_MAIN;
3057 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3064 FadeSetNextScreen();
3068 if (button != MB_MENU_INITIALIZE)
3069 FadeOut(REDRAW_FIELD);
3071 if (button != MB_MENU_INITIALIZE)
3072 FadeCrossSaveBackbuffer();
3075 DrawInfoScreen_CreditsScreen(screen_nr);
3078 if (button != MB_MENU_INITIALIZE)
3079 FadeIn(REDRAW_FIELD);
3081 if (button != MB_MENU_INITIALIZE)
3082 FadeCross(REDRAW_FIELD);
3087 PlayMenuSoundIfLoop();
3091 void DrawInfoScreen_Program()
3093 int ystart1 = mSY - SY + 100;
3094 int ystart2 = mSY - SY + 150;
3095 int ybottom = mSY - SY + SYSIZE - 20;
3098 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3101 FadeOut(REDRAW_FIELD);
3107 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
3109 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3110 "This game is Freeware!");
3111 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3112 "If you like it, send e-mail to:");
3113 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3114 PROGRAM_EMAIL_STRING);
3115 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
3116 "or SnailMail to:");
3117 DrawTextSCentered(ystart2 + 4 * ystep + 0, FONT_TEXT_3,
3119 DrawTextSCentered(ystart2 + 4 * ystep + 20, FONT_TEXT_3,
3120 "Detmolder Strasse 189");
3121 DrawTextSCentered(ystart2 + 4 * ystep + 40, FONT_TEXT_3,
3123 DrawTextSCentered(ystart2 + 4 * ystep + 60, FONT_TEXT_3,
3125 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3126 "More information and levels:");
3127 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3128 PROGRAM_WEBSITE_STRING);
3129 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3130 "If you have created new levels,");
3131 DrawTextSCentered(ystart2 + 10 * ystep, FONT_TEXT_2,
3132 "send them to me to include them!");
3133 DrawTextSCentered(ystart2 + 11 * ystep, FONT_TEXT_2,
3136 DrawTextSCentered(ybottom, FONT_TEXT_4,
3137 "Press any key or button for info menu");
3140 FadeIn(REDRAW_FIELD);
3144 void HandleInfoScreen_Program(int button)
3146 if (button == MB_MENU_LEAVE)
3148 PlaySound(SND_MENU_ITEM_SELECTING);
3150 info_mode = INFO_MODE_MAIN;
3155 else if (button == MB_MENU_CHOICE)
3157 PlaySound(SND_MENU_ITEM_SELECTING);
3159 FadeSoundsAndMusic();
3162 FadeOut(REDRAW_FIELD);
3165 info_mode = INFO_MODE_MAIN;
3166 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3170 PlayMenuSoundIfLoop();
3174 void DrawInfoScreen_Version()
3176 int font_header = FONT_TEXT_3;
3177 int font_text = FONT_TEXT_2;
3178 int xstep = getFontWidth(font_text);
3179 int ystep = getFontHeight(font_text);
3180 int ystart1 = mSY - SY + 100;
3181 int ystart2 = mSY - SY + 150;
3182 int ybottom = mSY - SY + SYSIZE - 20;
3183 int xstart1 = mSX + 2 * xstep;
3184 int xstart2 = mSX + 19 * xstep;
3185 #if defined(TARGET_SDL)
3186 int xstart3 = mSX + 29 * xstep;
3187 SDL_version sdl_version_compiled;
3188 const SDL_version *sdl_version_linked;
3189 int driver_name_len = 8;
3190 char driver_name[driver_name_len];
3193 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3196 FadeOut(REDRAW_FIELD);
3202 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
3204 DrawTextF(xstart1, ystart2, font_header, "Name");
3205 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
3208 DrawTextF(xstart1, ystart2, font_header, "Version");
3209 DrawTextF(xstart2, ystart2, font_text, getProgramFullVersionString());
3212 DrawTextF(xstart1, ystart2, font_header, "Platform");
3213 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
3216 DrawTextF(xstart1, ystart2, font_header, "Target");
3217 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
3220 DrawTextF(xstart1, ystart2, font_header, "Compile time");
3221 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
3223 #if defined(TARGET_SDL)
3224 ystart2 += 3 * ystep;
3225 DrawTextF(xstart1, ystart2, font_header, "Library");
3226 DrawTextF(xstart2, ystart2, font_header, "compiled");
3227 DrawTextF(xstart3, ystart2, font_header, "linked");
3229 SDL_VERSION(&sdl_version_compiled);
3230 sdl_version_linked = SDL_Linked_Version();
3232 ystart2 += 2 * ystep;
3233 DrawTextF(xstart1, ystart2, font_text, "SDL");
3234 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3235 sdl_version_compiled.major,
3236 sdl_version_compiled.minor,
3237 sdl_version_compiled.patch);
3238 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3239 sdl_version_linked->major,
3240 sdl_version_linked->minor,
3241 sdl_version_linked->patch);
3243 SDL_IMAGE_VERSION(&sdl_version_compiled);
3244 sdl_version_linked = IMG_Linked_Version();
3247 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
3248 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3249 sdl_version_compiled.major,
3250 sdl_version_compiled.minor,
3251 sdl_version_compiled.patch);
3252 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3253 sdl_version_linked->major,
3254 sdl_version_linked->minor,
3255 sdl_version_linked->patch);
3257 SDL_MIXER_VERSION(&sdl_version_compiled);
3258 sdl_version_linked = Mix_Linked_Version();
3261 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
3262 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3263 sdl_version_compiled.major,
3264 sdl_version_compiled.minor,
3265 sdl_version_compiled.patch);
3266 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3267 sdl_version_linked->major,
3268 sdl_version_linked->minor,
3269 sdl_version_linked->patch);
3271 SDL_NET_VERSION(&sdl_version_compiled);
3272 sdl_version_linked = SDLNet_Linked_Version();
3275 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
3276 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3277 sdl_version_compiled.major,
3278 sdl_version_compiled.minor,
3279 sdl_version_compiled.patch);
3280 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3281 sdl_version_linked->major,
3282 sdl_version_linked->minor,
3283 sdl_version_linked->patch);
3285 ystart2 += 3 * ystep;
3286 DrawTextF(xstart1, ystart2, font_header, "Driver");
3287 DrawTextF(xstart2, ystart2, font_header, "Requested");
3288 DrawTextF(xstart3, ystart2, font_header, "Used");
3290 SDL_VideoDriverName(driver_name, driver_name_len);
3292 ystart2 += 2 * ystep;
3293 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
3294 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
3295 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3297 SDL_AudioDriverName(driver_name, driver_name_len);
3300 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
3301 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
3302 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3305 DrawTextSCentered(ybottom, FONT_TEXT_4,
3306 "Press any key or button for info menu");
3309 FadeIn(REDRAW_FIELD);
3313 void HandleInfoScreen_Version(int button)
3315 if (button == MB_MENU_LEAVE)
3317 PlaySound(SND_MENU_ITEM_SELECTING);
3319 info_mode = INFO_MODE_MAIN;
3324 else if (button == MB_MENU_CHOICE)
3326 PlaySound(SND_MENU_ITEM_SELECTING);
3328 FadeSoundsAndMusic();
3331 FadeOut(REDRAW_FIELD);
3334 info_mode = INFO_MODE_MAIN;
3335 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3339 PlayMenuSoundIfLoop();
3343 void DrawInfoScreen_LevelSet()
3345 struct TitleMessageInfo *tmi = &readme;
3346 char *filename = getLevelSetInfoFilename();
3348 /* if chars set to "-1", automatically determine by text and font width */
3349 if (tmi->chars == -1)
3350 tmi->chars = tmi->width / getFontWidth(tmi->font);
3352 tmi->width = tmi->chars * getFontWidth(tmi->font);
3354 /* if lines set to "-1", automatically determine by text and font height */
3355 if (tmi->lines == -1)
3356 tmi->lines = tmi->height / getFontHeight(tmi->font);
3358 tmi->height = tmi->lines * getFontHeight(tmi->font);
3360 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3363 FadeOut(REDRAW_FIELD);
3369 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3371 if (filename != NULL)
3372 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3373 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
3374 tmi->autowrap, tmi->centered, tmi->parse_comments);
3376 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3377 "No information for this level set.");
3379 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3380 "Press any key or button for info menu");
3383 FadeIn(REDRAW_FIELD);
3387 void HandleInfoScreen_LevelSet(int button)
3389 if (button == MB_MENU_LEAVE)
3391 PlaySound(SND_MENU_ITEM_SELECTING);
3393 info_mode = INFO_MODE_MAIN;
3398 else if (button == MB_MENU_CHOICE)
3400 PlaySound(SND_MENU_ITEM_SELECTING);
3402 FadeSoundsAndMusic();
3405 FadeOut(REDRAW_FIELD);
3408 info_mode = INFO_MODE_MAIN;
3409 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3413 PlayMenuSoundIfLoop();
3417 static void DrawInfoScreenExt(int redraw_mask, boolean do_fading)
3419 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3421 if (info_mode == INFO_MODE_TITLE)
3422 DrawInfoScreen_TitleScreen();
3423 else if (info_mode == INFO_MODE_ELEMENTS)
3424 DrawInfoScreen_Elements();
3425 else if (info_mode == INFO_MODE_MUSIC)
3426 DrawInfoScreen_Music();
3427 else if (info_mode == INFO_MODE_CREDITS)
3428 DrawInfoScreen_Credits();
3429 else if (info_mode == INFO_MODE_PROGRAM)
3430 DrawInfoScreen_Program();
3431 else if (info_mode == INFO_MODE_VERSION)
3432 DrawInfoScreen_Version();
3433 else if (info_mode == INFO_MODE_LEVELSET)
3434 DrawInfoScreen_LevelSet();
3436 DrawInfoScreen_Main(redraw_mask, do_fading);
3438 if (info_mode != INFO_MODE_MAIN &&
3439 info_mode != INFO_MODE_TITLE &&
3440 info_mode != INFO_MODE_MUSIC)
3447 void DrawAndFadeInInfoScreen(int redraw_mask)
3449 DrawInfoScreenExt(redraw_mask, TRUE);
3452 void DrawInfoScreen()
3454 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3457 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3459 if (info_mode == INFO_MODE_TITLE)
3460 HandleInfoScreen_TitleScreen(button);
3461 else if (info_mode == INFO_MODE_ELEMENTS)
3462 HandleInfoScreen_Elements(button);
3463 else if (info_mode == INFO_MODE_MUSIC)
3464 HandleInfoScreen_Music(button);
3465 else if (info_mode == INFO_MODE_CREDITS)
3466 HandleInfoScreen_Credits(button);
3467 else if (info_mode == INFO_MODE_PROGRAM)
3468 HandleInfoScreen_Program(button);
3469 else if (info_mode == INFO_MODE_VERSION)
3470 HandleInfoScreen_Version(button);
3471 else if (info_mode == INFO_MODE_LEVELSET)
3472 HandleInfoScreen_LevelSet(button);
3474 HandleInfoScreen_Main(mx, my, dx, dy, button);
3480 /* ========================================================================= */
3481 /* type name functions */
3482 /* ========================================================================= */
3484 void HandleTypeName(int newxpos, Key key)
3486 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3487 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3489 struct TextPosInfo *pos = mci->pos_input;
3490 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3491 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3494 static int xpos = 0;
3496 static int xpos = 0, ypos = 2;
3498 int font_nr = pos->font;
3499 int font_active_nr = FONT_ACTIVE(font_nr);
3500 int font_width = getFontWidth(font_active_nr);
3503 int startx = mSX + mci->pos_input->x;
3504 int starty = mSY + mci->pos_input->y;
3507 int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
3508 int startx = mSX + 32 + name_width;
3509 int starty = mSY + ypos * 32;
3511 char key_char = getValidConfigValueChar(getCharFromKey(key));
3512 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3513 boolean is_active = TRUE;
3515 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3519 strcpy(last_player_name, setup.player_name);
3524 /* add one character width for added cursor character */
3525 pos->width += font_width;
3526 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3528 DrawText(startx, starty, setup.player_name, font_active_nr);
3529 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3532 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3534 setup.player_name[xpos] = key_char;
3535 setup.player_name[xpos + 1] = 0;
3540 /* add one character width for added name text character */
3541 pos->width += font_width;
3542 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3544 DrawText(startx, starty, setup.player_name, font_active_nr);
3545 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3548 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3552 setup.player_name[xpos] = 0;
3555 /* remove one character width for removed name text character */
3556 pos->width -= font_width;
3557 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3559 DrawText(startx, starty, setup.player_name, font_active_nr);
3560 DrawText(startx + xpos * font_width, starty, "_ ", font_active_nr);
3563 else if (key == KSYM_Return && xpos > 0)
3566 /* remove one character width for removed cursor text character */
3567 pos->width -= font_width;
3568 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3570 DrawText(startx, starty, setup.player_name, font_nr);
3571 DrawText(startx + xpos * font_width, starty, " ", font_active_nr);
3578 game_status = GAME_MODE_MAIN;
3580 else if (key == KSYM_Escape)
3582 strcpy(setup.player_name, last_player_name);
3586 game_status = GAME_MODE_MAIN;
3591 pos->width = (strlen(setup.player_name) + 1) * font_width;
3592 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3594 DrawText(startx, starty, setup.player_name, font_active_nr);
3595 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3599 pos->width = strlen(setup.player_name) * font_width;
3600 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3602 DrawText(startx, starty, setup.player_name, font_nr);
3607 /* ========================================================================= */
3608 /* tree menu functions */
3609 /* ========================================================================= */
3611 static void DrawChooseTree(TreeInfo **ti_ptr)
3615 FreeScreenGadgets();
3616 CreateScreenGadgets();
3618 CloseDoor(DOOR_CLOSE_2);
3621 FadeOut(REDRAW_FIELD);
3626 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3627 MapScreenTreeGadgets(*ti_ptr);
3630 FadeIn(REDRAW_FIELD);
3636 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3638 struct GadgetInfo *gi = screen_gadget[id];
3639 int items_max, items_visible, item_position;
3641 items_max = numTreeInfoInGroup(ti);
3642 items_visible = NUM_MENU_ENTRIES_ON_SCREEN;
3643 item_position = first_entry;
3645 if (item_position > items_max - items_visible)
3646 item_position = items_max - items_visible;
3648 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3649 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3650 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3653 static void drawChooseTreeList(int first_entry, int num_page_entries,
3657 char *title_string = NULL;
3658 int yoffset_sets = MENU_TITLE1_YPOS;
3659 int yoffset_setup = 16;
3660 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? yoffset_sets :
3662 int last_game_status = game_status; /* save current game status */
3664 title_string = ti->infotext;
3666 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3669 /* force LEVELS font on artwork setup screen */
3670 game_status = GAME_MODE_LEVELS;
3674 /* clear tree list area, but not title or scrollbar */
3675 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3676 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3677 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3679 /* clear tree list area, but not title or scrollbar */
3680 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3681 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3682 MAX_MENU_ENTRIES_ON_SCREEN * 32);
3685 for (i = 0; i < num_page_entries; i++)
3687 TreeInfo *node, *node_first;
3688 int entry_pos = first_entry + i;
3689 int xpos = MENU_SCREEN_START_XPOS;
3690 int ypos = MENU_SCREEN_START_YPOS + i;
3691 int startx = mSX + xpos * 32;
3692 int starty = mSY + ypos * 32;
3693 int font_nr = FONT_TEXT_1;
3694 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3695 int startx_text = startx + font_xoffset;
3696 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3697 int text_size = startx_scrollbar - startx_text;
3698 int max_buffer_len = text_size / getFontWidth(font_nr);
3699 char buffer[max_buffer_len + 1];
3701 node_first = getTreeInfoFirstGroupEntry(ti);
3702 node = getTreeInfoFromPos(node_first, entry_pos);
3704 strncpy(buffer, node->name, max_buffer_len);
3705 buffer[max_buffer_len] = '\0';
3707 DrawText(startx, starty, buffer, font_nr + node->color);
3709 if (node->parent_link)
3710 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3711 else if (node->level_group)
3712 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3714 initCursor(i, IMG_MENU_BUTTON);
3717 game_status = last_game_status; /* restore current game status */
3719 redraw_mask |= REDRAW_FIELD;
3722 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3724 TreeInfo *node, *node_first;
3725 int x, last_redraw_mask = redraw_mask;
3726 int ypos = MENU_TITLE2_YPOS;
3727 int font_nr = FONT_TITLE_2;
3729 if (ti->type != TREE_TYPE_LEVEL_DIR)
3732 node_first = getTreeInfoFirstGroupEntry(ti);
3733 node = getTreeInfoFromPos(node_first, entry_pos);
3735 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3737 if (node->parent_link)
3738 DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
3740 else if (node->level_group)
3741 DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
3743 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3744 DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
3745 node->levels, node->class_desc);
3747 /* let BackToFront() redraw only what is needed */
3748 redraw_mask = last_redraw_mask | REDRAW_TILES;
3749 for (x = 0; x < SCR_FIELDX; x++)
3750 MarkTileDirty(x, 1);
3753 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3756 TreeInfo *ti = *ti_ptr;
3758 int y = ti->cl_cursor;
3759 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3760 int num_entries = numTreeInfoInGroup(ti);
3761 int num_page_entries;
3762 int last_game_status = game_status; /* save current game status */
3763 boolean position_set_by_scrollbar = (dx == 999);
3766 /* force LEVELS draw offset on choose level and artwork setup screen */
3767 game_status = GAME_MODE_LEVELS;
3770 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3771 num_page_entries = num_entries;
3773 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3775 game_status = last_game_status; /* restore current game status */
3777 if (button == MB_MENU_INITIALIZE)
3779 int num_entries = numTreeInfoInGroup(ti);
3780 int entry_pos = posTreeInfo(ti);
3782 if (ti->cl_first == -1)
3784 /* only on initialization */
3785 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3786 ti->cl_cursor = entry_pos - ti->cl_first;
3788 else if (ti->cl_cursor >= num_page_entries ||
3789 (num_entries > num_page_entries &&
3790 num_entries - ti->cl_first < num_page_entries))
3792 /* only after change of list size (by custom graphic configuration) */
3793 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3794 ti->cl_cursor = entry_pos - ti->cl_first;
3797 if (position_set_by_scrollbar)
3800 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3803 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3804 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3805 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3809 else if (button == MB_MENU_LEAVE)
3813 PlaySound(SND_MENU_ITEM_SELECTING);
3815 if (ti->node_parent)
3817 *ti_ptr = ti->node_parent;
3818 DrawChooseTree(ti_ptr);
3820 else if (game_status == GAME_MODE_SETUP)
3822 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
3824 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3825 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3826 execSetupGraphics();
3832 game_status = GAME_MODE_MAIN;
3834 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3843 if (mx || my) /* mouse input */
3845 int last_game_status = game_status; /* save current game status */
3848 /* force LEVELS draw offset on artwork setup screen */
3849 game_status = GAME_MODE_LEVELS;
3852 x = (mx - mSX) / 32;
3853 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3855 game_status = last_game_status; /* restore current game status */
3857 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3859 /* move cursor instead of scrolling when already at start/end of list */
3860 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3862 else if (dy == +1 * SCROLL_LINE &&
3863 ti->cl_first + num_page_entries == num_entries)
3866 /* handle scrolling screen one line or page */
3867 if (ti->cl_cursor + dy < 0 ||
3868 ti->cl_cursor + dy > num_page_entries - 1)
3870 if (ABS(dy) == SCROLL_PAGE)
3871 step = num_page_entries - 1;
3873 if (dy < 0 && ti->cl_first > 0)
3875 /* scroll page/line up */
3877 ti->cl_first -= step;
3878 if (ti->cl_first < 0)
3881 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3882 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3883 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3885 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3888 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3890 /* scroll page/line down */
3892 ti->cl_first += step;
3893 if (ti->cl_first + num_page_entries > num_entries)
3894 ti->cl_first = MAX(0, num_entries - num_page_entries);
3896 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3897 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3898 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3900 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3907 /* handle moving cursor one line */
3908 y = ti->cl_cursor + dy;
3913 TreeInfo *node_first, *node_cursor;
3914 int entry_pos = ti->cl_first + y;
3916 node_first = getTreeInfoFirstGroupEntry(ti);
3917 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3919 if (node_cursor->node_group)
3923 PlaySound(SND_MENU_ITEM_SELECTING);
3925 node_cursor->cl_first = ti->cl_first;
3926 node_cursor->cl_cursor = ti->cl_cursor;
3927 *ti_ptr = node_cursor->node_group;
3928 DrawChooseTree(ti_ptr);
3933 else if (dx == -1 && ti->node_parent)
3937 PlaySound(SND_MENU_ITEM_SELECTING);
3939 *ti_ptr = ti->node_parent;
3940 DrawChooseTree(ti_ptr);
3945 if (!anyScrollbarGadgetActive() &&
3946 IN_VIS_FIELD(x, y) &&
3947 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3948 y >= 0 && y < num_page_entries)
3952 if (y != ti->cl_cursor)
3954 PlaySound(SND_MENU_ITEM_ACTIVATING);
3956 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3957 drawChooseTreeCursor(y, TRUE);
3958 drawChooseTreeInfo(ti->cl_first + y, ti);
3965 TreeInfo *node_first, *node_cursor;
3966 int entry_pos = ti->cl_first + y;
3968 PlaySound(SND_MENU_ITEM_SELECTING);
3970 node_first = getTreeInfoFirstGroupEntry(ti);
3971 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3973 if (node_cursor->node_group)
3977 node_cursor->cl_first = ti->cl_first;
3978 node_cursor->cl_cursor = ti->cl_cursor;
3979 *ti_ptr = node_cursor->node_group;
3980 DrawChooseTree(ti_ptr);
3982 else if (node_cursor->parent_link)
3986 *ti_ptr = node_cursor->node_parent;
3987 DrawChooseTree(ti_ptr);
3991 FadeSetEnterScreen();
3993 node_cursor->cl_first = ti->cl_first;
3994 node_cursor->cl_cursor = ti->cl_cursor;
3995 *ti_ptr = node_cursor;
3997 if (ti->type == TREE_TYPE_LEVEL_DIR)
3999 LoadLevelSetup_SeriesInfo();
4001 SaveLevelSetup_LastSeries();
4002 SaveLevelSetup_SeriesInfo();
4006 if (game_status == GAME_MODE_SETUP)
4008 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
4010 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
4011 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
4012 execSetupGraphics();
4018 game_status = GAME_MODE_MAIN;
4026 void DrawChooseLevel()
4028 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
4030 DrawChooseTree(&leveldir_current);
4036 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
4038 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4043 void DrawHallOfFame(int highlight_position)
4046 FadeSoundsAndMusic();
4048 /* (this is needed when called from GameEnd() after winning a game) */
4049 KeyboardAutoRepeatOn();
4052 /* (this is needed when called from GameEnd() after winning a game) */
4053 SetDrawDeactivationMask(REDRAW_NONE);
4054 SetDrawBackgroundMask(REDRAW_FIELD);
4056 CloseDoor(DOOR_CLOSE_2);
4058 if (highlight_position < 0)
4059 LoadScore(level_nr);
4061 FadeSetEnterScreen();
4063 // printf("::: %d: %d\n", game_status, menu.enter_screen[game_status]);
4066 FadeOut(REDRAW_FIELD);
4074 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4077 FadeIn(REDRAW_FIELD);
4081 static void drawHallOfFameList(int first_entry, int highlight_position)
4085 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4088 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4089 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4090 "HighScores of Level %d", level_nr);
4092 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4094 int entry = first_entry + i;
4095 boolean active = (entry == highlight_position);
4096 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4097 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4098 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4099 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4100 int dx1 = 3 * getFontWidth(font_nr1);
4101 int dx2 = dx1 + getFontWidth(font_nr1);
4102 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
4103 int sy = mSY + 64 + i * 32;
4105 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4106 DrawText(mSX + dx1, sy, ".", font_nr1);
4107 DrawText(mSX + dx2, sy, ".........................", font_nr3);
4109 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4110 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4112 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4115 redraw_mask |= REDRAW_FIELD;
4118 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4120 static int first_entry = 0;
4121 static int highlight_position = 0;
4122 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4124 if (button == MB_MENU_INITIALIZE)
4127 highlight_position = mx;
4128 drawHallOfFameList(first_entry, highlight_position);
4133 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4134 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4138 if (first_entry > 0)
4140 first_entry -= step;
4141 if (first_entry < 0)
4144 drawHallOfFameList(first_entry, highlight_position);
4149 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4151 first_entry += step;
4152 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4153 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4155 drawHallOfFameList(first_entry, highlight_position);
4158 else if (button == MB_MENU_LEAVE)
4160 PlaySound(SND_MENU_ITEM_SELECTING);
4162 FadeSound(SND_BACKGROUND_SCORES);
4164 game_status = GAME_MODE_MAIN;
4168 else if (button == MB_MENU_CHOICE)
4170 PlaySound(SND_MENU_ITEM_SELECTING);
4172 FadeSound(SND_BACKGROUND_SCORES);
4175 FadeOut(REDRAW_FIELD);
4178 game_status = GAME_MODE_MAIN;
4180 DrawAndFadeInMainMenu(REDRAW_FIELD);
4183 if (game_status == GAME_MODE_SCORES)
4184 PlayMenuSoundIfLoop();
4190 /* ========================================================================= */
4191 /* setup screen functions */
4192 /* ========================================================================= */
4194 static struct TokenInfo *setup_info;
4195 static int num_setup_info;
4197 static char *screen_mode_text;
4198 static char *scroll_delay_text;
4199 static char *game_speed_text;
4200 static char *graphics_set_name;
4201 static char *sounds_set_name;
4202 static char *music_set_name;
4204 static void execSetupMain()
4210 setup_mode = SETUP_MODE_MAIN;
4214 static void execSetupGame()
4220 if (game_speeds == NULL)
4224 for (i = 0; game_speeds_list[i].value != -1; i++)
4226 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4227 char identifier[32], name[32];
4228 int value = game_speeds_list[i].value;
4229 char *text = game_speeds_list[i].text;
4231 ti->node_top = &game_speeds;
4232 ti->sort_priority = 10000 - value;
4234 sprintf(identifier, "%d", value);
4235 sprintf(name, "%s", text);
4237 setString(&ti->identifier, identifier);
4238 setString(&ti->name, name);
4239 setString(&ti->name_sorting, name);
4240 setString(&ti->infotext, "Game Speed");
4242 pushTreeInfo(&game_speeds, ti);
4245 /* sort game speed values to start with slowest game speed */
4246 sortTreeInfo(&game_speeds);
4248 /* set current game speed to configured game speed value */
4249 game_speed_current =
4250 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4252 /* if that fails, set current game speed to reliable default value */
4253 if (game_speed_current == NULL)
4254 game_speed_current =
4255 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4257 /* if that also fails, set current game speed to first available speed */
4258 if (game_speed_current == NULL)
4259 game_speed_current = game_speeds;
4262 setup.game_frame_delay = atoi(game_speed_current->identifier);
4264 /* needed for displaying game speed text instead of identifier */
4265 game_speed_text = game_speed_current->name;
4267 setup_mode = SETUP_MODE_GAME;
4271 static void execSetupChooseGameSpeed()
4277 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4281 static void execSetupEditor()
4287 setup_mode = SETUP_MODE_EDITOR;
4291 static void execSetupGraphics()
4297 if (video.fullscreen_available && screen_modes == NULL)
4301 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4303 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4304 char identifier[32], name[32];
4305 int x = video.fullscreen_modes[i].width;
4306 int y = video.fullscreen_modes[i].height;
4309 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4311 ti->node_top = &screen_modes;
4312 ti->sort_priority = x * 10000 + y;
4314 sprintf(identifier, "%dx%d", x, y);
4315 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4317 setString(&ti->identifier, identifier);
4318 setString(&ti->name, name);
4319 setString(&ti->name_sorting, name);
4320 setString(&ti->infotext, "Fullscreen Mode");
4322 pushTreeInfo(&screen_modes, ti);
4325 /* sort fullscreen modes to start with lowest available screen resolution */
4326 sortTreeInfo(&screen_modes);
4328 /* set current screen mode for fullscreen mode to configured setup value */
4329 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4330 setup.fullscreen_mode);
4332 /* if that fails, set current screen mode to reliable default value */
4333 if (screen_mode_current == NULL)
4334 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4335 DEFAULT_FULLSCREEN_MODE);
4337 /* if that also fails, set current screen mode to first available mode */
4338 if (screen_mode_current == NULL)
4339 screen_mode_current = screen_modes;
4341 if (screen_mode_current == NULL)
4342 video.fullscreen_available = FALSE;
4345 if (video.fullscreen_available)
4347 setup.fullscreen_mode = screen_mode_current->identifier;
4349 /* needed for displaying screen mode name instead of identifier */
4350 screen_mode_text = screen_mode_current->name;
4354 if (scroll_delays == NULL)
4358 for (i = 0; scroll_delays_list[i].value != -1; i++)
4360 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4361 char identifier[32], name[32];
4362 int value = scroll_delays_list[i].value;
4363 char *text = scroll_delays_list[i].text;
4365 ti->node_top = &scroll_delays;
4366 ti->sort_priority = value;
4368 sprintf(identifier, "%d", value);
4369 sprintf(name, "%s", text);
4371 setString(&ti->identifier, identifier);
4372 setString(&ti->name, name);
4373 setString(&ti->name_sorting, name);
4374 setString(&ti->infotext, "Scroll Delay");
4376 pushTreeInfo(&scroll_delays, ti);
4379 /* sort scroll delay values to start with lowest scroll delay value */
4380 sortTreeInfo(&scroll_delays);
4382 /* set current scroll delay value to configured scroll delay value */
4383 scroll_delay_current =
4384 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4386 /* if that fails, set current scroll delay to reliable default value */
4387 if (scroll_delay_current == NULL)
4388 scroll_delay_current =
4389 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4391 /* if that also fails, set current scroll delay to first available value */
4392 if (scroll_delay_current == NULL)
4393 scroll_delay_current = scroll_delays;
4396 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4398 /* needed for displaying scroll delay text instead of identifier */
4399 scroll_delay_text = scroll_delay_current->name;
4402 setup_mode = SETUP_MODE_GRAPHICS;
4406 static void execSetupChooseScreenMode()
4412 if (!video.fullscreen_available)
4415 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4419 static void execSetupChooseScrollDelay()
4425 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4429 static void execSetupSound()
4435 setup_mode = SETUP_MODE_SOUND;
4439 static void execSetupArtwork()
4445 setup.graphics_set = artwork.gfx_current->identifier;
4446 setup.sounds_set = artwork.snd_current->identifier;
4447 setup.music_set = artwork.mus_current->identifier;
4449 /* needed if last screen (setup choice) changed graphics, sounds or music */
4450 ReloadCustomArtwork(0);
4452 /* needed for displaying artwork name instead of artwork identifier */
4453 graphics_set_name = artwork.gfx_current->name;
4454 sounds_set_name = artwork.snd_current->name;
4455 music_set_name = artwork.mus_current->name;
4457 setup_mode = SETUP_MODE_ARTWORK;
4461 static void execSetupChooseGraphics()
4467 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4471 static void execSetupChooseSounds()
4477 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4481 static void execSetupChooseMusic()
4487 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4491 static void execSetupInput()
4497 setup_mode = SETUP_MODE_INPUT;
4501 static void execSetupShortcuts1()
4507 setup_mode = SETUP_MODE_SHORTCUTS_1;
4511 static void execSetupShortcuts2()
4517 setup_mode = SETUP_MODE_SHORTCUTS_2;
4521 static void execExitSetup()
4527 game_status = GAME_MODE_MAIN;
4529 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4535 static void execSaveAndExitSetup()
4541 static struct TokenInfo setup_info_main[] =
4543 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4544 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4545 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4546 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4547 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4548 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4549 { TYPE_ENTER_MENU, execSetupShortcuts1, "Key Shortcuts 1" },
4550 { TYPE_ENTER_MENU, execSetupShortcuts2, "Key Shortcuts 2" },
4551 { TYPE_EMPTY, NULL, "" },
4552 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4553 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4558 static struct TokenInfo setup_info_game[] =
4560 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4561 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4562 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4563 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4564 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4565 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4566 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4567 { TYPE_STRING, &game_speed_text, "" },
4568 { TYPE_EMPTY, NULL, "" },
4569 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4574 static struct TokenInfo setup_info_editor[] =
4577 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4578 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4579 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4580 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4581 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4582 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4583 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4584 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4586 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4587 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4588 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4590 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4592 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4593 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4594 { TYPE_EMPTY, NULL, "" },
4596 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4597 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4598 { TYPE_EMPTY, NULL, "" },
4600 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4601 { TYPE_EMPTY, NULL, "" },
4602 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4607 static struct TokenInfo setup_info_graphics[] =
4609 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4610 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4611 { TYPE_STRING, &screen_mode_text, "" },
4613 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
4615 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay Value:" },
4616 { TYPE_STRING, &scroll_delay_text, "" },
4618 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" },
4619 { TYPE_SWITCH, &setup.double_buffering,"Double-Buffering:" },
4621 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4622 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4623 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4624 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4625 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4626 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4627 { TYPE_EMPTY, NULL, "" },
4628 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4633 static struct TokenInfo setup_info_sound[] =
4635 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4636 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4637 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4638 { TYPE_EMPTY, NULL, "" },
4639 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4644 static struct TokenInfo setup_info_artwork[] =
4646 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4647 { TYPE_STRING, &graphics_set_name, "" },
4648 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4649 { TYPE_STRING, &sounds_set_name, "" },
4650 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4651 { TYPE_STRING, &music_set_name, "" },
4652 { TYPE_EMPTY, NULL, "" },
4654 { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
4655 { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:" },
4656 { TYPE_YES_NO, &setup.override_level_music, "Override Level Music:" },
4658 { TYPE_STRING, NULL, "Override Level Artwork:"},
4659 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
4660 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
4661 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
4663 { TYPE_EMPTY, NULL, "" },
4664 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4669 static struct TokenInfo setup_info_input[] =
4671 { TYPE_SWITCH, NULL, "Player:" },
4672 { TYPE_SWITCH, NULL, "Device:" },
4673 { TYPE_ENTER_MENU, NULL, "" },
4674 { TYPE_EMPTY, NULL, "" },
4675 { TYPE_EMPTY, NULL, "" },
4676 { TYPE_EMPTY, NULL, "" },
4677 { TYPE_EMPTY, NULL, "" },
4678 { TYPE_EMPTY, NULL, "" },
4679 { TYPE_EMPTY, NULL, "" },
4680 { TYPE_EMPTY, NULL, "" },
4681 { TYPE_EMPTY, NULL, "" },
4682 { TYPE_EMPTY, NULL, "" },
4683 { TYPE_EMPTY, NULL, "" },
4684 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4689 static struct TokenInfo setup_info_shortcuts_1[] =
4691 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4692 { TYPE_KEY, &setup.shortcut.save_game, "" },
4693 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4694 { TYPE_KEY, &setup.shortcut.load_game, "" },
4695 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4696 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4697 { TYPE_EMPTY, NULL, "" },
4698 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4699 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4700 { TYPE_EMPTY, NULL, "" },
4701 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4706 static struct TokenInfo setup_info_shortcuts_2[] =
4708 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4709 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4710 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4711 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4712 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4713 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4714 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4715 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4716 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4717 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4718 { TYPE_EMPTY, NULL, "" },
4719 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4724 static Key getSetupKey()
4726 Key key = KSYM_UNDEFINED;
4727 boolean got_key_event = FALSE;
4729 while (!got_key_event)
4731 if (PendingEvent()) /* got event */
4739 case EVENT_KEYPRESS:
4741 key = GetEventKey((KeyEvent *)&event, TRUE);
4743 /* press 'Escape' or 'Enter' to keep the existing key binding */
4744 if (key == KSYM_Escape || key == KSYM_Return)
4745 key = KSYM_UNDEFINED; /* keep old value */
4747 got_key_event = TRUE;
4751 case EVENT_KEYRELEASE:
4752 key_joystick_mapping = 0;
4756 HandleOtherEvents(&event);
4764 /* don't eat all CPU time */
4771 static int getSetupTextFont(int type)
4773 if (type & (TYPE_SWITCH |
4784 static int getSetupValueFont(int type, void *value)
4786 if (type & TYPE_KEY)
4787 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
4788 else if (type & TYPE_STRING)
4789 return FONT_VALUE_2;
4790 else if (type & TYPE_ECS_AGA)
4791 return FONT_VALUE_1;
4792 else if (type & TYPE_BOOLEAN_STYLE)
4793 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
4795 return FONT_VALUE_1;
4798 static void drawSetupValue(int pos)
4800 boolean font_draw_xoffset_modified = FALSE;
4801 int font_draw_xoffset_old = -1;
4802 int xpos = MENU_SCREEN_VALUE_XPOS;
4803 int ypos = MENU_SCREEN_START_YPOS + pos;
4804 int startx = mSX + xpos * 32;
4805 int starty = mSY + ypos * 32;
4806 int font_nr, font_width;
4807 int type = setup_info[pos].type;
4808 void *value = setup_info[pos].value;
4809 char *value_string = getSetupValue(type, value);
4812 if (value_string == NULL)
4815 if (type & TYPE_KEY)
4817 xpos = MENU_SCREEN_START_XPOS;
4819 if (type & TYPE_QUERY)
4821 value_string = "<press key>";
4824 else if (type & TYPE_STRING)
4826 int max_value_len = (SCR_FIELDX - 2) * 2;
4828 xpos = MENU_SCREEN_START_XPOS;
4830 if (strlen(value_string) > max_value_len)
4831 value_string[max_value_len] = '\0';
4834 startx = mSX + xpos * 32;
4835 starty = mSY + ypos * 32;
4836 font_nr = getSetupValueFont(type, value);
4837 font_width = getFontWidth(font_nr);
4839 /* downward compatibility correction for Juergen Bonhagen's menu settings */
4840 if (setup_mode != SETUP_MODE_INPUT)
4842 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
4843 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
4844 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
4845 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
4846 int text_font_nr = getSetupTextFont(FONT_MENU_2);
4847 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
4848 int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr);
4849 boolean correct_font_draw_xoffset = FALSE;
4851 if (xpos == MENU_SCREEN_START_XPOS &&
4852 startx + font1_xoffset < text_startx + text_font_xoffset)
4853 correct_font_draw_xoffset = TRUE;
4855 if (xpos == MENU_SCREEN_VALUE_XPOS &&
4856 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
4857 correct_font_draw_xoffset = TRUE;
4859 /* check if setup value would overlap with setup text when printed */
4860 /* (this can happen for extreme/wrong values for font draw offset) */
4861 if (correct_font_draw_xoffset)
4863 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
4864 font_draw_xoffset_modified = TRUE;
4866 if (type & TYPE_KEY)
4867 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
4868 else if (!(type & TYPE_STRING))
4869 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
4870 MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
4874 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
4875 DrawText(startx + i * font_width, starty, " ", font_nr);
4877 DrawText(startx, starty, value_string, font_nr);
4879 if (font_draw_xoffset_modified)
4880 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
4883 static void changeSetupValue(int pos)
4885 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
4887 *(boolean *)setup_info[pos].value ^= TRUE;
4889 else if (setup_info[pos].type & TYPE_KEY)
4893 setup_info[pos].type |= TYPE_QUERY;
4894 drawSetupValue(pos);
4895 setup_info[pos].type &= ~TYPE_QUERY;
4897 key = getSetupKey();
4898 if (key != KSYM_UNDEFINED)
4899 *(Key *)setup_info[pos].value = key;
4902 drawSetupValue(pos);
4905 static void DrawCursorAndText_Setup(int pos, boolean active)
4907 int xpos = MENU_SCREEN_START_XPOS;
4908 int ypos = MENU_SCREEN_START_YPOS + pos;
4909 int font_nr = getSetupTextFont(setup_info[pos].type);
4911 if (setup_info == setup_info_input)
4912 font_nr = FONT_MENU_1;
4915 font_nr = FONT_ACTIVE(font_nr);
4917 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
4919 if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
4920 drawCursor(pos, active);
4923 static void DrawSetupScreen_Generic()
4925 boolean redraw_all = FALSE;
4926 char *title_string = NULL;
4930 CloseDoor(DOOR_CLOSE_2);
4932 if (redraw_mask & REDRAW_ALL)
4936 printf("::: %s\n", (redraw_mask & REDRAW_FIELD ? "REDRAW_FIELD" :
4937 redraw_mask & REDRAW_ALL ? "REDRAW_ALL" :
4938 int2str(0, redraw_mask)));
4942 FadeOut(redraw_mask);
4944 FadeOut(REDRAW_FIELD);
4949 if (setup_mode == SETUP_MODE_MAIN)
4951 setup_info = setup_info_main;
4952 title_string = "Setup";
4954 else if (setup_mode == SETUP_MODE_GAME)
4956 setup_info = setup_info_game;
4957 title_string = "Setup Game";
4959 else if (setup_mode == SETUP_MODE_EDITOR)
4961 setup_info = setup_info_editor;
4962 title_string = "Setup Editor";
4964 else if (setup_mode == SETUP_MODE_GRAPHICS)
4966 setup_info = setup_info_graphics;
4967 title_string = "Setup Graphics";
4969 else if (setup_mode == SETUP_MODE_SOUND)
4971 setup_info = setup_info_sound;
4972 title_string = "Setup Sound";
4974 else if (setup_mode == SETUP_MODE_ARTWORK)
4976 setup_info = setup_info_artwork;
4977 title_string = "Custom Artwork";
4979 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
4981 setup_info = setup_info_shortcuts_1;
4982 title_string = "Setup Shortcuts";
4984 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
4986 setup_info = setup_info_shortcuts_2;
4987 title_string = "Setup Shortcuts";
4990 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
4994 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
4996 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4999 void *value_ptr = setup_info[i].value;
5002 int xpos = MENU_SCREEN_START_XPOS;
5003 int ypos = MENU_SCREEN_START_YPOS + i;
5007 /* set some entries to "unchangeable" according to other variables */
5008 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5009 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5010 (value_ptr == &setup.sound_music && !audio.music_available) ||
5011 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5012 (value_ptr == &screen_mode_text && !video.fullscreen_available))
5013 setup_info[i].type |= TYPE_GHOSTED;
5015 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5016 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5017 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5018 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5019 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5020 initCursor(i, IMG_MENU_BUTTON);
5023 DrawCursorAndText_Setup(i, FALSE);
5025 font_nr = getSetupTextFont(setup_info[i].type);
5027 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr);
5030 if (setup_info[i].type & TYPE_VALUE)
5037 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5038 "Joysticks deactivated in setup menu");
5042 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5046 redraw_mask = REDRAW_ALL;
5049 FadeIn(redraw_mask);
5051 FadeIn(REDRAW_FIELD);
5056 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5060 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5062 static int choice_store[MAX_SETUP_MODES];
5063 int choice = choice_store[setup_mode]; /* always starts with 0 */
5067 if (button == MB_MENU_INITIALIZE)
5069 /* advance to first valid menu entry */
5070 while (choice < num_setup_info &&
5071 setup_info[choice].type & TYPE_SKIP_ENTRY)
5073 choice_store[setup_mode] = choice;
5076 DrawCursorAndText_Setup(choice, TRUE);
5078 drawCursor(choice, TRUE);
5083 else if (button == MB_MENU_LEAVE)
5085 PlaySound(SND_MENU_ITEM_SELECTING);
5087 for (y = 0; y < num_setup_info; y++)
5089 if (setup_info[y].type & TYPE_LEAVE_MENU)
5091 void (*menu_callback_function)(void) = setup_info[y].value;
5095 menu_callback_function();
5097 break; /* absolutely needed because function changes 'setup_info'! */
5104 if (mx || my) /* mouse input */
5106 x = (mx - mSX) / 32;
5107 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5109 else if (dx || dy) /* keyboard input */
5113 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5115 if (setup_info[choice].type & menu_navigation_type ||
5116 setup_info[choice].type & TYPE_BOOLEAN_STYLE)
5117 button = MB_MENU_CHOICE;
5122 /* jump to next non-empty menu entry (up or down) */
5123 while (y > 0 && y < num_setup_info - 1 &&
5124 setup_info[y].type & TYPE_SKIP_ENTRY)
5128 if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
5132 if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
5134 PlaySound(SND_MENU_ITEM_ACTIVATING);
5137 DrawCursorAndText_Setup(choice, FALSE);
5138 DrawCursorAndText_Setup(y, TRUE);
5140 drawCursor(choice, FALSE);
5141 drawCursor(y, TRUE);
5144 choice = choice_store[setup_mode] = y;
5147 else if (!(setup_info[y].type & TYPE_GHOSTED))
5149 PlaySound(SND_MENU_ITEM_SELECTING);
5151 /* when selecting key headline, execute function for key value change */
5152 if (setup_info[y].type & TYPE_KEYTEXT &&
5153 setup_info[y + 1].type & TYPE_KEY)
5156 /* when selecting string value, execute function for list selection */
5157 if (setup_info[y].type & TYPE_STRING && y > 0 &&
5158 setup_info[y - 1].type & TYPE_ENTER_LIST)
5161 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
5163 void (*menu_callback_function)(void) = setup_info[y].value;
5165 FadeSetFromType(setup_info[y].type);
5167 menu_callback_function();
5171 if (setup_info[y].type & TYPE_VALUE)
5172 changeSetupValue(y);
5178 void DrawSetupScreen_Input()
5185 FadeOut(REDRAW_FIELD);
5191 setup_info = setup_info_input;
5194 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5198 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5199 "Joysticks deactivated on this screen");
5201 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5202 "Joysticks deactivated on this screen");
5208 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5210 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5213 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5214 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5215 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5216 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5217 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5218 initCursor(i, IMG_MENU_BUTTON);
5220 DrawCursorAndText_Setup(i, FALSE);
5223 initCursor(0, IMG_MENU_BUTTON);
5224 initCursor(1, IMG_MENU_BUTTON);
5225 initCursor(2, IMG_MENU_BUTTON_ENTER_MENU);
5226 initCursor(13, IMG_MENU_BUTTON_LEAVE_MENU);
5228 DrawText(mSX + 32, mSY + 2 * 32, "Player:", FONT_MENU_1);
5229 DrawText(mSX + 32, mSY + 3 * 32, "Device:", FONT_MENU_1);
5230 DrawText(mSX + 32, mSY + 15 * 32, "Back", FONT_MENU_1);
5234 DeactivateJoystickForCalibration();
5239 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5240 "Joysticks deactivated on this screen");
5242 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5243 "Joysticks deactivated on this screen");
5247 /* create gadgets for setup input menu screen */
5248 FreeScreenGadgets();
5249 CreateScreenGadgets();
5251 /* map gadgets for setup input menu screen */
5252 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5254 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5257 FadeIn(REDRAW_FIELD);
5263 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5265 if (device_name == NULL)
5268 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5271 if (strlen(device_name) > 1)
5273 char c1 = device_name[strlen(device_name) - 1];
5274 char c2 = device_name[strlen(device_name) - 2];
5276 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5277 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5280 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5281 strlen(device_name));
5284 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5287 static struct SetupKeyboardInfo custom_key;
5294 { &custom_key.left, "Joystick Left" },
5295 { &custom_key.right, "Joystick Right" },
5296 { &custom_key.up, "Joystick Up" },
5297 { &custom_key.down, "Joystick Down" },
5298 { &custom_key.snap, "Button 1" },
5299 { &custom_key.drop, "Button 2" }
5301 static char *joystick_name[MAX_PLAYERS] =
5308 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5312 custom_key = setup.input[player_nr].key;
5314 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5315 FONT_INPUT_1_ACTIVE);
5317 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5319 DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5320 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5322 if (setup.input[player_nr].use_joystick)
5324 char *device_name = setup.input[player_nr].joy.device_name;
5325 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5326 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5328 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5329 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5333 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5334 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5337 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5339 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5340 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5341 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5342 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5344 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5345 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5346 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5347 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5348 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5349 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5351 for (i = 0; i < 6; i++)
5353 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5355 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5357 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5358 (setup.input[player_nr].use_joystick ?
5360 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5364 static int input_player_nr = 0;
5366 void HandleSetupScreen_Input_Player(int step, int direction)
5368 int old_player_nr = input_player_nr;
5371 new_player_nr = old_player_nr + step * direction;
5372 if (new_player_nr < 0)
5374 if (new_player_nr > MAX_PLAYERS - 1)
5375 new_player_nr = MAX_PLAYERS - 1;
5377 if (new_player_nr != old_player_nr)
5379 input_player_nr = new_player_nr;
5381 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5385 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5387 static int choice = 0;
5390 int pos_start = SETUPINPUT_SCREEN_POS_START;
5391 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5392 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5393 int pos_end = SETUPINPUT_SCREEN_POS_END;
5395 if (button == MB_MENU_INITIALIZE)
5397 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5400 DrawCursorAndText_Setup(choice, TRUE);
5402 drawCursor(choice, TRUE);
5407 else if (button == MB_MENU_LEAVE)
5409 setup_mode = SETUP_MODE_MAIN;
5416 if (mx || my) /* mouse input */
5418 x = (mx - mSX) / 32;
5419 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5421 else if (dx || dy) /* keyboard input */
5423 if (dx && choice == 0)
5424 x = (dx < 0 ? 10 : 12);
5425 else if ((dx && choice == 1) ||
5426 (dx == +1 && choice == 2) ||
5427 (dx == -1 && choice == pos_end))
5428 button = MB_MENU_CHOICE;
5432 if (y >= pos_empty1 && y <= pos_empty2)
5433 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5436 if (y == 0 && dx != 0 && button)
5438 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5440 else if (IN_VIS_FIELD(x, y) &&
5441 y >= pos_start && y <= pos_end &&
5442 !(y >= pos_empty1 && y <= pos_empty2))
5449 DrawCursorAndText_Setup(choice, FALSE);
5450 DrawCursorAndText_Setup(y, TRUE);
5452 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5454 drawCursor(choice, FALSE);
5455 drawCursor(y, TRUE);
5465 char *device_name = setup.input[input_player_nr].joy.device_name;
5467 if (!setup.input[input_player_nr].use_joystick)
5469 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5471 setJoystickDeviceToNr(device_name, new_device_nr);
5472 setup.input[input_player_nr].use_joystick = TRUE;
5476 int device_nr = getJoystickNrFromDeviceName(device_name);
5477 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5479 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5480 setup.input[input_player_nr].use_joystick = FALSE;
5482 setJoystickDeviceToNr(device_name, new_device_nr);
5485 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5489 if (setup.input[input_player_nr].use_joystick)
5492 CalibrateJoystick(input_player_nr);
5495 CustomizeKeyboard(input_player_nr);
5497 else if (y == pos_end)
5503 setup_mode = SETUP_MODE_MAIN;
5510 void CustomizeKeyboard(int player_nr)
5514 boolean finished = FALSE;
5515 static struct SetupKeyboardInfo custom_key;
5520 } customize_step[] =
5522 { &custom_key.left, "Move Left" },
5523 { &custom_key.right, "Move Right" },
5524 { &custom_key.up, "Move Up" },
5525 { &custom_key.down, "Move Down" },
5526 { &custom_key.snap, "Snap Field" },
5527 { &custom_key.drop, "Drop Element" }
5530 /* read existing key bindings from player setup */
5531 custom_key = setup.input[player_nr].key;
5534 FadeOut(REDRAW_FIELD);
5538 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5546 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5547 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5548 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5549 "Key:", FONT_INPUT_1_ACTIVE);
5550 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5551 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5554 FadeIn(REDRAW_FIELD);
5561 if (PendingEvent()) /* got event */
5569 case EVENT_KEYPRESS:
5571 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5573 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5575 if (key == KSYM_Escape)
5576 FadeSkipNextFadeIn();
5582 /* all keys configured -- wait for "Escape" or "Return" key */
5586 /* press 'Enter' to keep the existing key binding */
5587 if (key == KSYM_Return)
5588 key = *customize_step[step_nr].key;
5590 /* check if key already used */
5591 for (i = 0; i < step_nr; i++)
5592 if (*customize_step[i].key == key)
5597 /* got new key binding */
5598 *customize_step[step_nr].key = key;
5599 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5601 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5602 getKeyNameFromKey(key), FONT_VALUE_1);
5605 /* un-highlight last query */
5606 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
5607 customize_step[step_nr - 1].text, FONT_MENU_1);
5608 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
5609 "Key:", FONT_MENU_1);
5611 /* press 'Enter' to leave */
5614 DrawText(mSX + 16, mSY + 15 * 32 + 16,
5615 "Press Enter", FONT_TITLE_1);
5619 /* query next key binding */
5620 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5621 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5622 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5623 "Key:", FONT_INPUT_1_ACTIVE);
5624 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5625 getKeyNameFromKey(*customize_step[step_nr].key),
5630 case EVENT_KEYRELEASE:
5631 key_joystick_mapping = 0;
5635 HandleOtherEvents(&event);
5643 /* don't eat all CPU time */
5647 /* write new key bindings back to player setup */
5648 setup.input[player_nr].key = custom_key;
5651 DrawSetupScreen_Input();
5654 static boolean CalibrateJoystickMain(int player_nr)
5656 int new_joystick_xleft = JOYSTICK_XMIDDLE;
5657 int new_joystick_xright = JOYSTICK_XMIDDLE;
5658 int new_joystick_yupper = JOYSTICK_YMIDDLE;
5659 int new_joystick_ylower = JOYSTICK_YMIDDLE;
5660 int new_joystick_xmiddle, new_joystick_ymiddle;
5662 int joystick_fd = joystick.fd[player_nr];
5663 int x, y, last_x, last_y, xpos = 8, ypos = 3;
5664 boolean check[3][3];
5665 int check_remaining = 3 * 3;
5670 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
5673 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
5677 FadeOut(REDRAW_FIELD);
5681 for (y = 0; y < 3; y++)
5683 for (x = 0; x < 3; x++)
5685 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
5686 check[x][y] = FALSE;
5690 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
5691 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
5692 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
5693 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
5694 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
5695 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
5696 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
5698 joy_value = Joystick(player_nr);
5699 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5700 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5702 /* eventually uncalibrated center position (joystick could be uncentered) */
5703 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5706 new_joystick_xmiddle = joy_x;
5707 new_joystick_ymiddle = joy_y;
5709 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
5712 FadeIn(REDRAW_FIELD);
5717 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
5722 if (PendingEvent()) /* got event */
5730 case EVENT_KEYPRESS:
5731 switch (GetEventKey((KeyEvent *)&event, TRUE))
5734 if (check_remaining == 0)
5739 FadeSkipNextFadeIn();
5748 case EVENT_KEYRELEASE:
5749 key_joystick_mapping = 0;
5753 HandleOtherEvents(&event);
5758 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5761 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
5762 new_joystick_xright = MAX(new_joystick_xright, joy_x);
5763 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
5764 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
5766 setup.input[player_nr].joy.xleft = new_joystick_xleft;
5767 setup.input[player_nr].joy.yupper = new_joystick_yupper;
5768 setup.input[player_nr].joy.xright = new_joystick_xright;
5769 setup.input[player_nr].joy.ylower = new_joystick_ylower;
5770 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
5771 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
5773 CheckJoystickData();
5775 joy_value = Joystick(player_nr);
5777 if (joy_value & JOY_BUTTON && check_remaining == 0)
5780 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5781 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5783 if (x != last_x || y != last_y)
5785 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0);
5786 DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0);
5791 if (check_remaining > 0 && !check[x+1][y+1])
5793 check[x+1][y+1] = TRUE;
5799 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
5800 setup.input[player_nr].joy.xleft,
5801 setup.input[player_nr].joy.xmiddle,
5802 setup.input[player_nr].joy.xright);
5803 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
5804 setup.input[player_nr].joy.yupper,
5805 setup.input[player_nr].joy.ymiddle,
5806 setup.input[player_nr].joy.ylower);
5815 /* don't eat all CPU time */
5819 /* calibrated center position (joystick should now be centered) */
5820 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5823 new_joystick_xmiddle = joy_x;
5824 new_joystick_ymiddle = joy_y;
5829 DrawSetupScreen_Input();
5832 /* wait until the last pressed button was released */
5833 while (Joystick(player_nr) & JOY_BUTTON)
5835 if (PendingEvent()) /* got event */
5840 HandleOtherEvents(&event);
5849 void CalibrateJoystick(int player_nr)
5851 if (!CalibrateJoystickMain(player_nr))
5853 char *device_name = setup.input[player_nr].joy.device_name;
5854 int nr = getJoystickNrFromDeviceName(device_name) + 1;
5855 int xpos = mSX - SX;
5856 int ypos = mSY - SY;
5860 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
5861 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
5864 Delay(2000); /* show error message for a short time */
5870 DrawSetupScreen_Input();
5874 void DrawSetupScreen()
5876 DeactivateJoystick();
5878 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
5880 if (setup_mode == SETUP_MODE_INPUT)
5881 DrawSetupScreen_Input();
5882 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5883 DrawChooseTree(&game_speed_current);
5884 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5885 DrawChooseTree(&screen_mode_current);
5886 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5887 DrawChooseTree(&scroll_delay_current);
5888 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5889 DrawChooseTree(&artwork.gfx_current);
5890 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5891 DrawChooseTree(&artwork.snd_current);
5892 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5893 DrawChooseTree(&artwork.mus_current);
5895 DrawSetupScreen_Generic();
5901 void RedrawSetupScreenAfterFullscreenToggle()
5903 if (setup_mode == SETUP_MODE_GRAPHICS)
5907 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
5909 if (setup_mode == SETUP_MODE_INPUT)
5910 HandleSetupScreen_Input(mx, my, dx, dy, button);
5911 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5912 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
5913 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5914 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
5915 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5916 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
5917 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5918 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
5919 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5920 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
5921 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5922 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
5924 HandleSetupScreen_Generic(mx, my, dx, dy, button);
5929 void HandleGameActions()
5931 if (game_status != GAME_MODE_PLAYING)
5934 GameActions(); /* main game loop */
5936 if (tape.auto_play && !tape.playing)
5937 AutoPlayTape(); /* continue automatically playing next tape */
5941 /* ---------- new screen button stuff -------------------------------------- */
5943 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
5948 case SCREEN_CTRL_ID_PREV_LEVEL:
5949 *x = mSX + menu.main.button.prev_level.x;
5950 *y = mSY + menu.main.button.prev_level.y;
5953 case SCREEN_CTRL_ID_NEXT_LEVEL:
5954 *x = mSX + menu.main.button.next_level.x;
5955 *y = mSY + menu.main.button.next_level.y;
5958 case SCREEN_CTRL_ID_PREV_LEVEL:
5959 *x = mSX + TILEX * getPrevlevelButtonPos();
5960 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5963 case SCREEN_CTRL_ID_NEXT_LEVEL:
5964 *x = mSX + TILEX * getNextLevelButtonPos();
5965 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5969 case SCREEN_CTRL_ID_PREV_PLAYER:
5970 *x = mSX + TILEX * 10;
5971 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5974 case SCREEN_CTRL_ID_NEXT_PLAYER:
5975 *x = mSX + TILEX * 12;
5976 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5980 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
5986 int gfx_unpressed, gfx_pressed;
5987 void (*get_gadget_position)(int *, int *, int);
5991 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
5994 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
5995 getScreenMenuButtonPos,
5996 SCREEN_CTRL_ID_PREV_LEVEL,
6001 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6002 getScreenMenuButtonPos,
6003 SCREEN_CTRL_ID_NEXT_LEVEL,
6008 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6009 getScreenMenuButtonPos,
6010 SCREEN_CTRL_ID_PREV_PLAYER,
6015 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6016 getScreenMenuButtonPos,
6017 SCREEN_CTRL_ID_NEXT_PLAYER,
6025 int gfx_unpressed, gfx_pressed;
6029 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6032 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6033 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
6034 SCREEN_CTRL_ID_SCROLL_UP,
6038 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6039 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
6040 SCREEN_CTRL_ID_SCROLL_DOWN,
6047 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6048 Bitmap **gfx_unpressed, **gfx_pressed;
6050 int gfx_unpressed, gfx_pressed;
6057 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6060 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6061 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
6063 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6065 SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
6066 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
6067 GD_TYPE_SCROLLBAR_VERTICAL,
6068 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6069 "scroll level series vertically"
6073 static void CreateScreenMenubuttons()
6075 struct GadgetInfo *gi;
6076 unsigned long event_mask;
6079 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6081 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6082 int gfx_unpressed, gfx_pressed;
6083 int x, y, width, height;
6084 int gd_x1, gd_x2, gd_y1, gd_y2;
6085 int id = menubutton_info[i].gadget_id;
6087 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6089 menubutton_info[i].get_gadget_position(&x, &y, id);
6091 width = SC_MENUBUTTON_XSIZE;
6092 height = SC_MENUBUTTON_YSIZE;
6094 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6095 gfx_pressed = menubutton_info[i].gfx_pressed;
6096 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6097 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6098 gd_x1 = graphic_info[gfx_unpressed].src_x;
6099 gd_y1 = graphic_info[gfx_unpressed].src_y;
6100 gd_x2 = graphic_info[gfx_pressed].src_x;
6101 gd_y2 = graphic_info[gfx_pressed].src_y;
6103 gi = CreateGadget(GDI_CUSTOM_ID, id,
6104 GDI_CUSTOM_TYPE_ID, i,
6105 GDI_INFO_TEXT, menubutton_info[i].infotext,
6110 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6111 GDI_STATE, GD_BUTTON_UNPRESSED,
6112 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6113 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6114 GDI_DIRECT_DRAW, FALSE,
6115 GDI_EVENT_MASK, event_mask,
6116 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6120 Error(ERR_EXIT, "cannot create gadget");
6122 screen_gadget[id] = gi;
6126 static void CreateScreenScrollbuttons()
6128 struct GadgetInfo *gi;
6129 unsigned long event_mask;
6132 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6134 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6135 int gfx_unpressed, gfx_pressed;
6136 int x, y, width, height;
6137 int gd_x1, gd_x2, gd_y1, gd_y2;
6138 int id = scrollbutton_info[i].gadget_id;
6140 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6142 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6143 y = mSY + scrollbutton_info[i].y;
6144 width = SC_SCROLLBUTTON_XSIZE;
6145 height = SC_SCROLLBUTTON_YSIZE;
6147 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6148 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6149 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6151 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6152 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6153 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6154 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6155 gd_x1 = graphic_info[gfx_unpressed].src_x;
6156 gd_y1 = graphic_info[gfx_unpressed].src_y;
6157 gd_x2 = graphic_info[gfx_pressed].src_x;
6158 gd_y2 = graphic_info[gfx_pressed].src_y;
6160 gi = CreateGadget(GDI_CUSTOM_ID, id,
6161 GDI_CUSTOM_TYPE_ID, i,
6162 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6167 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6168 GDI_STATE, GD_BUTTON_UNPRESSED,
6169 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6170 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6171 GDI_DIRECT_DRAW, FALSE,
6172 GDI_EVENT_MASK, event_mask,
6173 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6177 Error(ERR_EXIT, "cannot create gadget");
6179 screen_gadget[id] = gi;
6183 static void CreateScreenScrollbars()
6187 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6189 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6190 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6191 int gfx_unpressed, gfx_pressed;
6193 int x, y, width, height;
6194 int gd_x1, gd_x2, gd_y1, gd_y2;
6195 struct GadgetInfo *gi;
6196 int items_max, items_visible, item_position;
6197 unsigned long event_mask;
6198 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6199 int id = scrollbar_info[i].gadget_id;
6201 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6203 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6204 y = mSY + scrollbar_info[i].y;
6205 width = scrollbar_info[i].width;
6206 height = scrollbar_info[i].height;
6208 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6209 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6211 items_max = num_page_entries;
6212 items_visible = num_page_entries;
6215 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6216 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
6217 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
6223 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6224 gfx_pressed = scrollbar_info[i].gfx_pressed;
6225 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6226 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6227 gd_x1 = graphic_info[gfx_unpressed].src_x;
6228 gd_y1 = graphic_info[gfx_unpressed].src_y;
6229 gd_x2 = graphic_info[gfx_pressed].src_x;
6230 gd_y2 = graphic_info[gfx_pressed].src_y;
6233 gi = CreateGadget(GDI_CUSTOM_ID, id,
6234 GDI_CUSTOM_TYPE_ID, i,
6235 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6240 GDI_TYPE, scrollbar_info[i].type,
6241 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6242 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6243 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6245 GDI_WHEEL_AREA_X, SX,
6246 GDI_WHEEL_AREA_Y, SY,
6247 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6248 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6250 GDI_WHEEL_AREA_X, 0,
6251 GDI_WHEEL_AREA_Y, 0,
6252 GDI_WHEEL_AREA_WIDTH, WIN_XSIZE,
6253 GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE,
6255 GDI_STATE, GD_BUTTON_UNPRESSED,
6256 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6257 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6258 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6259 GDI_DIRECT_DRAW, FALSE,
6260 GDI_EVENT_MASK, event_mask,
6261 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6265 Error(ERR_EXIT, "cannot create gadget");
6267 screen_gadget[id] = gi;
6271 void CreateScreenGadgets()
6273 int last_game_status = game_status; /* save current game status */
6275 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6278 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6280 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
6282 /* copy pointers to clip mask and GC */
6283 scrollbar_bitmap[i]->clip_mask =
6284 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
6285 scrollbar_bitmap[i]->stored_clip_gc =
6286 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
6288 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
6289 scrollbar_bitmap[i],
6290 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
6291 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
6292 TILEX, TILEY, 0, 0);
6296 CreateScreenMenubuttons();
6299 /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */
6300 game_status = GAME_MODE_LEVELS;
6303 CreateScreenScrollbuttons();
6304 CreateScreenScrollbars();
6306 game_status = last_game_status; /* restore current game status */
6309 void FreeScreenGadgets()
6313 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6314 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6316 /* prevent freeing clip mask and GC twice */
6317 scrollbar_bitmap[i]->clip_mask = None;
6318 scrollbar_bitmap[i]->stored_clip_gc = None;
6320 FreeBitmap(scrollbar_bitmap[i]);
6324 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6325 FreeGadget(screen_gadget[i]);
6328 void MapScreenMenuGadgets(int screen_mask)
6332 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6333 if (screen_mask & menubutton_info[i].screen_mask)
6334 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6337 void MapScreenTreeGadgets(TreeInfo *ti)
6339 int num_entries = numTreeInfoInGroup(ti);
6342 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6345 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6346 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6348 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6349 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6352 static void HandleScreenGadgets(struct GadgetInfo *gi)
6354 int id = gi->custom_id;
6355 int button = gi->event.button;
6356 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6360 case SCREEN_CTRL_ID_PREV_LEVEL:
6361 HandleMainMenu_SelectLevel(step, -1);
6364 case SCREEN_CTRL_ID_NEXT_LEVEL:
6365 HandleMainMenu_SelectLevel(step, +1);
6368 case SCREEN_CTRL_ID_PREV_PLAYER:
6369 HandleSetupScreen_Input_Player(step, -1);
6372 case SCREEN_CTRL_ID_NEXT_PLAYER:
6373 HandleSetupScreen_Input_Player(step, +1);
6376 case SCREEN_CTRL_ID_SCROLL_UP:
6377 if (game_status == GAME_MODE_LEVELS)
6378 HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6379 else if (game_status == GAME_MODE_SETUP)
6380 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6383 case SCREEN_CTRL_ID_SCROLL_DOWN:
6384 if (game_status == GAME_MODE_LEVELS)
6385 HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6386 else if (game_status == GAME_MODE_SETUP)
6387 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6390 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6391 if (game_status == GAME_MODE_LEVELS)
6392 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
6393 else if (game_status == GAME_MODE_SETUP)
6394 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);