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_SOUND 9
39 #define SETUP_MODE_ARTWORK 10
40 #define SETUP_MODE_CHOOSE_GRAPHICS 11
41 #define SETUP_MODE_CHOOSE_SOUNDS 12
42 #define SETUP_MODE_CHOOSE_MUSIC 13
44 #define MAX_SETUP_MODES 14
46 /* for input setup functions */
47 #define SETUPINPUT_SCREEN_POS_START 0
48 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
49 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
50 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
52 /* screens on the info screen */
53 #define INFO_MODE_MAIN 0
54 #define INFO_MODE_TITLE 1
55 #define INFO_MODE_ELEMENTS 2
56 #define INFO_MODE_MUSIC 3
57 #define INFO_MODE_CREDITS 4
58 #define INFO_MODE_PROGRAM 5
59 #define INFO_MODE_VERSION 6
60 #define INFO_MODE_LEVELSET 7
62 #define MAX_INFO_MODES 8
64 /* for various menu stuff */
65 #define MENU_SCREEN_START_XPOS 1
66 #define MENU_SCREEN_START_YPOS 2
67 #define MENU_SCREEN_VALUE_XPOS 14
68 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
69 #define MENU_TITLE1_YPOS 8
70 #define MENU_TITLE2_YPOS 46
71 #define MAX_INFO_ELEMENTS_ON_SCREEN 10
72 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
73 #define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \
74 MENU_SCREEN_START_XPOS)
75 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
77 /* buttons and scrollbars identifiers */
78 #define SCREEN_CTRL_ID_PREV_LEVEL 0
79 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
80 #define SCREEN_CTRL_ID_PREV_PLAYER 2
81 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
82 #define SCREEN_CTRL_ID_SCROLL_UP 4
83 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
84 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
86 #define NUM_SCREEN_GADGETS 7
88 #define NUM_SCREEN_MENUBUTTONS 4
89 #define NUM_SCREEN_SCROLLBUTTONS 2
90 #define NUM_SCREEN_SCROLLBARS 1
92 #define SCREEN_MASK_MAIN (1 << 0)
93 #define SCREEN_MASK_INPUT (1 << 1)
95 /* graphic position and size values for buttons and scrollbars */
96 #define SC_MENUBUTTON_XSIZE TILEX
97 #define SC_MENUBUTTON_YSIZE TILEY
99 #define SC_SCROLLBUTTON_XSIZE TILEX
100 #define SC_SCROLLBUTTON_YSIZE TILEY
102 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
104 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
105 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
106 SC_SCROLLBUTTON_YSIZE)
108 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
109 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
111 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
112 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
113 SC_SCROLLBUTTON_YSIZE)
115 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
116 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
117 SC_SCROLL_VERTICAL_YSIZE)
119 #define SC_BORDER_SIZE 14
121 /* other useful macro definitions */
122 #define BUTTON_GRAPHIC_ACTIVE(g) \
123 (g == IMG_MENU_BUTTON_LEFT ? IMG_MENU_BUTTON_LEFT_ACTIVE : \
124 g == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE : \
125 g == IMG_MENU_BUTTON_UP ? IMG_MENU_BUTTON_UP_ACTIVE : \
126 g == IMG_MENU_BUTTON_DOWN ? IMG_MENU_BUTTON_DOWN_ACTIVE : \
127 g == IMG_MENU_BUTTON_LEAVE_MENU ? IMG_MENU_BUTTON_LEAVE_MENU_ACTIVE : \
128 g == IMG_MENU_BUTTON_ENTER_MENU ? IMG_MENU_BUTTON_ENTER_MENU_ACTIVE : \
129 g == IMG_MENU_BUTTON_PREV_LEVEL ? IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE : \
130 g == IMG_MENU_BUTTON_NEXT_LEVEL ? IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE : \
131 IMG_MENU_BUTTON_ACTIVE)
134 /* forward declarations of internal functions */
135 static void HandleScreenGadgets(struct GadgetInfo *);
136 static void HandleSetupScreen_Generic(int, int, int, int, int);
137 static void HandleSetupScreen_Input(int, int, int, int, int);
138 static void CustomizeKeyboard(int);
139 static void CalibrateJoystick(int);
140 static void execSetupGame(void);
141 static void execSetupGraphics(void);
142 static void execSetupArtwork(void);
143 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
145 static void DrawChooseLevel(void);
146 static void DrawInfoScreen(void);
147 static void DrawAndFadeInInfoScreen(int);
148 static void DrawSetupScreen(void);
150 static void DrawInfoScreenExt(int, int);
151 static void DrawInfoScreen_NotAvailable(char *, char *);
152 static void DrawInfoScreen_HelpAnim(int, int, boolean);
153 static void DrawInfoScreen_HelpText(int, int, int, int);
154 static void HandleInfoScreen_Main(int, int, int, int, int);
155 static void HandleInfoScreen_TitleScreen(int);
156 static void HandleInfoScreen_Elements(int);
157 static void HandleInfoScreen_Music(int);
158 static void HandleInfoScreen_Credits(int);
159 static void HandleInfoScreen_Program(int);
160 static void HandleInfoScreen_Version(int);
162 static void MapScreenMenuGadgets(int);
163 static void MapScreenTreeGadgets(TreeInfo *);
165 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
167 static int setup_mode = SETUP_MODE_MAIN;
168 static int info_mode = INFO_MODE_MAIN;
170 static TreeInfo *screen_modes = NULL;
171 static TreeInfo *screen_mode_current = NULL;
173 static TreeInfo *game_speeds = NULL;
174 static TreeInfo *game_speed_current = NULL;
180 } game_speeds_list[] =
189 { 1000, "1/1s (Extremely Slow)" },
194 { 29, "1/35s (Original Supaplex)" },
196 { 20, "1/50s (Normal Speed)" },
197 { 14, "1/70s (Maximum Supaplex)" },
201 { 1, "1/1000s (Extremely Fast)" },
209 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
210 (s) <= GAME_MODE_SETUP ? (s) : \
211 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
212 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
214 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
215 (i) <= INFO_MODE_LEVELSET ? (i) : \
218 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
219 menu.draw_xoffset[GAME_MODE_INFO] : \
220 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
221 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
222 menu.draw_yoffset[GAME_MODE_INFO] : \
223 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
225 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
226 DRAW_XOFFSET_INFO(info_mode) : \
227 menu.draw_xoffset[DRAW_MODE(s)])
228 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
229 DRAW_YOFFSET_INFO(info_mode) : \
230 menu.draw_yoffset[DRAW_MODE(s)])
232 #define mSX (SX + DRAW_XOFFSET(game_status))
233 #define mSY (SY + DRAW_YOFFSET(game_status))
235 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
236 menu.list_size[game_status] : \
237 MAX_MENU_ENTRIES_ON_SCREEN)
239 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
240 #define NUM_SCROLLBAR_BITMAPS 2
241 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS];
245 /* title display and control definitions */
247 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
248 2 * MAX_NUM_TITLE_MESSAGES)
250 static int num_title_screens = 0;
252 struct TitleControlInfo
260 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
262 /* main menu display and control definitions */
264 #define MAIN_CONTROL_NAME 0
265 #define MAIN_CONTROL_LEVELS 1
266 #define MAIN_CONTROL_SCORES 2
267 #define MAIN_CONTROL_EDITOR 3
268 #define MAIN_CONTROL_INFO 4
269 #define MAIN_CONTROL_GAME 5
270 #define MAIN_CONTROL_SETUP 6
271 #define MAIN_CONTROL_QUIT 7
272 #define MAIN_CONTROL_PREV_LEVEL 8
273 #define MAIN_CONTROL_NEXT_LEVEL 9
274 #define MAIN_CONTROL_FIRST_LEVEL 10
275 #define MAIN_CONTROL_LAST_LEVEL 11
276 #define MAIN_CONTROL_LEVEL_NUMBER 12
277 #define MAIN_CONTROL_LEVEL_INFO_1 13
278 #define MAIN_CONTROL_LEVEL_INFO_2 14
279 #define MAIN_CONTROL_LEVEL_NAME 15
280 #define MAIN_CONTROL_LEVEL_AUTHOR 16
281 #define MAIN_CONTROL_LEVEL_YEAR 17
282 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
283 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
284 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
285 #define MAIN_CONTROL_TITLE_1 21
286 #define MAIN_CONTROL_TITLE_2 22
287 #define MAIN_CONTROL_TITLE_3 23
289 static char str_main_text_name[10];
290 static char str_main_text_first_level[10];
291 static char str_main_text_last_level[10];
292 static char str_main_text_level_number[10];
294 static char *main_text_name = str_main_text_name;
295 static char *main_text_first_level = str_main_text_first_level;
296 static char *main_text_last_level = str_main_text_last_level;
297 static char *main_text_level_number = str_main_text_level_number;
298 static char *main_text_levels = "Levelset";
299 static char *main_text_scores = "Hall Of Fame";
300 static char *main_text_editor = "Level Creator";
301 static char *main_text_info = "Info Screen";
302 static char *main_text_game = "Start Game";
303 static char *main_text_setup = "Setup";
304 static char *main_text_quit = "Quit";
305 static char *main_text_level_name = level.name;
306 static char *main_text_level_author = level.author;
307 static char *main_text_level_year = NULL;
308 static char *main_text_level_imported_from = NULL;
309 static char *main_text_level_imported_by = NULL;
310 static char *main_text_level_tested_by = NULL;
311 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
312 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
313 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
315 struct MainControlInfo
319 struct MenuPosInfo *pos_button;
322 struct TextPosInfo *pos_text;
325 struct TextPosInfo *pos_input;
329 static struct MainControlInfo main_controls[] =
333 &menu.main.button.name, IMG_MENU_BUTTON,
334 &menu.main.text.name, &main_text_name,
335 &menu.main.input.name, &setup.player_name,
339 &menu.main.button.levels, IMG_MENU_BUTTON_ENTER_MENU,
340 &menu.main.text.levels, &main_text_levels,
345 &menu.main.button.scores, IMG_MENU_BUTTON,
346 &menu.main.text.scores, &main_text_scores,
351 &menu.main.button.editor, IMG_MENU_BUTTON,
352 &menu.main.text.editor, &main_text_editor,
357 &menu.main.button.info, IMG_MENU_BUTTON_ENTER_MENU,
358 &menu.main.text.info, &main_text_info,
363 &menu.main.button.game, IMG_MENU_BUTTON,
364 &menu.main.text.game, &main_text_game,
369 &menu.main.button.setup, IMG_MENU_BUTTON_ENTER_MENU,
370 &menu.main.text.setup, &main_text_setup,
375 &menu.main.button.quit, IMG_MENU_BUTTON,
376 &menu.main.text.quit, &main_text_quit,
380 /* (these two buttons are real gadgets) */
382 MAIN_CONTROL_PREV_LEVEL,
383 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
388 MAIN_CONTROL_NEXT_LEVEL,
389 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
395 MAIN_CONTROL_FIRST_LEVEL,
397 &menu.main.text.first_level, &main_text_first_level,
401 MAIN_CONTROL_LAST_LEVEL,
403 &menu.main.text.last_level, &main_text_last_level,
407 MAIN_CONTROL_LEVEL_NUMBER,
409 &menu.main.text.level_number, &main_text_level_number,
413 MAIN_CONTROL_LEVEL_INFO_1,
415 &menu.main.text.level_info_1, NULL,
419 MAIN_CONTROL_LEVEL_INFO_2,
421 &menu.main.text.level_info_2, NULL,
425 MAIN_CONTROL_LEVEL_NAME,
427 &menu.main.text.level_name, &main_text_level_name,
431 MAIN_CONTROL_LEVEL_AUTHOR,
433 &menu.main.text.level_author, &main_text_level_author,
437 MAIN_CONTROL_LEVEL_YEAR,
439 &menu.main.text.level_year, &main_text_level_year,
443 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
445 &menu.main.text.level_imported_from, &main_text_level_imported_from,
449 MAIN_CONTROL_LEVEL_IMPORTED_BY,
451 &menu.main.text.level_imported_by, &main_text_level_imported_by,
455 MAIN_CONTROL_LEVEL_TESTED_BY,
457 &menu.main.text.level_tested_by, &main_text_level_tested_by,
461 MAIN_CONTROL_TITLE_1,
463 &menu.main.text.title_1, &main_text_title_1,
467 MAIN_CONTROL_TITLE_2,
469 &menu.main.text.title_2, &main_text_title_2,
473 MAIN_CONTROL_TITLE_3,
475 &menu.main.text.title_3, &main_text_title_3,
488 static int getTitleScreenGraphic(int nr, boolean initial)
490 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
493 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
495 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
499 static int getTitleScreenGameMode(boolean initial)
501 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
505 static int getTitleMessageGameMode(boolean initial)
507 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
511 static int getTitleScreenBackground(boolean initial)
513 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
518 static int getTitleMessageBackground(int nr, boolean initial)
520 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
524 static int getTitleBackground(int nr, boolean initial, boolean is_image)
526 int base = (is_image ?
527 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
528 IMG_BACKGROUND_TITLESCREEN_1) :
529 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
530 IMG_BACKGROUND_TITLEMESSAGE_1));
531 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
532 IMG_BACKGROUND_TITLE);
533 int graphic_local = base + nr;
535 if (graphic_info[graphic_local].bitmap != NULL)
536 return graphic_local;
538 if (graphic_info[graphic_global].bitmap != NULL)
539 return graphic_global;
541 return IMG_UNDEFINED;
544 static int getTitleSound(struct TitleControlInfo *tci)
546 boolean is_image = tci->is_image;
547 int initial = tci->initial;
548 int nr = tci->local_nr;
549 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
550 int base = (is_image ?
551 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
552 SND_BACKGROUND_TITLESCREEN_1) :
553 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
554 SND_BACKGROUND_TITLEMESSAGE_1));
555 int sound_global = menu.sound[mode];
556 int sound_local = base + nr;
559 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
560 nr, initial, is_image,
561 sound_global, getSoundListEntry(sound_global)->filename,
562 sound_local, getSoundListEntry(sound_local)->filename);
565 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
568 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
571 return SND_UNDEFINED;
574 static int getTitleMusic(struct TitleControlInfo *tci)
576 boolean is_image = tci->is_image;
577 int initial = tci->initial;
578 int nr = tci->local_nr;
579 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
580 int base = (is_image ?
581 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
582 MUS_BACKGROUND_TITLESCREEN_1) :
583 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
584 MUS_BACKGROUND_TITLEMESSAGE_1));
585 int music_global = menu.music[mode];
586 int music_local = base + nr;
589 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
590 nr, initial, is_image,
591 music_global, getMusicListEntry(music_global)->filename,
592 music_local, getMusicListEntry(music_local)->filename);
595 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
598 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
601 return MUS_UNDEFINED;
604 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
606 boolean is_image = tci->is_image;
607 int initial = tci->initial;
608 int nr = tci->local_nr;
609 struct TitleFadingInfo ti;
613 int graphic = getTitleScreenGraphic(nr, initial);
615 /* initialize fading control values to default title config settings */
616 ti = (initial ? title_initial_default : title_default);
618 /* override default settings with image config settings, if defined */
619 if (graphic_info[graphic].anim_mode != ANIM_DEFAULT)
620 ti.anim_mode = graphic_info[graphic].anim_mode;
621 if (graphic_info[graphic].fade_delay > -1)
622 ti.fade_delay = graphic_info[graphic].fade_delay;
623 if (graphic_info[graphic].post_delay > -1)
624 ti.post_delay = graphic_info[graphic].post_delay;
625 if (graphic_info[graphic].auto_delay > -1)
626 ti.auto_delay = graphic_info[graphic].auto_delay;
632 ti.anim_mode = titlemessage_initial[nr].anim_mode;
633 ti.fade_delay = titlemessage_initial[nr].fade_delay;
634 ti.post_delay = titlemessage_initial[nr].post_delay;
635 ti.auto_delay = titlemessage_initial[nr].auto_delay;
639 ti.anim_mode = titlemessage[nr].anim_mode;
640 ti.fade_delay = titlemessage[nr].fade_delay;
641 ti.post_delay = titlemessage[nr].post_delay;
642 ti.auto_delay = titlemessage[nr].auto_delay;
647 if (ti.anim_mode == ANIM_NONE)
648 ti.fade_delay = ti.post_delay = 0;
654 static int compareTitleControlInfo(const void *object1, const void *object2)
656 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
657 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
660 if (tci1->initial != tci2->initial)
661 compare_result = (tci1->initial ? -1 : +1);
662 else if (tci1->sort_priority != tci2->sort_priority)
663 compare_result = tci1->sort_priority - tci2->sort_priority;
664 else if (tci1->is_image != tci2->is_image)
665 compare_result = (tci1->is_image ? -1 : +1);
667 compare_result = tci1->local_nr - tci2->local_nr;
669 return compare_result;
672 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
674 int nr, int sort_priority)
676 title_controls[num_title_screens].is_image = is_image;
677 title_controls[num_title_screens].initial = initial;
678 title_controls[num_title_screens].local_nr = nr;
679 title_controls[num_title_screens].sort_priority = sort_priority;
684 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
688 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
690 int graphic = getTitleScreenGraphic(i, initial);
691 Bitmap *bitmap = graphic_info[graphic].bitmap;
692 int sort_priority = graphic_info[graphic].sort_priority;
695 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
698 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
700 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
701 char *filename = getLevelSetTitleMessageFilename(i, initial);
702 int sort_priority = tmi->sort_priority;
704 if (filename != NULL)
705 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
709 static void InitializeTitleControls(boolean show_title_initial)
711 num_title_screens = 0;
713 if (show_title_initial)
714 InitializeTitleControls_CheckTitleInfo(TRUE);
716 InitializeTitleControls_CheckTitleInfo(FALSE);
718 /* sort title screens according to sort_priority and title number */
719 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
720 compareTitleControlInfo);
723 static boolean visibleMenuPos(struct MenuPosInfo *pos)
725 return (pos != NULL && pos->x != -1 && pos->y != -1);
728 static boolean visibleTextPos(struct TextPosInfo *pos)
730 return (pos != NULL && pos->x != -1 && pos->y != -1);
733 static void InitializeMainControls()
735 boolean local_team_mode = (!options.network && setup.team_mode);
738 /* set main control text values to dynamically determined values */
739 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
740 sprintf(main_text_first_level, "%03d", leveldir_current->first_level);
741 sprintf(main_text_last_level, "%03d", leveldir_current->last_level);
742 sprintf(main_text_level_number, "%s", int2str(level_nr, 3));
744 main_text_level_year = leveldir_current->year;
745 main_text_level_imported_from = leveldir_current->imported_from;
746 main_text_level_imported_by = leveldir_current->imported_by;
747 main_text_level_tested_by = leveldir_current->tested_by;
749 /* set main control screen positions to dynamically determined values */
750 for (i = 0; main_controls[i].nr != -1; i++)
752 struct MainControlInfo *mci = &main_controls[i];
754 struct MenuPosInfo *pos_button = mci->pos_button;
755 struct TextPosInfo *pos_text = mci->pos_text;
756 struct TextPosInfo *pos_input = mci->pos_input;
757 char *text = (mci->text ? *mci->text : NULL);
758 char *input = (mci->input ? *mci->input : NULL);
759 int button_graphic = mci->button_graphic;
761 int font_text = (pos_text ? pos_text->font : -1);
762 int font_input = (pos_input ? pos_input->font : -1);
764 int font_text = mci->font_text;
765 int font_input = mci->font_input;
768 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
769 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
770 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
771 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
772 int text_chars = (text != NULL ? strlen(text) : 0);
773 int input_chars = (input != NULL ? strlen(input) : 0);
776 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
778 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
779 int text_width = font_text_width * text_chars;
780 int text_height = font_text_height;
781 int input_width = font_input_width * input_chars;
782 int input_height = font_input_height;
784 if (nr == MAIN_CONTROL_NAME)
787 if (menu.main.input.name.x == -1)
788 menu.main.input.name.x = menu.main.text.name.x + text_width;
789 if (menu.main.input.name.y == -1)
790 menu.main.input.name.y = menu.main.text.name.y;
794 menu.main.input.name.width = input_width;
795 menu.main.input.name.height = input_height;
797 menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
798 menu.main.input.name.height = font_input_height;
802 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
804 if (pos_button->width == 0)
805 pos_button->width = button_width;
806 if (pos_button->height == 0)
807 pos_button->height = button_height;
810 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
812 /* calculate width for non-clickable text -- needed for text alignment */
813 boolean calculate_text_width = (pos_button == NULL && text != NULL);
815 if (visibleMenuPos(pos_button))
817 if (pos_text->x == -1)
818 pos_text->x = pos_button->x + pos_button->width;
819 if (pos_text->y == -1)
820 pos_text->y = pos_button->y;
823 if (pos_text->width == -1 || calculate_text_width)
824 pos_text->width = text_width;
825 if (pos_text->height == -1)
826 pos_text->height = text_height;
829 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
831 if (visibleTextPos(pos_text))
833 if (pos_input->x == -1)
834 pos_input->x = pos_text->x + pos_text->width;
835 if (pos_input->y == -1)
836 pos_input->y = pos_text->y;
839 if (pos_input->width == -1)
840 pos_input->width = input_width;
841 if (pos_input->height == -1)
842 pos_input->height = input_height;
847 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
848 boolean active_input)
852 for (i = 0; main_controls[i].nr != -1; i++)
854 struct MainControlInfo *mci = &main_controls[i];
856 if (mci->nr == nr || nr == -1)
858 struct MenuPosInfo *pos_button = mci->pos_button;
859 struct TextPosInfo *pos_text = mci->pos_text;
860 struct TextPosInfo *pos_input = mci->pos_input;
861 char *text = (mci->text ? *mci->text : NULL);
862 char *input = (mci->input ? *mci->input : NULL);
863 int button_graphic = mci->button_graphic;
865 int font_text = (pos_text ? pos_text->font : -1);
866 int font_input = (pos_input ? pos_input->font : -1);
868 int font_text = mci->font_text;
869 int font_input = mci->font_input;
874 button_graphic = BUTTON_GRAPHIC_ACTIVE(button_graphic);
875 font_text = FONT_ACTIVE(font_text);
880 font_input = FONT_ACTIVE(font_input);
883 if (visibleMenuPos(pos_button))
885 struct MenuPosInfo *pos = pos_button;
886 int x = mSX + pos->x;
887 int y = mSY + pos->y;
889 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
890 DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
893 if (visibleTextPos(pos_text) && text != NULL)
895 struct TextPosInfo *pos = pos_text;
896 int x = mSX + ALIGNED_TEXT_XPOS(pos);
897 int y = mSY + ALIGNED_TEXT_YPOS(pos);
900 /* (check why/if this is needed) */
901 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
903 DrawText(x, y, text, font_text);
906 if (visibleTextPos(pos_input) && input != NULL)
908 struct TextPosInfo *pos = pos_input;
909 int x = mSX + ALIGNED_TEXT_XPOS(pos);
910 int y = mSY + ALIGNED_TEXT_YPOS(pos);
913 /* (check why/if this is needed) */
914 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
916 DrawText(x, y, input, font_input);
922 static void DrawCursorAndText_Main(int nr, boolean active_text)
924 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
928 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
930 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
934 static struct MainControlInfo *getMainControlInfo(int nr)
938 for (i = 0; main_controls[i].nr != -1; i++)
939 if (main_controls[i].nr == nr)
940 return &main_controls[i];
945 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
950 int rect_x = ALIGNED_TEXT_XPOS(rect);
951 int rect_y = ALIGNED_TEXT_YPOS(rect);
953 return (x >= rect_x && x < rect_x + rect->width &&
954 y >= rect_y && y < rect_y + rect->height);
957 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
962 int rect_x = ALIGNED_TEXT_XPOS(rect);
963 int rect_y = ALIGNED_TEXT_YPOS(rect);
965 return (x >= rect_x && x < rect_x + rect->width &&
966 y >= rect_y && y < rect_y + rect->height);
969 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
971 static int cursor_array[SCR_FIELDY];
972 int x = mSX + TILEX * xpos;
973 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
978 cursor_array[ypos] = graphic;
980 graphic = cursor_array[ypos];
984 graphic = BUTTON_GRAPHIC_ACTIVE(graphic);
986 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
987 DrawGraphicThruMaskExt(drawto, x, y, graphic, 0);
990 static void initCursor(int ypos, int graphic)
992 drawCursorExt(0, ypos, FALSE, graphic);
995 static void drawCursor(int ypos, boolean active)
997 drawCursorExt(0, ypos, active, -1);
1000 static void drawCursorXY(int xpos, int ypos, int graphic)
1002 drawCursorExt(xpos, ypos, FALSE, graphic);
1005 static void drawChooseTreeCursor(int ypos, boolean active)
1007 int last_game_status = game_status; /* save current game status */
1009 /* force LEVELS draw offset on artwork setup screen */
1010 game_status = GAME_MODE_LEVELS;
1012 drawCursorExt(0, ypos, active, -1);
1014 game_status = last_game_status; /* restore current game status */
1019 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1020 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1024 static int getPrevlevelButtonPos()
1029 static int getCurrentLevelTextPos()
1031 return (getPrevlevelButtonPos() + 1);
1034 static int getNextLevelButtonPos()
1036 return getPrevlevelButtonPos() + 3 + 1;
1039 static int getLevelRangeTextPos()
1041 return getNextLevelButtonPos() + 1;
1045 int effectiveGameStatus()
1047 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1048 return GAME_MODE_TITLE;
1053 void DrawTitleScreenImage(int nr, boolean initial)
1055 int graphic = getTitleScreenGraphic(nr, initial);
1056 Bitmap *bitmap = graphic_info[graphic].bitmap;
1058 int width = graphic_info[graphic].width;
1059 int height = graphic_info[graphic].height;
1060 int src_x = graphic_info[graphic].src_x;
1061 int src_y = graphic_info[graphic].src_y;
1063 int width = graphic_info[graphic].src_image_width;
1064 int height = graphic_info[graphic].src_image_height;
1065 int src_x = 0, src_y = 0;
1072 if (width > WIN_XSIZE)
1074 /* image width too large for window => center image horizontally */
1075 src_x = (width - WIN_XSIZE) / 2;
1079 if (height > WIN_YSIZE)
1081 /* image height too large for window => center image vertically */
1082 src_y = (height - WIN_YSIZE) / 2;
1086 /* always display title screens centered */
1087 dst_x = (WIN_XSIZE - width) / 2;
1088 dst_y = (WIN_YSIZE - height) / 2;
1090 SetDrawBackgroundMask(REDRAW_ALL);
1091 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1093 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1095 if (DrawingOnBackground(dst_x, dst_y))
1096 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1098 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1100 redraw_mask = REDRAW_ALL;
1102 /* reset fading control values to default config settings */
1106 title = getTitleFading(nr, initial, TRUE);
1111 title.fade_delay_final = title.fade_delay;
1112 title.post_delay_final = title.post_delay;
1113 title.auto_delay_final = title.auto_delay;
1115 /* override default settings with image config settings, if defined */
1116 if (graphic_info[graphic].anim_mode != ANIM_DEFAULT)
1117 title.anim_mode = graphic_info[graphic].anim_mode;
1118 if (graphic_info[graphic].fade_delay > -1)
1119 title.fade_delay = graphic_info[graphic].fade_delay;
1120 if (graphic_info[graphic].post_delay > -1)
1121 title.post_delay = graphic_info[graphic].post_delay;
1122 if (graphic_info[graphic].auto_delay > -1)
1123 title.auto_delay = graphic_info[graphic].auto_delay;
1127 void DrawTitleScreenMessage(int nr, boolean initial)
1129 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1130 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1132 int font_nr = FONT_TEXT_1;
1136 int pad_y = 32 + 14;
1139 int max_chars_per_line;
1140 int max_lines_per_screen;
1142 int last_game_status = game_status; /* save current game status */
1144 if (filename == NULL)
1147 /* force TITLE font on title message screen */
1148 game_status = getTitleMessageGameMode(initial);
1150 /* if chars set to "-1", automatically determine by text and font width */
1151 if (tmi->chars == -1)
1152 tmi->chars = tmi->width / getFontWidth(tmi->font);
1154 tmi->width = tmi->chars * getFontWidth(tmi->font);
1156 /* if lines set to "-1", automatically determine by text and font height */
1157 if (tmi->lines == -1)
1158 tmi->lines = tmi->height / getFontHeight(tmi->font);
1160 tmi->height = tmi->lines * getFontHeight(tmi->font);
1162 SetDrawBackgroundMask(REDRAW_ALL);
1163 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1165 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1168 font_width = getFontWidth(font_nr);
1169 font_height = getFontHeight(font_nr);
1170 max_chars_per_line = (WIN_XSIZE - 2 * pad_x) / font_width;
1171 max_lines_per_screen = (WIN_YSIZE - pad_y) / font_height - 1;
1175 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1176 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
1177 tmi->autowrap, tmi->centered, tmi->parse_comments);
1179 DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1,
1180 max_lines_per_screen, -1, tmi->autowrap, tmi->centered,
1181 tmi->parse_comments);
1184 game_status = last_game_status; /* restore current game status */
1187 void DrawTitleScreen()
1189 KeyboardAutoRepeatOff();
1192 SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
1195 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1200 boolean CheckTitleScreen(boolean levelset_has_changed)
1202 static boolean show_title_initial = TRUE;
1203 boolean show_titlescreen = FALSE;
1205 /* needed to be able to skip title screen, if no image or message defined */
1206 InitializeTitleControls(show_title_initial);
1208 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1209 show_titlescreen = TRUE;
1211 /* show initial title images and messages only once at program start */
1212 show_title_initial = FALSE;
1214 return (show_titlescreen && num_title_screens > 0);
1217 void DrawMainMenuExt(int redraw_mask, boolean do_fading)
1219 static LevelDirTree *leveldir_last_valid = NULL;
1220 boolean levelset_has_changed = FALSE;
1222 boolean local_team_mode = (!options.network && setup.team_mode);
1223 char *name_text = (local_team_mode ? "Team:" : "Name:");
1224 int name_width, level_width;
1231 /* !!! CHANGE THIS !!! */
1232 title = title_default;
1236 printf("::: %d, %d\n", fading.anim_mode == ANIM_CROSSFADE,
1237 redraw_mask == REDRAW_ALL);
1242 if (fading.anim_mode == ANIM_CROSSFADE)
1243 FadeCrossSaveBackbuffer();
1245 FadeOut(redraw_mask);
1250 FadeSoundsAndMusic();
1252 KeyboardAutoRepeatOn();
1255 SetDrawDeactivationMask(REDRAW_NONE);
1256 SetDrawBackgroundMask(REDRAW_FIELD);
1258 audio.sound_deactivated = FALSE;
1262 /* needed if last screen was the playing screen, invoked from level editor */
1263 if (level_editor_test_game)
1265 game_status = GAME_MODE_EDITOR;
1271 /* needed if last screen was the editor screen */
1272 UndrawSpecialEditorDoor();
1274 /* needed if last screen was the setup screen and fullscreen state changed */
1275 ToggleFullscreenIfNeeded();
1277 /* leveldir_current may be invalid (level group, parent link) */
1278 if (!validLevelSeries(leveldir_current))
1279 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1281 if (leveldir_current != leveldir_last_valid)
1282 levelset_has_changed = TRUE;
1284 /* store valid level series information */
1285 leveldir_last_valid = leveldir_current;
1287 /* needed if last screen (level choice) changed graphics, sounds or music */
1288 ReloadCustomArtwork(0);
1290 #if defined(TARGET_SDL)
1291 SetDrawtoField(DRAW_BACKBUFFER);
1295 if (levelset_has_changed)
1296 fading = title_default;
1300 if (CheckTitleScreen(levelset_has_changed))
1302 game_status = GAME_MODE_TITLE;
1311 if (setup.show_titlescreen &&
1312 ((levelset_has_changed &&
1313 (graphic_info[IMG_TITLESCREEN_1].bitmap != NULL ||
1314 getLevelSetMessageFilename(1, FALSE) != NULL)) ||
1315 (show_title_initial &&
1316 (graphic_info[IMG_TITLESCREEN_INITIAL_1].bitmap != NULL ||
1317 getLevelSetMessageFilename(1, TRUE) != NULL))))
1319 game_status = GAME_MODE_TITLE;
1327 /* level_nr may have been set to value over handicap with level editor */
1328 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1329 level_nr = leveldir_current->handicap_level;
1331 LoadLevel(level_nr);
1333 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1337 if (fading.anim_mode == ANIM_CROSSFADE)
1338 FadeCrossSaveBackbuffer();
1340 FadeOut(redraw_mask);
1345 if (redraw_mask == REDRAW_ALL)
1347 int door_state = GetDoorState();
1351 // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1355 OpenDoor(DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1357 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1366 InitializeMainControls();
1369 DrawCursorAndText_Main(-1, FALSE);
1371 for (i = 0; main_controls[i].nr != -1; i++)
1373 struct MenuPosInfo *pos_button = main_controls[i].pos_button;
1374 struct MenuPosInfo *pos_text = main_controls[i].pos_text;
1375 struct MenuPosInfo *pos_input = main_controls[i].pos_input;
1376 char *text = main_controls[i].text;
1377 char *input = main_controls[i].input;
1378 int button_graphic = main_controls[i].button_graphic;
1379 int font_text = main_controls[i].font_text;
1380 int font_input = main_controls[i].font_input;
1382 if (pos_button != NULL)
1383 DrawGraphicThruMaskExt(drawto, mSX + pos_button->x, mSY + pos_button->y,
1386 if (pos_text != NULL && text != NULL)
1387 DrawText(mSX + pos_text->x, mSY + pos_text->y, text, font_text);
1389 if (pos_input != NULL && input != NULL)
1390 DrawText(mSX + pos_input->x, mSY + pos_input->y, input, font_input);
1398 DrawText(mSX + 32, mSY + 2 * 32, name_text, FONT_MENU_1);
1399 DrawText(mSX + 32, mSY + 3 * 32, "Levelset", FONT_MENU_1);
1400 DrawText(mSX + 32, mSY + 4 * 32, "Hall Of Fame", FONT_MENU_1);
1401 DrawText(mSX + 32, mSY + 5 * 32, "Level Creator", FONT_MENU_1);
1402 DrawText(mSX + 32, mSY + 6 * 32, "Info Screen", FONT_MENU_1);
1403 DrawText(mSX + 32, mSY + 7 * 32, "Start Game", FONT_MENU_1);
1404 DrawText(mSX + 32, mSY + 8 * 32, "Setup", FONT_MENU_1);
1405 DrawText(mSX + 32, mSY + 9 * 32, "Quit", FONT_MENU_1);
1407 /* calculated after (possible) reload of custom artwork */
1408 name_width = getTextWidth(name_text, FONT_MENU_1);
1409 level_width = 9 * 32;
1411 DrawText(mSX + 32 + name_width, mSY + 2 * 32, setup.player_name,
1414 DrawText(mSX + getCurrentLevelTextPos() * 32, mSY + 3 * 32,
1415 int2str(level_nr, 3), FONT_VALUE_1);
1418 int text_height = getFontHeight(FONT_TEXT_3);
1419 int xpos = getLevelRangeTextPos() * 32 + 8;
1420 int ypos2 = 3 * 32 + 16;
1421 int ypos1 = ypos2 - text_height;
1423 DrawTextF(mSX - SX + xpos, mSY - SY + ypos1, FONT_TEXT_3,
1424 "%03d", leveldir_current->first_level);
1425 DrawTextF(mSX - SX + xpos, mSY - SY + ypos2, FONT_TEXT_3,
1426 "%03d", leveldir_current->last_level);
1429 for (i = 0; i < 8; i++)
1430 initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_ENTER_MENU :
1433 DrawTextSCentered(326, FONT_TITLE_2, PROGRAM_GAME_BY_STRING);
1436 DrawPreviewLevel(TRUE);
1438 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1441 if (TAPE_IS_EMPTY(tape))
1443 DrawCompleteVideoDisplay();
1448 /* create gadgets for main menu screen */
1449 FreeScreenGadgets();
1450 CreateScreenGadgets();
1453 BlitBitmap(drawto, window, VX, VY, VXSIZE, VYSIZE, VX, VY);
1457 /* map gadgets for main menu screen */
1459 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1461 DrawMaskedBorder(REDRAW_ALL);
1464 if (redraw_mask == REDRAW_ALL)
1466 int door_state = GetDoorState();
1468 OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1473 if (fading.anim_mode == ANIM_CROSSFADE)
1474 FadeCross(redraw_mask);
1476 FadeIn(redraw_mask);
1481 else if (fading.anim_mode == ANIM_CROSSFADE)
1482 FadeCross(redraw_mask);
1484 FadeIn(redraw_mask);
1487 FadeIn(redraw_mask);
1494 fading = menu.navigation;
1496 fading = title_default;
1499 SetMouseCursor(CURSOR_DEFAULT);
1503 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1506 void DrawAndFadeInMainMenu(int redraw_mask)
1508 DrawMainMenuExt(redraw_mask, TRUE);
1513 DrawMainMenuExt(REDRAW_ALL, FALSE);
1517 static void gotoTopLevelDir()
1519 /* move upwards to top level directory */
1520 while (leveldir_current->node_parent)
1522 /* write a "path" into level tree for easy navigation to last level */
1523 if (leveldir_current->node_parent->node_group->cl_first == -1)
1525 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1526 int leveldir_pos = posTreeInfo(leveldir_current);
1527 int num_page_entries;
1528 int cl_first, cl_cursor;
1530 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1531 num_page_entries = num_leveldirs;
1533 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1535 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1536 cl_cursor = leveldir_pos - cl_first;
1538 leveldir_current->node_parent->node_group->cl_first = cl_first;
1539 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1542 leveldir_current = leveldir_current->node_parent;
1547 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1549 static unsigned long title_delay = 0;
1550 static int title_screen_nr = 0;
1551 static int last_sound = -1, last_music = -1;
1552 boolean return_to_main_menu = FALSE;
1553 boolean use_fading_main_menu = TRUE;
1556 boolean use_cross_fading = FALSE;
1558 boolean use_cross_fading = !show_title_initial; /* default */
1561 struct TitleControlInfo *tci;
1562 struct TitleFadingInfo fading_next;
1565 if (button == MB_MENU_INITIALIZE)
1568 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1572 int last_game_status = game_status; /* save current game status */
1576 title_screen_nr = 0;
1577 tci = &title_controls[title_screen_nr];
1579 last_sound = SND_UNDEFINED;
1580 last_music = MUS_UNDEFINED;
1583 /* determine number of title screens to display (images and messages) */
1584 InitializeTitleControls();
1587 if (game_status == GAME_MODE_INFO)
1589 if (num_title_screens == 0)
1591 DrawInfoScreen_NotAvailable("Title screen information:",
1592 "No title screen for this level set.");
1594 /* use default settings for fading, but always disable auto delay */
1595 fading = title_default;
1596 fading.auto_delay = -1;
1601 FadeSoundsAndMusic();
1604 if (use_cross_fading)
1605 FadeCrossSaveBackbuffer();
1607 FadeOut(REDRAW_ALL);
1609 FadeOut(REDRAW_ALL);
1614 DrawTitleScreenImage(tci->local_nr, tci->initial);
1616 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1618 fading = getTitleFading(tci);
1621 sound = getTitleSound(tci);
1622 music = getTitleMusic(tci);
1624 if (sound != last_sound)
1625 PlayMenuSoundExt(sound);
1626 if (music != last_music)
1627 PlayMenuMusicExt(music);
1633 SetMouseCursor(CURSOR_NONE);
1636 if (use_cross_fading)
1637 FadeCross(REDRAW_ALL);
1644 DelayReached(&title_delay, 0); /* reset delay counter */
1649 if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
1650 button = MB_MENU_CHOICE;
1652 if (button == MB_MENU_LEAVE)
1654 return_to_main_menu = TRUE;
1655 use_fading_main_menu = FALSE;
1657 else if (button == MB_MENU_CHOICE)
1660 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1663 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1667 if (fading.anim_mode == ANIM_CROSSFADE)
1668 FadeCrossSaveBackbuffer();
1670 FadeOut(REDRAW_FIELD);
1672 FadeOut(REDRAW_FIELD);
1676 fading = menu.destination;
1678 info_mode = INFO_MODE_MAIN;
1679 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1685 tci = &title_controls[title_screen_nr];
1687 if (title_screen_nr < num_title_screens)
1691 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1698 graphic_info[getTitleScreenGraphic(tci->local_nr,
1699 tci->initial)].anim_mode;
1701 anim_mode = ANIM_FADE; /* ??? */
1703 use_cross_fading = (anim_mode == ANIM_FADE ? FALSE :
1704 anim_mode == ANIM_CROSSFADE ? TRUE :
1708 sound = getTitleSound(tci);
1709 music = getTitleMusic(tci);
1711 if (sound == SND_UNDEFINED || sound != last_sound)
1713 if (music == MUS_UNDEFINED || music != last_music)
1716 if (use_cross_fading)
1717 FadeCrossSaveBackbuffer();
1719 FadeOut(REDRAW_ALL);
1722 DrawTitleScreenImage(tci->local_nr, tci->initial);
1724 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1726 fading_next = getTitleFading(tci);
1729 sound = getTitleSound(tci);
1730 music = getTitleMusic(tci);
1732 if (sound != last_sound)
1733 PlayMenuSoundExt(sound);
1734 if (music != last_music)
1735 PlayMenuMusicExt(music);
1741 /* last screen already faded out, next screen has no animation */
1742 if (!use_cross_fading && fading_next.anim_mode == ANIM_NONE)
1743 fading = fading_next;
1745 if (use_cross_fading)
1746 FadeCross(REDRAW_ALL);
1750 fading = fading_next;
1752 DelayReached(&title_delay, 0); /* reset delay counter */
1756 FadeSoundsAndMusic();
1762 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
1765 if (use_cross_fading)
1766 FadeCrossSaveBackbuffer();
1768 FadeOut(REDRAW_ALL);
1771 FadeOut(REDRAW_ALL);
1775 return_to_main_menu = TRUE;
1779 if (return_to_main_menu)
1785 SetMouseCursor(CURSOR_DEFAULT);
1787 if (game_status == GAME_MODE_INFO)
1790 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1793 info_mode = INFO_MODE_MAIN;
1794 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1796 else /* default: return to main menu */
1799 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1802 game_status = GAME_MODE_MAIN;
1803 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1808 void HandleMainMenu_SelectLevel(int step, int direction)
1810 int old_level_nr = level_nr;
1813 new_level_nr = old_level_nr + step * direction;
1814 if (new_level_nr < leveldir_current->first_level)
1815 new_level_nr = leveldir_current->first_level;
1816 if (new_level_nr > leveldir_current->last_level)
1817 new_level_nr = leveldir_current->last_level;
1819 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1821 /* skipping levels is only allowed when trying to skip single level */
1822 if (setup.skip_levels && step == 1 &&
1823 Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK))
1825 leveldir_current->handicap_level++;
1826 SaveLevelSetup_SeriesInfo();
1829 new_level_nr = leveldir_current->handicap_level;
1832 if (new_level_nr != old_level_nr)
1834 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1836 PlaySound(SND_MENU_ITEM_SELECTING);
1838 level_nr = new_level_nr;
1841 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1842 int2str(level_nr, 3), mci->pos_text->font);
1844 DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
1847 LoadLevel(level_nr);
1848 DrawPreviewLevel(TRUE);
1852 DrawCompleteVideoDisplay();
1854 /* needed because DrawPreviewLevel() takes some time */
1862 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1864 static int choice = MAIN_CONTROL_GAME;
1868 if (button == MB_MENU_INITIALIZE)
1870 DrawCursorAndText_Main(choice, TRUE);
1875 if (mx || my) /* mouse input */
1879 for (i = 0; main_controls[i].nr != -1; i++)
1881 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1882 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1883 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1885 pos = main_controls[i].nr;
1891 else if (dx || dy) /* keyboard input */
1893 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1894 choice == MAIN_CONTROL_SETUP))
1895 button = MB_MENU_CHOICE;
1900 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1902 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1904 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1910 PlaySound(SND_MENU_ITEM_ACTIVATING);
1912 DrawCursorAndText_Main(choice, FALSE);
1913 DrawCursorAndText_Main(pos, TRUE);
1920 PlaySound(SND_MENU_ITEM_SELECTING);
1922 if (pos == MAIN_CONTROL_NAME)
1924 game_status = GAME_MODE_PSEUDO_TYPENAME;
1926 HandleTypeName(strlen(setup.player_name), 0);
1928 else if (pos == MAIN_CONTROL_LEVELS)
1932 game_status = GAME_MODE_LEVELS;
1934 SaveLevelSetup_LastSeries();
1935 SaveLevelSetup_SeriesInfo();
1944 else if (pos == MAIN_CONTROL_SCORES)
1946 game_status = GAME_MODE_SCORES;
1950 else if (pos == MAIN_CONTROL_EDITOR)
1952 if (leveldir_current->readonly &&
1953 !strEqual(setup.player_name, "Artsoft"))
1954 Request("This level is read only !", REQ_CONFIRM);
1956 game_status = GAME_MODE_EDITOR;
1958 fading = menu.destination;
1962 else if (pos == MAIN_CONTROL_INFO)
1964 game_status = GAME_MODE_INFO;
1965 info_mode = INFO_MODE_MAIN;
1967 fading = menu.navigation;
1971 else if (pos == MAIN_CONTROL_GAME)
1973 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
1975 else if (pos == MAIN_CONTROL_SETUP)
1977 game_status = GAME_MODE_SETUP;
1978 setup_mode = SETUP_MODE_MAIN;
1982 else if (pos == MAIN_CONTROL_QUIT)
1984 SaveLevelSetup_LastSeries();
1985 SaveLevelSetup_SeriesInfo();
1987 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
1988 game_status = GAME_MODE_QUIT;
1993 if (game_status == GAME_MODE_MAIN)
1995 DrawPreviewLevel(FALSE);
2002 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
2004 static int choice = 5;
2008 if (button == MB_MENU_INITIALIZE)
2010 drawCursor(choice, TRUE);
2015 if (mx || my) /* mouse input */
2017 x = (mx - mSX) / 32;
2018 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2020 else if (dx || dy) /* keyboard input */
2022 if (dx && choice == 1)
2023 x = (dx < 0 ? 10 : 14);
2026 if (choice == 4 || choice == 6)
2027 button = MB_MENU_CHOICE;
2033 if (y == 1 && dx != 0 && button)
2035 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
2037 else if (IN_VIS_FIELD(x, y) &&
2038 y >= 0 && y <= 7 && (y != 1 || x < 10))
2044 drawCursor(choice, FALSE);
2045 drawCursor(y, TRUE);
2054 game_status = GAME_MODE_PSEUDO_TYPENAME;
2055 HandleTypeName(strlen(setup.player_name), 0);
2061 game_status = GAME_MODE_LEVELS;
2062 SaveLevelSetup_LastSeries();
2063 SaveLevelSetup_SeriesInfo();
2074 game_status = GAME_MODE_SCORES;
2079 if (leveldir_current->readonly &&
2080 !strEqual(setup.player_name, "Artsoft"))
2081 Request("This level is read only !", REQ_CONFIRM);
2082 game_status = GAME_MODE_EDITOR;
2087 game_status = GAME_MODE_INFO;
2088 info_mode = INFO_MODE_MAIN;
2093 StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
2097 game_status = GAME_MODE_SETUP;
2098 setup_mode = SETUP_MODE_MAIN;
2104 SaveLevelSetup_LastSeries();
2105 SaveLevelSetup_SeriesInfo();
2107 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
2108 game_status = GAME_MODE_QUIT;
2113 if (game_status == GAME_MODE_MAIN)
2115 DrawPreviewLevel(FALSE);
2123 /* ========================================================================= */
2124 /* info screen functions */
2125 /* ========================================================================= */
2127 static struct TokenInfo *info_info;
2128 static int num_info_info;
2130 static void execInfoTitleScreen()
2132 fading = menu.destination;
2134 info_mode = INFO_MODE_TITLE;
2138 static void execInfoElements()
2140 fading = menu.destination;
2142 info_mode = INFO_MODE_ELEMENTS;
2146 static void execInfoMusic()
2148 fading = menu.destination;
2150 info_mode = INFO_MODE_MUSIC;
2154 static void execInfoCredits()
2156 fading = menu.destination;
2158 info_mode = INFO_MODE_CREDITS;
2162 static void execInfoProgram()
2164 fading = menu.destination;
2166 info_mode = INFO_MODE_PROGRAM;
2170 static void execInfoVersion()
2172 fading = menu.destination;
2174 info_mode = INFO_MODE_VERSION;
2178 static void execInfoLevelSet()
2180 fading = menu.destination;
2182 info_mode = INFO_MODE_LEVELSET;
2186 static void execExitInfo()
2188 fading = menu.navigation;
2190 game_status = GAME_MODE_MAIN;
2192 DrawMainMenuExt(REDRAW_FIELD, FALSE);
2198 static struct TokenInfo info_info_main[] =
2200 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2201 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2202 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2203 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2204 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2205 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2206 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2207 { TYPE_EMPTY, NULL, "" },
2208 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2213 static void DrawCursorAndText_Info(int pos, boolean active)
2215 int xpos = MENU_SCREEN_START_XPOS;
2216 int ypos = MENU_SCREEN_START_YPOS + pos;
2217 int font_nr = FONT_MENU_1;
2220 font_nr = FONT_ACTIVE(font_nr);
2222 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
2224 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
2225 drawCursor(pos, active);
2228 static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading)
2233 CloseDoor(DOOR_CLOSE_2);
2236 if (fading.anim_mode == ANIM_CROSSFADE)
2237 FadeCrossSaveBackbuffer();
2239 FadeOut(redraw_mask);
2243 if (redraw_mask == REDRAW_ALL)
2246 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2252 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2254 info_info = info_info_main;
2257 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2260 int xpos = MENU_SCREEN_START_XPOS;
2261 int ypos = MENU_SCREEN_START_YPOS + i;
2262 int font_nr = FONT_MENU_1;
2265 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2266 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2267 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2268 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2269 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
2270 initCursor(i, IMG_MENU_BUTTON);
2273 DrawCursorAndText_Info(i, FALSE);
2275 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[i].text, font_nr);
2281 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2286 DrawMaskedBorder(REDRAW_ALL);
2289 if (fading.anim_mode == ANIM_CROSSFADE)
2290 FadeCross(redraw_mask);
2292 FadeIn(redraw_mask);
2297 else if (fading.anim_mode == ANIM_CROSSFADE)
2298 FadeCross(redraw_mask);
2300 FadeIn(redraw_mask);
2303 FadeIn(redraw_mask);
2312 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2314 static int choice_store[MAX_INFO_MODES];
2315 int choice = choice_store[info_mode]; /* always starts with 0 */
2319 if (button == MB_MENU_INITIALIZE)
2321 /* advance to first valid menu entry */
2322 while (choice < num_info_info &&
2323 info_info[choice].type & TYPE_SKIP_ENTRY)
2325 choice_store[info_mode] = choice;
2328 DrawCursorAndText_Info(choice, TRUE);
2330 drawCursor(choice, TRUE);
2335 else if (button == MB_MENU_LEAVE)
2337 for (y = 0; y < num_info_info; y++)
2339 if (info_info[y].type & TYPE_LEAVE_MENU)
2341 void (*menu_callback_function)(void) = info_info[y].value;
2343 menu_callback_function();
2345 break; /* absolutely needed because function changes 'info_info'! */
2352 if (mx || my) /* mouse input */
2354 x = (mx - mSX) / 32;
2355 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2357 else if (dx || dy) /* keyboard input */
2361 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2363 if (info_info[choice].type & menu_navigation_type ||
2364 info_info[choice].type & TYPE_ENTER_SCREEN ||
2365 info_info[choice].type & TYPE_BOOLEAN_STYLE)
2366 button = MB_MENU_CHOICE;
2371 /* jump to next non-empty menu entry (up or down) */
2372 while (y > 0 && y < num_info_info - 1 &&
2373 info_info[y].type & TYPE_SKIP_ENTRY)
2377 if (IN_VIS_FIELD(x, y) &&
2378 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2384 PlaySound(SND_MENU_ITEM_ACTIVATING);
2387 DrawCursorAndText_Info(choice, FALSE);
2388 DrawCursorAndText_Info(y, TRUE);
2390 drawCursor(choice, FALSE);
2391 drawCursor(y, TRUE);
2394 choice = choice_store[info_mode] = y;
2397 else if (!(info_info[y].type & TYPE_GHOSTED))
2399 PlaySound(SND_MENU_ITEM_SELECTING);
2401 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2403 void (*menu_callback_function)(void) = info_info[choice].value;
2405 menu_callback_function();
2411 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2414 int ystart1 = mSY - SY + 100;
2415 int ystart2 = mSY - SY + 150;
2416 int ybottom = mSY - SY + SYSIZE - 20;
2420 int ybottom = SYSIZE - 20;
2423 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2426 if (fading.anim_mode == ANIM_CROSSFADE)
2427 FadeCrossSaveBackbuffer();
2429 FadeOut(REDRAW_FIELD);
2431 FadeOut(REDRAW_FIELD);
2437 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2438 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2440 DrawTextSCentered(ybottom, FONT_TEXT_4,
2441 "Press any key or button for info menu");
2444 if (fading.anim_mode == ANIM_CROSSFADE)
2445 FadeCross(REDRAW_FIELD);
2447 FadeIn(REDRAW_FIELD);
2449 FadeIn(REDRAW_FIELD);
2453 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2455 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2456 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2457 int xstart = mSX + 16;
2458 int ystart1 = mSY - SY + 100;
2459 int ystart2 = mSY + 64 + 2 * 32;
2460 int ybottom = mSY - SY + SYSIZE - 20;
2461 int ystep = TILEY + 4;
2462 int element, action, direction;
2470 for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++)
2471 infoscreen_step[i] = infoscreen_frame[i] = 0;
2476 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2478 DrawTextSCentered(ybottom, FONT_TEXT_4,
2479 "Press any key or button for next page");
2485 while (helpanim_info[j].element != HELPANIM_LIST_END)
2487 if (i >= start + MAX_INFO_ELEMENTS_ON_SCREEN ||
2492 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2501 j += infoscreen_step[i - start];
2503 element = helpanim_info[j].element;
2504 action = helpanim_info[j].action;
2505 direction = helpanim_info[j].direction;
2508 element = EL_UNKNOWN;
2510 if (action != -1 && direction != -1)
2511 graphic = el_act_dir2img(element, action, direction);
2512 else if (action != -1)
2513 graphic = el_act2img(element, action);
2514 else if (direction != -1)
2515 graphic = el_dir2img(element, direction);
2517 graphic = el2img(element);
2519 delay = helpanim_info[j++].delay;
2524 if (infoscreen_frame[i - start] == 0)
2527 infoscreen_frame[i - start] = delay - 1;
2531 sync_frame = delay - infoscreen_frame[i - start];
2532 infoscreen_frame[i - start]--;
2535 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2537 if (!infoscreen_frame[i - start])
2538 infoscreen_step[i - start] = 0;
2542 if (!infoscreen_frame[i - start])
2543 infoscreen_step[i - start]++;
2544 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2550 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2552 DrawGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2553 graphic, sync_frame, USE_MASKING);
2556 DrawInfoScreen_HelpText(element, action, direction, i - start);
2561 redraw_mask |= REDRAW_FIELD;
2566 static char *getHelpText(int element, int action, int direction)
2568 char token[MAX_LINE_LEN];
2570 strcpy(token, element_info[element].token_name);
2573 strcat(token, element_action_info[action].suffix);
2575 if (direction != -1)
2576 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2578 return getHashEntry(helptext_info, token);
2581 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2584 int font_nr = FONT_INFO_ELEMENTS;
2586 int font_nr = FONT_LEVEL_NUMBER;
2588 int font_width = getFontWidth(font_nr);
2589 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2590 int sy = mSY + 65 + 2 * 32 + 1;
2591 int ystep = TILEY + 4;
2592 int pad_x = sx - SX;
2593 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2594 int max_lines_per_text = 2;
2597 if (action != -1 && direction != -1) /* element.action.direction */
2598 text = getHelpText(element, action, direction);
2600 if (text == NULL && action != -1) /* element.action */
2601 text = getHelpText(element, action, -1);
2603 if (text == NULL && direction != -1) /* element.direction */
2604 text = getHelpText(element, -1, direction);
2606 if (text == NULL) /* base element */
2607 text = getHelpText(element, -1, -1);
2609 if (text == NULL) /* not found */
2610 text = "No description available";
2612 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2613 sy += getFontHeight(font_nr) / 2;
2616 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2617 max_chars_per_line, -1, max_lines_per_text, -1,
2618 TRUE, FALSE, FALSE);
2620 DrawTextWrapped(sx, sy + ypos * ystep, text, font_nr,
2621 max_chars_per_line, max_lines_per_text);
2625 void DrawInfoScreen_TitleScreen()
2630 void HandleInfoScreen_TitleScreen(int button)
2632 HandleTitleScreen(0, 0, 0, 0, button);
2635 void DrawInfoScreen_Elements()
2637 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2640 if (fading.anim_mode == ANIM_CROSSFADE)
2641 FadeCrossSaveBackbuffer();
2643 FadeOut(REDRAW_FIELD);
2645 FadeOut(REDRAW_FIELD);
2651 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2654 if (fading.anim_mode == ANIM_CROSSFADE)
2655 FadeCross(REDRAW_FIELD);
2657 FadeIn(REDRAW_FIELD);
2659 FadeIn(REDRAW_FIELD);
2665 void HandleInfoScreen_Elements(int button)
2667 static unsigned long info_delay = 0;
2668 static int num_anims;
2669 static int num_pages;
2671 int anims_per_page = MAX_INFO_ELEMENTS_ON_SCREEN;
2674 if (button == MB_MENU_INITIALIZE)
2676 boolean new_element = TRUE;
2680 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2682 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2684 else if (new_element)
2687 new_element = FALSE;
2691 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2695 if (button == MB_MENU_LEAVE)
2697 PlaySound(SND_MENU_ITEM_SELECTING);
2699 info_mode = INFO_MODE_MAIN;
2704 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2706 if (button != MB_MENU_INITIALIZE)
2708 PlaySound(SND_MENU_ITEM_SELECTING);
2713 if (page >= num_pages)
2715 FadeSoundsAndMusic();
2719 if (fading.anim_mode == ANIM_CROSSFADE)
2720 FadeCrossSaveBackbuffer();
2722 FadeOut(REDRAW_FIELD);
2724 FadeOut(REDRAW_FIELD);
2728 info_mode = INFO_MODE_MAIN;
2729 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2734 if (button != MB_MENU_INITIALIZE)
2735 FadeCrossSaveBackbuffer();
2737 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2739 if (button != MB_MENU_INITIALIZE)
2740 FadeCross(REDRAW_FIELD);
2744 if (DelayReached(&info_delay, GameFrameDelay))
2745 if (page < num_pages)
2746 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2748 PlayMenuSoundIfLoop();
2752 void DrawInfoScreen_Music()
2754 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2757 if (fading.anim_mode == ANIM_CROSSFADE)
2758 FadeCrossSaveBackbuffer();
2760 FadeOut(REDRAW_FIELD);
2762 FadeOut(REDRAW_FIELD);
2770 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2773 if (fading.anim_mode == ANIM_CROSSFADE)
2774 FadeCross(REDRAW_FIELD);
2776 FadeIn(REDRAW_FIELD);
2778 FadeIn(REDRAW_FIELD);
2782 void HandleInfoScreen_Music(int button)
2784 static struct MusicFileInfo *list = NULL;
2785 int ystart1 = mSY - SY + 100;
2786 int ystart2 = mSY - SY + 150;
2787 int ybottom = mSY - SY + SYSIZE - 20;
2790 if (button == MB_MENU_INITIALIZE)
2792 list = music_file_info;
2796 FadeSoundsAndMusic();
2801 DrawTextSCentered(ystart1, FONT_TEXT_1,
2802 "No music info for this level set.");
2804 DrawTextSCentered(ybottom, FONT_TEXT_4,
2805 "Press any key or button for info menu");
2811 if (button == MB_MENU_LEAVE)
2813 PlaySound(SND_MENU_ITEM_SELECTING);
2815 FadeSoundsAndMusic();
2817 info_mode = INFO_MODE_MAIN;
2822 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2826 if (button != MB_MENU_INITIALIZE)
2828 PlaySound(SND_MENU_ITEM_SELECTING);
2836 FadeSoundsAndMusic();
2840 if (fading.anim_mode == ANIM_CROSSFADE)
2841 FadeCrossSaveBackbuffer();
2843 FadeOut(REDRAW_FIELD);
2845 FadeOut(REDRAW_FIELD);
2849 info_mode = INFO_MODE_MAIN;
2850 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2855 FadeSoundsAndMusic();
2857 if (button != MB_MENU_INITIALIZE)
2858 FadeCrossSaveBackbuffer();
2865 int sound = list->music;
2867 if (sound_info[sound].loop)
2868 PlaySoundLoop(sound);
2872 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2876 PlayMusic(list->music);
2878 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2881 if (!strEqual(list->title, UNKNOWN_NAME))
2883 if (!strEqual(list->title_header, UNKNOWN_NAME))
2884 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2886 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2889 if (!strEqual(list->artist, UNKNOWN_NAME))
2891 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2892 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2894 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2896 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2899 if (!strEqual(list->album, UNKNOWN_NAME))
2901 if (!strEqual(list->album_header, UNKNOWN_NAME))
2902 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2904 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2906 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2909 if (!strEqual(list->year, UNKNOWN_NAME))
2911 if (!strEqual(list->year_header, UNKNOWN_NAME))
2912 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2914 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2916 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2919 DrawTextSCentered(ybottom, FONT_TEXT_4,
2920 "Press any key or button for next page");
2922 if (button != MB_MENU_INITIALIZE)
2923 FadeCross(REDRAW_FIELD);
2926 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2927 PlaySoundLoop(list->music);
2930 static boolean DrawInfoScreen_CreditsScreen(int screen_nr)
2932 int ystart1 = mSY - SY + 100;
2933 int ystart2 = mSY - SY + 150;
2934 int ybottom = mSY - SY + SYSIZE - 20;
2943 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2947 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2948 "Special thanks to");
2949 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2951 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2953 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2954 "\"Boulder Dash\"");
2955 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2957 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2959 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2961 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2962 "First Star Software");
2964 else if (screen_nr == 1)
2966 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2967 "Special thanks to");
2968 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2969 "Klaus Heinz & Volker Wertich");
2970 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2972 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2973 "\"Emerald Mine\"");
2974 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2976 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2978 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2980 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2983 else if (screen_nr == 2)
2985 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2986 "Special thanks to");
2987 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2988 "Michael Stopp & Philip Jespersen");
2989 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2991 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2993 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2995 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2997 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2999 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
3000 "Digital Integration");
3002 else if (screen_nr == 3)
3004 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3005 "Special thanks to");
3006 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3007 "Hiroyuki Imabayashi");
3008 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3010 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3012 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3014 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3016 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3018 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
3021 else if (screen_nr == 4)
3023 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3024 "Special thanks to");
3025 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3027 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3029 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3030 "Jürgen Bonhagen");
3031 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3032 "for the continuous creation");
3033 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
3034 "of outstanding level sets");
3036 else if (screen_nr == 5)
3038 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3040 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3042 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3043 "for ideas and inspiration by");
3044 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3047 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
3049 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
3051 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3052 "for ideas and inspiration by");
3053 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3056 else if (screen_nr == 6)
3058 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3060 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3062 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3063 "for the new Emerald Mine engine");
3065 else if (screen_nr == 7)
3067 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3069 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
3071 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
3072 "for the initial DOS port");
3074 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3076 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3078 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
3079 "for some additional toons");
3081 else if (screen_nr == 8)
3083 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3084 "And not to forget:");
3085 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3087 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3088 "All those who contributed");
3089 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
3090 "levels to this game");
3091 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
3101 DrawTextSCentered(ybottom, FONT_TEXT_4,
3102 "Press any key or button for next page");
3107 void DrawInfoScreen_Credits()
3109 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
3111 FadeSoundsAndMusic();
3114 if (fading.anim_mode == ANIM_CROSSFADE)
3115 FadeCrossSaveBackbuffer();
3117 FadeOut(REDRAW_FIELD);
3119 FadeOut(REDRAW_FIELD);
3122 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3125 if (fading.anim_mode == ANIM_CROSSFADE)
3126 FadeCross(REDRAW_FIELD);
3128 FadeIn(REDRAW_FIELD);
3130 FadeIn(REDRAW_FIELD);
3134 void HandleInfoScreen_Credits(int button)
3136 static int screen_nr = 0;
3138 if (button == MB_MENU_INITIALIZE)
3142 DrawInfoScreen_CreditsScreen(screen_nr);
3144 else if (button == MB_MENU_LEAVE)
3146 PlaySound(SND_MENU_ITEM_SELECTING);
3148 info_mode = INFO_MODE_MAIN;
3153 else if (button == MB_MENU_CHOICE)
3155 boolean show_screen;
3157 PlaySound(SND_MENU_ITEM_SELECTING);
3161 FadeCrossSaveBackbuffer();
3163 show_screen = DrawInfoScreen_CreditsScreen(screen_nr);
3167 FadeCross(REDRAW_FIELD);
3171 FadeSoundsAndMusic();
3175 if (fading.anim_mode == ANIM_CROSSFADE)
3176 FadeCrossSaveBackbuffer();
3178 FadeOut(REDRAW_FIELD);
3180 FadeOut(REDRAW_FIELD);
3184 info_mode = INFO_MODE_MAIN;
3185 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3190 PlayMenuSoundIfLoop();
3194 void DrawInfoScreen_Program()
3196 int ystart1 = mSY - SY + 100;
3197 int ystart2 = mSY - SY + 150;
3198 int ybottom = mSY - SY + SYSIZE - 20;
3201 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3204 if (fading.anim_mode == ANIM_CROSSFADE)
3205 FadeCrossSaveBackbuffer();
3207 FadeOut(REDRAW_FIELD);
3209 FadeOut(REDRAW_FIELD);
3215 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
3217 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3218 "This game is Freeware!");
3219 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3220 "If you like it, send e-mail to:");
3221 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3222 PROGRAM_EMAIL_STRING);
3223 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
3224 "or SnailMail to:");
3225 DrawTextSCentered(ystart2 + 4 * ystep + 0, FONT_TEXT_3,
3227 DrawTextSCentered(ystart2 + 4 * ystep + 20, FONT_TEXT_3,
3228 "Detmolder Strasse 189");
3229 DrawTextSCentered(ystart2 + 4 * ystep + 40, FONT_TEXT_3,
3231 DrawTextSCentered(ystart2 + 4 * ystep + 60, FONT_TEXT_3,
3233 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3234 "More information and levels:");
3235 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3236 PROGRAM_WEBSITE_STRING);
3237 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3238 "If you have created new levels,");
3239 DrawTextSCentered(ystart2 + 10 * ystep, FONT_TEXT_2,
3240 "send them to me to include them!");
3241 DrawTextSCentered(ystart2 + 11 * ystep, FONT_TEXT_2,
3244 DrawTextSCentered(ybottom, FONT_TEXT_4,
3245 "Press any key or button for info menu");
3248 if (fading.anim_mode == ANIM_CROSSFADE)
3249 FadeCross(REDRAW_FIELD);
3251 FadeIn(REDRAW_FIELD);
3253 FadeIn(REDRAW_FIELD);
3257 void HandleInfoScreen_Program(int button)
3259 if (button == MB_MENU_LEAVE)
3261 PlaySound(SND_MENU_ITEM_SELECTING);
3263 info_mode = INFO_MODE_MAIN;
3268 else if (button == MB_MENU_CHOICE)
3270 PlaySound(SND_MENU_ITEM_SELECTING);
3272 FadeSoundsAndMusic();
3276 if (fading.anim_mode == ANIM_CROSSFADE)
3277 FadeCrossSaveBackbuffer();
3279 FadeOut(REDRAW_FIELD);
3281 FadeOut(REDRAW_FIELD);
3285 info_mode = INFO_MODE_MAIN;
3286 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3290 PlayMenuSoundIfLoop();
3294 void DrawInfoScreen_Version()
3296 int font_header = FONT_TEXT_3;
3297 int font_text = FONT_TEXT_2;
3298 int xstep = getFontWidth(font_text);
3299 int ystep = getFontHeight(font_text);
3300 int ystart1 = mSY - SY + 100;
3301 int ystart2 = mSY - SY + 150;
3302 int ybottom = mSY - SY + SYSIZE - 20;
3303 int xstart1 = mSX + 2 * xstep;
3304 int xstart2 = mSX + 19 * xstep;
3305 #if defined(TARGET_SDL)
3306 int xstart3 = mSX + 29 * xstep;
3307 SDL_version sdl_version_compiled;
3308 const SDL_version *sdl_version_linked;
3309 int driver_name_len = 8;
3310 char driver_name[driver_name_len];
3313 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3316 if (fading.anim_mode == ANIM_CROSSFADE)
3317 FadeCrossSaveBackbuffer();
3319 FadeOut(REDRAW_FIELD);
3321 FadeOut(REDRAW_FIELD);
3327 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
3329 DrawTextF(xstart1, ystart2, font_header, "Name");
3330 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
3333 DrawTextF(xstart1, ystart2, font_header, "Version");
3334 DrawTextF(xstart2, ystart2, font_text, getProgramFullVersionString());
3337 DrawTextF(xstart1, ystart2, font_header, "Platform");
3338 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
3341 DrawTextF(xstart1, ystart2, font_header, "Target");
3342 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
3345 DrawTextF(xstart1, ystart2, font_header, "Compile time");
3346 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
3348 #if defined(TARGET_SDL)
3349 ystart2 += 3 * ystep;
3350 DrawTextF(xstart1, ystart2, font_header, "Library");
3351 DrawTextF(xstart2, ystart2, font_header, "compiled");
3352 DrawTextF(xstart3, ystart2, font_header, "linked");
3354 SDL_VERSION(&sdl_version_compiled);
3355 sdl_version_linked = SDL_Linked_Version();
3357 ystart2 += 2 * ystep;
3358 DrawTextF(xstart1, ystart2, font_text, "SDL");
3359 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3360 sdl_version_compiled.major,
3361 sdl_version_compiled.minor,
3362 sdl_version_compiled.patch);
3363 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3364 sdl_version_linked->major,
3365 sdl_version_linked->minor,
3366 sdl_version_linked->patch);
3368 SDL_IMAGE_VERSION(&sdl_version_compiled);
3369 sdl_version_linked = IMG_Linked_Version();
3372 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
3373 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3374 sdl_version_compiled.major,
3375 sdl_version_compiled.minor,
3376 sdl_version_compiled.patch);
3377 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3378 sdl_version_linked->major,
3379 sdl_version_linked->minor,
3380 sdl_version_linked->patch);
3382 SDL_MIXER_VERSION(&sdl_version_compiled);
3383 sdl_version_linked = Mix_Linked_Version();
3386 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
3387 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3388 sdl_version_compiled.major,
3389 sdl_version_compiled.minor,
3390 sdl_version_compiled.patch);
3391 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3392 sdl_version_linked->major,
3393 sdl_version_linked->minor,
3394 sdl_version_linked->patch);
3396 SDL_NET_VERSION(&sdl_version_compiled);
3397 sdl_version_linked = SDLNet_Linked_Version();
3400 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
3401 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3402 sdl_version_compiled.major,
3403 sdl_version_compiled.minor,
3404 sdl_version_compiled.patch);
3405 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3406 sdl_version_linked->major,
3407 sdl_version_linked->minor,
3408 sdl_version_linked->patch);
3410 ystart2 += 3 * ystep;
3411 DrawTextF(xstart1, ystart2, font_header, "Driver");
3412 DrawTextF(xstart2, ystart2, font_header, "Requested");
3413 DrawTextF(xstart3, ystart2, font_header, "Used");
3415 SDL_VideoDriverName(driver_name, driver_name_len);
3417 ystart2 += 2 * ystep;
3418 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
3419 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
3420 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3422 SDL_AudioDriverName(driver_name, driver_name_len);
3425 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
3426 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
3427 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3430 DrawTextSCentered(ybottom, FONT_TEXT_4,
3431 "Press any key or button for info menu");
3434 if (fading.anim_mode == ANIM_CROSSFADE)
3435 FadeCross(REDRAW_FIELD);
3437 FadeIn(REDRAW_FIELD);
3439 FadeIn(REDRAW_FIELD);
3443 void HandleInfoScreen_Version(int button)
3445 if (button == MB_MENU_LEAVE)
3447 PlaySound(SND_MENU_ITEM_SELECTING);
3449 info_mode = INFO_MODE_MAIN;
3454 else if (button == MB_MENU_CHOICE)
3456 PlaySound(SND_MENU_ITEM_SELECTING);
3458 FadeSoundsAndMusic();
3462 if (fading.anim_mode == ANIM_CROSSFADE)
3463 FadeCrossSaveBackbuffer();
3465 FadeOut(REDRAW_FIELD);
3467 FadeOut(REDRAW_FIELD);
3471 info_mode = INFO_MODE_MAIN;
3472 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3476 PlayMenuSoundIfLoop();
3480 void DrawInfoScreen_LevelSet()
3482 struct TitleMessageInfo *tmi = &readme;
3483 char *filename = getLevelSetInfoFilename();
3485 /* if chars set to "-1", automatically determine by text and font width */
3486 if (tmi->chars == -1)
3487 tmi->chars = tmi->width / getFontWidth(tmi->font);
3489 tmi->width = tmi->chars * getFontWidth(tmi->font);
3491 /* if lines set to "-1", automatically determine by text and font height */
3492 if (tmi->lines == -1)
3493 tmi->lines = tmi->height / getFontHeight(tmi->font);
3495 tmi->height = tmi->lines * getFontHeight(tmi->font);
3497 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3500 if (fading.anim_mode == ANIM_CROSSFADE)
3501 FadeCrossSaveBackbuffer();
3503 FadeOut(REDRAW_FIELD);
3505 FadeOut(REDRAW_FIELD);
3511 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3513 if (filename != NULL)
3514 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3515 filename, tmi->font, tmi->chars, -1, tmi->lines, -1,
3516 tmi->autowrap, tmi->centered, tmi->parse_comments);
3518 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3519 "No information for this level set.");
3521 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3522 "Press any key or button for info menu");
3525 if (fading.anim_mode == ANIM_CROSSFADE)
3526 FadeCross(REDRAW_FIELD);
3528 FadeIn(REDRAW_FIELD);
3530 FadeIn(REDRAW_FIELD);
3534 void HandleInfoScreen_LevelSet(int button)
3536 if (button == MB_MENU_LEAVE)
3538 PlaySound(SND_MENU_ITEM_SELECTING);
3540 info_mode = INFO_MODE_MAIN;
3545 else if (button == MB_MENU_CHOICE)
3547 PlaySound(SND_MENU_ITEM_SELECTING);
3549 FadeSoundsAndMusic();
3553 if (fading.anim_mode == ANIM_CROSSFADE)
3554 FadeCrossSaveBackbuffer();
3556 FadeOut(REDRAW_FIELD);
3558 FadeOut(REDRAW_FIELD);
3562 info_mode = INFO_MODE_MAIN;
3563 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3567 PlayMenuSoundIfLoop();
3571 static void DrawInfoScreenExt(int redraw_mask, boolean do_fading)
3573 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3575 if (info_mode == INFO_MODE_TITLE)
3576 DrawInfoScreen_TitleScreen();
3577 else if (info_mode == INFO_MODE_ELEMENTS)
3578 DrawInfoScreen_Elements();
3579 else if (info_mode == INFO_MODE_MUSIC)
3580 DrawInfoScreen_Music();
3581 else if (info_mode == INFO_MODE_CREDITS)
3582 DrawInfoScreen_Credits();
3583 else if (info_mode == INFO_MODE_PROGRAM)
3584 DrawInfoScreen_Program();
3585 else if (info_mode == INFO_MODE_VERSION)
3586 DrawInfoScreen_Version();
3587 else if (info_mode == INFO_MODE_LEVELSET)
3588 DrawInfoScreen_LevelSet();
3590 DrawInfoScreen_Main(redraw_mask, do_fading);
3592 if (info_mode != INFO_MODE_MAIN &&
3593 info_mode != INFO_MODE_TITLE &&
3594 info_mode != INFO_MODE_MUSIC)
3601 void DrawAndFadeInInfoScreen(int redraw_mask)
3603 DrawInfoScreenExt(redraw_mask, TRUE);
3606 void DrawInfoScreen()
3608 DrawInfoScreenExt(REDRAW_ALL, FALSE);
3611 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3613 if (info_mode == INFO_MODE_TITLE)
3614 HandleInfoScreen_TitleScreen(button);
3615 else if (info_mode == INFO_MODE_ELEMENTS)
3616 HandleInfoScreen_Elements(button);
3617 else if (info_mode == INFO_MODE_MUSIC)
3618 HandleInfoScreen_Music(button);
3619 else if (info_mode == INFO_MODE_CREDITS)
3620 HandleInfoScreen_Credits(button);
3621 else if (info_mode == INFO_MODE_PROGRAM)
3622 HandleInfoScreen_Program(button);
3623 else if (info_mode == INFO_MODE_VERSION)
3624 HandleInfoScreen_Version(button);
3625 else if (info_mode == INFO_MODE_LEVELSET)
3626 HandleInfoScreen_LevelSet(button);
3628 HandleInfoScreen_Main(mx, my, dx, dy, button);
3634 /* ========================================================================= */
3635 /* type name functions */
3636 /* ========================================================================= */
3638 void HandleTypeName(int newxpos, Key key)
3640 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3641 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3643 struct TextPosInfo *pos = mci->pos_input;
3644 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3645 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3648 static int xpos = 0;
3650 static int xpos = 0, ypos = 2;
3652 int font_nr = pos->font;
3653 int font_active_nr = FONT_ACTIVE(font_nr);
3654 int font_width = getFontWidth(font_active_nr);
3657 int startx = mSX + mci->pos_input->x;
3658 int starty = mSY + mci->pos_input->y;
3661 int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
3662 int startx = mSX + 32 + name_width;
3663 int starty = mSY + ypos * 32;
3665 char key_char = getValidConfigValueChar(getCharFromKey(key));
3666 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3667 boolean is_active = TRUE;
3669 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3673 strcpy(last_player_name, setup.player_name);
3678 /* add one character width for added cursor character */
3679 pos->width += font_width;
3680 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3682 DrawText(startx, starty, setup.player_name, font_active_nr);
3683 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3686 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3688 setup.player_name[xpos] = key_char;
3689 setup.player_name[xpos + 1] = 0;
3694 /* add one character width for added name text character */
3695 pos->width += font_width;
3696 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3698 DrawText(startx, starty, setup.player_name, font_active_nr);
3699 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3702 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3706 setup.player_name[xpos] = 0;
3709 /* remove one character width for removed name text character */
3710 pos->width -= font_width;
3711 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3713 DrawText(startx, starty, setup.player_name, font_active_nr);
3714 DrawText(startx + xpos * font_width, starty, "_ ", font_active_nr);
3717 else if (key == KSYM_Return && xpos > 0)
3720 /* remove one character width for removed cursor text character */
3721 pos->width -= font_width;
3722 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3724 DrawText(startx, starty, setup.player_name, font_nr);
3725 DrawText(startx + xpos * font_width, starty, " ", font_active_nr);
3732 game_status = GAME_MODE_MAIN;
3734 else if (key == KSYM_Escape)
3736 strcpy(setup.player_name, last_player_name);
3740 game_status = GAME_MODE_MAIN;
3745 pos->width = (strlen(setup.player_name) + 1) * font_width;
3746 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3748 DrawText(startx, starty, setup.player_name, font_active_nr);
3749 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3753 pos->width = strlen(setup.player_name) * font_width;
3754 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3756 DrawText(startx, starty, setup.player_name, font_nr);
3761 /* ========================================================================= */
3762 /* tree menu functions */
3763 /* ========================================================================= */
3765 static void DrawChooseTree(TreeInfo **ti_ptr)
3769 FreeScreenGadgets();
3770 CreateScreenGadgets();
3772 CloseDoor(DOOR_CLOSE_2);
3775 if (fading.anim_mode == ANIM_CROSSFADE)
3776 FadeCrossSaveBackbuffer();
3778 FadeOut(REDRAW_FIELD);
3783 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3784 MapScreenTreeGadgets(*ti_ptr);
3787 if (fading.anim_mode == ANIM_CROSSFADE)
3788 FadeCross(redraw_mask);
3790 FadeIn(redraw_mask);
3798 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3800 struct GadgetInfo *gi = screen_gadget[id];
3801 int items_max, items_visible, item_position;
3803 items_max = numTreeInfoInGroup(ti);
3804 items_visible = NUM_MENU_ENTRIES_ON_SCREEN;
3805 item_position = first_entry;
3807 if (item_position > items_max - items_visible)
3808 item_position = items_max - items_visible;
3810 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3811 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3812 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3815 static void drawChooseTreeList(int first_entry, int num_page_entries,
3819 char *title_string = NULL;
3820 int yoffset_sets = MENU_TITLE1_YPOS;
3821 int yoffset_setup = 16;
3822 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? yoffset_sets :
3824 int last_game_status = game_status; /* save current game status */
3826 title_string = ti->infotext;
3828 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3830 /* force LEVELS font on artwork setup screen */
3831 game_status = GAME_MODE_LEVELS;
3834 /* clear tree list area, but not title or scrollbar */
3835 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3836 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3837 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3839 /* clear tree list area, but not title or scrollbar */
3840 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3841 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3842 MAX_MENU_ENTRIES_ON_SCREEN * 32);
3845 for (i = 0; i < num_page_entries; i++)
3847 TreeInfo *node, *node_first;
3848 int entry_pos = first_entry + i;
3849 int xpos = MENU_SCREEN_START_XPOS;
3850 int ypos = MENU_SCREEN_START_YPOS + i;
3851 int startx = mSX + xpos * 32;
3852 int starty = mSY + ypos * 32;
3853 int font_nr = FONT_TEXT_1;
3854 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3855 int startx_text = startx + font_xoffset;
3856 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3857 int text_size = startx_scrollbar - startx_text;
3858 int max_buffer_len = text_size / getFontWidth(font_nr);
3859 char buffer[max_buffer_len + 1];
3861 node_first = getTreeInfoFirstGroupEntry(ti);
3862 node = getTreeInfoFromPos(node_first, entry_pos);
3864 strncpy(buffer, node->name, max_buffer_len);
3865 buffer[max_buffer_len] = '\0';
3867 DrawText(startx, starty, buffer, font_nr + node->color);
3869 if (node->parent_link)
3870 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3871 else if (node->level_group)
3872 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3874 initCursor(i, IMG_MENU_BUTTON);
3877 game_status = last_game_status; /* restore current game status */
3879 redraw_mask |= REDRAW_FIELD;
3882 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3884 TreeInfo *node, *node_first;
3885 int x, last_redraw_mask = redraw_mask;
3886 int ypos = MENU_TITLE2_YPOS;
3887 int font_nr = FONT_TITLE_2;
3889 if (ti->type != TREE_TYPE_LEVEL_DIR)
3892 node_first = getTreeInfoFirstGroupEntry(ti);
3893 node = getTreeInfoFromPos(node_first, entry_pos);
3895 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3897 if (node->parent_link)
3898 DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
3900 else if (node->level_group)
3901 DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
3903 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3904 DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
3905 node->levels, node->class_desc);
3907 /* let BackToFront() redraw only what is needed */
3908 redraw_mask = last_redraw_mask | REDRAW_TILES;
3909 for (x = 0; x < SCR_FIELDX; x++)
3910 MarkTileDirty(x, 1);
3913 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3916 TreeInfo *ti = *ti_ptr;
3918 int y = ti->cl_cursor;
3919 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3920 int num_entries = numTreeInfoInGroup(ti);
3921 int num_page_entries;
3922 int last_game_status = game_status; /* save current game status */
3923 boolean position_set_by_scrollbar = (dx == 999);
3925 /* force LEVELS draw offset on choose level and artwork setup screen */
3926 game_status = GAME_MODE_LEVELS;
3928 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3929 num_page_entries = num_entries;
3931 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3933 game_status = last_game_status; /* restore current game status */
3935 if (button == MB_MENU_INITIALIZE)
3937 int num_entries = numTreeInfoInGroup(ti);
3938 int entry_pos = posTreeInfo(ti);
3940 if (ti->cl_first == -1)
3942 /* only on initialization */
3943 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3944 ti->cl_cursor = entry_pos - ti->cl_first;
3946 else if (ti->cl_cursor >= num_page_entries ||
3947 (num_entries > num_page_entries &&
3948 num_entries - ti->cl_first < num_page_entries))
3950 /* only after change of list size (by custom graphic configuration) */
3951 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3952 ti->cl_cursor = entry_pos - ti->cl_first;
3955 if (position_set_by_scrollbar)
3958 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3961 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3962 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3963 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3967 else if (button == MB_MENU_LEAVE)
3969 PlaySound(SND_MENU_ITEM_SELECTING);
3971 if (ti->node_parent)
3973 *ti_ptr = ti->node_parent;
3974 DrawChooseTree(ti_ptr);
3976 else if (game_status == GAME_MODE_SETUP)
3978 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
3980 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
3981 execSetupGraphics();
3987 game_status = GAME_MODE_MAIN;
3989 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3998 if (mx || my) /* mouse input */
4000 int last_game_status = game_status; /* save current game status */
4002 /* force LEVELS draw offset on artwork setup screen */
4003 game_status = GAME_MODE_LEVELS;
4005 x = (mx - mSX) / 32;
4006 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
4008 game_status = last_game_status; /* restore current game status */
4010 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
4012 /* move cursor instead of scrolling when already at start/end of list */
4013 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
4015 else if (dy == +1 * SCROLL_LINE &&
4016 ti->cl_first + num_page_entries == num_entries)
4019 /* handle scrolling screen one line or page */
4020 if (ti->cl_cursor + dy < 0 ||
4021 ti->cl_cursor + dy > num_page_entries - 1)
4023 if (ABS(dy) == SCROLL_PAGE)
4024 step = num_page_entries - 1;
4026 if (dy < 0 && ti->cl_first > 0)
4028 /* scroll page/line up */
4030 ti->cl_first -= step;
4031 if (ti->cl_first < 0)
4034 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
4035 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
4036 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4038 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
4041 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
4043 /* scroll page/line down */
4045 ti->cl_first += step;
4046 if (ti->cl_first + num_page_entries > num_entries)
4047 ti->cl_first = MAX(0, num_entries - num_page_entries);
4049 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
4050 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
4051 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4053 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
4060 /* handle moving cursor one line */
4061 y = ti->cl_cursor + dy;
4066 TreeInfo *node_first, *node_cursor;
4067 int entry_pos = ti->cl_first + y;
4069 node_first = getTreeInfoFirstGroupEntry(ti);
4070 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4072 if (node_cursor->node_group)
4074 PlaySound(SND_MENU_ITEM_SELECTING);
4076 node_cursor->cl_first = ti->cl_first;
4077 node_cursor->cl_cursor = ti->cl_cursor;
4078 *ti_ptr = node_cursor->node_group;
4079 DrawChooseTree(ti_ptr);
4084 else if (dx == -1 && ti->node_parent)
4086 PlaySound(SND_MENU_ITEM_SELECTING);
4088 *ti_ptr = ti->node_parent;
4089 DrawChooseTree(ti_ptr);
4094 if (!anyScrollbarGadgetActive() &&
4095 IN_VIS_FIELD(x, y) &&
4096 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
4097 y >= 0 && y < num_page_entries)
4101 if (y != ti->cl_cursor)
4103 PlaySound(SND_MENU_ITEM_ACTIVATING);
4105 drawChooseTreeCursor(ti->cl_cursor, FALSE);
4106 drawChooseTreeCursor(y, TRUE);
4107 drawChooseTreeInfo(ti->cl_first + y, ti);
4114 TreeInfo *node_first, *node_cursor;
4115 int entry_pos = ti->cl_first + y;
4117 PlaySound(SND_MENU_ITEM_SELECTING);
4119 node_first = getTreeInfoFirstGroupEntry(ti);
4120 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4122 if (node_cursor->node_group)
4124 node_cursor->cl_first = ti->cl_first;
4125 node_cursor->cl_cursor = ti->cl_cursor;
4126 *ti_ptr = node_cursor->node_group;
4127 DrawChooseTree(ti_ptr);
4129 else if (node_cursor->parent_link)
4131 *ti_ptr = node_cursor->node_parent;
4132 DrawChooseTree(ti_ptr);
4136 node_cursor->cl_first = ti->cl_first;
4137 node_cursor->cl_cursor = ti->cl_cursor;
4138 *ti_ptr = node_cursor;
4140 if (ti->type == TREE_TYPE_LEVEL_DIR)
4142 LoadLevelSetup_SeriesInfo();
4144 SaveLevelSetup_LastSeries();
4145 SaveLevelSetup_SeriesInfo();
4149 if (game_status == GAME_MODE_SETUP)
4151 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
4153 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
4154 execSetupGraphics();
4160 game_status = GAME_MODE_MAIN;
4168 void DrawChooseLevel()
4170 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
4172 DrawChooseTree(&leveldir_current);
4178 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
4180 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4185 void DrawHallOfFame(int highlight_position)
4188 FadeSoundsAndMusic();
4190 /* (this is needed when called from GameEnd() after winning a game) */
4191 KeyboardAutoRepeatOn();
4194 /* (this is needed when called from GameEnd() after winning a game) */
4195 SetDrawDeactivationMask(REDRAW_NONE);
4196 SetDrawBackgroundMask(REDRAW_FIELD);
4198 CloseDoor(DOOR_CLOSE_2);
4200 if (highlight_position < 0)
4201 LoadScore(level_nr);
4203 fading = menu.destination;
4206 if (fading.anim_mode == ANIM_CROSSFADE)
4207 FadeCrossSaveBackbuffer();
4209 FadeOut(REDRAW_FIELD);
4211 FadeOut(REDRAW_FIELD);
4219 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4222 if (fading.anim_mode == ANIM_CROSSFADE)
4223 FadeCross(REDRAW_FIELD);
4225 FadeIn(REDRAW_FIELD);
4227 FadeIn(REDRAW_FIELD);
4231 static void drawHallOfFameList(int first_entry, int highlight_position)
4235 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4238 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4239 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4240 "HighScores of Level %d", level_nr);
4242 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4244 int entry = first_entry + i;
4245 boolean active = (entry == highlight_position);
4246 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4247 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4248 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4249 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4250 int dx1 = 3 * getFontWidth(font_nr1);
4251 int dx2 = dx1 + getFontWidth(font_nr1);
4252 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
4253 int sy = mSY + 64 + i * 32;
4255 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4256 DrawText(mSX + dx1, sy, ".", font_nr1);
4257 DrawText(mSX + dx2, sy, ".........................", font_nr3);
4259 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4260 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4262 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4265 redraw_mask |= REDRAW_FIELD;
4268 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4270 static int first_entry = 0;
4271 static int highlight_position = 0;
4272 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4274 if (button == MB_MENU_INITIALIZE)
4277 highlight_position = mx;
4278 drawHallOfFameList(first_entry, highlight_position);
4283 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4284 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4288 if (first_entry > 0)
4290 first_entry -= step;
4291 if (first_entry < 0)
4294 drawHallOfFameList(first_entry, highlight_position);
4299 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4301 first_entry += step;
4302 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4303 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4305 drawHallOfFameList(first_entry, highlight_position);
4308 else if (button == MB_MENU_LEAVE)
4310 PlaySound(SND_MENU_ITEM_SELECTING);
4312 FadeSound(SND_BACKGROUND_SCORES);
4314 game_status = GAME_MODE_MAIN;
4318 else if (button == MB_MENU_CHOICE)
4320 PlaySound(SND_MENU_ITEM_SELECTING);
4322 FadeSound(SND_BACKGROUND_SCORES);
4326 if (fading.anim_mode == ANIM_CROSSFADE)
4327 FadeCrossSaveBackbuffer();
4329 FadeOut(REDRAW_FIELD);
4331 FadeOut(REDRAW_FIELD);
4335 game_status = GAME_MODE_MAIN;
4337 DrawAndFadeInMainMenu(REDRAW_FIELD);
4340 if (game_status == GAME_MODE_SCORES)
4341 PlayMenuSoundIfLoop();
4347 /* ========================================================================= */
4348 /* setup screen functions */
4349 /* ========================================================================= */
4351 static struct TokenInfo *setup_info;
4352 static int num_setup_info;
4354 static char *screen_mode_text;
4355 static char *game_speed_text;
4356 static char *graphics_set_name;
4357 static char *sounds_set_name;
4358 static char *music_set_name;
4360 static void execSetupMain()
4362 setup_mode = SETUP_MODE_MAIN;
4366 static void execSetupGame()
4368 if (game_speeds == NULL)
4372 for (i = 0; game_speeds_list[i].value != -1; i++)
4374 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4375 char identifier[32], name[32];
4376 int value = game_speeds_list[i].value;
4377 char *text = game_speeds_list[i].text;
4379 ti->node_top = &game_speeds;
4380 ti->sort_priority = 10000 - value;
4382 sprintf(identifier, "%d", value);
4383 sprintf(name, "%s", text);
4385 setString(&ti->identifier, identifier);
4386 setString(&ti->name, name);
4387 setString(&ti->name_sorting, name);
4388 setString(&ti->infotext, "Game Speed");
4390 pushTreeInfo(&game_speeds, ti);
4393 /* sort game speed values to start with slowest game speed */
4394 sortTreeInfo(&game_speeds);
4396 /* set current game speed to configured game speed value */
4397 game_speed_current =
4398 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4400 /* if that fails, set current game speed to reliable default value */
4401 if (game_speed_current == NULL)
4402 game_speed_current =
4403 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4405 /* if that also fails, set current game speed to first available speed */
4406 if (game_speed_current == NULL)
4407 game_speed_current = game_speeds;
4410 setup.game_frame_delay = atoi(game_speed_current->identifier);
4412 /* needed for displaying game speed text instead of identifier */
4413 game_speed_text = game_speed_current->name;
4415 setup_mode = SETUP_MODE_GAME;
4419 static void execSetupChooseGameSpeed()
4421 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4425 static void execSetupEditor()
4427 setup_mode = SETUP_MODE_EDITOR;
4431 static void execSetupGraphics()
4433 if (video.fullscreen_available && screen_modes == NULL)
4437 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4439 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4440 char identifier[32], name[32];
4441 int x = video.fullscreen_modes[i].width;
4442 int y = video.fullscreen_modes[i].height;
4445 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4447 ti->node_top = &screen_modes;
4448 ti->sort_priority = x * 10000 + y;
4450 sprintf(identifier, "%dx%d", x, y);
4451 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4453 setString(&ti->identifier, identifier);
4454 setString(&ti->name, name);
4455 setString(&ti->name_sorting, name);
4456 setString(&ti->infotext, "Fullscreen Mode");
4458 pushTreeInfo(&screen_modes, ti);
4461 /* sort fullscreen modes to start with lowest available screen resolution */
4462 sortTreeInfo(&screen_modes);
4464 /* set current screen mode for fullscreen mode to configured setup value */
4465 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4466 setup.fullscreen_mode);
4468 /* if that fails, set current screen mode to reliable default value */
4469 if (screen_mode_current == NULL)
4470 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4471 DEFAULT_FULLSCREEN_MODE);
4473 /* if that also fails, set current screen mode to first available mode */
4474 if (screen_mode_current == NULL)
4475 screen_mode_current = screen_modes;
4477 if (screen_mode_current == NULL)
4478 video.fullscreen_available = FALSE;
4481 if (video.fullscreen_available)
4483 setup.fullscreen_mode = screen_mode_current->identifier;
4485 /* needed for displaying screen mode name instead of identifier */
4486 screen_mode_text = screen_mode_current->name;
4489 setup_mode = SETUP_MODE_GRAPHICS;
4493 static void execSetupChooseScreenMode()
4495 if (!video.fullscreen_available)
4498 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4502 static void execSetupSound()
4504 setup_mode = SETUP_MODE_SOUND;
4508 static void execSetupArtwork()
4510 setup.graphics_set = artwork.gfx_current->identifier;
4511 setup.sounds_set = artwork.snd_current->identifier;
4512 setup.music_set = artwork.mus_current->identifier;
4514 /* needed if last screen (setup choice) changed graphics, sounds or music */
4515 ReloadCustomArtwork(0);
4517 /* needed for displaying artwork name instead of artwork identifier */
4518 graphics_set_name = artwork.gfx_current->name;
4519 sounds_set_name = artwork.snd_current->name;
4520 music_set_name = artwork.mus_current->name;
4522 setup_mode = SETUP_MODE_ARTWORK;
4526 static void execSetupChooseGraphics()
4528 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4532 static void execSetupChooseSounds()
4534 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4538 static void execSetupChooseMusic()
4540 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4544 static void execSetupInput()
4546 setup_mode = SETUP_MODE_INPUT;
4550 static void execSetupShortcut1()
4552 setup_mode = SETUP_MODE_SHORTCUT_1;
4556 static void execSetupShortcut2()
4558 setup_mode = SETUP_MODE_SHORTCUT_2;
4562 static void execExitSetup()
4564 game_status = GAME_MODE_MAIN;
4566 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4572 static void execSaveAndExitSetup()
4578 static struct TokenInfo setup_info_main[] =
4580 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4581 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4582 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4583 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4584 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4585 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4586 { TYPE_ENTER_MENU, execSetupShortcut1, "Key Shortcuts 1" },
4587 { TYPE_ENTER_MENU, execSetupShortcut2, "Key Shortcuts 2" },
4588 { TYPE_EMPTY, NULL, "" },
4589 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4590 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4595 static struct TokenInfo setup_info_game[] =
4597 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4598 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4599 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4600 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4601 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4602 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4603 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4604 { TYPE_STRING, &game_speed_text, "" },
4605 { TYPE_EMPTY, NULL, "" },
4606 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4611 static struct TokenInfo setup_info_editor[] =
4614 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4615 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4616 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4617 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4618 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4619 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4620 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4621 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4623 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4624 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4625 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4627 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4629 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4630 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4631 { TYPE_EMPTY, NULL, "" },
4633 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4634 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4635 { TYPE_EMPTY, NULL, "" },
4637 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4638 { TYPE_EMPTY, NULL, "" },
4639 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4644 static struct TokenInfo setup_info_graphics[] =
4646 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4647 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4648 { TYPE_STRING, &screen_mode_text, "" },
4649 { TYPE_SWITCH, &setup.scroll_delay, "Delayed Scrolling:" },
4651 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" },
4652 { TYPE_SWITCH, &setup.double_buffering,"Double-Buffering:" },
4654 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4655 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4656 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4657 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4658 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4659 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4660 { TYPE_EMPTY, NULL, "" },
4661 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4666 static struct TokenInfo setup_info_sound[] =
4668 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4669 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4670 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4671 { TYPE_EMPTY, NULL, "" },
4672 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4677 static struct TokenInfo setup_info_artwork[] =
4679 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4680 { TYPE_STRING, &graphics_set_name, "" },
4681 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4682 { TYPE_STRING, &sounds_set_name, "" },
4683 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4684 { TYPE_STRING, &music_set_name, "" },
4685 { TYPE_EMPTY, NULL, "" },
4687 { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
4688 { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:" },
4689 { TYPE_YES_NO, &setup.override_level_music, "Override Level Music:" },
4691 { TYPE_STRING, NULL, "Override Level Artwork:"},
4692 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
4693 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
4694 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
4696 { TYPE_EMPTY, NULL, "" },
4697 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4702 static struct TokenInfo setup_info_input[] =
4704 { TYPE_SWITCH, NULL, "Player:" },
4705 { TYPE_SWITCH, NULL, "Device:" },
4706 { TYPE_ENTER_MENU, NULL, "" },
4707 { TYPE_EMPTY, NULL, "" },
4708 { TYPE_EMPTY, NULL, "" },
4709 { TYPE_EMPTY, NULL, "" },
4710 { TYPE_EMPTY, NULL, "" },
4711 { TYPE_EMPTY, NULL, "" },
4712 { TYPE_EMPTY, NULL, "" },
4713 { TYPE_EMPTY, NULL, "" },
4714 { TYPE_EMPTY, NULL, "" },
4715 { TYPE_EMPTY, NULL, "" },
4716 { TYPE_EMPTY, NULL, "" },
4717 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4722 static struct TokenInfo setup_info_shortcut_1[] =
4724 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4725 { TYPE_KEY, &setup.shortcut.save_game, "" },
4726 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4727 { TYPE_KEY, &setup.shortcut.load_game, "" },
4728 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4729 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4730 { TYPE_EMPTY, NULL, "" },
4731 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4732 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4733 { TYPE_EMPTY, NULL, "" },
4734 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4739 static struct TokenInfo setup_info_shortcut_2[] =
4741 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4742 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4743 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4744 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4745 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4746 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4747 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4748 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4749 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4750 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4751 { TYPE_EMPTY, NULL, "" },
4752 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4757 static Key getSetupKey()
4759 Key key = KSYM_UNDEFINED;
4760 boolean got_key_event = FALSE;
4762 while (!got_key_event)
4764 if (PendingEvent()) /* got event */
4772 case EVENT_KEYPRESS:
4774 key = GetEventKey((KeyEvent *)&event, TRUE);
4776 /* press 'Escape' or 'Enter' to keep the existing key binding */
4777 if (key == KSYM_Escape || key == KSYM_Return)
4778 key = KSYM_UNDEFINED; /* keep old value */
4780 got_key_event = TRUE;
4784 case EVENT_KEYRELEASE:
4785 key_joystick_mapping = 0;
4789 HandleOtherEvents(&event);
4797 /* don't eat all CPU time */
4804 static int getSetupTextFont(int type)
4806 if (type & (TYPE_SWITCH |
4817 static int getSetupValueFont(int type, void *value)
4819 if (type & TYPE_KEY)
4820 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
4821 else if (type & TYPE_STRING)
4822 return FONT_VALUE_2;
4823 else if (type & TYPE_ECS_AGA)
4824 return FONT_VALUE_1;
4825 else if (type & TYPE_BOOLEAN_STYLE)
4826 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
4828 return FONT_VALUE_1;
4831 static void drawSetupValue(int pos)
4833 boolean font_draw_xoffset_modified = FALSE;
4834 int font_draw_xoffset_old = -1;
4835 int xpos = MENU_SCREEN_VALUE_XPOS;
4836 int ypos = MENU_SCREEN_START_YPOS + pos;
4837 int startx = mSX + xpos * 32;
4838 int starty = mSY + ypos * 32;
4839 int font_nr, font_width;
4840 int type = setup_info[pos].type;
4841 void *value = setup_info[pos].value;
4842 char *value_string = getSetupValue(type, value);
4845 if (value_string == NULL)
4848 if (type & TYPE_KEY)
4850 xpos = MENU_SCREEN_START_XPOS;
4852 if (type & TYPE_QUERY)
4854 value_string = "<press key>";
4857 else if (type & TYPE_STRING)
4859 int max_value_len = (SCR_FIELDX - 2) * 2;
4861 xpos = MENU_SCREEN_START_XPOS;
4863 if (strlen(value_string) > max_value_len)
4864 value_string[max_value_len] = '\0';
4867 startx = mSX + xpos * 32;
4868 starty = mSY + ypos * 32;
4869 font_nr = getSetupValueFont(type, value);
4870 font_width = getFontWidth(font_nr);
4872 /* downward compatibility correction for Juergen Bonhagen's menu settings */
4873 if (setup_mode != SETUP_MODE_INPUT)
4875 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
4876 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
4877 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
4878 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
4879 int text_font_nr = getSetupTextFont(FONT_MENU_2);
4880 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
4881 int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr);
4882 boolean correct_font_draw_xoffset = FALSE;
4884 if (xpos == MENU_SCREEN_START_XPOS &&
4885 startx + font1_xoffset < text_startx + text_font_xoffset)
4886 correct_font_draw_xoffset = TRUE;
4888 if (xpos == MENU_SCREEN_VALUE_XPOS &&
4889 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
4890 correct_font_draw_xoffset = TRUE;
4892 /* check if setup value would overlap with setup text when printed */
4893 /* (this can happen for extreme/wrong values for font draw offset) */
4894 if (correct_font_draw_xoffset)
4896 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
4897 font_draw_xoffset_modified = TRUE;
4899 if (type & TYPE_KEY)
4900 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
4901 else if (!(type & TYPE_STRING))
4902 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
4903 MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
4907 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
4908 DrawText(startx + i * font_width, starty, " ", font_nr);
4910 DrawText(startx, starty, value_string, font_nr);
4912 if (font_draw_xoffset_modified)
4913 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
4916 static void changeSetupValue(int pos)
4918 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
4920 *(boolean *)setup_info[pos].value ^= TRUE;
4922 else if (setup_info[pos].type & TYPE_KEY)
4926 setup_info[pos].type |= TYPE_QUERY;
4927 drawSetupValue(pos);
4928 setup_info[pos].type &= ~TYPE_QUERY;
4930 key = getSetupKey();
4931 if (key != KSYM_UNDEFINED)
4932 *(Key *)setup_info[pos].value = key;
4935 drawSetupValue(pos);
4938 static void DrawCursorAndText_Setup(int pos, boolean active)
4940 int xpos = MENU_SCREEN_START_XPOS;
4941 int ypos = MENU_SCREEN_START_YPOS + pos;
4942 int font_nr = getSetupTextFont(setup_info[pos].type);
4944 if (setup_info == setup_info_input)
4945 font_nr = FONT_MENU_1;
4948 font_nr = FONT_ACTIVE(font_nr);
4950 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
4952 if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
4953 drawCursor(pos, active);
4956 static void DrawSetupScreen_Generic()
4958 char *title_string = NULL;
4962 CloseDoor(DOOR_CLOSE_2);
4965 if (fading.anim_mode == ANIM_CROSSFADE)
4966 FadeCrossSaveBackbuffer();
4968 FadeOut(REDRAW_FIELD);
4973 if (setup_mode == SETUP_MODE_MAIN)
4975 setup_info = setup_info_main;
4976 title_string = "Setup";
4978 else if (setup_mode == SETUP_MODE_GAME)
4980 setup_info = setup_info_game;
4981 title_string = "Setup Game";
4983 else if (setup_mode == SETUP_MODE_EDITOR)
4985 setup_info = setup_info_editor;
4986 title_string = "Setup Editor";
4988 else if (setup_mode == SETUP_MODE_GRAPHICS)
4990 setup_info = setup_info_graphics;
4991 title_string = "Setup Graphics";
4993 else if (setup_mode == SETUP_MODE_SOUND)
4995 setup_info = setup_info_sound;
4996 title_string = "Setup Sound";
4998 else if (setup_mode == SETUP_MODE_ARTWORK)
5000 setup_info = setup_info_artwork;
5001 title_string = "Custom Artwork";
5003 else if (setup_mode == SETUP_MODE_SHORTCUT_1)
5005 setup_info = setup_info_shortcut_1;
5006 title_string = "Setup Shortcuts";
5008 else if (setup_mode == SETUP_MODE_SHORTCUT_2)
5010 setup_info = setup_info_shortcut_2;
5011 title_string = "Setup Shortcuts";
5014 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5017 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5019 void *value_ptr = setup_info[i].value;
5022 int xpos = MENU_SCREEN_START_XPOS;
5023 int ypos = MENU_SCREEN_START_YPOS + i;
5027 /* set some entries to "unchangeable" according to other variables */
5028 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5029 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5030 (value_ptr == &setup.sound_music && !audio.music_available) ||
5031 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5032 (value_ptr == &screen_mode_text && !video.fullscreen_available))
5033 setup_info[i].type |= TYPE_GHOSTED;
5035 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5036 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5037 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5038 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5039 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5040 initCursor(i, IMG_MENU_BUTTON);
5043 DrawCursorAndText_Setup(i, FALSE);
5045 font_nr = getSetupTextFont(setup_info[i].type);
5047 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr);
5050 if (setup_info[i].type & TYPE_VALUE)
5057 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5058 "Joysticks deactivated in setup menu");
5062 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5066 if (fading.anim_mode == ANIM_CROSSFADE)
5067 FadeCross(redraw_mask);
5069 FadeIn(redraw_mask);
5076 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5080 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5082 static int choice_store[MAX_SETUP_MODES];
5083 int choice = choice_store[setup_mode]; /* always starts with 0 */
5087 if (button == MB_MENU_INITIALIZE)
5089 /* advance to first valid menu entry */
5090 while (choice < num_setup_info &&
5091 setup_info[choice].type & TYPE_SKIP_ENTRY)
5093 choice_store[setup_mode] = choice;
5096 DrawCursorAndText_Setup(choice, TRUE);
5098 drawCursor(choice, TRUE);
5103 else if (button == MB_MENU_LEAVE)
5105 PlaySound(SND_MENU_ITEM_SELECTING);
5107 for (y = 0; y < num_setup_info; y++)
5109 if (setup_info[y].type & TYPE_LEAVE_MENU)
5111 void (*menu_callback_function)(void) = setup_info[y].value;
5113 menu_callback_function();
5115 break; /* absolutely needed because function changes 'setup_info'! */
5122 if (mx || my) /* mouse input */
5124 x = (mx - mSX) / 32;
5125 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5127 else if (dx || dy) /* keyboard input */
5131 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5133 if (setup_info[choice].type & menu_navigation_type ||
5134 setup_info[choice].type & TYPE_BOOLEAN_STYLE)
5135 button = MB_MENU_CHOICE;
5140 /* jump to next non-empty menu entry (up or down) */
5141 while (y > 0 && y < num_setup_info - 1 &&
5142 setup_info[y].type & TYPE_SKIP_ENTRY)
5146 if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
5150 if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
5152 PlaySound(SND_MENU_ITEM_ACTIVATING);
5155 DrawCursorAndText_Setup(choice, FALSE);
5156 DrawCursorAndText_Setup(y, TRUE);
5158 drawCursor(choice, FALSE);
5159 drawCursor(y, TRUE);
5162 choice = choice_store[setup_mode] = y;
5165 else if (!(setup_info[y].type & TYPE_GHOSTED))
5167 PlaySound(SND_MENU_ITEM_SELECTING);
5169 /* when selecting key headline, execute function for key value change */
5170 if (setup_info[y].type & TYPE_KEYTEXT &&
5171 setup_info[y + 1].type & TYPE_KEY)
5174 /* when selecting string value, execute function for list selection */
5175 if (setup_info[y].type & TYPE_STRING && y > 0 &&
5176 setup_info[y - 1].type & TYPE_ENTER_LIST)
5179 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
5181 void (*menu_callback_function)(void) = setup_info[y].value;
5183 menu_callback_function();
5187 if (setup_info[y].type & TYPE_VALUE)
5188 changeSetupValue(y);
5194 void DrawSetupScreen_Input()
5201 if (fading.anim_mode == ANIM_CROSSFADE)
5202 FadeCrossSaveBackbuffer();
5204 FadeOut(REDRAW_FIELD);
5210 setup_info = setup_info_input;
5213 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5216 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5218 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5219 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5220 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5221 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5222 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5223 initCursor(i, IMG_MENU_BUTTON);
5225 DrawCursorAndText_Setup(i, FALSE);
5228 initCursor(0, IMG_MENU_BUTTON);
5229 initCursor(1, IMG_MENU_BUTTON);
5230 initCursor(2, IMG_MENU_BUTTON_ENTER_MENU);
5231 initCursor(13, IMG_MENU_BUTTON_LEAVE_MENU);
5233 DrawText(mSX + 32, mSY + 2 * 32, "Player:", FONT_MENU_1);
5234 DrawText(mSX + 32, mSY + 3 * 32, "Device:", FONT_MENU_1);
5235 DrawText(mSX + 32, mSY + 15 * 32, "Back", FONT_MENU_1);
5239 DeactivateJoystickForCalibration();
5242 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
5243 "Joysticks deactivated on this screen");
5246 /* create gadgets for setup input menu screen */
5247 FreeScreenGadgets();
5248 CreateScreenGadgets();
5250 /* map gadgets for setup input menu screen */
5251 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5253 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5256 if (fading.anim_mode == ANIM_CROSSFADE)
5257 FadeCross(redraw_mask);
5259 FadeIn(redraw_mask);
5267 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5269 if (device_name == NULL)
5272 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5275 if (strlen(device_name) > 1)
5277 char c1 = device_name[strlen(device_name) - 1];
5278 char c2 = device_name[strlen(device_name) - 2];
5280 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5281 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5284 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5285 strlen(device_name));
5288 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5291 static struct SetupKeyboardInfo custom_key;
5298 { &custom_key.left, "Joystick Left" },
5299 { &custom_key.right, "Joystick Right" },
5300 { &custom_key.up, "Joystick Up" },
5301 { &custom_key.down, "Joystick Down" },
5302 { &custom_key.snap, "Button 1" },
5303 { &custom_key.drop, "Button 2" }
5305 static char *joystick_name[MAX_PLAYERS] =
5312 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5316 custom_key = setup.input[player_nr].key;
5318 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5319 FONT_INPUT_1_ACTIVE);
5321 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5323 DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5324 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5326 if (setup.input[player_nr].use_joystick)
5328 char *device_name = setup.input[player_nr].joy.device_name;
5329 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5330 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5332 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5333 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5337 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5338 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5341 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5343 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5344 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5345 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5346 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5348 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5349 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5350 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5351 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5352 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5353 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5355 for (i = 0; i < 6; i++)
5357 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5359 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5361 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5362 (setup.input[player_nr].use_joystick ?
5364 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5368 static int input_player_nr = 0;
5370 void HandleSetupScreen_Input_Player(int step, int direction)
5372 int old_player_nr = input_player_nr;
5375 new_player_nr = old_player_nr + step * direction;
5376 if (new_player_nr < 0)
5378 if (new_player_nr > MAX_PLAYERS - 1)
5379 new_player_nr = MAX_PLAYERS - 1;
5381 if (new_player_nr != old_player_nr)
5383 input_player_nr = new_player_nr;
5385 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5389 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5391 static int choice = 0;
5394 int pos_start = SETUPINPUT_SCREEN_POS_START;
5395 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5396 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5397 int pos_end = SETUPINPUT_SCREEN_POS_END;
5399 if (button == MB_MENU_INITIALIZE)
5401 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5404 DrawCursorAndText_Setup(choice, TRUE);
5406 drawCursor(choice, TRUE);
5411 else if (button == MB_MENU_LEAVE)
5413 setup_mode = SETUP_MODE_MAIN;
5420 if (mx || my) /* mouse input */
5422 x = (mx - mSX) / 32;
5423 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5425 else if (dx || dy) /* keyboard input */
5427 if (dx && choice == 0)
5428 x = (dx < 0 ? 10 : 12);
5429 else if ((dx && choice == 1) ||
5430 (dx == +1 && choice == 2) ||
5431 (dx == -1 && choice == pos_end))
5432 button = MB_MENU_CHOICE;
5436 if (y >= pos_empty1 && y <= pos_empty2)
5437 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5440 if (y == 0 && dx != 0 && button)
5442 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5444 else if (IN_VIS_FIELD(x, y) &&
5445 y >= pos_start && y <= pos_end &&
5446 !(y >= pos_empty1 && y <= pos_empty2))
5453 DrawCursorAndText_Setup(choice, FALSE);
5454 DrawCursorAndText_Setup(y, TRUE);
5456 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5458 drawCursor(choice, FALSE);
5459 drawCursor(y, TRUE);
5469 char *device_name = setup.input[input_player_nr].joy.device_name;
5471 if (!setup.input[input_player_nr].use_joystick)
5473 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5475 setJoystickDeviceToNr(device_name, new_device_nr);
5476 setup.input[input_player_nr].use_joystick = TRUE;
5480 int device_nr = getJoystickNrFromDeviceName(device_name);
5481 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5483 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5484 setup.input[input_player_nr].use_joystick = FALSE;
5486 setJoystickDeviceToNr(device_name, new_device_nr);
5489 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5493 if (setup.input[input_player_nr].use_joystick)
5496 CalibrateJoystick(input_player_nr);
5499 CustomizeKeyboard(input_player_nr);
5501 else if (y == pos_end)
5505 setup_mode = SETUP_MODE_MAIN;
5512 void CustomizeKeyboard(int player_nr)
5516 boolean finished = FALSE;
5517 static struct SetupKeyboardInfo custom_key;
5522 } customize_step[] =
5524 { &custom_key.left, "Move Left" },
5525 { &custom_key.right, "Move Right" },
5526 { &custom_key.up, "Move Up" },
5527 { &custom_key.down, "Move Down" },
5528 { &custom_key.snap, "Snap Field" },
5529 { &custom_key.drop, "Drop Element" }
5532 /* read existing key bindings from player setup */
5533 custom_key = setup.input[player_nr].key;
5537 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5543 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5544 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5545 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5546 "Key:", FONT_INPUT_1_ACTIVE);
5547 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5548 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5552 if (PendingEvent()) /* got event */
5560 case EVENT_KEYPRESS:
5562 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5564 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5570 /* all keys configured -- wait for "Escape" or "Return" key */
5574 /* press 'Enter' to keep the existing key binding */
5575 if (key == KSYM_Return)
5576 key = *customize_step[step_nr].key;
5578 /* check if key already used */
5579 for (i = 0; i < step_nr; i++)
5580 if (*customize_step[i].key == key)
5585 /* got new key binding */
5586 *customize_step[step_nr].key = key;
5587 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5589 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5590 getKeyNameFromKey(key), FONT_VALUE_1);
5593 /* un-highlight last query */
5594 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
5595 customize_step[step_nr - 1].text, FONT_MENU_1);
5596 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
5597 "Key:", FONT_MENU_1);
5599 /* press 'Enter' to leave */
5602 DrawText(mSX + 16, mSY + 15 * 32 + 16,
5603 "Press Enter", FONT_TITLE_1);
5607 /* query next key binding */
5608 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5609 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5610 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5611 "Key:", FONT_INPUT_1_ACTIVE);
5612 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5613 getKeyNameFromKey(*customize_step[step_nr].key),
5618 case EVENT_KEYRELEASE:
5619 key_joystick_mapping = 0;
5623 HandleOtherEvents(&event);
5631 /* don't eat all CPU time */
5635 /* write new key bindings back to player setup */
5636 setup.input[player_nr].key = custom_key;
5639 DrawSetupScreen_Input();
5642 static boolean CalibrateJoystickMain(int player_nr)
5644 int new_joystick_xleft = JOYSTICK_XMIDDLE;
5645 int new_joystick_xright = JOYSTICK_XMIDDLE;
5646 int new_joystick_yupper = JOYSTICK_YMIDDLE;
5647 int new_joystick_ylower = JOYSTICK_YMIDDLE;
5648 int new_joystick_xmiddle, new_joystick_ymiddle;
5650 int joystick_fd = joystick.fd[player_nr];
5651 int x, y, last_x, last_y, xpos = 8, ypos = 3;
5652 boolean check[3][3];
5653 int check_remaining = 3 * 3;
5658 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
5661 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
5666 for (y = 0; y < 3; y++)
5668 for (x = 0; x < 3; x++)
5670 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
5671 check[x][y] = FALSE;
5675 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
5676 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
5677 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
5678 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
5679 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
5680 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
5681 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
5683 joy_value = Joystick(player_nr);
5684 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5685 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5687 /* eventually uncalibrated center position (joystick could be uncentered) */
5688 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5691 new_joystick_xmiddle = joy_x;
5692 new_joystick_ymiddle = joy_y;
5694 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
5697 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
5702 if (PendingEvent()) /* got event */
5710 case EVENT_KEYPRESS:
5711 switch (GetEventKey((KeyEvent *)&event, TRUE))
5714 if (check_remaining == 0)
5727 case EVENT_KEYRELEASE:
5728 key_joystick_mapping = 0;
5732 HandleOtherEvents(&event);
5737 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5740 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
5741 new_joystick_xright = MAX(new_joystick_xright, joy_x);
5742 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
5743 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
5745 setup.input[player_nr].joy.xleft = new_joystick_xleft;
5746 setup.input[player_nr].joy.yupper = new_joystick_yupper;
5747 setup.input[player_nr].joy.xright = new_joystick_xright;
5748 setup.input[player_nr].joy.ylower = new_joystick_ylower;
5749 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
5750 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
5752 CheckJoystickData();
5754 joy_value = Joystick(player_nr);
5756 if (joy_value & JOY_BUTTON && check_remaining == 0)
5759 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
5760 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
5762 if (x != last_x || y != last_y)
5764 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0);
5765 DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0);
5770 if (check_remaining > 0 && !check[x+1][y+1])
5772 check[x+1][y+1] = TRUE;
5778 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
5779 setup.input[player_nr].joy.xleft,
5780 setup.input[player_nr].joy.xmiddle,
5781 setup.input[player_nr].joy.xright);
5782 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
5783 setup.input[player_nr].joy.yupper,
5784 setup.input[player_nr].joy.ymiddle,
5785 setup.input[player_nr].joy.ylower);
5794 /* don't eat all CPU time */
5798 /* calibrated center position (joystick should now be centered) */
5799 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
5802 new_joystick_xmiddle = joy_x;
5803 new_joystick_ymiddle = joy_y;
5808 DrawSetupScreen_Input();
5811 /* wait until the last pressed button was released */
5812 while (Joystick(player_nr) & JOY_BUTTON)
5814 if (PendingEvent()) /* got event */
5819 HandleOtherEvents(&event);
5828 void CalibrateJoystick(int player_nr)
5830 if (!CalibrateJoystickMain(player_nr))
5832 char *device_name = setup.input[player_nr].joy.device_name;
5833 int nr = getJoystickNrFromDeviceName(device_name) + 1;
5834 int xpos = mSX - SX;
5835 int ypos = mSY - SY;
5839 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
5840 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
5843 Delay(2000); /* show error message for a short time */
5849 DrawSetupScreen_Input();
5853 void DrawSetupScreen()
5855 DeactivateJoystick();
5857 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
5859 if (setup_mode == SETUP_MODE_INPUT)
5860 DrawSetupScreen_Input();
5861 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5862 DrawChooseTree(&game_speed_current);
5863 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5864 DrawChooseTree(&screen_mode_current);
5865 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5866 DrawChooseTree(&artwork.gfx_current);
5867 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5868 DrawChooseTree(&artwork.snd_current);
5869 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5870 DrawChooseTree(&artwork.mus_current);
5872 DrawSetupScreen_Generic();
5878 void RedrawSetupScreenAfterFullscreenToggle()
5880 if (setup_mode == SETUP_MODE_GRAPHICS)
5884 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
5886 if (setup_mode == SETUP_MODE_INPUT)
5887 HandleSetupScreen_Input(mx, my, dx, dy, button);
5888 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
5889 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
5890 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
5891 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
5892 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
5893 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
5894 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
5895 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
5896 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
5897 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
5899 HandleSetupScreen_Generic(mx, my, dx, dy, button);
5904 void HandleGameActions()
5906 if (game_status != GAME_MODE_PLAYING)
5909 GameActions(); /* main game loop */
5911 if (tape.auto_play && !tape.playing)
5912 AutoPlayTape(); /* continue automatically playing next tape */
5916 /* ---------- new screen button stuff -------------------------------------- */
5918 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
5923 case SCREEN_CTRL_ID_PREV_LEVEL:
5924 *x = mSX + menu.main.button.prev_level.x;
5925 *y = mSY + menu.main.button.prev_level.y;
5928 case SCREEN_CTRL_ID_NEXT_LEVEL:
5929 *x = mSX + menu.main.button.next_level.x;
5930 *y = mSY + menu.main.button.next_level.y;
5933 case SCREEN_CTRL_ID_PREV_LEVEL:
5934 *x = mSX + TILEX * getPrevlevelButtonPos();
5935 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5938 case SCREEN_CTRL_ID_NEXT_LEVEL:
5939 *x = mSX + TILEX * getNextLevelButtonPos();
5940 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
5944 case SCREEN_CTRL_ID_PREV_PLAYER:
5945 *x = mSX + TILEX * 10;
5946 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5949 case SCREEN_CTRL_ID_NEXT_PLAYER:
5950 *x = mSX + TILEX * 12;
5951 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
5955 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
5961 int gfx_unpressed, gfx_pressed;
5962 void (*get_gadget_position)(int *, int *, int);
5966 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
5969 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
5970 getScreenMenuButtonPos,
5971 SCREEN_CTRL_ID_PREV_LEVEL,
5976 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
5977 getScreenMenuButtonPos,
5978 SCREEN_CTRL_ID_NEXT_LEVEL,
5983 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
5984 getScreenMenuButtonPos,
5985 SCREEN_CTRL_ID_PREV_PLAYER,
5990 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
5991 getScreenMenuButtonPos,
5992 SCREEN_CTRL_ID_NEXT_PLAYER,
6000 int gfx_unpressed, gfx_pressed;
6004 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6007 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6008 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
6009 SCREEN_CTRL_ID_SCROLL_UP,
6013 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6014 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
6015 SCREEN_CTRL_ID_SCROLL_DOWN,
6022 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6023 Bitmap **gfx_unpressed, **gfx_pressed;
6025 int gfx_unpressed, gfx_pressed;
6032 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6035 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6036 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
6038 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6040 SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
6041 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
6042 GD_TYPE_SCROLLBAR_VERTICAL,
6043 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6044 "scroll level series vertically"
6048 static void CreateScreenMenubuttons()
6050 struct GadgetInfo *gi;
6051 unsigned long event_mask;
6054 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6056 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6057 int gfx_unpressed, gfx_pressed;
6058 int x, y, width, height;
6059 int gd_x1, gd_x2, gd_y1, gd_y2;
6060 int id = menubutton_info[i].gadget_id;
6062 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6064 menubutton_info[i].get_gadget_position(&x, &y, id);
6066 width = SC_MENUBUTTON_XSIZE;
6067 height = SC_MENUBUTTON_YSIZE;
6069 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6070 gfx_pressed = menubutton_info[i].gfx_pressed;
6071 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6072 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6073 gd_x1 = graphic_info[gfx_unpressed].src_x;
6074 gd_y1 = graphic_info[gfx_unpressed].src_y;
6075 gd_x2 = graphic_info[gfx_pressed].src_x;
6076 gd_y2 = graphic_info[gfx_pressed].src_y;
6078 gi = CreateGadget(GDI_CUSTOM_ID, id,
6079 GDI_CUSTOM_TYPE_ID, i,
6080 GDI_INFO_TEXT, menubutton_info[i].infotext,
6085 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6086 GDI_STATE, GD_BUTTON_UNPRESSED,
6087 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6088 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6089 GDI_DIRECT_DRAW, FALSE,
6090 GDI_EVENT_MASK, event_mask,
6091 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6095 Error(ERR_EXIT, "cannot create gadget");
6097 screen_gadget[id] = gi;
6101 static void CreateScreenScrollbuttons()
6103 struct GadgetInfo *gi;
6104 unsigned long event_mask;
6107 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6109 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6110 int gfx_unpressed, gfx_pressed;
6111 int x, y, width, height;
6112 int gd_x1, gd_x2, gd_y1, gd_y2;
6113 int id = scrollbutton_info[i].gadget_id;
6115 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6117 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6118 y = mSY + scrollbutton_info[i].y;
6119 width = SC_SCROLLBUTTON_XSIZE;
6120 height = SC_SCROLLBUTTON_YSIZE;
6122 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6123 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6124 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6126 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6127 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6128 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6129 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6130 gd_x1 = graphic_info[gfx_unpressed].src_x;
6131 gd_y1 = graphic_info[gfx_unpressed].src_y;
6132 gd_x2 = graphic_info[gfx_pressed].src_x;
6133 gd_y2 = graphic_info[gfx_pressed].src_y;
6135 gi = CreateGadget(GDI_CUSTOM_ID, id,
6136 GDI_CUSTOM_TYPE_ID, i,
6137 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6142 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6143 GDI_STATE, GD_BUTTON_UNPRESSED,
6144 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6145 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6146 GDI_DIRECT_DRAW, FALSE,
6147 GDI_EVENT_MASK, event_mask,
6148 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6152 Error(ERR_EXIT, "cannot create gadget");
6154 screen_gadget[id] = gi;
6158 static void CreateScreenScrollbars()
6162 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6164 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6165 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6166 int gfx_unpressed, gfx_pressed;
6168 int x, y, width, height;
6169 int gd_x1, gd_x2, gd_y1, gd_y2;
6170 struct GadgetInfo *gi;
6171 int items_max, items_visible, item_position;
6172 unsigned long event_mask;
6173 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6174 int id = scrollbar_info[i].gadget_id;
6176 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6178 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6179 y = mSY + scrollbar_info[i].y;
6180 width = scrollbar_info[i].width;
6181 height = scrollbar_info[i].height;
6183 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6184 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6186 items_max = num_page_entries;
6187 items_visible = num_page_entries;
6190 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6191 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
6192 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
6198 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6199 gfx_pressed = scrollbar_info[i].gfx_pressed;
6200 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6201 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6202 gd_x1 = graphic_info[gfx_unpressed].src_x;
6203 gd_y1 = graphic_info[gfx_unpressed].src_y;
6204 gd_x2 = graphic_info[gfx_pressed].src_x;
6205 gd_y2 = graphic_info[gfx_pressed].src_y;
6208 gi = CreateGadget(GDI_CUSTOM_ID, id,
6209 GDI_CUSTOM_TYPE_ID, i,
6210 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6215 GDI_TYPE, scrollbar_info[i].type,
6216 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6217 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6218 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6220 GDI_WHEEL_AREA_X, SX,
6221 GDI_WHEEL_AREA_Y, SY,
6222 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6223 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6225 GDI_WHEEL_AREA_X, 0,
6226 GDI_WHEEL_AREA_Y, 0,
6227 GDI_WHEEL_AREA_WIDTH, WIN_XSIZE,
6228 GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE,
6230 GDI_STATE, GD_BUTTON_UNPRESSED,
6231 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6232 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6233 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6234 GDI_DIRECT_DRAW, FALSE,
6235 GDI_EVENT_MASK, event_mask,
6236 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6240 Error(ERR_EXIT, "cannot create gadget");
6242 screen_gadget[id] = gi;
6246 void CreateScreenGadgets()
6248 int last_game_status = game_status; /* save current game status */
6250 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6253 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6255 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
6257 /* copy pointers to clip mask and GC */
6258 scrollbar_bitmap[i]->clip_mask =
6259 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
6260 scrollbar_bitmap[i]->stored_clip_gc =
6261 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
6263 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
6264 scrollbar_bitmap[i],
6265 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
6266 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
6267 TILEX, TILEY, 0, 0);
6271 CreateScreenMenubuttons();
6273 /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */
6274 game_status = GAME_MODE_LEVELS;
6276 CreateScreenScrollbuttons();
6277 CreateScreenScrollbars();
6279 game_status = last_game_status; /* restore current game status */
6282 void FreeScreenGadgets()
6286 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
6287 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
6289 /* prevent freeing clip mask and GC twice */
6290 scrollbar_bitmap[i]->clip_mask = None;
6291 scrollbar_bitmap[i]->stored_clip_gc = None;
6293 FreeBitmap(scrollbar_bitmap[i]);
6297 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6298 FreeGadget(screen_gadget[i]);
6301 void MapScreenMenuGadgets(int screen_mask)
6305 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6306 if (screen_mask & menubutton_info[i].screen_mask)
6307 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6310 void MapScreenTreeGadgets(TreeInfo *ti)
6312 int num_entries = numTreeInfoInGroup(ti);
6315 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6318 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6319 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6321 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6322 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6325 static void HandleScreenGadgets(struct GadgetInfo *gi)
6327 int id = gi->custom_id;
6328 int button = gi->event.button;
6329 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6333 case SCREEN_CTRL_ID_PREV_LEVEL:
6334 HandleMainMenu_SelectLevel(step, -1);
6337 case SCREEN_CTRL_ID_NEXT_LEVEL:
6338 HandleMainMenu_SelectLevel(step, +1);
6341 case SCREEN_CTRL_ID_PREV_PLAYER:
6342 HandleSetupScreen_Input_Player(step, -1);
6345 case SCREEN_CTRL_ID_NEXT_PLAYER:
6346 HandleSetupScreen_Input_Player(step, +1);
6349 case SCREEN_CTRL_ID_SCROLL_UP:
6350 if (game_status == GAME_MODE_LEVELS)
6351 HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6352 else if (game_status == GAME_MODE_SETUP)
6353 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6356 case SCREEN_CTRL_ID_SCROLL_DOWN:
6357 if (game_status == GAME_MODE_LEVELS)
6358 HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6359 else if (game_status == GAME_MODE_SETUP)
6360 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6363 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6364 if (game_status == GAME_MODE_LEVELS)
6365 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
6366 else if (game_status == GAME_MODE_SETUP)
6367 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);