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 in the setup menu */
29 #define SETUP_MODE_MAIN 0
30 #define SETUP_MODE_GAME 1
31 #define SETUP_MODE_CHOOSE_GAME_SPEED 2
32 #define SETUP_MODE_EDITOR 3
33 #define SETUP_MODE_INPUT 4
34 #define SETUP_MODE_SHORTCUT_1 5
35 #define SETUP_MODE_SHORTCUT_2 6
36 #define SETUP_MODE_GRAPHICS 7
37 #define SETUP_MODE_CHOOSE_SCREEN_MODE 8
38 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 9
39 #define SETUP_MODE_SOUND 10
40 #define SETUP_MODE_ARTWORK 11
41 #define SETUP_MODE_CHOOSE_GRAPHICS 12
42 #define SETUP_MODE_CHOOSE_SOUNDS 13
43 #define SETUP_MODE_CHOOSE_MUSIC 14
45 #define MAX_SETUP_MODES 15
47 /* for input setup functions */
48 #define SETUPINPUT_SCREEN_POS_START 0
49 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
50 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
51 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
53 /* screens on the info screen */
54 #define INFO_MODE_MAIN 0
55 #define INFO_MODE_TITLE 1
56 #define INFO_MODE_ELEMENTS 2
57 #define INFO_MODE_MUSIC 3
58 #define INFO_MODE_CREDITS 4
59 #define INFO_MODE_PROGRAM 5
60 #define INFO_MODE_VERSION 6
61 #define INFO_MODE_LEVELSET 7
63 #define MAX_INFO_MODES 8
65 /* for various menu stuff */
66 #define MENU_SCREEN_START_XPOS 1
67 #define MENU_SCREEN_START_YPOS 2
68 #define MENU_SCREEN_VALUE_XPOS 14
69 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
70 #define MENU_TITLE1_YPOS 8
71 #define MENU_TITLE2_YPOS 46
72 #define MAX_INFO_ELEMENTS_ON_SCREEN 10
73 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
74 #define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \
75 MENU_SCREEN_START_XPOS)
76 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
78 /* buttons and scrollbars identifiers */
79 #define SCREEN_CTRL_ID_PREV_LEVEL 0
80 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
81 #define SCREEN_CTRL_ID_PREV_PLAYER 2
82 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
83 #define SCREEN_CTRL_ID_SCROLL_UP 4
84 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
85 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
87 #define NUM_SCREEN_GADGETS 7
89 #define NUM_SCREEN_MENUBUTTONS 4
90 #define NUM_SCREEN_SCROLLBUTTONS 2
91 #define NUM_SCREEN_SCROLLBARS 1
93 #define SCREEN_MASK_MAIN (1 << 0)
94 #define SCREEN_MASK_INPUT (1 << 1)
96 /* graphic position and size values for buttons and scrollbars */
97 #define SC_MENUBUTTON_XSIZE TILEX
98 #define SC_MENUBUTTON_YSIZE TILEY
100 #define SC_SCROLLBUTTON_XSIZE TILEX
101 #define SC_SCROLLBUTTON_YSIZE TILEY
103 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
105 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
106 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
107 SC_SCROLLBUTTON_YSIZE)
109 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
110 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
112 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
113 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
114 SC_SCROLLBUTTON_YSIZE)
116 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
117 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
118 SC_SCROLL_VERTICAL_YSIZE)
120 #define SC_BORDER_SIZE 14
122 /* other useful macro definitions */
123 #define BUTTON_GRAPHIC_ACTIVE(g) \
124 (g == IMG_MENU_BUTTON_LEFT ? IMG_MENU_BUTTON_LEFT_ACTIVE : \
125 g == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE : \
126 g == IMG_MENU_BUTTON_UP ? IMG_MENU_BUTTON_UP_ACTIVE : \
127 g == IMG_MENU_BUTTON_DOWN ? IMG_MENU_BUTTON_DOWN_ACTIVE : \
128 g == IMG_MENU_BUTTON_LEAVE_MENU ? IMG_MENU_BUTTON_LEAVE_MENU_ACTIVE : \
129 g == IMG_MENU_BUTTON_ENTER_MENU ? IMG_MENU_BUTTON_ENTER_MENU_ACTIVE : \
130 g == IMG_MENU_BUTTON_PREV_LEVEL ? IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE : \
131 g == IMG_MENU_BUTTON_NEXT_LEVEL ? IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE : \
132 IMG_MENU_BUTTON_ACTIVE)
135 /* forward declarations of internal functions */
136 static void HandleScreenGadgets(struct GadgetInfo *);
137 static void HandleSetupScreen_Generic(int, int, int, int, int);
138 static void HandleSetupScreen_Input(int, int, int, int, int);
139 static void CustomizeKeyboard(int);
140 static void CalibrateJoystick(int);
141 static void execSetupGame(void);
142 static void execSetupGraphics(void);
143 static void execSetupArtwork(void);
144 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
146 static void DrawChooseLevel(void);
147 static void DrawInfoScreen(void);
148 static void DrawAndFadeInInfoScreen(int);
149 static void DrawSetupScreen(void);
151 static void DrawInfoScreenExt(int, int);
152 static void DrawInfoScreen_NotAvailable(char *, char *);
153 static void DrawInfoScreen_HelpAnim(int, int, boolean);
154 static void DrawInfoScreen_HelpText(int, int, int, int);
155 static void HandleInfoScreen_Main(int, int, int, int, int);
156 static void HandleInfoScreen_TitleScreen(int);
157 static void HandleInfoScreen_Elements(int);
158 static void HandleInfoScreen_Music(int);
159 static void HandleInfoScreen_Credits(int);
160 static void HandleInfoScreen_Program(int);
161 static void HandleInfoScreen_Version(int);
163 static void MapScreenMenuGadgets(int);
164 static void MapScreenTreeGadgets(TreeInfo *);
166 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
168 static int setup_mode = SETUP_MODE_MAIN;
169 static int info_mode = INFO_MODE_MAIN;
171 static TreeInfo *screen_modes = NULL;
172 static TreeInfo *screen_mode_current = NULL;
174 static TreeInfo *scroll_delays = NULL;
175 static TreeInfo *scroll_delay_current = NULL;
177 static TreeInfo *game_speeds = NULL;
178 static TreeInfo *game_speed_current = NULL;
184 } game_speeds_list[] =
193 { 1000, "1/1s (Extremely Slow)" },
198 { 29, "1/35s (Original Supaplex)" },
200 { 20, "1/50s (Normal Speed)" },
201 { 14, "1/70s (Maximum Supaplex)" },
205 { 1, "1/1000s (Extremely Fast)" },
215 } scroll_delays_list[] =
217 { 0, "0 Tiles (No Scroll Delay)" },
220 { 3, "3 Tiles (Default)" },
225 { 8, "8 Tiles (Maximum Scroll Delay)"},
230 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
231 (s) <= GAME_MODE_SETUP ? (s) : \
232 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
233 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
235 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
236 (i) <= INFO_MODE_LEVELSET ? (i) : \
239 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
240 menu.draw_xoffset[GAME_MODE_INFO] : \
241 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
242 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
243 menu.draw_yoffset[GAME_MODE_INFO] : \
244 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
246 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
247 DRAW_XOFFSET_INFO(info_mode) : \
248 menu.draw_xoffset[DRAW_MODE(s)])
249 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
250 DRAW_YOFFSET_INFO(info_mode) : \
251 menu.draw_yoffset[DRAW_MODE(s)])
253 #define mSX (SX + DRAW_XOFFSET(game_status))
254 #define mSY (SY + DRAW_YOFFSET(game_status))
256 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
257 menu.list_size[game_status] : \
258 MAX_MENU_ENTRIES_ON_SCREEN)
260 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
261 #define NUM_SCROLLBAR_BITMAPS 2
262 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS];
266 /* title display and control definitions */
268 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
269 2 * MAX_NUM_TITLE_MESSAGES)
271 static int num_title_screens = 0;
273 struct TitleControlInfo
281 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
283 /* main menu display and control definitions */
285 #define MAIN_CONTROL_NAME 0
286 #define MAIN_CONTROL_LEVELS 1
287 #define MAIN_CONTROL_SCORES 2
288 #define MAIN_CONTROL_EDITOR 3
289 #define MAIN_CONTROL_INFO 4
290 #define MAIN_CONTROL_GAME 5
291 #define MAIN_CONTROL_SETUP 6
292 #define MAIN_CONTROL_QUIT 7
293 #define MAIN_CONTROL_PREV_LEVEL 8
294 #define MAIN_CONTROL_NEXT_LEVEL 9
295 #define MAIN_CONTROL_FIRST_LEVEL 10
296 #define MAIN_CONTROL_LAST_LEVEL 11
297 #define MAIN_CONTROL_LEVEL_NUMBER 12
298 #define MAIN_CONTROL_LEVEL_INFO_1 13
299 #define MAIN_CONTROL_LEVEL_INFO_2 14
300 #define MAIN_CONTROL_LEVEL_NAME 15
301 #define MAIN_CONTROL_LEVEL_AUTHOR 16
302 #define MAIN_CONTROL_LEVEL_YEAR 17
303 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
304 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
305 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
306 #define MAIN_CONTROL_TITLE_1 21
307 #define MAIN_CONTROL_TITLE_2 22
308 #define MAIN_CONTROL_TITLE_3 23
310 static char str_main_text_name[10];
311 static char str_main_text_first_level[10];
312 static char str_main_text_last_level[10];
313 static char str_main_text_level_number[10];
315 static char *main_text_name = str_main_text_name;
316 static char *main_text_first_level = str_main_text_first_level;
317 static char *main_text_last_level = str_main_text_last_level;
318 static char *main_text_level_number = str_main_text_level_number;
319 static char *main_text_levels = "Levelset";
320 static char *main_text_scores = "Hall Of Fame";
321 static char *main_text_editor = "Level Creator";
322 static char *main_text_info = "Info Screen";
323 static char *main_text_game = "Start Game";
324 static char *main_text_setup = "Setup";
325 static char *main_text_quit = "Quit";
326 static char *main_text_level_name = level.name;
327 static char *main_text_level_author = level.author;
328 static char *main_text_level_year = NULL;
329 static char *main_text_level_imported_from = NULL;
330 static char *main_text_level_imported_by = NULL;
331 static char *main_text_level_tested_by = NULL;
332 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
333 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
334 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
336 struct MainControlInfo
340 struct MenuPosInfo *pos_button;
343 struct TextPosInfo *pos_text;
346 struct TextPosInfo *pos_input;
350 static struct MainControlInfo main_controls[] =
354 &menu.main.button.name, IMG_MENU_BUTTON,
355 &menu.main.text.name, &main_text_name,
356 &menu.main.input.name, &setup.player_name,
360 &menu.main.button.levels, IMG_MENU_BUTTON_ENTER_MENU,
361 &menu.main.text.levels, &main_text_levels,
366 &menu.main.button.scores, IMG_MENU_BUTTON,
367 &menu.main.text.scores, &main_text_scores,
372 &menu.main.button.editor, IMG_MENU_BUTTON,
373 &menu.main.text.editor, &main_text_editor,
378 &menu.main.button.info, IMG_MENU_BUTTON_ENTER_MENU,
379 &menu.main.text.info, &main_text_info,
384 &menu.main.button.game, IMG_MENU_BUTTON,
385 &menu.main.text.game, &main_text_game,
390 &menu.main.button.setup, IMG_MENU_BUTTON_ENTER_MENU,
391 &menu.main.text.setup, &main_text_setup,
396 &menu.main.button.quit, IMG_MENU_BUTTON,
397 &menu.main.text.quit, &main_text_quit,
401 /* (these two buttons are real gadgets) */
403 MAIN_CONTROL_PREV_LEVEL,
404 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
409 MAIN_CONTROL_NEXT_LEVEL,
410 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
416 MAIN_CONTROL_FIRST_LEVEL,
418 &menu.main.text.first_level, &main_text_first_level,
422 MAIN_CONTROL_LAST_LEVEL,
424 &menu.main.text.last_level, &main_text_last_level,
428 MAIN_CONTROL_LEVEL_NUMBER,
430 &menu.main.text.level_number, &main_text_level_number,
434 MAIN_CONTROL_LEVEL_INFO_1,
436 &menu.main.text.level_info_1, NULL,
440 MAIN_CONTROL_LEVEL_INFO_2,
442 &menu.main.text.level_info_2, NULL,
446 MAIN_CONTROL_LEVEL_NAME,
448 &menu.main.text.level_name, &main_text_level_name,
452 MAIN_CONTROL_LEVEL_AUTHOR,
454 &menu.main.text.level_author, &main_text_level_author,
458 MAIN_CONTROL_LEVEL_YEAR,
460 &menu.main.text.level_year, &main_text_level_year,
464 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
466 &menu.main.text.level_imported_from, &main_text_level_imported_from,
470 MAIN_CONTROL_LEVEL_IMPORTED_BY,
472 &menu.main.text.level_imported_by, &main_text_level_imported_by,
476 MAIN_CONTROL_LEVEL_TESTED_BY,
478 &menu.main.text.level_tested_by, &main_text_level_tested_by,
482 MAIN_CONTROL_TITLE_1,
484 &menu.main.text.title_1, &main_text_title_1,
488 MAIN_CONTROL_TITLE_2,
490 &menu.main.text.title_2, &main_text_title_2,
494 MAIN_CONTROL_TITLE_3,
496 &menu.main.text.title_3, &main_text_title_3,
509 static int getTitleScreenGraphic(int nr, boolean initial)
511 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
514 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
516 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
520 static int getTitleScreenGameMode(boolean initial)
522 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
526 static int getTitleMessageGameMode(boolean initial)
528 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
532 static int getTitleScreenBackground(boolean initial)
534 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
539 static int getTitleMessageBackground(int nr, boolean initial)
541 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
545 static int getTitleBackground(int nr, boolean initial, boolean is_image)
547 int base = (is_image ?
548 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
549 IMG_BACKGROUND_TITLESCREEN_1) :
550 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
551 IMG_BACKGROUND_TITLEMESSAGE_1));
552 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
553 IMG_BACKGROUND_TITLE);
554 int graphic_local = base + nr;
556 if (graphic_info[graphic_local].bitmap != NULL)
557 return graphic_local;
559 if (graphic_info[graphic_global].bitmap != NULL)
560 return graphic_global;
562 return IMG_UNDEFINED;
565 static int getTitleSound(struct TitleControlInfo *tci)
567 boolean is_image = tci->is_image;
568 int initial = tci->initial;
569 int nr = tci->local_nr;
570 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
571 int base = (is_image ?
572 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
573 SND_BACKGROUND_TITLESCREEN_1) :
574 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
575 SND_BACKGROUND_TITLEMESSAGE_1));
576 int sound_global = menu.sound[mode];
577 int sound_local = base + nr;
580 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
581 nr, initial, is_image,
582 sound_global, getSoundListEntry(sound_global)->filename,
583 sound_local, getSoundListEntry(sound_local)->filename);
586 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
589 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
592 return SND_UNDEFINED;
595 static int getTitleMusic(struct TitleControlInfo *tci)
597 boolean is_image = tci->is_image;
598 int initial = tci->initial;
599 int nr = tci->local_nr;
600 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
601 int base = (is_image ?
602 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
603 MUS_BACKGROUND_TITLESCREEN_1) :
604 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
605 MUS_BACKGROUND_TITLEMESSAGE_1));
606 int music_global = menu.music[mode];
607 int music_local = base + nr;
610 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
611 nr, initial, is_image,
612 music_global, getMusicListEntry(music_global)->filename,
613 music_local, getMusicListEntry(music_local)->filename);
616 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
619 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
622 return MUS_UNDEFINED;
625 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
627 boolean is_image = tci->is_image;
628 int initial = tci->initial;
629 int nr = tci->local_nr;
630 struct TitleFadingInfo ti;
634 int graphic = getTitleScreenGraphic(nr, initial);
636 /* initialize fading control values to default title config settings */
637 ti = (initial ? title_initial_default : title_default);
639 /* override default settings with image config settings, if defined */
640 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
641 ti.fade_mode = graphic_info[graphic].fade_mode;
642 if (graphic_info[graphic].fade_delay > -1)
643 ti.fade_delay = graphic_info[graphic].fade_delay;
644 if (graphic_info[graphic].post_delay > -1)
645 ti.post_delay = graphic_info[graphic].post_delay;
646 if (graphic_info[graphic].auto_delay > -1)
647 ti.auto_delay = graphic_info[graphic].auto_delay;
653 ti.fade_mode = titlemessage_initial[nr].fade_mode;
654 ti.fade_delay = titlemessage_initial[nr].fade_delay;
655 ti.post_delay = titlemessage_initial[nr].post_delay;
656 ti.auto_delay = titlemessage_initial[nr].auto_delay;
660 ti.fade_mode = titlemessage[nr].fade_mode;
661 ti.fade_delay = titlemessage[nr].fade_delay;
662 ti.post_delay = titlemessage[nr].post_delay;
663 ti.auto_delay = titlemessage[nr].auto_delay;
668 if (ti.anim_mode == ANIM_NONE)
669 ti.fade_delay = ti.post_delay = 0;
675 static int compareTitleControlInfo(const void *object1, const void *object2)
677 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
678 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
681 if (tci1->initial != tci2->initial)
682 compare_result = (tci1->initial ? -1 : +1);
683 else if (tci1->sort_priority != tci2->sort_priority)
684 compare_result = tci1->sort_priority - tci2->sort_priority;
685 else if (tci1->is_image != tci2->is_image)
686 compare_result = (tci1->is_image ? -1 : +1);
688 compare_result = tci1->local_nr - tci2->local_nr;
690 return compare_result;
693 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
695 int nr, int sort_priority)
697 title_controls[num_title_screens].is_image = is_image;
698 title_controls[num_title_screens].initial = initial;
699 title_controls[num_title_screens].local_nr = nr;
700 title_controls[num_title_screens].sort_priority = sort_priority;
705 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
709 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
711 int graphic = getTitleScreenGraphic(i, initial);
712 Bitmap *bitmap = graphic_info[graphic].bitmap;
713 int sort_priority = graphic_info[graphic].sort_priority;
716 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
719 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
721 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
722 char *filename = getLevelSetTitleMessageFilename(i, initial);
723 int sort_priority = tmi->sort_priority;
725 if (filename != NULL)
726 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
730 static void InitializeTitleControls(boolean show_title_initial)
732 num_title_screens = 0;
734 if (show_title_initial)
735 InitializeTitleControls_CheckTitleInfo(TRUE);
737 InitializeTitleControls_CheckTitleInfo(FALSE);
739 /* sort title screens according to sort_priority and title number */
740 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
741 compareTitleControlInfo);
744 static boolean visibleMenuPos(struct MenuPosInfo *pos)
746 return (pos != NULL && pos->x != -1 && pos->y != -1);
749 static boolean visibleTextPos(struct TextPosInfo *pos)
751 return (pos != NULL && pos->x != -1 && pos->y != -1);
754 static void InitializeMainControls()
756 boolean local_team_mode = (!options.network && setup.team_mode);
759 /* set main control text values to dynamically determined values */
760 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
761 sprintf(main_text_first_level, "%03d", leveldir_current->first_level);
762 sprintf(main_text_last_level, "%03d", leveldir_current->last_level);
763 sprintf(main_text_level_number, "%s", int2str(level_nr, 3));
765 main_text_level_year = leveldir_current->year;
766 main_text_level_imported_from = leveldir_current->imported_from;
767 main_text_level_imported_by = leveldir_current->imported_by;
768 main_text_level_tested_by = leveldir_current->tested_by;
770 /* set main control screen positions to dynamically determined values */
771 for (i = 0; main_controls[i].nr != -1; i++)
773 struct MainControlInfo *mci = &main_controls[i];
775 struct MenuPosInfo *pos_button = mci->pos_button;
776 struct TextPosInfo *pos_text = mci->pos_text;
777 struct TextPosInfo *pos_input = mci->pos_input;
778 char *text = (mci->text ? *mci->text : NULL);
779 char *input = (mci->input ? *mci->input : NULL);
780 int button_graphic = mci->button_graphic;
782 int font_text = (pos_text ? pos_text->font : -1);
783 int font_input = (pos_input ? pos_input->font : -1);
785 int font_text = mci->font_text;
786 int font_input = mci->font_input;
789 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
790 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
791 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
792 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
793 int text_chars = (text != NULL ? strlen(text) : 0);
794 int input_chars = (input != NULL ? strlen(input) : 0);
797 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
799 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
800 int text_width = font_text_width * text_chars;
801 int text_height = font_text_height;
802 int input_width = font_input_width * input_chars;
803 int input_height = font_input_height;
805 if (nr == MAIN_CONTROL_NAME)
808 if (menu.main.input.name.x == -1)
809 menu.main.input.name.x = menu.main.text.name.x + text_width;
810 if (menu.main.input.name.y == -1)
811 menu.main.input.name.y = menu.main.text.name.y;
815 menu.main.input.name.width = input_width;
816 menu.main.input.name.height = input_height;
818 menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
819 menu.main.input.name.height = font_input_height;
823 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
825 if (pos_button->width == 0)
826 pos_button->width = button_width;
827 if (pos_button->height == 0)
828 pos_button->height = button_height;
831 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
833 /* calculate width for non-clickable text -- needed for text alignment */
834 boolean calculate_text_width = (pos_button == NULL && text != NULL);
836 if (visibleMenuPos(pos_button))
838 if (pos_text->x == -1)
839 pos_text->x = pos_button->x + pos_button->width;
840 if (pos_text->y == -1)
841 pos_text->y = pos_button->y;
844 if (pos_text->width == -1 || calculate_text_width)
845 pos_text->width = text_width;
846 if (pos_text->height == -1)
847 pos_text->height = text_height;
850 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
852 if (visibleTextPos(pos_text))
854 if (pos_input->x == -1)
855 pos_input->x = pos_text->x + pos_text->width;
856 if (pos_input->y == -1)
857 pos_input->y = pos_text->y;
860 if (pos_input->width == -1)
861 pos_input->width = input_width;
862 if (pos_input->height == -1)
863 pos_input->height = input_height;
868 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
869 boolean active_input)
873 for (i = 0; main_controls[i].nr != -1; i++)
875 struct MainControlInfo *mci = &main_controls[i];
877 if (mci->nr == nr || nr == -1)
879 struct MenuPosInfo *pos_button = mci->pos_button;
880 struct TextPosInfo *pos_text = mci->pos_text;
881 struct TextPosInfo *pos_input = mci->pos_input;
882 char *text = (mci->text ? *mci->text : NULL);
883 char *input = (mci->input ? *mci->input : NULL);
884 int button_graphic = mci->button_graphic;
886 int font_text = (pos_text ? pos_text->font : -1);
887 int font_input = (pos_input ? pos_input->font : -1);
889 int font_text = mci->font_text;
890 int font_input = mci->font_input;
895 button_graphic = BUTTON_GRAPHIC_ACTIVE(button_graphic);
896 font_text = FONT_ACTIVE(font_text);
901 font_input = FONT_ACTIVE(font_input);
904 if (visibleMenuPos(pos_button))
906 struct MenuPosInfo *pos = pos_button;
907 int x = mSX + pos->x;
908 int y = mSY + pos->y;
910 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
911 DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
914 if (visibleTextPos(pos_text) && text != NULL)
916 struct TextPosInfo *pos = pos_text;
917 int x = mSX + ALIGNED_TEXT_XPOS(pos);
918 int y = mSY + ALIGNED_TEXT_YPOS(pos);
921 /* (check why/if this is needed) */
922 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
924 DrawText(x, y, text, font_text);
927 if (visibleTextPos(pos_input) && input != NULL)
929 struct TextPosInfo *pos = pos_input;
930 int x = mSX + ALIGNED_TEXT_XPOS(pos);
931 int y = mSY + ALIGNED_TEXT_YPOS(pos);
934 /* (check why/if this is needed) */
935 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
937 DrawText(x, y, input, font_input);
943 static void DrawCursorAndText_Main(int nr, boolean active_text)
945 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
949 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
951 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
955 static struct MainControlInfo *getMainControlInfo(int nr)
959 for (i = 0; main_controls[i].nr != -1; i++)
960 if (main_controls[i].nr == nr)
961 return &main_controls[i];
966 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
971 int rect_x = ALIGNED_TEXT_XPOS(rect);
972 int rect_y = ALIGNED_TEXT_YPOS(rect);
974 return (x >= rect_x && x < rect_x + rect->width &&
975 y >= rect_y && y < rect_y + rect->height);
978 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
983 int rect_x = ALIGNED_TEXT_XPOS(rect);
984 int rect_y = ALIGNED_TEXT_YPOS(rect);
986 return (x >= rect_x && x < rect_x + rect->width &&
987 y >= rect_y && y < rect_y + rect->height);
990 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
992 static int cursor_array[SCR_FIELDY];
993 int x = mSX + TILEX * xpos;
994 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
999 cursor_array[ypos] = graphic;
1001 graphic = cursor_array[ypos];
1005 graphic = BUTTON_GRAPHIC_ACTIVE(graphic);
1007 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1008 DrawGraphicThruMaskExt(drawto, x, y, graphic, 0);
1011 static void initCursor(int ypos, int graphic)
1013 drawCursorExt(0, ypos, FALSE, graphic);
1016 static void drawCursor(int ypos, boolean active)
1018 drawCursorExt(0, ypos, active, -1);
1021 static void drawCursorXY(int xpos, int ypos, int graphic)
1023 drawCursorExt(xpos, ypos, FALSE, graphic);
1026 static void drawChooseTreeCursor(int ypos, boolean active)
1028 int last_game_status = game_status; /* save current game status */
1030 /* force LEVELS draw offset on artwork setup screen */
1031 game_status = GAME_MODE_LEVELS;
1033 drawCursorExt(0, ypos, active, -1);
1035 game_status = last_game_status; /* restore current game status */
1040 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1041 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1045 static int getPrevlevelButtonPos()
1050 static int getCurrentLevelTextPos()
1052 return (getPrevlevelButtonPos() + 1);
1055 static int getNextLevelButtonPos()
1057 return getPrevlevelButtonPos() + 3 + 1;
1060 static int getLevelRangeTextPos()
1062 return getNextLevelButtonPos() + 1;
1066 int effectiveGameStatus()
1068 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1069 return GAME_MODE_TITLE;
1074 void DrawTitleScreenImage(int nr, boolean initial)
1076 int graphic = getTitleScreenGraphic(nr, initial);
1077 Bitmap *bitmap = graphic_info[graphic].bitmap;
1079 int width = graphic_info[graphic].width;
1080 int height = graphic_info[graphic].height;
1081 int src_x = graphic_info[graphic].src_x;
1082 int src_y = graphic_info[graphic].src_y;
1084 int width = graphic_info[graphic].src_image_width;
1085 int height = graphic_info[graphic].src_image_height;
1086 int src_x = 0, src_y = 0;
1093 if (width > WIN_XSIZE)
1095 /* image width too large for window => center image horizontally */
1096 src_x = (width - WIN_XSIZE) / 2;
1100 if (height > WIN_YSIZE)
1102 /* image height too large for window => center image vertically */
1103 src_y = (height - WIN_YSIZE) / 2;
1107 /* always display title screens centered */
1108 dst_x = (WIN_XSIZE - width) / 2;
1109 dst_y = (WIN_YSIZE - height) / 2;
1111 SetDrawBackgroundMask(REDRAW_ALL);
1112 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1114 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1116 if (DrawingOnBackground(dst_x, dst_y))
1117 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1119 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1121 redraw_mask = REDRAW_ALL;
1123 /* reset fading control values to default config settings */
1127 title = getTitleFading(nr, initial, TRUE);
1132 title.fade_delay_final = title.fade_delay;
1133 title.post_delay_final = title.post_delay;
1134 title.auto_delay_final = title.auto_delay;
1136 /* override default settings with image config settings, if defined */
1137 if (graphic_info[graphic].anim_mode != ANIM_DEFAULT)
1138 title.anim_mode = graphic_info[graphic].anim_mode;
1139 if (graphic_info[graphic].fade_delay > -1)
1140 title.fade_delay = graphic_info[graphic].fade_delay;
1141 if (graphic_info[graphic].post_delay > -1)
1142 title.post_delay = graphic_info[graphic].post_delay;
1143 if (graphic_info[graphic].auto_delay > -1)
1144 title.auto_delay = graphic_info[graphic].auto_delay;
1148 void DrawTitleScreenMessage(int nr, boolean initial)
1150 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1151 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1153 int font_nr = FONT_TEXT_1;
1157 int pad_y = 32 + 14;
1160 int max_chars_per_line;
1161 int max_lines_per_screen;
1163 int last_game_status = game_status; /* save current game status */
1165 if (filename == NULL)
1168 /* force TITLE font on title message screen */
1169 game_status = getTitleMessageGameMode(initial);
1171 /* if chars set to "-1", automatically determine by text and font width */
1172 if (tmi->chars == -1)
1173 tmi->chars = tmi->width / getFontWidth(tmi->font);
1175 tmi->width = tmi->chars * getFontWidth(tmi->font);
1177 /* if lines set to "-1", automatically determine by text and font height */
1178 if (tmi->lines == -1)
1179 tmi->lines = tmi->height / getFontHeight(tmi->font);
1181 tmi->height = tmi->lines * getFontHeight(tmi->font);
1183 SetDrawBackgroundMask(REDRAW_ALL);
1184 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1186 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1189 font_width = getFontWidth(font_nr);
1190 font_height = getFontHeight(font_nr);
1191 max_chars_per_line = (WIN_XSIZE - 2 * pad_x) / font_width;
1192 max_lines_per_screen = (WIN_YSIZE - pad_y) / font_height - 1;
1196 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1197 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
1198 tmi->autowrap, tmi->centered, tmi->parse_comments);
1200 DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
1201 max_lines_per_screen, -1, tmi->autowrap, tmi->centered,
1202 tmi->parse_comments);
1205 game_status = last_game_status; /* restore current game status */
1208 void DrawTitleScreen()
1210 KeyboardAutoRepeatOff();
1213 SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
1216 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1221 boolean CheckTitleScreen(boolean levelset_has_changed)
1223 static boolean show_title_initial = TRUE;
1224 boolean show_titlescreen = FALSE;
1226 /* needed to be able to skip title screen, if no image or message defined */
1227 InitializeTitleControls(show_title_initial);
1229 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1230 show_titlescreen = TRUE;
1232 /* show initial title images and messages only once at program start */
1233 show_title_initial = FALSE;
1235 return (show_titlescreen && num_title_screens > 0);
1238 void DrawMainMenuExt(int redraw_mask, boolean do_fading)
1240 static LevelDirTree *leveldir_last_valid = NULL;
1241 boolean levelset_has_changed = FALSE;
1243 boolean local_team_mode = (!options.network && setup.team_mode);
1244 char *name_text = (local_team_mode ? "Team:" : "Name:");
1245 int name_width, level_width;
1252 /* !!! CHANGE THIS !!! */
1253 title = title_default;
1257 printf("::: %d, %d\n", fading.anim_mode == ANIM_CROSSFADE,
1258 redraw_mask == REDRAW_ALL);
1262 FadeOut(redraw_mask);
1266 FadeSoundsAndMusic();
1268 KeyboardAutoRepeatOn();
1271 SetDrawDeactivationMask(REDRAW_NONE);
1272 SetDrawBackgroundMask(REDRAW_FIELD);
1274 audio.sound_deactivated = FALSE;
1278 /* needed if last screen was the playing screen, invoked from level editor */
1279 if (level_editor_test_game)
1281 game_status = GAME_MODE_EDITOR;
1287 /* needed if last screen was the editor screen */
1288 UndrawSpecialEditorDoor();
1290 /* needed if last screen was the setup screen and fullscreen state changed */
1291 ToggleFullscreenIfNeeded();
1293 /* leveldir_current may be invalid (level group, parent link) */
1294 if (!validLevelSeries(leveldir_current))
1295 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1297 if (leveldir_current != leveldir_last_valid)
1298 levelset_has_changed = TRUE;
1300 /* store valid level series information */
1301 leveldir_last_valid = leveldir_current;
1303 /* needed if last screen (level choice) changed graphics, sounds or music */
1304 ReloadCustomArtwork(0);
1306 #if defined(TARGET_SDL)
1307 SetDrawtoField(DRAW_BACKBUFFER);
1311 if (levelset_has_changed)
1312 fading = title_default;
1316 if (CheckTitleScreen(levelset_has_changed))
1318 game_status = GAME_MODE_TITLE;
1327 if (setup.show_titlescreen &&
1328 ((levelset_has_changed &&
1329 (graphic_info[IMG_TITLESCREEN_1].bitmap != NULL ||
1330 getLevelSetMessageFilename(1, FALSE) != NULL)) ||
1331 (show_title_initial &&
1332 (graphic_info[IMG_TITLESCREEN_INITIAL_1].bitmap != NULL ||
1333 getLevelSetMessageFilename(1, TRUE) != NULL))))
1335 game_status = GAME_MODE_TITLE;
1343 /* level_nr may have been set to value over handicap with level editor */
1344 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1345 level_nr = leveldir_current->handicap_level;
1347 LoadLevel(level_nr);
1349 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1352 FadeOut(redraw_mask);
1356 if (redraw_mask == REDRAW_ALL)
1359 int door_state = GetDoorState();
1364 // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1368 OpenDoor(DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1370 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1379 InitializeMainControls();
1382 DrawCursorAndText_Main(-1, FALSE);
1384 for (i = 0; main_controls[i].nr != -1; i++)
1386 struct MenuPosInfo *pos_button = main_controls[i].pos_button;
1387 struct MenuPosInfo *pos_text = main_controls[i].pos_text;
1388 struct MenuPosInfo *pos_input = main_controls[i].pos_input;
1389 char *text = main_controls[i].text;
1390 char *input = main_controls[i].input;
1391 int button_graphic = main_controls[i].button_graphic;
1392 int font_text = main_controls[i].font_text;
1393 int font_input = main_controls[i].font_input;
1395 if (pos_button != NULL)
1396 DrawGraphicThruMaskExt(drawto, mSX + pos_button->x, mSY + pos_button->y,
1399 if (pos_text != NULL && text != NULL)
1400 DrawText(mSX + pos_text->x, mSY + pos_text->y, text, font_text);
1402 if (pos_input != NULL && input != NULL)
1403 DrawText(mSX + pos_input->x, mSY + pos_input->y, input, font_input);
1411 DrawText(mSX + 32, mSY + 2 * 32, name_text, FONT_MENU_1);
1412 DrawText(mSX + 32, mSY + 3 * 32, "Levelset", FONT_MENU_1);
1413 DrawText(mSX + 32, mSY + 4 * 32, "Hall Of Fame", FONT_MENU_1);
1414 DrawText(mSX + 32, mSY + 5 * 32, "Level Creator", FONT_MENU_1);
1415 DrawText(mSX + 32, mSY + 6 * 32, "Info Screen", FONT_MENU_1);
1416 DrawText(mSX + 32, mSY + 7 * 32, "Start Game", FONT_MENU_1);
1417 DrawText(mSX + 32, mSY + 8 * 32, "Setup", FONT_MENU_1);
1418 DrawText(mSX + 32, mSY + 9 * 32, "Quit", FONT_MENU_1);
1420 /* calculated after (possible) reload of custom artwork */
1421 name_width = getTextWidth(name_text, FONT_MENU_1);
1422 level_width = 9 * 32;
1424 DrawText(mSX + 32 + name_width, mSY + 2 * 32, setup.player_name,
1427 DrawText(mSX + getCurrentLevelTextPos() * 32, mSY + 3 * 32,
1428 int2str(level_nr, 3), FONT_VALUE_1);
1431 int text_height = getFontHeight(FONT_TEXT_3);
1432 int xpos = getLevelRangeTextPos() * 32 + 8;
1433 int ypos2 = 3 * 32 + 16;
1434 int ypos1 = ypos2 - text_height;
1436 DrawTextF(mSX - SX + xpos, mSY - SY + ypos1, FONT_TEXT_3,
1437 "%03d", leveldir_current->first_level);
1438 DrawTextF(mSX - SX + xpos, mSY - SY + ypos2, FONT_TEXT_3,
1439 "%03d", leveldir_current->last_level);
1442 for (i = 0; i < 8; i++)
1443 initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_ENTER_MENU :
1446 DrawTextSCentered(326, FONT_TITLE_2, PROGRAM_GAME_BY_STRING);
1449 DrawPreviewLevel(TRUE);
1451 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1454 if (TAPE_IS_EMPTY(tape))
1456 DrawCompleteVideoDisplay();
1461 /* create gadgets for main menu screen */
1462 FreeScreenGadgets();
1463 CreateScreenGadgets();
1466 BlitBitmap(drawto, window, VX, VY, VXSIZE, VYSIZE, VX, VY);
1470 /* map gadgets for main menu screen */
1472 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1474 DrawMaskedBorder(REDRAW_ALL);
1477 if (redraw_mask == REDRAW_ALL)
1479 int door_state = GetDoorState();
1481 OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1487 game_status = GAME_MODE_PSEUDO_PREVIEW;
1489 DrawText(20, 400, "text_3.PREVIEW", FONT_TEXT_3);
1490 DrawText(20, 420, "text_4.PREVIEW", FONT_TEXT_4);
1492 game_status = GAME_MODE_MAIN;
1494 DrawText(20, 440, "text_3.MAIN", FONT_TEXT_3);
1495 DrawText(20, 460, "text_4.MAIN", FONT_TEXT_4);
1500 FadeIn(redraw_mask);
1505 else if (fading.anim_mode == ANIM_CROSSFADE)
1506 FadeCross(redraw_mask);
1508 FadeIn(redraw_mask);
1511 FadeIn(redraw_mask);
1520 fading = title_default;
1523 SetMouseCursor(CURSOR_DEFAULT);
1527 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1530 void DrawAndFadeInMainMenu(int redraw_mask)
1532 DrawMainMenuExt(redraw_mask, TRUE);
1537 DrawMainMenuExt(REDRAW_ALL, FALSE);
1541 static void gotoTopLevelDir()
1543 /* move upwards to top level directory */
1544 while (leveldir_current->node_parent)
1546 /* write a "path" into level tree for easy navigation to last level */
1547 if (leveldir_current->node_parent->node_group->cl_first == -1)
1549 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1550 int leveldir_pos = posTreeInfo(leveldir_current);
1551 int num_page_entries;
1552 int cl_first, cl_cursor;
1554 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1555 num_page_entries = num_leveldirs;
1557 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1559 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1560 cl_cursor = leveldir_pos - cl_first;
1562 leveldir_current->node_parent->node_group->cl_first = cl_first;
1563 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1566 leveldir_current = leveldir_current->node_parent;
1571 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1573 static unsigned long title_delay = 0;
1574 static int title_screen_nr = 0;
1575 static int last_sound = -1, last_music = -1;
1576 boolean return_to_main_menu = FALSE;
1577 boolean use_fading_main_menu = TRUE;
1580 boolean use_cross_fading = FALSE;
1582 boolean use_cross_fading = !show_title_initial; /* default */
1585 struct TitleControlInfo *tci;
1586 struct TitleFadingInfo fading_default;
1587 struct TitleFadingInfo fading_last = fading;
1588 struct TitleFadingInfo fading_next;
1591 if (button == MB_MENU_INITIALIZE)
1594 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1598 int last_game_status = game_status; /* save current game status */
1602 title_screen_nr = 0;
1603 tci = &title_controls[title_screen_nr];
1605 last_sound = SND_UNDEFINED;
1606 last_music = MUS_UNDEFINED;
1609 /* determine number of title screens to display (images and messages) */
1610 InitializeTitleControls();
1613 if (game_status == GAME_MODE_INFO)
1615 if (num_title_screens == 0)
1617 DrawInfoScreen_NotAvailable("Title screen information:",
1618 "No title screen for this level set.");
1621 /* use default settings for fading, but always disable auto delay */
1622 fading = title_default;
1623 fading.auto_delay = -1;
1629 FadeSoundsAndMusic();
1632 FadeOut(REDRAW_ALL);
1637 DrawTitleScreenImage(tci->local_nr, tci->initial);
1639 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1641 fading_default = (tci->initial ? title_initial_default : title_default);
1643 fading = fading_next = getTitleFading(tci);
1647 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1648 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1650 fading.fade_mode = FADE_MODE_FADE;
1651 fading.fade_delay = fading_default.fade_delay;
1654 if (fading_last.fade_mode != FADE_MODE_CROSSFADE &&
1655 fading_next.fade_mode == FADE_MODE_CROSSFADE)
1656 fading.fade_mode = FADE_MODE_FADE;
1661 sound = getTitleSound(tci);
1662 music = getTitleMusic(tci);
1664 if (sound != last_sound)
1665 PlayMenuSoundExt(sound);
1666 if (music != last_music)
1667 PlayMenuMusicExt(music);
1673 SetMouseCursor(CURSOR_NONE);
1675 // printf("::: mode: %d, delay: %d\n", fading.fade_mode, fading.fade_delay);
1681 fading = fading_next;
1683 DelayReached(&title_delay, 0); /* reset delay counter */
1689 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1690 button = MB_MENU_CHOICE;
1692 if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
1693 button = MB_MENU_CHOICE;
1696 if (button == MB_MENU_LEAVE)
1698 return_to_main_menu = TRUE;
1699 use_fading_main_menu = FALSE;
1701 else if (button == MB_MENU_CHOICE)
1704 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1707 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1710 FadeOut(REDRAW_FIELD);
1715 info_mode = INFO_MODE_MAIN;
1716 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1722 tci = &title_controls[title_screen_nr];
1724 if (title_screen_nr < num_title_screens)
1728 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1735 graphic_info[getTitleScreenGraphic(tci->local_nr,
1736 tci->initial)].anim_mode;
1738 anim_mode = ANIM_FADE; /* ??? */
1740 use_cross_fading = (anim_mode == ANIM_FADE ? FALSE :
1741 anim_mode == ANIM_CROSSFADE ? TRUE :
1745 sound = getTitleSound(tci);
1746 music = getTitleMusic(tci);
1748 if (sound == SND_UNDEFINED || sound != last_sound)
1750 if (music == MUS_UNDEFINED || music != last_music)
1754 FadeOut(REDRAW_ALL);
1758 DrawTitleScreenImage(tci->local_nr, tci->initial);
1760 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1762 fading_next = getTitleFading(tci);
1765 sound = getTitleSound(tci);
1766 music = getTitleMusic(tci);
1768 if (sound != last_sound)
1769 PlayMenuSoundExt(sound);
1770 if (music != last_music)
1771 PlayMenuMusicExt(music);
1778 printf("::: %d -> %d\n", fading.fade_mode, fading_next.fade_mode);
1782 /* last screen already faded out, next screen has no animation */
1783 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1784 fading_next.fade_mode == FADE_MODE_NONE)
1785 fading = fading_next;
1787 /* last screen already faded out, next screen has no animation */
1788 if (fading.fade_mode != FADE_MODE_CROSSFADE &&
1789 fading_next.fade_mode == FADE_MODE_NONE)
1790 fading = fading_next;
1797 fading = fading_next;
1799 DelayReached(&title_delay, 0); /* reset delay counter */
1803 FadeSoundsAndMusic();
1809 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1813 FadeOut(REDRAW_ALL);
1817 FadeOut(REDRAW_ALL);
1821 return_to_main_menu = TRUE;
1825 if (return_to_main_menu)
1831 SetMouseCursor(CURSOR_DEFAULT);
1833 if (game_status == GAME_MODE_INFO)
1836 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1839 info_mode = INFO_MODE_MAIN;
1840 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1842 else /* default: return to main menu */
1845 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1848 game_status = GAME_MODE_MAIN;
1849 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1854 void HandleMainMenu_SelectLevel(int step, int direction)
1856 int old_level_nr = level_nr;
1859 new_level_nr = old_level_nr + step * direction;
1860 if (new_level_nr < leveldir_current->first_level)
1861 new_level_nr = leveldir_current->first_level;
1862 if (new_level_nr > leveldir_current->last_level)
1863 new_level_nr = leveldir_current->last_level;
1865 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1867 /* skipping levels is only allowed when trying to skip single level */
1868 if (setup.skip_levels && step == 1 &&
1869 Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK))
1871 leveldir_current->handicap_level++;
1872 SaveLevelSetup_SeriesInfo();
1875 new_level_nr = leveldir_current->handicap_level;
1878 if (new_level_nr != old_level_nr)
1880 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1882 PlaySound(SND_MENU_ITEM_SELECTING);
1884 level_nr = new_level_nr;
1887 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1888 int2str(level_nr, 3), mci->pos_text->font);
1890 DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
1893 LoadLevel(level_nr);
1894 DrawPreviewLevel(TRUE);
1898 DrawCompleteVideoDisplay();
1900 /* needed because DrawPreviewLevel() takes some time */
1908 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1910 static int choice = MAIN_CONTROL_GAME;
1914 if (button == MB_MENU_INITIALIZE)
1916 DrawCursorAndText_Main(choice, TRUE);
1921 if (mx || my) /* mouse input */
1925 for (i = 0; main_controls[i].nr != -1; i++)
1927 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1928 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1929 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1931 pos = main_controls[i].nr;
1937 else if (dx || dy) /* keyboard input */
1939 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1940 choice == MAIN_CONTROL_SETUP))
1941 button = MB_MENU_CHOICE;
1946 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1948 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1950 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1956 PlaySound(SND_MENU_ITEM_ACTIVATING);
1958 DrawCursorAndText_Main(choice, FALSE);
1959 DrawCursorAndText_Main(pos, TRUE);
1966 PlaySound(SND_MENU_ITEM_SELECTING);
1968 if (pos == MAIN_CONTROL_NAME)
1970 game_status = GAME_MODE_PSEUDO_TYPENAME;
1972 HandleTypeName(strlen(setup.player_name), 0);
1974 else if (pos == MAIN_CONTROL_LEVELS)
1978 game_status = GAME_MODE_LEVELS;
1980 SaveLevelSetup_LastSeries();
1981 SaveLevelSetup_SeriesInfo();
1990 else if (pos == MAIN_CONTROL_SCORES)
1992 game_status = GAME_MODE_SCORES;
1996 else if (pos == MAIN_CONTROL_EDITOR)
1998 if (leveldir_current->readonly &&
1999 !strEqual(setup.player_name, "Artsoft"))
2000 Request("This level is read only !", REQ_CONFIRM);
2002 game_status = GAME_MODE_EDITOR;
2008 else if (pos == MAIN_CONTROL_INFO)
2010 game_status = GAME_MODE_INFO;
2011 info_mode = INFO_MODE_MAIN;
2014 fading = menu.navigation;
2019 else if (pos == MAIN_CONTROL_GAME)
2021 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
2023 else if (pos == MAIN_CONTROL_SETUP)
2025 game_status = GAME_MODE_SETUP;
2026 setup_mode = SETUP_MODE_MAIN;
2030 else if (pos == MAIN_CONTROL_QUIT)
2032 SaveLevelSetup_LastSeries();
2033 SaveLevelSetup_SeriesInfo();
2035 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
2036 game_status = GAME_MODE_QUIT;
2041 if (game_status == GAME_MODE_MAIN)
2043 DrawPreviewLevel(FALSE);
2050 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
2052 static int choice = 5;
2056 if (button == MB_MENU_INITIALIZE)
2058 drawCursor(choice, TRUE);
2063 if (mx || my) /* mouse input */
2065 x = (mx - mSX) / 32;
2066 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2068 else if (dx || dy) /* keyboard input */
2070 if (dx && choice == 1)
2071 x = (dx < 0 ? 10 : 14);
2074 if (choice == 4 || choice == 6)
2075 button = MB_MENU_CHOICE;
2081 if (y == 1 && dx != 0 && button)
2083 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
2085 else if (IN_VIS_FIELD(x, y) &&
2086 y >= 0 && y <= 7 && (y != 1 || x < 10))
2092 drawCursor(choice, FALSE);
2093 drawCursor(y, TRUE);
2102 game_status = GAME_MODE_PSEUDO_TYPENAME;
2103 HandleTypeName(strlen(setup.player_name), 0);
2109 game_status = GAME_MODE_LEVELS;
2110 SaveLevelSetup_LastSeries();
2111 SaveLevelSetup_SeriesInfo();
2122 game_status = GAME_MODE_SCORES;
2127 if (leveldir_current->readonly &&
2128 !strEqual(setup.player_name, "Artsoft"))
2129 Request("This level is read only !", REQ_CONFIRM);
2130 game_status = GAME_MODE_EDITOR;
2135 game_status = GAME_MODE_INFO;
2136 info_mode = INFO_MODE_MAIN;
2141 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
2145 game_status = GAME_MODE_SETUP;
2146 setup_mode = SETUP_MODE_MAIN;
2152 SaveLevelSetup_LastSeries();
2153 SaveLevelSetup_SeriesInfo();
2155 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
2156 game_status = GAME_MODE_QUIT;
2161 if (game_status == GAME_MODE_MAIN)
2163 DrawPreviewLevel(FALSE);
2171 /* ========================================================================= */
2172 /* info screen functions */
2173 /* ========================================================================= */
2175 static struct TokenInfo *info_info;
2176 static int num_info_info;
2178 static void execInfoTitleScreen()
2184 info_mode = INFO_MODE_TITLE;
2188 static void execInfoElements()
2194 info_mode = INFO_MODE_ELEMENTS;
2198 static void execInfoMusic()
2204 info_mode = INFO_MODE_MUSIC;
2208 static void execInfoCredits()
2214 info_mode = INFO_MODE_CREDITS;
2218 static void execInfoProgram()
2224 info_mode = INFO_MODE_PROGRAM;
2228 static void execInfoVersion()
2234 info_mode = INFO_MODE_VERSION;
2238 static void execInfoLevelSet()
2244 info_mode = INFO_MODE_LEVELSET;
2248 static void execExitInfo()
2254 game_status = GAME_MODE_MAIN;
2256 DrawMainMenuExt(REDRAW_FIELD, FALSE);
2262 static struct TokenInfo info_info_main[] =
2264 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2265 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2266 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2267 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2268 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2269 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2270 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2271 { TYPE_EMPTY, NULL, "" },
2272 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2277 static void DrawCursorAndText_Info(int pos, boolean active)
2279 int xpos = MENU_SCREEN_START_XPOS;
2280 int ypos = MENU_SCREEN_START_YPOS + pos;
2281 int font_nr = FONT_MENU_1;
2284 font_nr = FONT_ACTIVE(font_nr);
2286 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
2288 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
2289 drawCursor(pos, active);
2292 static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading)
2297 CloseDoor(DOOR_CLOSE_2);
2299 /* (needed after displaying title screens which disable auto repeat) */
2300 KeyboardAutoRepeatOn();
2303 FadeOut(redraw_mask);
2307 if (redraw_mask == REDRAW_ALL)
2310 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2316 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2318 info_info = info_info_main;
2321 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2324 int xpos = MENU_SCREEN_START_XPOS;
2325 int ypos = MENU_SCREEN_START_YPOS + i;
2326 int font_nr = FONT_MENU_1;
2329 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2330 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2331 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2332 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2333 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
2334 initCursor(i, IMG_MENU_BUTTON);
2337 DrawCursorAndText_Info(i, FALSE);
2339 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[i].text, font_nr);
2345 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2350 DrawMaskedBorder(redraw_mask);
2353 FadeIn(redraw_mask);
2358 else if (fading.anim_mode == ANIM_CROSSFADE)
2359 FadeCross(redraw_mask);
2361 FadeIn(redraw_mask);
2364 FadeIn(redraw_mask);
2373 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2375 static int choice_store[MAX_INFO_MODES];
2376 int choice = choice_store[info_mode]; /* always starts with 0 */
2380 if (button == MB_MENU_INITIALIZE)
2382 /* advance to first valid menu entry */
2383 while (choice < num_info_info &&
2384 info_info[choice].type & TYPE_SKIP_ENTRY)
2386 choice_store[info_mode] = choice;
2389 DrawCursorAndText_Info(choice, TRUE);
2391 drawCursor(choice, TRUE);
2396 else if (button == MB_MENU_LEAVE)
2398 for (y = 0; y < num_info_info; y++)
2400 if (info_info[y].type & TYPE_LEAVE_MENU)
2402 void (*menu_callback_function)(void) = info_info[y].value;
2406 menu_callback_function();
2408 break; /* absolutely needed because function changes 'info_info'! */
2415 if (mx || my) /* mouse input */
2417 x = (mx - mSX) / 32;
2418 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2420 else if (dx || dy) /* keyboard input */
2424 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2426 if (info_info[choice].type & menu_navigation_type ||
2427 info_info[choice].type & TYPE_ENTER_SCREEN ||
2428 info_info[choice].type & TYPE_BOOLEAN_STYLE)
2429 button = MB_MENU_CHOICE;
2434 /* jump to next non-empty menu entry (up or down) */
2435 while (y > 0 && y < num_info_info - 1 &&
2436 info_info[y].type & TYPE_SKIP_ENTRY)
2440 if (IN_VIS_FIELD(x, y) &&
2441 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2447 PlaySound(SND_MENU_ITEM_ACTIVATING);
2450 DrawCursorAndText_Info(choice, FALSE);
2451 DrawCursorAndText_Info(y, TRUE);
2453 drawCursor(choice, FALSE);
2454 drawCursor(y, TRUE);
2457 choice = choice_store[info_mode] = y;
2460 else if (!(info_info[y].type & TYPE_GHOSTED))
2462 PlaySound(SND_MENU_ITEM_SELECTING);
2464 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2466 void (*menu_callback_function)(void) = info_info[choice].value;
2468 FadeSetFromType(info_info[y].type);
2470 menu_callback_function();
2476 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2479 int ystart1 = mSY - SY + 100;
2480 int ystart2 = mSY - SY + 150;
2481 int ybottom = mSY - SY + SYSIZE - 20;
2485 int ybottom = SYSIZE - 20;
2488 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2491 FadeOut(REDRAW_FIELD);
2497 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2498 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2500 DrawTextSCentered(ybottom, FONT_TEXT_4,
2501 "Press any key or button for info menu");
2504 FadeIn(REDRAW_FIELD);
2508 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2510 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2511 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2512 int xstart = mSX + 16;
2513 int ystart1 = mSY - SY + 100;
2514 int ystart2 = mSY + 64 + 2 * 32;
2515 int ybottom = mSY - SY + SYSIZE - 20;
2516 int ystep = TILEY + 4;
2517 int element, action, direction;
2525 for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++)
2526 infoscreen_step[i] = infoscreen_frame[i] = 0;
2531 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2533 DrawTextSCentered(ybottom, FONT_TEXT_4,
2534 "Press any key or button for next page");
2540 while (helpanim_info[j].element != HELPANIM_LIST_END)
2542 if (i >= start + MAX_INFO_ELEMENTS_ON_SCREEN ||
2547 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2556 j += infoscreen_step[i - start];
2558 element = helpanim_info[j].element;
2559 action = helpanim_info[j].action;
2560 direction = helpanim_info[j].direction;
2563 element = EL_UNKNOWN;
2565 if (action != -1 && direction != -1)
2566 graphic = el_act_dir2img(element, action, direction);
2567 else if (action != -1)
2568 graphic = el_act2img(element, action);
2569 else if (direction != -1)
2570 graphic = el_dir2img(element, direction);
2572 graphic = el2img(element);
2574 delay = helpanim_info[j++].delay;
2579 if (infoscreen_frame[i - start] == 0)
2582 infoscreen_frame[i - start] = delay - 1;
2586 sync_frame = delay - infoscreen_frame[i - start];
2587 infoscreen_frame[i - start]--;
2590 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2592 if (!infoscreen_frame[i - start])
2593 infoscreen_step[i - start] = 0;
2597 if (!infoscreen_frame[i - start])
2598 infoscreen_step[i - start]++;
2599 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2605 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2607 DrawGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2608 graphic, sync_frame, USE_MASKING);
2611 DrawInfoScreen_HelpText(element, action, direction, i - start);
2616 redraw_mask |= REDRAW_FIELD;
2621 static char *getHelpText(int element, int action, int direction)
2623 char token[MAX_LINE_LEN];
2625 strcpy(token, element_info[element].token_name);
2628 strcat(token, element_action_info[action].suffix);
2630 if (direction != -1)
2631 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2633 return getHashEntry(helptext_info, token);
2636 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2639 int font_nr = FONT_INFO_ELEMENTS;
2641 int font_nr = FONT_LEVEL_NUMBER;
2643 int font_width = getFontWidth(font_nr);
2644 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2645 int sy = mSY + 65 + 2 * 32 + 1;
2646 int ystep = TILEY + 4;
2647 int pad_x = sx - SX;
2648 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2649 int max_lines_per_text = 2;
2652 if (action != -1 && direction != -1) /* element.action.direction */
2653 text = getHelpText(element, action, direction);
2655 if (text == NULL && action != -1) /* element.action */
2656 text = getHelpText(element, action, -1);
2658 if (text == NULL && direction != -1) /* element.direction */
2659 text = getHelpText(element, -1, direction);
2661 if (text == NULL) /* base element */
2662 text = getHelpText(element, -1, -1);
2664 if (text == NULL) /* not found */
2665 text = "No description available";
2667 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2668 sy += getFontHeight(font_nr) / 2;
2671 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2672 max_chars_per_line, -1, max_lines_per_text, -1,
2673 TRUE, FALSE, FALSE);
2675 DrawTextWrapped(sx, sy + ypos * ystep, text, font_nr,
2676 max_chars_per_line, max_lines_per_text);
2680 void DrawInfoScreen_TitleScreen()
2685 void HandleInfoScreen_TitleScreen(int button)
2687 HandleTitleScreen(0, 0, 0, 0, button);
2690 void DrawInfoScreen_Elements()
2692 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2695 FadeOut(REDRAW_FIELD);
2701 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2704 FadeIn(REDRAW_FIELD);
2710 void HandleInfoScreen_Elements(int button)
2712 static unsigned long info_delay = 0;
2713 static int num_anims;
2714 static int num_pages;
2716 int anims_per_page = MAX_INFO_ELEMENTS_ON_SCREEN;
2719 if (button == MB_MENU_INITIALIZE)
2721 boolean new_element = TRUE;
2725 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2727 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2729 else if (new_element)
2732 new_element = FALSE;
2736 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2740 if (button == MB_MENU_LEAVE)
2742 PlaySound(SND_MENU_ITEM_SELECTING);
2744 info_mode = INFO_MODE_MAIN;
2749 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2751 if (button != MB_MENU_INITIALIZE)
2753 PlaySound(SND_MENU_ITEM_SELECTING);
2758 if (page >= num_pages)
2760 FadeSoundsAndMusic();
2763 FadeOut(REDRAW_FIELD);
2766 info_mode = INFO_MODE_MAIN;
2767 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2772 if (button != MB_MENU_INITIALIZE)
2773 FadeCrossSaveBackbuffer();
2775 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2777 if (button != MB_MENU_INITIALIZE)
2778 FadeCross(REDRAW_FIELD);
2782 if (DelayReached(&info_delay, GameFrameDelay))
2783 if (page < num_pages)
2784 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2786 PlayMenuSoundIfLoop();
2790 void DrawInfoScreen_Music()
2792 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2795 FadeOut(REDRAW_FIELD);
2803 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2806 FadeIn(REDRAW_FIELD);
2810 void HandleInfoScreen_Music(int button)
2812 static struct MusicFileInfo *list = NULL;
2813 int ystart1 = mSY - SY + 100;
2814 int ystart2 = mSY - SY + 150;
2815 int ybottom = mSY - SY + SYSIZE - 20;
2818 if (button == MB_MENU_INITIALIZE)
2820 list = music_file_info;
2824 FadeSoundsAndMusic();
2829 DrawTextSCentered(ystart1, FONT_TEXT_1,
2830 "No music info for this level set.");
2832 DrawTextSCentered(ybottom, FONT_TEXT_4,
2833 "Press any key or button for info menu");
2839 if (button == MB_MENU_LEAVE)
2841 PlaySound(SND_MENU_ITEM_SELECTING);
2843 FadeSoundsAndMusic();
2845 info_mode = INFO_MODE_MAIN;
2850 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2854 if (button != MB_MENU_INITIALIZE)
2856 PlaySound(SND_MENU_ITEM_SELECTING);
2864 FadeSoundsAndMusic();
2867 FadeOut(REDRAW_FIELD);
2870 info_mode = INFO_MODE_MAIN;
2871 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2876 FadeSoundsAndMusic();
2878 if (button != MB_MENU_INITIALIZE)
2879 FadeCrossSaveBackbuffer();
2886 int sound = list->music;
2888 if (sound_info[sound].loop)
2889 PlaySoundLoop(sound);
2893 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2897 PlayMusic(list->music);
2899 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2902 if (!strEqual(list->title, UNKNOWN_NAME))
2904 if (!strEqual(list->title_header, UNKNOWN_NAME))
2905 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2907 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2910 if (!strEqual(list->artist, UNKNOWN_NAME))
2912 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2913 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2915 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2917 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2920 if (!strEqual(list->album, UNKNOWN_NAME))
2922 if (!strEqual(list->album_header, UNKNOWN_NAME))
2923 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2925 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2927 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2930 if (!strEqual(list->year, UNKNOWN_NAME))
2932 if (!strEqual(list->year_header, UNKNOWN_NAME))
2933 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2935 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2937 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2940 DrawTextSCentered(ybottom, FONT_TEXT_4,
2941 "Press any key or button for next page");
2943 if (button != MB_MENU_INITIALIZE)
2944 FadeCross(REDRAW_FIELD);
2947 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2948 PlaySoundLoop(list->music);
2951 static boolean DrawInfoScreen_CreditsScreen(int screen_nr)
2953 int ystart1 = mSY - SY + 100;
2954 int ystart2 = mSY - SY + 150;
2955 int ybottom = mSY - SY + SYSIZE - 20;
2964 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2968 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2969 "Special thanks to");
2970 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2972 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2974 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2975 "\"Boulder Dash\"");
2976 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2978 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2980 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2982 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2983 "First Star Software");
2985 else if (screen_nr == 1)
2987 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2988 "Special thanks to");
2989 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2990 "Klaus Heinz & Volker Wertich");
2991 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2993 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2994 "\"Emerald Mine\"");
2995 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2997 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2999 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3001 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
3004 else if (screen_nr == 2)
3006 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3007 "Special thanks to");
3008 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3009 "Michael Stopp & Philip Jespersen");
3010 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3012 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3014 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3016 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3018 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3020 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
3021 "Digital Integration");
3023 else if (screen_nr == 3)
3025 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3026 "Special thanks to");
3027 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3028 "Hiroyuki Imabayashi");
3029 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3031 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3033 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3035 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3037 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3039 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
3042 else if (screen_nr == 4)
3044 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3045 "Special thanks to");
3046 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3048 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3050 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3051 "Jürgen Bonhagen");
3052 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3053 "for the continuous creation");
3054 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
3055 "of outstanding level sets");
3057 else if (screen_nr == 5)
3059 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3061 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3063 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3064 "for ideas and inspiration by");
3065 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3068 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
3070 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
3072 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3073 "for ideas and inspiration by");
3074 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3077 else if (screen_nr == 6)
3079 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3081 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3083 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3084 "for the new Emerald Mine engine");
3086 else if (screen_nr == 7)
3088 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3090 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3092 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3093 "for the initial DOS port");
3095 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3097 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3099 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3100 "for some additional toons");
3102 else if (screen_nr == 8)
3104 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3105 "And not to forget:");
3106 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3108 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3109 "All those who contributed");
3110 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3111 "levels to this game");
3112 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
3122 DrawTextSCentered(ybottom, FONT_TEXT_4,
3123 "Press any key or button for next page");
3128 void DrawInfoScreen_Credits()
3130 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
3132 FadeSoundsAndMusic();
3135 FadeOut(REDRAW_FIELD);
3138 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3141 FadeIn(REDRAW_FIELD);
3145 void HandleInfoScreen_Credits(int button)
3147 static int screen_nr = 0;
3149 if (button == MB_MENU_INITIALIZE)
3153 DrawInfoScreen_CreditsScreen(screen_nr);
3155 else if (button == MB_MENU_LEAVE)
3157 PlaySound(SND_MENU_ITEM_SELECTING);
3159 info_mode = INFO_MODE_MAIN;
3164 else if (button == MB_MENU_CHOICE)
3166 boolean show_screen;
3168 PlaySound(SND_MENU_ITEM_SELECTING);
3172 FadeCrossSaveBackbuffer();
3174 show_screen = DrawInfoScreen_CreditsScreen(screen_nr);
3178 FadeCross(REDRAW_FIELD);
3182 FadeSoundsAndMusic();
3185 FadeOut(REDRAW_FIELD);
3188 info_mode = INFO_MODE_MAIN;
3189 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3194 PlayMenuSoundIfLoop();
3198 void DrawInfoScreen_Program()
3200 int ystart1 = mSY - SY + 100;
3201 int ystart2 = mSY - SY + 150;
3202 int ybottom = mSY - SY + SYSIZE - 20;
3205 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3208 FadeOut(REDRAW_FIELD);
3214 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
3216 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3217 "This game is Freeware!");
3218 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3219 "If you like it, send e-mail to:");
3220 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3221 PROGRAM_EMAIL_STRING);
3222 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
3223 "or SnailMail to:");
3224 DrawTextSCentered(ystart2 + 4 * ystep + 0, FONT_TEXT_3,
3226 DrawTextSCentered(ystart2 + 4 * ystep + 20, FONT_TEXT_3,
3227 "Detmolder Strasse 189");
3228 DrawTextSCentered(ystart2 + 4 * ystep + 40, FONT_TEXT_3,
3230 DrawTextSCentered(ystart2 + 4 * ystep + 60, FONT_TEXT_3,
3232 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3233 "More information and levels:");
3234 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3235 PROGRAM_WEBSITE_STRING);
3236 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3237 "If you have created new levels,");
3238 DrawTextSCentered(ystart2 + 10 * ystep, FONT_TEXT_2,
3239 "send them to me to include them!");
3240 DrawTextSCentered(ystart2 + 11 * ystep, FONT_TEXT_2,
3243 DrawTextSCentered(ybottom, FONT_TEXT_4,
3244 "Press any key or button for info menu");
3247 FadeIn(REDRAW_FIELD);
3251 void HandleInfoScreen_Program(int button)
3253 if (button == MB_MENU_LEAVE)
3255 PlaySound(SND_MENU_ITEM_SELECTING);
3257 info_mode = INFO_MODE_MAIN;
3262 else if (button == MB_MENU_CHOICE)
3264 PlaySound(SND_MENU_ITEM_SELECTING);
3266 FadeSoundsAndMusic();
3269 FadeOut(REDRAW_FIELD);
3272 info_mode = INFO_MODE_MAIN;
3273 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3277 PlayMenuSoundIfLoop();
3281 void DrawInfoScreen_Version()
3283 int font_header = FONT_TEXT_3;
3284 int font_text = FONT_TEXT_2;
3285 int xstep = getFontWidth(font_text);
3286 int ystep = getFontHeight(font_text);
3287 int ystart1 = mSY - SY + 100;
3288 int ystart2 = mSY - SY + 150;
3289 int ybottom = mSY - SY + SYSIZE - 20;
3290 int xstart1 = mSX + 2 * xstep;
3291 int xstart2 = mSX + 19 * xstep;
3292 #if defined(TARGET_SDL)
3293 int xstart3 = mSX + 29 * xstep;
3294 SDL_version sdl_version_compiled;
3295 const SDL_version *sdl_version_linked;
3296 int driver_name_len = 8;
3297 char driver_name[driver_name_len];
3300 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3303 FadeOut(REDRAW_FIELD);
3309 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
3311 DrawTextF(xstart1, ystart2, font_header, "Name");
3312 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
3315 DrawTextF(xstart1, ystart2, font_header, "Version");
3316 DrawTextF(xstart2, ystart2, font_text, getProgramFullVersionString());
3319 DrawTextF(xstart1, ystart2, font_header, "Platform");
3320 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
3323 DrawTextF(xstart1, ystart2, font_header, "Target");
3324 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
3327 DrawTextF(xstart1, ystart2, font_header, "Compile time");
3328 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
3330 #if defined(TARGET_SDL)
3331 ystart2 += 3 * ystep;
3332 DrawTextF(xstart1, ystart2, font_header, "Library");
3333 DrawTextF(xstart2, ystart2, font_header, "compiled");
3334 DrawTextF(xstart3, ystart2, font_header, "linked");
3336 SDL_VERSION(&sdl_version_compiled);
3337 sdl_version_linked = SDL_Linked_Version();
3339 ystart2 += 2 * ystep;
3340 DrawTextF(xstart1, ystart2, font_text, "SDL");
3341 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3342 sdl_version_compiled.major,
3343 sdl_version_compiled.minor,
3344 sdl_version_compiled.patch);
3345 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3346 sdl_version_linked->major,
3347 sdl_version_linked->minor,
3348 sdl_version_linked->patch);
3350 SDL_IMAGE_VERSION(&sdl_version_compiled);
3351 sdl_version_linked = IMG_Linked_Version();
3354 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
3355 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3356 sdl_version_compiled.major,
3357 sdl_version_compiled.minor,
3358 sdl_version_compiled.patch);
3359 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3360 sdl_version_linked->major,
3361 sdl_version_linked->minor,
3362 sdl_version_linked->patch);
3364 SDL_MIXER_VERSION(&sdl_version_compiled);
3365 sdl_version_linked = Mix_Linked_Version();
3368 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
3369 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3370 sdl_version_compiled.major,
3371 sdl_version_compiled.minor,
3372 sdl_version_compiled.patch);
3373 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3374 sdl_version_linked->major,
3375 sdl_version_linked->minor,
3376 sdl_version_linked->patch);
3378 SDL_NET_VERSION(&sdl_version_compiled);
3379 sdl_version_linked = SDLNet_Linked_Version();
3382 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
3383 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3384 sdl_version_compiled.major,
3385 sdl_version_compiled.minor,
3386 sdl_version_compiled.patch);
3387 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3388 sdl_version_linked->major,
3389 sdl_version_linked->minor,
3390 sdl_version_linked->patch);
3392 ystart2 += 3 * ystep;
3393 DrawTextF(xstart1, ystart2, font_header, "Driver");
3394 DrawTextF(xstart2, ystart2, font_header, "Requested");
3395 DrawTextF(xstart3, ystart2, font_header, "Used");
3397 SDL_VideoDriverName(driver_name, driver_name_len);
3399 ystart2 += 2 * ystep;
3400 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
3401 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
3402 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3404 SDL_AudioDriverName(driver_name, driver_name_len);
3407 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
3408 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
3409 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3412 DrawTextSCentered(ybottom, FONT_TEXT_4,
3413 "Press any key or button for info menu");
3416 FadeIn(REDRAW_FIELD);
3420 void HandleInfoScreen_Version(int button)
3422 if (button == MB_MENU_LEAVE)
3424 PlaySound(SND_MENU_ITEM_SELECTING);
3426 info_mode = INFO_MODE_MAIN;
3431 else if (button == MB_MENU_CHOICE)
3433 PlaySound(SND_MENU_ITEM_SELECTING);
3435 FadeSoundsAndMusic();
3438 FadeOut(REDRAW_FIELD);
3441 info_mode = INFO_MODE_MAIN;
3442 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3446 PlayMenuSoundIfLoop();
3450 void DrawInfoScreen_LevelSet()
3452 struct TitleMessageInfo *tmi = &readme;
3453 char *filename = getLevelSetInfoFilename();
3455 /* if chars set to "-1", automatically determine by text and font width */
3456 if (tmi->chars == -1)
3457 tmi->chars = tmi->width / getFontWidth(tmi->font);
3459 tmi->width = tmi->chars * getFontWidth(tmi->font);
3461 /* if lines set to "-1", automatically determine by text and font height */
3462 if (tmi->lines == -1)
3463 tmi->lines = tmi->height / getFontHeight(tmi->font);
3465 tmi->height = tmi->lines * getFontHeight(tmi->font);
3467 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3470 FadeOut(REDRAW_FIELD);
3476 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3478 if (filename != NULL)
3479 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3480 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
3481 tmi->autowrap, tmi->centered, tmi->parse_comments);
3483 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3484 "No information for this level set.");
3486 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3487 "Press any key or button for info menu");
3490 FadeIn(REDRAW_FIELD);
3494 void HandleInfoScreen_LevelSet(int button)
3496 if (button == MB_MENU_LEAVE)
3498 PlaySound(SND_MENU_ITEM_SELECTING);
3500 info_mode = INFO_MODE_MAIN;
3505 else if (button == MB_MENU_CHOICE)
3507 PlaySound(SND_MENU_ITEM_SELECTING);
3509 FadeSoundsAndMusic();
3512 FadeOut(REDRAW_FIELD);
3515 info_mode = INFO_MODE_MAIN;
3516 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3520 PlayMenuSoundIfLoop();
3524 static void DrawInfoScreenExt(int redraw_mask, boolean do_fading)
3526 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3528 if (info_mode == INFO_MODE_TITLE)
3529 DrawInfoScreen_TitleScreen();
3530 else if (info_mode == INFO_MODE_ELEMENTS)
3531 DrawInfoScreen_Elements();
3532 else if (info_mode == INFO_MODE_MUSIC)
3533 DrawInfoScreen_Music();
3534 else if (info_mode == INFO_MODE_CREDITS)
3535 DrawInfoScreen_Credits();
3536 else if (info_mode == INFO_MODE_PROGRAM)
3537 DrawInfoScreen_Program();
3538 else if (info_mode == INFO_MODE_VERSION)
3539 DrawInfoScreen_Version();
3540 else if (info_mode == INFO_MODE_LEVELSET)
3541 DrawInfoScreen_LevelSet();
3543 DrawInfoScreen_Main(redraw_mask, do_fading);
3545 if (info_mode != INFO_MODE_MAIN &&
3546 info_mode != INFO_MODE_TITLE &&
3547 info_mode != INFO_MODE_MUSIC)
3554 void DrawAndFadeInInfoScreen(int redraw_mask)
3556 DrawInfoScreenExt(redraw_mask, TRUE);
3559 void DrawInfoScreen()
3561 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3564 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3566 if (info_mode == INFO_MODE_TITLE)
3567 HandleInfoScreen_TitleScreen(button);
3568 else if (info_mode == INFO_MODE_ELEMENTS)
3569 HandleInfoScreen_Elements(button);
3570 else if (info_mode == INFO_MODE_MUSIC)
3571 HandleInfoScreen_Music(button);
3572 else if (info_mode == INFO_MODE_CREDITS)
3573 HandleInfoScreen_Credits(button);
3574 else if (info_mode == INFO_MODE_PROGRAM)
3575 HandleInfoScreen_Program(button);
3576 else if (info_mode == INFO_MODE_VERSION)
3577 HandleInfoScreen_Version(button);
3578 else if (info_mode == INFO_MODE_LEVELSET)
3579 HandleInfoScreen_LevelSet(button);
3581 HandleInfoScreen_Main(mx, my, dx, dy, button);
3587 /* ========================================================================= */
3588 /* type name functions */
3589 /* ========================================================================= */
3591 void HandleTypeName(int newxpos, Key key)
3593 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3594 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3596 struct TextPosInfo *pos = mci->pos_input;
3597 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3598 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3601 static int xpos = 0;
3603 static int xpos = 0, ypos = 2;
3605 int font_nr = pos->font;
3606 int font_active_nr = FONT_ACTIVE(font_nr);
3607 int font_width = getFontWidth(font_active_nr);
3610 int startx = mSX + mci->pos_input->x;
3611 int starty = mSY + mci->pos_input->y;
3614 int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
3615 int startx = mSX + 32 + name_width;
3616 int starty = mSY + ypos * 32;
3618 char key_char = getValidConfigValueChar(getCharFromKey(key));
3619 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3620 boolean is_active = TRUE;
3622 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3626 strcpy(last_player_name, setup.player_name);
3631 /* add one character width for added cursor character */
3632 pos->width += font_width;
3633 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3635 DrawText(startx, starty, setup.player_name, font_active_nr);
3636 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3639 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3641 setup.player_name[xpos] = key_char;
3642 setup.player_name[xpos + 1] = 0;
3647 /* add one character width for added name text character */
3648 pos->width += font_width;
3649 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3651 DrawText(startx, starty, setup.player_name, font_active_nr);
3652 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3655 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3659 setup.player_name[xpos] = 0;
3662 /* remove one character width for removed name text character */
3663 pos->width -= font_width;
3664 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3666 DrawText(startx, starty, setup.player_name, font_active_nr);
3667 DrawText(startx + xpos * font_width, starty, "_ ", font_active_nr);
3670 else if (key == KSYM_Return && xpos > 0)
3673 /* remove one character width for removed cursor text character */
3674 pos->width -= font_width;
3675 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3677 DrawText(startx, starty, setup.player_name, font_nr);
3678 DrawText(startx + xpos * font_width, starty, " ", font_active_nr);
3685 game_status = GAME_MODE_MAIN;
3687 else if (key == KSYM_Escape)
3689 strcpy(setup.player_name, last_player_name);
3693 game_status = GAME_MODE_MAIN;
3698 pos->width = (strlen(setup.player_name) + 1) * font_width;
3699 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3701 DrawText(startx, starty, setup.player_name, font_active_nr);
3702 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3706 pos->width = strlen(setup.player_name) * font_width;
3707 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3709 DrawText(startx, starty, setup.player_name, font_nr);
3714 /* ========================================================================= */
3715 /* tree menu functions */
3716 /* ========================================================================= */
3718 static void DrawChooseTree(TreeInfo **ti_ptr)
3722 FreeScreenGadgets();
3723 CreateScreenGadgets();
3725 CloseDoor(DOOR_CLOSE_2);
3728 FadeOut(REDRAW_FIELD);
3733 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3734 MapScreenTreeGadgets(*ti_ptr);
3737 FadeIn(REDRAW_FIELD);
3743 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3745 struct GadgetInfo *gi = screen_gadget[id];
3746 int items_max, items_visible, item_position;
3748 items_max = numTreeInfoInGroup(ti);
3749 items_visible = NUM_MENU_ENTRIES_ON_SCREEN;
3750 item_position = first_entry;
3752 if (item_position > items_max - items_visible)
3753 item_position = items_max - items_visible;
3755 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3756 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3757 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3760 static void drawChooseTreeList(int first_entry, int num_page_entries,
3764 char *title_string = NULL;
3765 int yoffset_sets = MENU_TITLE1_YPOS;
3766 int yoffset_setup = 16;
3767 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? yoffset_sets :
3769 int last_game_status = game_status; /* save current game status */
3771 title_string = ti->infotext;
3773 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3775 /* force LEVELS font on artwork setup screen */
3776 game_status = GAME_MODE_LEVELS;
3779 /* clear tree list area, but not title or scrollbar */
3780 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3781 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3782 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3784 /* clear tree list area, but not title or scrollbar */
3785 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3786 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3787 MAX_MENU_ENTRIES_ON_SCREEN * 32);
3790 for (i = 0; i < num_page_entries; i++)
3792 TreeInfo *node, *node_first;
3793 int entry_pos = first_entry + i;
3794 int xpos = MENU_SCREEN_START_XPOS;
3795 int ypos = MENU_SCREEN_START_YPOS + i;
3796 int startx = mSX + xpos * 32;
3797 int starty = mSY + ypos * 32;
3798 int font_nr = FONT_TEXT_1;
3799 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3800 int startx_text = startx + font_xoffset;
3801 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3802 int text_size = startx_scrollbar - startx_text;
3803 int max_buffer_len = text_size / getFontWidth(font_nr);
3804 char buffer[max_buffer_len + 1];
3806 node_first = getTreeInfoFirstGroupEntry(ti);
3807 node = getTreeInfoFromPos(node_first, entry_pos);
3809 strncpy(buffer, node->name, max_buffer_len);
3810 buffer[max_buffer_len] = '\0';
3812 DrawText(startx, starty, buffer, font_nr + node->color);
3814 if (node->parent_link)
3815 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3816 else if (node->level_group)
3817 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3819 initCursor(i, IMG_MENU_BUTTON);
3822 game_status = last_game_status; /* restore current game status */
3824 redraw_mask |= REDRAW_FIELD;
3827 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3829 TreeInfo *node, *node_first;
3830 int x, last_redraw_mask = redraw_mask;
3831 int ypos = MENU_TITLE2_YPOS;
3832 int font_nr = FONT_TITLE_2;
3834 if (ti->type != TREE_TYPE_LEVEL_DIR)
3837 node_first = getTreeInfoFirstGroupEntry(ti);
3838 node = getTreeInfoFromPos(node_first, entry_pos);
3840 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3842 if (node->parent_link)
3843 DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
3845 else if (node->level_group)
3846 DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
3848 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3849 DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
3850 node->levels, node->class_desc);
3852 /* let BackToFront() redraw only what is needed */
3853 redraw_mask = last_redraw_mask | REDRAW_TILES;
3854 for (x = 0; x < SCR_FIELDX; x++)
3855 MarkTileDirty(x, 1);
3858 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3861 TreeInfo *ti = *ti_ptr;
3863 int y = ti->cl_cursor;
3864 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3865 int num_entries = numTreeInfoInGroup(ti);
3866 int num_page_entries;
3867 int last_game_status = game_status; /* save current game status */
3868 boolean position_set_by_scrollbar = (dx == 999);
3870 /* force LEVELS draw offset on choose level and artwork setup screen */
3871 game_status = GAME_MODE_LEVELS;
3873 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3874 num_page_entries = num_entries;
3876 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3878 game_status = last_game_status; /* restore current game status */
3880 if (button == MB_MENU_INITIALIZE)
3882 int num_entries = numTreeInfoInGroup(ti);
3883 int entry_pos = posTreeInfo(ti);
3885 if (ti->cl_first == -1)
3887 /* only on initialization */
3888 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3889 ti->cl_cursor = entry_pos - ti->cl_first;
3891 else if (ti->cl_cursor >= num_page_entries ||
3892 (num_entries > num_page_entries &&
3893 num_entries - ti->cl_first < num_page_entries))
3895 /* only after change of list size (by custom graphic configuration) */
3896 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3897 ti->cl_cursor = entry_pos - ti->cl_first;
3900 if (position_set_by_scrollbar)
3903 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3906 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3907 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3908 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3912 else if (button == MB_MENU_LEAVE)
3916 PlaySound(SND_MENU_ITEM_SELECTING);
3918 if (ti->node_parent)
3920 *ti_ptr = ti->node_parent;
3921 DrawChooseTree(ti_ptr);
3923 else if (game_status == GAME_MODE_SETUP)
3925 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
3927 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3928 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3929 execSetupGraphics();
3935 game_status = GAME_MODE_MAIN;
3937 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3946 if (mx || my) /* mouse input */
3948 int last_game_status = game_status; /* save current game status */
3950 /* force LEVELS draw offset on artwork setup screen */
3951 game_status = GAME_MODE_LEVELS;
3953 x = (mx - mSX) / 32;
3954 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3956 game_status = last_game_status; /* restore current game status */
3958 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3960 /* move cursor instead of scrolling when already at start/end of list */
3961 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3963 else if (dy == +1 * SCROLL_LINE &&
3964 ti->cl_first + num_page_entries == num_entries)
3967 /* handle scrolling screen one line or page */
3968 if (ti->cl_cursor + dy < 0 ||
3969 ti->cl_cursor + dy > num_page_entries - 1)
3971 if (ABS(dy) == SCROLL_PAGE)
3972 step = num_page_entries - 1;
3974 if (dy < 0 && ti->cl_first > 0)
3976 /* scroll page/line up */
3978 ti->cl_first -= step;
3979 if (ti->cl_first < 0)
3982 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3983 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3984 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3986 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3989 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3991 /* scroll page/line down */
3993 ti->cl_first += step;
3994 if (ti->cl_first + num_page_entries > num_entries)
3995 ti->cl_first = MAX(0, num_entries - num_page_entries);
3997 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3998 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3999 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4001 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
4008 /* handle moving cursor one line */
4009 y = ti->cl_cursor + dy;
4014 TreeInfo *node_first, *node_cursor;
4015 int entry_pos = ti->cl_first + y;
4017 node_first = getTreeInfoFirstGroupEntry(ti);
4018 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4020 if (node_cursor->node_group)
4024 PlaySound(SND_MENU_ITEM_SELECTING);
4026 node_cursor->cl_first = ti->cl_first;
4027 node_cursor->cl_cursor = ti->cl_cursor;
4028 *ti_ptr = node_cursor->node_group;
4029 DrawChooseTree(ti_ptr);
4034 else if (dx == -1 && ti->node_parent)
4038 PlaySound(SND_MENU_ITEM_SELECTING);
4040 *ti_ptr = ti->node_parent;
4041 DrawChooseTree(ti_ptr);
4046 if (!anyScrollbarGadgetActive() &&
4047 IN_VIS_FIELD(x, y) &&
4048 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
4049 y >= 0 && y < num_page_entries)
4053 if (y != ti->cl_cursor)
4055 PlaySound(SND_MENU_ITEM_ACTIVATING);
4057 drawChooseTreeCursor(ti->cl_cursor, FALSE);
4058 drawChooseTreeCursor(y, TRUE);
4059 drawChooseTreeInfo(ti->cl_first + y, ti);
4066 TreeInfo *node_first, *node_cursor;
4067 int entry_pos = ti->cl_first + y;
4069 PlaySound(SND_MENU_ITEM_SELECTING);
4071 node_first = getTreeInfoFirstGroupEntry(ti);
4072 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4074 if (node_cursor->node_group)
4078 node_cursor->cl_first = ti->cl_first;
4079 node_cursor->cl_cursor = ti->cl_cursor;
4080 *ti_ptr = node_cursor->node_group;
4081 DrawChooseTree(ti_ptr);
4083 else if (node_cursor->parent_link)
4087 *ti_ptr = node_cursor->node_parent;
4088 DrawChooseTree(ti_ptr);
4094 node_cursor->cl_first = ti->cl_first;
4095 node_cursor->cl_cursor = ti->cl_cursor;
4096 *ti_ptr = node_cursor;
4098 if (ti->type == TREE_TYPE_LEVEL_DIR)
4100 LoadLevelSetup_SeriesInfo();
4102 SaveLevelSetup_LastSeries();
4103 SaveLevelSetup_SeriesInfo();
4107 if (game_status == GAME_MODE_SETUP)
4109 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
4111 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
4112 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
4113 execSetupGraphics();
4119 game_status = GAME_MODE_MAIN;
4127 void DrawChooseLevel()
4129 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
4131 DrawChooseTree(&leveldir_current);
4137 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
4139 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4144 void DrawHallOfFame(int highlight_position)
4147 FadeSoundsAndMusic();
4149 /* (this is needed when called from GameEnd() after winning a game) */
4150 KeyboardAutoRepeatOn();
4153 /* (this is needed when called from GameEnd() after winning a game) */
4154 SetDrawDeactivationMask(REDRAW_NONE);
4155 SetDrawBackgroundMask(REDRAW_FIELD);
4157 CloseDoor(DOOR_CLOSE_2);
4159 if (highlight_position < 0)
4160 LoadScore(level_nr);
4165 FadeOut(REDRAW_FIELD);
4173 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4176 FadeIn(REDRAW_FIELD);
4180 static void drawHallOfFameList(int first_entry, int highlight_position)
4184 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4187 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4188 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4189 "HighScores of Level %d", level_nr);
4191 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4193 int entry = first_entry + i;
4194 boolean active = (entry == highlight_position);
4195 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4196 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4197 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4198 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4199 int dx1 = 3 * getFontWidth(font_nr1);
4200 int dx2 = dx1 + getFontWidth(font_nr1);
4201 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
4202 int sy = mSY + 64 + i * 32;
4204 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4205 DrawText(mSX + dx1, sy, ".", font_nr1);
4206 DrawText(mSX + dx2, sy, ".........................", font_nr3);
4208 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4209 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4211 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4214 redraw_mask |= REDRAW_FIELD;
4217 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4219 static int first_entry = 0;
4220 static int highlight_position = 0;
4221 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4223 if (button == MB_MENU_INITIALIZE)
4226 highlight_position = mx;
4227 drawHallOfFameList(first_entry, highlight_position);
4232 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4233 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4237 if (first_entry > 0)
4239 first_entry -= step;
4240 if (first_entry < 0)
4243 drawHallOfFameList(first_entry, highlight_position);
4248 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4250 first_entry += step;
4251 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4252 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4254 drawHallOfFameList(first_entry, highlight_position);
4257 else if (button == MB_MENU_LEAVE)
4259 PlaySound(SND_MENU_ITEM_SELECTING);
4261 FadeSound(SND_BACKGROUND_SCORES);
4263 game_status = GAME_MODE_MAIN;
4267 else if (button == MB_MENU_CHOICE)
4269 PlaySound(SND_MENU_ITEM_SELECTING);
4271 FadeSound(SND_BACKGROUND_SCORES);
4274 FadeOut(REDRAW_FIELD);
4277 game_status = GAME_MODE_MAIN;
4279 DrawAndFadeInMainMenu(REDRAW_FIELD);
4282 if (game_status == GAME_MODE_SCORES)
4283 PlayMenuSoundIfLoop();
4289 /* ========================================================================= */
4290 /* setup screen functions */
4291 /* ========================================================================= */
4293 static struct TokenInfo *setup_info;
4294 static int num_setup_info;
4296 static char *screen_mode_text;
4297 static char *scroll_delay_text;
4298 static char *game_speed_text;
4299 static char *graphics_set_name;
4300 static char *sounds_set_name;
4301 static char *music_set_name;
4303 static void execSetupMain()
4309 setup_mode = SETUP_MODE_MAIN;
4313 static void execSetupGame()
4319 if (game_speeds == NULL)
4323 for (i = 0; game_speeds_list[i].value != -1; i++)
4325 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4326 char identifier[32], name[32];
4327 int value = game_speeds_list[i].value;
4328 char *text = game_speeds_list[i].text;
4330 ti->node_top = &game_speeds;
4331 ti->sort_priority = 10000 - value;
4333 sprintf(identifier, "%d", value);
4334 sprintf(name, "%s", text);
4336 setString(&ti->identifier, identifier);
4337 setString(&ti->name, name);
4338 setString(&ti->name_sorting, name);
4339 setString(&ti->infotext, "Game Speed");
4341 pushTreeInfo(&game_speeds, ti);
4344 /* sort game speed values to start with slowest game speed */
4345 sortTreeInfo(&game_speeds);
4347 /* set current game speed to configured game speed value */
4348 game_speed_current =
4349 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4351 /* if that fails, set current game speed to reliable default value */
4352 if (game_speed_current == NULL)
4353 game_speed_current =
4354 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4356 /* if that also fails, set current game speed to first available speed */
4357 if (game_speed_current == NULL)
4358 game_speed_current = game_speeds;
4361 setup.game_frame_delay = atoi(game_speed_current->identifier);
4363 /* needed for displaying game speed text instead of identifier */
4364 game_speed_text = game_speed_current->name;
4366 setup_mode = SETUP_MODE_GAME;
4370 static void execSetupChooseGameSpeed()
4376 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4380 static void execSetupEditor()
4386 setup_mode = SETUP_MODE_EDITOR;
4390 static void execSetupGraphics()
4396 if (video.fullscreen_available && screen_modes == NULL)
4400 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4402 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4403 char identifier[32], name[32];
4404 int x = video.fullscreen_modes[i].width;
4405 int y = video.fullscreen_modes[i].height;
4408 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4410 ti->node_top = &screen_modes;
4411 ti->sort_priority = x * 10000 + y;
4413 sprintf(identifier, "%dx%d", x, y);
4414 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4416 setString(&ti->identifier, identifier);
4417 setString(&ti->name, name);
4418 setString(&ti->name_sorting, name);
4419 setString(&ti->infotext, "Fullscreen Mode");
4421 pushTreeInfo(&screen_modes, ti);
4424 /* sort fullscreen modes to start with lowest available screen resolution */
4425 sortTreeInfo(&screen_modes);
4427 /* set current screen mode for fullscreen mode to configured setup value */
4428 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4429 setup.fullscreen_mode);
4431 /* if that fails, set current screen mode to reliable default value */
4432 if (screen_mode_current == NULL)
4433 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4434 DEFAULT_FULLSCREEN_MODE);
4436 /* if that also fails, set current screen mode to first available mode */
4437 if (screen_mode_current == NULL)
4438 screen_mode_current = screen_modes;
4440 if (screen_mode_current == NULL)
4441 video.fullscreen_available = FALSE;
4444 if (video.fullscreen_available)
4446 setup.fullscreen_mode = screen_mode_current->identifier;
4448 /* needed for displaying screen mode name instead of identifier */
4449 screen_mode_text = screen_mode_current->name;
4453 if (scroll_delays == NULL)
4457 for (i = 0; scroll_delays_list[i].value != -1; i++)
4459 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4460 char identifier[32], name[32];
4461 int value = scroll_delays_list[i].value;
4462 char *text = scroll_delays_list[i].text;
4464 ti->node_top = &scroll_delays;
4465 ti->sort_priority = value;
4467 sprintf(identifier, "%d", value);
4468 sprintf(name, "%s", text);
4470 setString(&ti->identifier, identifier);
4471 setString(&ti->name, name);
4472 setString(&ti->name_sorting, name);
4473 setString(&ti->infotext, "Scroll Delay");
4475 pushTreeInfo(&scroll_delays, ti);
4478 /* sort scroll delay values to start with lowest scroll delay value */
4479 sortTreeInfo(&scroll_delays);
4481 /* set current scroll delay value to configured scroll delay value */
4482 scroll_delay_current =
4483 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4485 /* if that fails, set current scroll delay to reliable default value */
4486 if (scroll_delay_current == NULL)
4487 scroll_delay_current =
4488 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4490 /* if that also fails, set current scroll delay to first available value */
4491 if (scroll_delay_current == NULL)
4492 scroll_delay_current = scroll_delays;
4495 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4497 /* needed for displaying scroll delay text instead of identifier */
4498 scroll_delay_text = scroll_delay_current->name;
4501 setup_mode = SETUP_MODE_GRAPHICS;
4505 static void execSetupChooseScreenMode()
4511 if (!video.fullscreen_available)
4514 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4518 static void execSetupChooseScrollDelay()
4524 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4528 static void execSetupSound()
4534 setup_mode = SETUP_MODE_SOUND;
4538 static void execSetupArtwork()
4544 setup.graphics_set = artwork.gfx_current->identifier;
4545 setup.sounds_set = artwork.snd_current->identifier;
4546 setup.music_set = artwork.mus_current->identifier;
4548 /* needed if last screen (setup choice) changed graphics, sounds or music */
4549 ReloadCustomArtwork(0);
4551 /* needed for displaying artwork name instead of artwork identifier */
4552 graphics_set_name = artwork.gfx_current->name;
4553 sounds_set_name = artwork.snd_current->name;
4554 music_set_name = artwork.mus_current->name;
4556 setup_mode = SETUP_MODE_ARTWORK;
4560 static void execSetupChooseGraphics()
4566 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4570 static void execSetupChooseSounds()
4576 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4580 static void execSetupChooseMusic()
4586 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4590 static void execSetupInput()
4596 setup_mode = SETUP_MODE_INPUT;
4600 static void execSetupShortcut1()
4606 setup_mode = SETUP_MODE_SHORTCUT_1;
4610 static void execSetupShortcut2()
4616 setup_mode = SETUP_MODE_SHORTCUT_2;
4620 static void execExitSetup()
4626 game_status = GAME_MODE_MAIN;
4628 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4634 static void execSaveAndExitSetup()
4640 static struct TokenInfo setup_info_main[] =
4642 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4643 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4644 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4645 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4646 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4647 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4648 { TYPE_ENTER_MENU, execSetupShortcut1, "Key Shortcuts 1" },
4649 { TYPE_ENTER_MENU, execSetupShortcut2, "Key Shortcuts 2" },
4650 { TYPE_EMPTY, NULL, "" },
4651 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4652 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4657 static struct TokenInfo setup_info_game[] =
4659 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4660 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4661 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4662 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4663 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4664 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4665 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4666 { TYPE_STRING, &game_speed_text, "" },
4667 { TYPE_EMPTY, NULL, "" },
4668 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4673 static struct TokenInfo setup_info_editor[] =
4676 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4677 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4678 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4679 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4680 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4681 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4682 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4683 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4685 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4686 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4687 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4689 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4691 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4692 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4693 { TYPE_EMPTY, NULL, "" },
4695 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4696 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4697 { TYPE_EMPTY, NULL, "" },
4699 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4700 { TYPE_EMPTY, NULL, "" },
4701 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4706 static struct TokenInfo setup_info_graphics[] =
4708 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4709 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4710 { TYPE_STRING, &screen_mode_text, "" },
4712 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
4714 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay Value:" },
4715 { TYPE_STRING, &scroll_delay_text, "" },
4717 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" },
4718 { TYPE_SWITCH, &setup.double_buffering,"Double-Buffering:" },
4720 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4721 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4722 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4723 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4724 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4725 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4726 { TYPE_EMPTY, NULL, "" },
4727 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4732 static struct TokenInfo setup_info_sound[] =
4734 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4735 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4736 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4737 { TYPE_EMPTY, NULL, "" },
4738 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4743 static struct TokenInfo setup_info_artwork[] =
4745 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4746 { TYPE_STRING, &graphics_set_name, "" },
4747 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4748 { TYPE_STRING, &sounds_set_name, "" },
4749 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4750 { TYPE_STRING, &music_set_name, "" },
4751 { TYPE_EMPTY, NULL, "" },
4753 { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
4754 { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:" },
4755 { TYPE_YES_NO, &setup.override_level_music, "Override Level Music:" },
4757 { TYPE_STRING, NULL, "Override Level Artwork:"},
4758 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
4759 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
4760 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
4762 { TYPE_EMPTY, NULL, "" },
4763 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4768 static struct TokenInfo setup_info_input[] =
4770 { TYPE_SWITCH, NULL, "Player:" },
4771 { TYPE_SWITCH, NULL, "Device:" },
4772 { TYPE_ENTER_MENU, NULL, "" },
4773 { TYPE_EMPTY, NULL, "" },
4774 { TYPE_EMPTY, NULL, "" },
4775 { TYPE_EMPTY, NULL, "" },
4776 { TYPE_EMPTY, NULL, "" },
4777 { TYPE_EMPTY, NULL, "" },
4778 { TYPE_EMPTY, NULL, "" },
4779 { TYPE_EMPTY, NULL, "" },
4780 { TYPE_EMPTY, NULL, "" },
4781 { TYPE_EMPTY, NULL, "" },
4782 { TYPE_EMPTY, NULL, "" },
4783 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4788 static struct TokenInfo setup_info_shortcut_1[] =
4790 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4791 { TYPE_KEY, &setup.shortcut.save_game, "" },
4792 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4793 { TYPE_KEY, &setup.shortcut.load_game, "" },
4794 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4795 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4796 { TYPE_EMPTY, NULL, "" },
4797 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4798 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4799 { TYPE_EMPTY, NULL, "" },
4800 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4805 static struct TokenInfo setup_info_shortcut_2[] =
4807 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4808 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4809 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4810 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4811 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4812 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4813 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4814 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4815 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4816 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4817 { TYPE_EMPTY, NULL, "" },
4818 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4823 static Key getSetupKey()
4825 Key key = KSYM_UNDEFINED;
4826 boolean got_key_event = FALSE;
4828 while (!got_key_event)
4830 if (PendingEvent()) /* got event */
4838 case EVENT_KEYPRESS:
4840 key = GetEventKey((KeyEvent *)&event, TRUE);
4842 /* press 'Escape' or 'Enter' to keep the existing key binding */
4843 if (key == KSYM_Escape || key == KSYM_Return)
4844 key = KSYM_UNDEFINED; /* keep old value */
4846 got_key_event = TRUE;
4850 case EVENT_KEYRELEASE:
4851 key_joystick_mapping = 0;
4855 HandleOtherEvents(&event);
4863 /* don't eat all CPU time */
4870 static int getSetupTextFont(int type)
4872 if (type & (TYPE_SWITCH |
4883 static int getSetupValueFont(int type, void *value)
4885 if (type & TYPE_KEY)
4886 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
4887 else if (type & TYPE_STRING)
4888 return FONT_VALUE_2;
4889 else if (type & TYPE_ECS_AGA)
4890 return FONT_VALUE_1;
4891 else if (type & TYPE_BOOLEAN_STYLE)
4892 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
4894 return FONT_VALUE_1;
4897 static void drawSetupValue(int pos)
4899 boolean font_draw_xoffset_modified = FALSE;
4900 int font_draw_xoffset_old = -1;
4901 int xpos = MENU_SCREEN_VALUE_XPOS;
4902 int ypos = MENU_SCREEN_START_YPOS + pos;
4903 int startx = mSX + xpos * 32;
4904 int starty = mSY + ypos * 32;
4905 int font_nr, font_width;
4906 int type = setup_info[pos].type;
4907 void *value = setup_info[pos].value;
4908 char *value_string = getSetupValue(type, value);
4911 if (value_string == NULL)
4914 if (type & TYPE_KEY)
4916 xpos = MENU_SCREEN_START_XPOS;
4918 if (type & TYPE_QUERY)
4920 value_string = "<press key>";
4923 else if (type & TYPE_STRING)
4925 int max_value_len = (SCR_FIELDX - 2) * 2;
4927 xpos = MENU_SCREEN_START_XPOS;
4929 if (strlen(value_string) > max_value_len)
4930 value_string[max_value_len] = '\0';
4933 startx = mSX + xpos * 32;
4934 starty = mSY + ypos * 32;
4935 font_nr = getSetupValueFont(type, value);
4936 font_width = getFontWidth(font_nr);
4938 /* downward compatibility correction for Juergen Bonhagen's menu settings */
4939 if (setup_mode != SETUP_MODE_INPUT)
4941 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
4942 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
4943 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
4944 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
4945 int text_font_nr = getSetupTextFont(FONT_MENU_2);
4946 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
4947 int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr);
4948 boolean correct_font_draw_xoffset = FALSE;
4950 if (xpos == MENU_SCREEN_START_XPOS &&
4951 startx + font1_xoffset < text_startx + text_font_xoffset)
4952 correct_font_draw_xoffset = TRUE;
4954 if (xpos == MENU_SCREEN_VALUE_XPOS &&
4955 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
4956 correct_font_draw_xoffset = TRUE;
4958 /* check if setup value would overlap with setup text when printed */
4959 /* (this can happen for extreme/wrong values for font draw offset) */
4960 if (correct_font_draw_xoffset)
4962 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
4963 font_draw_xoffset_modified = TRUE;
4965 if (type & TYPE_KEY)
4966 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
4967 else if (!(type & TYPE_STRING))
4968 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
4969 MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
4973 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
4974 DrawText(startx + i * font_width, starty, " ", font_nr);
4976 DrawText(startx, starty, value_string, font_nr);
4978 if (font_draw_xoffset_modified)
4979 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
4982 static void changeSetupValue(int pos)
4984 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
4986 *(boolean *)setup_info[pos].value ^= TRUE;
4988 else if (setup_info[pos].type & TYPE_KEY)
4992 setup_info[pos].type |= TYPE_QUERY;
4993 drawSetupValue(pos);
4994 setup_info[pos].type &= ~TYPE_QUERY;
4996 key = getSetupKey();
4997 if (key != KSYM_UNDEFINED)
4998 *(Key *)setup_info[pos].value = key;
5001 drawSetupValue(pos);
5004 static void DrawCursorAndText_Setup(int pos, boolean active)
5006 int xpos = MENU_SCREEN_START_XPOS;
5007 int ypos = MENU_SCREEN_START_YPOS + pos;
5008 int font_nr = getSetupTextFont(setup_info[pos].type);
5010 if (setup_info == setup_info_input)
5011 font_nr = FONT_MENU_1;
5014 font_nr = FONT_ACTIVE(font_nr);
5016 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
5018 if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
5019 drawCursor(pos, active);
5022 static void DrawSetupScreen_Generic()
5024 char *title_string = NULL;
5028 CloseDoor(DOOR_CLOSE_2);
5031 FadeOut(REDRAW_FIELD);
5036 if (setup_mode == SETUP_MODE_MAIN)
5038 setup_info = setup_info_main;
5039 title_string = "Setup";
5041 else if (setup_mode == SETUP_MODE_GAME)
5043 setup_info = setup_info_game;
5044 title_string = "Setup Game";
5046 else if (setup_mode == SETUP_MODE_EDITOR)
5048 setup_info = setup_info_editor;
5049 title_string = "Setup Editor";
5051 else if (setup_mode == SETUP_MODE_GRAPHICS)
5053 setup_info = setup_info_graphics;
5054 title_string = "Setup Graphics";
5056 else if (setup_mode == SETUP_MODE_SOUND)
5058 setup_info = setup_info_sound;
5059 title_string = "Setup Sound";
5061 else if (setup_mode == SETUP_MODE_ARTWORK)
5063 setup_info = setup_info_artwork;
5064 title_string = "Custom Artwork";
5066 else if (setup_mode == SETUP_MODE_SHORTCUT_1)
5068 setup_info = setup_info_shortcut_1;
5069 title_string = "Setup Shortcuts";
5071 else if (setup_mode == SETUP_MODE_SHORTCUT_2)
5073 setup_info = setup_info_shortcut_2;
5074 title_string = "Setup Shortcuts";
5077 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5080 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5082 void *value_ptr = setup_info[i].value;
5085 int xpos = MENU_SCREEN_START_XPOS;
5086 int ypos = MENU_SCREEN_START_YPOS + i;
5090 /* set some entries to "unchangeable" according to other variables */
5091 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5092 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5093 (value_ptr == &setup.sound_music && !audio.music_available) ||
5094 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5095 (value_ptr == &screen_mode_text && !video.fullscreen_available))
5096 setup_info[i].type |= TYPE_GHOSTED;
5098 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5099 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5100 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5101 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5102 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5103 initCursor(i, IMG_MENU_BUTTON);
5106 DrawCursorAndText_Setup(i, FALSE);
5108 font_nr = getSetupTextFont(setup_info[i].type);
5110 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr);
5113 if (setup_info[i].type & TYPE_VALUE)
5120 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5121 "Joysticks deactivated in setup menu");
5125 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5129 FadeIn(REDRAW_FIELD);
5134 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5138 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5140 static int choice_store[MAX_SETUP_MODES];
5141 int choice = choice_store[setup_mode]; /* always starts with 0 */
5145 if (button == MB_MENU_INITIALIZE)
5147 /* advance to first valid menu entry */
5148 while (choice < num_setup_info &&
5149 setup_info[choice].type & TYPE_SKIP_ENTRY)
5151 choice_store[setup_mode] = choice;
5154 DrawCursorAndText_Setup(choice, TRUE);
5156 drawCursor(choice, TRUE);
5161 else if (button == MB_MENU_LEAVE)
5163 PlaySound(SND_MENU_ITEM_SELECTING);
5165 for (y = 0; y < num_setup_info; y++)
5167 if (setup_info[y].type & TYPE_LEAVE_MENU)
5169 void (*menu_callback_function)(void) = setup_info[y].value;
5173 menu_callback_function();
5175 break; /* absolutely needed because function changes 'setup_info'! */
5182 if (mx || my) /* mouse input */
5184 x = (mx - mSX) / 32;
5185 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5187 else if (dx || dy) /* keyboard input */
5191 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5193 if (setup_info[choice].type & menu_navigation_type ||
5194 setup_info[choice].type & TYPE_BOOLEAN_STYLE)
5195 button = MB_MENU_CHOICE;
5200 /* jump to next non-empty menu entry (up or down) */
5201 while (y > 0 && y < num_setup_info - 1 &&
5202 setup_info[y].type & TYPE_SKIP_ENTRY)
5206 if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
5210 if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
5212 PlaySound(SND_MENU_ITEM_ACTIVATING);
5215 DrawCursorAndText_Setup(choice, FALSE);
5216 DrawCursorAndText_Setup(y, TRUE);
5218 drawCursor(choice, FALSE);
5219 drawCursor(y, TRUE);
5222 choice = choice_store[setup_mode] = y;
5225 else if (!(setup_info[y].type & TYPE_GHOSTED))
5227 PlaySound(SND_MENU_ITEM_SELECTING);
5229 /* when selecting key headline, execute function for key value change */
5230 if (setup_info[y].type & TYPE_KEYTEXT &&
5231 setup_info[y + 1].type & TYPE_KEY)
5234 /* when selecting string value, execute function for list selection */
5235 if (setup_info[y].type & TYPE_STRING && y > 0 &&
5236 setup_info[y - 1].type & TYPE_ENTER_LIST)
5239 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
5241 void (*menu_callback_function)(void) = setup_info[y].value;
5243 FadeSetFromType(setup_info[y].type);
5245 menu_callback_function();
5249 if (setup_info[y].type & TYPE_VALUE)
5250 changeSetupValue(y);
5256 void DrawSetupScreen_Input()
5263 FadeOut(REDRAW_FIELD);
5269 setup_info = setup_info_input;
5272 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5275 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5277 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5278 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5279 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5280 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5281 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5282 initCursor(i, IMG_MENU_BUTTON);
5284 DrawCursorAndText_Setup(i, FALSE);
5287 initCursor(0, IMG_MENU_BUTTON);
5288 initCursor(1, IMG_MENU_BUTTON);
5289 initCursor(2, IMG_MENU_BUTTON_ENTER_MENU);
5290 initCursor(13, IMG_MENU_BUTTON_LEAVE_MENU);
5292 DrawText(mSX + 32, mSY + 2 * 32, "Player:", FONT_MENU_1);
5293 DrawText(mSX + 32, mSY + 3 * 32, "Device:", FONT_MENU_1);
5294 DrawText(mSX + 32, mSY + 15 * 32, "Back", FONT_MENU_1);
5298 DeactivateJoystickForCalibration();
5301 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5302 "Joysticks deactivated on this screen");
5305 /* create gadgets for setup input menu screen */
5306 FreeScreenGadgets();
5307 CreateScreenGadgets();
5309 /* map gadgets for setup input menu screen */
5310 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5312 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5315 FadeIn(REDRAW_FIELD);
5321 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5323 if (device_name == NULL)
5326 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5329 if (strlen(device_name) > 1)
5331 char c1 = device_name[strlen(device_name) - 1];
5332 char c2 = device_name[strlen(device_name) - 2];
5334 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5335 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5338 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5339 strlen(device_name));
5342 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5345 static struct SetupKeyboardInfo custom_key;
5352 { &custom_key.left, "Joystick Left" },
5353 { &custom_key.right, "Joystick Right" },
5354 { &custom_key.up, "Joystick Up" },
5355 { &custom_key.down, "Joystick Down" },
5356 { &custom_key.snap, "Button 1" },
5357 { &custom_key.drop, "Button 2" }
5359 static char *joystick_name[MAX_PLAYERS] =
5366 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5370 custom_key = setup.input[player_nr].key;
5372 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5373 FONT_INPUT_1_ACTIVE);
5375 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5377 DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5378 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5380 if (setup.input[player_nr].use_joystick)
5382 char *device_name = setup.input[player_nr].joy.device_name;
5383 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5384 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5386 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5387 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5391 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5392 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5395 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5397 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5398 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5399 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5400 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5402 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5403 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5404 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5405 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5406 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5407 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5409 for (i = 0; i < 6; i++)
5411 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5413 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5415 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5416 (setup.input[player_nr].use_joystick ?
5418 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5422 static int input_player_nr = 0;
5424 void HandleSetupScreen_Input_Player(int step, int direction)
5426 int old_player_nr = input_player_nr;
5429 new_player_nr = old_player_nr + step * direction;
5430 if (new_player_nr < 0)
5432 if (new_player_nr > MAX_PLAYERS - 1)
5433 new_player_nr = MAX_PLAYERS - 1;
5435 if (new_player_nr != old_player_nr)
5437 input_player_nr = new_player_nr;
5439 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5443 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5445 static int choice = 0;
5448 int pos_start = SETUPINPUT_SCREEN_POS_START;
5449 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5450 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5451 int pos_end = SETUPINPUT_SCREEN_POS_END;
5453 if (button == MB_MENU_INITIALIZE)
5455 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5458 DrawCursorAndText_Setup(choice, TRUE);
5460 drawCursor(choice, TRUE);
5465 else if (button == MB_MENU_LEAVE)
5467 setup_mode = SETUP_MODE_MAIN;
5474 if (mx || my) /* mouse input */
5476 x = (mx - mSX) / 32;
5477 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5479 else if (dx || dy) /* keyboard input */
5481 if (dx && choice == 0)
5482 x = (dx < 0 ? 10 : 12);
5483 else if ((dx && choice == 1) ||
5484 (dx == +1 && choice == 2) ||
5485 (dx == -1 && choice == pos_end))
5486 button = MB_MENU_CHOICE;
5490 if (y >= pos_empty1 && y <= pos_empty2)
5491 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5494 if (y == 0 && dx != 0 && button)
5496 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5498 else if (IN_VIS_FIELD(x, y) &&
5499 y >= pos_start && y <= pos_end &&
5500 !(y >= pos_empty1 && y <= pos_empty2))
5507 DrawCursorAndText_Setup(choice, FALSE);
5508 DrawCursorAndText_Setup(y, TRUE);
5510 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5512 drawCursor(choice, FALSE);
5513 drawCursor(y, TRUE);
5523 char *device_name = setup.input[input_player_nr].joy.device_name;
5525 if (!setup.input[input_player_nr].use_joystick)
5527 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5529 setJoystickDeviceToNr(device_name, new_device_nr);
5530 setup.input[input_player_nr].use_joystick = TRUE;
5534 int device_nr = getJoystickNrFromDeviceName(device_name);
5535 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5537 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5538 setup.input[input_player_nr].use_joystick = FALSE;
5540 setJoystickDeviceToNr(device_name, new_device_nr);
5543 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5547 if (setup.input[input_player_nr].use_joystick)
5550 CalibrateJoystick(input_player_nr);
5553 CustomizeKeyboard(input_player_nr);
5555 else if (y == pos_end)
5561 setup_mode = SETUP_MODE_MAIN;
5568 void CustomizeKeyboard(int player_nr)
5572 boolean finished = FALSE;
5573 static struct SetupKeyboardInfo custom_key;
5578 } customize_step[] =
5580 { &custom_key.left, "Move Left" },
5581 { &custom_key.right, "Move Right" },
5582 { &custom_key.up, "Move Up" },
5583 { &custom_key.down, "Move Down" },
5584 { &custom_key.snap, "Snap Field" },
5585 { &custom_key.drop, "Drop Element" }
5588 /* read existing key bindings from player setup */
5589 custom_key = setup.input[player_nr].key;
5592 FadeOut(REDRAW_FIELD);
5596 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5604 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5605 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5606 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5607 "Key:", FONT_INPUT_1_ACTIVE);
5608 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5609 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5612 FadeIn(REDRAW_FIELD);
5619 if (PendingEvent()) /* got event */
5627 case EVENT_KEYPRESS:
5629 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5631 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5633 if (key == KSYM_Escape)
5634 FadeSkipNextFadeIn();
5640 /* all keys configured -- wait for "Escape" or "Return" key */
5644 /* press 'Enter' to keep the existing key binding */
5645 if (key == KSYM_Return)
5646 key = *customize_step[step_nr].key;
5648 /* check if key already used */
5649 for (i = 0; i < step_nr; i++)
5650 if (*customize_step[i].key == key)
5655 /* got new key binding */
5656 *customize_step[step_nr].key = key;
5657 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5659 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5660 getKeyNameFromKey(key), FONT_VALUE_1);
5663 /* un-highlight last query */
5664 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
5665 customize_step[step_nr - 1].text, FONT_MENU_1);
5666 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
5667 "Key:", FONT_MENU_1);
5669 /* press 'Enter' to leave */
5672 DrawText(mSX + 16, mSY + 15 * 32 + 16,
5673 "Press Enter", FONT_TITLE_1);
5677 /* query next key binding */
5678 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5679 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5680 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5681 "Key:", FONT_INPUT_1_ACTIVE);
5682 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5683 getKeyNameFromKey(*customize_step[step_nr].key),
5688 case EVENT_KEYRELEASE:
5689 key_joystick_mapping = 0;
5693 HandleOtherEvents(&event);
5701 /* don't eat all CPU time */
5705 /* write new key bindings back to player setup */
5706 setup.input[player_nr].key = custom_key;
5709 DrawSetupScreen_Input();
5712 static boolean CalibrateJoystickMain(int player_nr)
5714 int new_joystick_xleft = JOYSTICK_XMIDDLE;
5715 int new_joystick_xright = JOYSTICK_XMIDDLE;
5716 int new_joystick_yupper = JOYSTICK_YMIDDLE;
5717 int new_joystick_ylower = JOYSTICK_YMIDDLE;
5718 int new_joystick_xmiddle, new_joystick_ymiddle;
5720 int joystick_fd = joystick.fd[player_nr];
5721 int x, y, last_x, last_y, xpos = 8, ypos = 3;
5722 boolean check[3][3];
5723 int check_remaining = 3 * 3;
5728 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
5731 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
5735 FadeOut(REDRAW_FIELD);
5739 for (y = 0; y < 3; y++)
5741 for (x = 0; x < 3; x++)
5743 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
5744 check[x][y] = FALSE;
5748 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
5749 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
5750 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
5751 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
5752 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
5753 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
5754 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
5756 joy_value = Joystick(player_nr);
5757 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5758 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5760 /* eventually uncalibrated center position (joystick could be uncentered) */
5761 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5764 new_joystick_xmiddle = joy_x;
5765 new_joystick_ymiddle = joy_y;
5767 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
5770 FadeIn(REDRAW_FIELD);
5775 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
5780 if (PendingEvent()) /* got event */
5788 case EVENT_KEYPRESS:
5789 switch (GetEventKey((KeyEvent *)&event, TRUE))
5792 if (check_remaining == 0)
5797 FadeSkipNextFadeIn();
5806 case EVENT_KEYRELEASE:
5807 key_joystick_mapping = 0;
5811 HandleOtherEvents(&event);
5816 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5819 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
5820 new_joystick_xright = MAX(new_joystick_xright, joy_x);
5821 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
5822 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
5824 setup.input[player_nr].joy.xleft = new_joystick_xleft;
5825 setup.input[player_nr].joy.yupper = new_joystick_yupper;
5826 setup.input[player_nr].joy.xright = new_joystick_xright;
5827 setup.input[player_nr].joy.ylower = new_joystick_ylower;
5828 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
5829 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
5831 CheckJoystickData();
5833 joy_value = Joystick(player_nr);
5835 if (joy_value & JOY_BUTTON && check_remaining == 0)
5838 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5839 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5841 if (x != last_x || y != last_y)
5843 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0);
5844 DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0);
5849 if (check_remaining > 0 && !check[x+1][y+1])
5851 check[x+1][y+1] = TRUE;
5857 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
5858 setup.input[player_nr].joy.xleft,
5859 setup.input[player_nr].joy.xmiddle,
5860 setup.input[player_nr].joy.xright);
5861 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
5862 setup.input[player_nr].joy.yupper,
5863 setup.input[player_nr].joy.ymiddle,
5864 setup.input[player_nr].joy.ylower);
5873 /* don't eat all CPU time */
5877 /* calibrated center position (joystick should now be centered) */
5878 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5881 new_joystick_xmiddle = joy_x;
5882 new_joystick_ymiddle = joy_y;
5887 DrawSetupScreen_Input();
5890 /* wait until the last pressed button was released */
5891 while (Joystick(player_nr) & JOY_BUTTON)
5893 if (PendingEvent()) /* got event */
5898 HandleOtherEvents(&event);
5907 void CalibrateJoystick(int player_nr)
5909 if (!CalibrateJoystickMain(player_nr))
5911 char *device_name = setup.input[player_nr].joy.device_name;
5912 int nr = getJoystickNrFromDeviceName(device_name) + 1;
5913 int xpos = mSX - SX;
5914 int ypos = mSY - SY;
5918 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
5919 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
5922 Delay(2000); /* show error message for a short time */
5928 DrawSetupScreen_Input();
5932 void DrawSetupScreen()
5934 DeactivateJoystick();
5936 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
5938 if (setup_mode == SETUP_MODE_INPUT)
5939 DrawSetupScreen_Input();
5940 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5941 DrawChooseTree(&game_speed_current);
5942 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5943 DrawChooseTree(&screen_mode_current);
5944 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5945 DrawChooseTree(&scroll_delay_current);
5946 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5947 DrawChooseTree(&artwork.gfx_current);
5948 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5949 DrawChooseTree(&artwork.snd_current);
5950 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5951 DrawChooseTree(&artwork.mus_current);
5953 DrawSetupScreen_Generic();
5959 void RedrawSetupScreenAfterFullscreenToggle()
5961 if (setup_mode == SETUP_MODE_GRAPHICS)
5965 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
5967 if (setup_mode == SETUP_MODE_INPUT)
5968 HandleSetupScreen_Input(mx, my, dx, dy, button);
5969 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5970 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
5971 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5972 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
5973 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
5974 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
5975 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5976 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
5977 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5978 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
5979 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5980 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
5982 HandleSetupScreen_Generic(mx, my, dx, dy, button);
5987 void HandleGameActions()
5989 if (game_status != GAME_MODE_PLAYING)
5992 GameActions(); /* main game loop */
5994 if (tape.auto_play && !tape.playing)
5995 AutoPlayTape(); /* continue automatically playing next tape */
5999 /* ---------- new screen button stuff -------------------------------------- */
6001 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6006 case SCREEN_CTRL_ID_PREV_LEVEL:
6007 *x = mSX + menu.main.button.prev_level.x;
6008 *y = mSY + menu.main.button.prev_level.y;
6011 case SCREEN_CTRL_ID_NEXT_LEVEL:
6012 *x = mSX + menu.main.button.next_level.x;
6013 *y = mSY + menu.main.button.next_level.y;
6016 case SCREEN_CTRL_ID_PREV_LEVEL:
6017 *x = mSX + TILEX * getPrevlevelButtonPos();
6018 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
6021 case SCREEN_CTRL_ID_NEXT_LEVEL:
6022 *x = mSX + TILEX * getNextLevelButtonPos();
6023 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
6027 case SCREEN_CTRL_ID_PREV_PLAYER:
6028 *x = mSX + TILEX * 10;
6029 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6032 case SCREEN_CTRL_ID_NEXT_PLAYER:
6033 *x = mSX + TILEX * 12;
6034 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6038 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6044 int gfx_unpressed, gfx_pressed;
6045 void (*get_gadget_position)(int *, int *, int);
6049 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6052 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6053 getScreenMenuButtonPos,
6054 SCREEN_CTRL_ID_PREV_LEVEL,
6059 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6060 getScreenMenuButtonPos,
6061 SCREEN_CTRL_ID_NEXT_LEVEL,
6066 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6067 getScreenMenuButtonPos,
6068 SCREEN_CTRL_ID_PREV_PLAYER,
6073 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6074 getScreenMenuButtonPos,
6075 SCREEN_CTRL_ID_NEXT_PLAYER,
6083 int gfx_unpressed, gfx_pressed;
6087 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6090 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6091 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
6092 SCREEN_CTRL_ID_SCROLL_UP,
6096 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6097 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
6098 SCREEN_CTRL_ID_SCROLL_DOWN,
6105 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6106 Bitmap **gfx_unpressed, **gfx_pressed;
6108 int gfx_unpressed, gfx_pressed;
6115 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6118 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6119 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
6121 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6123 SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
6124 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
6125 GD_TYPE_SCROLLBAR_VERTICAL,
6126 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6127 "scroll level series vertically"
6131 static void CreateScreenMenubuttons()
6133 struct GadgetInfo *gi;
6134 unsigned long event_mask;
6137 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6139 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6140 int gfx_unpressed, gfx_pressed;
6141 int x, y, width, height;
6142 int gd_x1, gd_x2, gd_y1, gd_y2;
6143 int id = menubutton_info[i].gadget_id;
6145 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6147 menubutton_info[i].get_gadget_position(&x, &y, id);
6149 width = SC_MENUBUTTON_XSIZE;
6150 height = SC_MENUBUTTON_YSIZE;
6152 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6153 gfx_pressed = menubutton_info[i].gfx_pressed;
6154 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6155 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6156 gd_x1 = graphic_info[gfx_unpressed].src_x;
6157 gd_y1 = graphic_info[gfx_unpressed].src_y;
6158 gd_x2 = graphic_info[gfx_pressed].src_x;
6159 gd_y2 = graphic_info[gfx_pressed].src_y;
6161 gi = CreateGadget(GDI_CUSTOM_ID, id,
6162 GDI_CUSTOM_TYPE_ID, i,
6163 GDI_INFO_TEXT, menubutton_info[i].infotext,
6168 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6169 GDI_STATE, GD_BUTTON_UNPRESSED,
6170 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6171 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6172 GDI_DIRECT_DRAW, FALSE,
6173 GDI_EVENT_MASK, event_mask,
6174 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6178 Error(ERR_EXIT, "cannot create gadget");
6180 screen_gadget[id] = gi;
6184 static void CreateScreenScrollbuttons()
6186 struct GadgetInfo *gi;
6187 unsigned long event_mask;
6190 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6192 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6193 int gfx_unpressed, gfx_pressed;
6194 int x, y, width, height;
6195 int gd_x1, gd_x2, gd_y1, gd_y2;
6196 int id = scrollbutton_info[i].gadget_id;
6198 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6200 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6201 y = mSY + scrollbutton_info[i].y;
6202 width = SC_SCROLLBUTTON_XSIZE;
6203 height = SC_SCROLLBUTTON_YSIZE;
6205 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6206 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6207 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6209 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6210 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6211 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6212 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6213 gd_x1 = graphic_info[gfx_unpressed].src_x;
6214 gd_y1 = graphic_info[gfx_unpressed].src_y;
6215 gd_x2 = graphic_info[gfx_pressed].src_x;
6216 gd_y2 = graphic_info[gfx_pressed].src_y;
6218 gi = CreateGadget(GDI_CUSTOM_ID, id,
6219 GDI_CUSTOM_TYPE_ID, i,
6220 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6225 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6226 GDI_STATE, GD_BUTTON_UNPRESSED,
6227 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6228 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6229 GDI_DIRECT_DRAW, FALSE,
6230 GDI_EVENT_MASK, event_mask,
6231 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6235 Error(ERR_EXIT, "cannot create gadget");
6237 screen_gadget[id] = gi;
6241 static void CreateScreenScrollbars()
6245 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6247 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6248 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6249 int gfx_unpressed, gfx_pressed;
6251 int x, y, width, height;
6252 int gd_x1, gd_x2, gd_y1, gd_y2;
6253 struct GadgetInfo *gi;
6254 int items_max, items_visible, item_position;
6255 unsigned long event_mask;
6256 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6257 int id = scrollbar_info[i].gadget_id;
6259 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6261 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6262 y = mSY + scrollbar_info[i].y;
6263 width = scrollbar_info[i].width;
6264 height = scrollbar_info[i].height;
6266 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6267 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6269 items_max = num_page_entries;
6270 items_visible = num_page_entries;
6273 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6274 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
6275 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
6281 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6282 gfx_pressed = scrollbar_info[i].gfx_pressed;
6283 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6284 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6285 gd_x1 = graphic_info[gfx_unpressed].src_x;
6286 gd_y1 = graphic_info[gfx_unpressed].src_y;
6287 gd_x2 = graphic_info[gfx_pressed].src_x;
6288 gd_y2 = graphic_info[gfx_pressed].src_y;
6291 gi = CreateGadget(GDI_CUSTOM_ID, id,
6292 GDI_CUSTOM_TYPE_ID, i,
6293 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6298 GDI_TYPE, scrollbar_info[i].type,
6299 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6300 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6301 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6303 GDI_WHEEL_AREA_X, SX,
6304 GDI_WHEEL_AREA_Y, SY,
6305 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6306 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6308 GDI_WHEEL_AREA_X, 0,
6309 GDI_WHEEL_AREA_Y, 0,
6310 GDI_WHEEL_AREA_WIDTH, WIN_XSIZE,
6311 GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE,
6313 GDI_STATE, GD_BUTTON_UNPRESSED,
6314 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6315 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6316 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6317 GDI_DIRECT_DRAW, FALSE,
6318 GDI_EVENT_MASK, event_mask,
6319 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6323 Error(ERR_EXIT, "cannot create gadget");
6325 screen_gadget[id] = gi;
6329 void CreateScreenGadgets()
6331 int last_game_status = game_status; /* save current game status */
6333 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6336 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6338 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
6340 /* copy pointers to clip mask and GC */
6341 scrollbar_bitmap[i]->clip_mask =
6342 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
6343 scrollbar_bitmap[i]->stored_clip_gc =
6344 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
6346 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
6347 scrollbar_bitmap[i],
6348 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
6349 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
6350 TILEX, TILEY, 0, 0);
6354 CreateScreenMenubuttons();
6356 /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */
6357 game_status = GAME_MODE_LEVELS;
6359 CreateScreenScrollbuttons();
6360 CreateScreenScrollbars();
6362 game_status = last_game_status; /* restore current game status */
6365 void FreeScreenGadgets()
6369 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6370 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6372 /* prevent freeing clip mask and GC twice */
6373 scrollbar_bitmap[i]->clip_mask = None;
6374 scrollbar_bitmap[i]->stored_clip_gc = None;
6376 FreeBitmap(scrollbar_bitmap[i]);
6380 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6381 FreeGadget(screen_gadget[i]);
6384 void MapScreenMenuGadgets(int screen_mask)
6388 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6389 if (screen_mask & menubutton_info[i].screen_mask)
6390 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6393 void MapScreenTreeGadgets(TreeInfo *ti)
6395 int num_entries = numTreeInfoInGroup(ti);
6398 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6401 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6402 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6404 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6405 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6408 static void HandleScreenGadgets(struct GadgetInfo *gi)
6410 int id = gi->custom_id;
6411 int button = gi->event.button;
6412 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6416 case SCREEN_CTRL_ID_PREV_LEVEL:
6417 HandleMainMenu_SelectLevel(step, -1);
6420 case SCREEN_CTRL_ID_NEXT_LEVEL:
6421 HandleMainMenu_SelectLevel(step, +1);
6424 case SCREEN_CTRL_ID_PREV_PLAYER:
6425 HandleSetupScreen_Input_Player(step, -1);
6428 case SCREEN_CTRL_ID_NEXT_PLAYER:
6429 HandleSetupScreen_Input_Player(step, +1);
6432 case SCREEN_CTRL_ID_SCROLL_UP:
6433 if (game_status == GAME_MODE_LEVELS)
6434 HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6435 else if (game_status == GAME_MODE_SETUP)
6436 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6439 case SCREEN_CTRL_ID_SCROLL_DOWN:
6440 if (game_status == GAME_MODE_LEVELS)
6441 HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6442 else if (game_status == GAME_MODE_SETUP)
6443 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6446 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6447 if (game_status == GAME_MODE_LEVELS)
6448 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
6449 else if (game_status == GAME_MODE_SETUP)
6450 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);