1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
12 #include "libgame/libgame.h"
26 /* screens on the info screen */
27 #define INFO_MODE_MAIN 0
28 #define INFO_MODE_TITLE 1
29 #define INFO_MODE_ELEMENTS 2
30 #define INFO_MODE_MUSIC 3
31 #define INFO_MODE_CREDITS 4
32 #define INFO_MODE_PROGRAM 5
33 #define INFO_MODE_VERSION 6
34 #define INFO_MODE_LEVELSET 7
36 #define MAX_INFO_MODES 8
38 /* screens on the setup screen */
39 /* (must match GFX_SPECIAL_ARG_SETUP_* values as defined in src/main.h) */
40 /* (should also match corresponding entries in src/conf_gfx.c) */
41 #define SETUP_MODE_MAIN 0
42 #define SETUP_MODE_GAME 1
43 #define SETUP_MODE_EDITOR 2
44 #define SETUP_MODE_GRAPHICS 3
45 #define SETUP_MODE_SOUND 4
46 #define SETUP_MODE_ARTWORK 5
47 #define SETUP_MODE_INPUT 6
48 #define SETUP_MODE_TOUCH 7
49 #define SETUP_MODE_SHORTCUTS 8
50 #define SETUP_MODE_SHORTCUTS_1 9
51 #define SETUP_MODE_SHORTCUTS_2 10
52 #define SETUP_MODE_SHORTCUTS_3 11
53 #define SETUP_MODE_SHORTCUTS_4 12
54 #define SETUP_MODE_SHORTCUTS_5 13
56 /* sub-screens on the setup screen (generic) */
57 #define SETUP_MODE_CHOOSE_ARTWORK 14
58 #define SETUP_MODE_CHOOSE_OTHER 15
60 /* sub-screens on the setup screen (specific) */
61 #define SETUP_MODE_CHOOSE_GAME_SPEED 16
62 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17
63 #define SETUP_MODE_CHOOSE_SCREEN_MODE 18
64 #define SETUP_MODE_CHOOSE_WINDOW_SIZE 19
65 #define SETUP_MODE_CHOOSE_SCALING_TYPE 20
66 #define SETUP_MODE_CHOOSE_GRAPHICS 21
67 #define SETUP_MODE_CHOOSE_SOUNDS 22
68 #define SETUP_MODE_CHOOSE_MUSIC 23
69 #define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 24
70 #define SETUP_MODE_CHOOSE_VOLUME_LOOPS 25
71 #define SETUP_MODE_CHOOSE_VOLUME_MUSIC 26
72 #define SETUP_MODE_CHOOSE_TOUCH_CONTROL 27
73 #define SETUP_MODE_CHOOSE_MOVE_DISTANCE 28
74 #define SETUP_MODE_CHOOSE_DROP_DISTANCE 29
76 #define MAX_SETUP_MODES 30
78 /* for input setup functions */
79 #define SETUPINPUT_SCREEN_POS_START 0
80 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
81 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
82 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
84 /* for various menu stuff */
85 #define MENU_SCREEN_START_XPOS 1
86 #define MENU_SCREEN_START_YPOS 2
87 #define MENU_SCREEN_VALUE_XPOS (SCR_FIELDX - 3)
88 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
89 #define MENU_TITLE1_YPOS 8
90 #define MENU_TITLE2_YPOS 46
91 #define MENU_SCREEN_INFO_XSTART 16
92 #define MENU_SCREEN_INFO_YSTART1 100
93 #define MENU_SCREEN_INFO_YSTART2 128
94 #define MENU_SCREEN_INFO_YSTEP (TILEY + 4)
95 #define MENU_SCREEN_INFO_YBOTTOM (SYSIZE - 20)
96 #define MENU_SCREEN_INFO_YSIZE (MENU_SCREEN_INFO_YBOTTOM - \
97 MENU_SCREEN_INFO_YSTART2 - \
99 #define MAX_INFO_ELEMENTS_ON_SCREEN 128
100 #define NUM_INFO_ELEMENTS_ON_SCREEN MIN(MENU_SCREEN_INFO_YSIZE / \
101 MENU_SCREEN_INFO_YSTEP, \
102 MAX_INFO_ELEMENTS_ON_SCREEN)
103 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
104 #define MAX_MENU_TEXT_LENGTH_BIG 13
105 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
107 /* buttons and scrollbars identifiers */
108 #define SCREEN_CTRL_ID_PREV_LEVEL 0
109 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
110 #define SCREEN_CTRL_ID_PREV_PLAYER 2
111 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
112 #define SCREEN_CTRL_ID_SCROLL_UP 4
113 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
114 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
116 #define NUM_SCREEN_GADGETS 7
118 #define NUM_SCREEN_MENUBUTTONS 4
119 #define NUM_SCREEN_SCROLLBUTTONS 2
120 #define NUM_SCREEN_SCROLLBARS 1
122 #define SCREEN_MASK_MAIN (1 << 0)
123 #define SCREEN_MASK_INPUT (1 << 1)
125 /* graphic position and size values for buttons and scrollbars */
126 #define SC_MENUBUTTON_XSIZE TILEX
127 #define SC_MENUBUTTON_YSIZE TILEY
129 #define SC_SCROLLBUTTON_XSIZE TILEX
130 #define SC_SCROLLBUTTON_YSIZE TILEY
132 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
134 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
135 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
136 SC_SCROLLBUTTON_YSIZE)
138 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
139 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
141 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
142 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
143 SC_SCROLLBUTTON_YSIZE)
145 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
146 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
147 SC_SCROLL_VERTICAL_YSIZE)
149 #define SC_BORDER_SIZE 14
152 /* forward declarations of internal functions */
153 static void HandleScreenGadgets(struct GadgetInfo *);
154 static void HandleSetupScreen_Generic(int, int, int, int, int);
155 static void HandleSetupScreen_Input(int, int, int, int, int);
156 static void CustomizeKeyboard(int);
157 static void CalibrateJoystick(int);
158 static void execSetupGame(void);
159 static void execSetupGraphics(void);
160 static void execSetupSound(void);
161 static void execSetupTouch(void);
162 static void execSetupArtwork(void);
163 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
165 static void DrawChooseLevelSet(void);
166 static void DrawChooseLevelNr(void);
167 static void DrawInfoScreen(void);
168 static void DrawAndFadeInInfoScreen(int);
169 static void DrawSetupScreen(void);
171 static void DrawInfoScreenExt(int, int);
172 static void DrawInfoScreen_NotAvailable(char *, char *);
173 static void DrawInfoScreen_HelpAnim(int, int, boolean);
174 static void DrawInfoScreen_HelpText(int, int, int, int);
175 static void HandleInfoScreen_Main(int, int, int, int, int);
176 static void HandleInfoScreen_TitleScreen(int);
177 static void HandleInfoScreen_Elements(int);
178 static void HandleInfoScreen_Music(int);
179 static void HandleInfoScreen_Credits(int);
180 static void HandleInfoScreen_Program(int);
181 static void HandleInfoScreen_Version(int);
183 static void MapScreenMenuGadgets(int);
184 static void MapScreenGadgets(int);
185 static void MapScreenTreeGadgets(TreeInfo *);
187 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
189 static int info_mode = INFO_MODE_MAIN;
190 static int setup_mode = SETUP_MODE_MAIN;
192 static TreeInfo *screen_modes = NULL;
193 static TreeInfo *screen_mode_current = NULL;
195 static TreeInfo *window_sizes = NULL;
196 static TreeInfo *window_size_current = NULL;
198 static TreeInfo *scaling_types = NULL;
199 static TreeInfo *scaling_type_current = NULL;
201 static TreeInfo *scroll_delays = NULL;
202 static TreeInfo *scroll_delay_current = NULL;
204 static TreeInfo *game_speeds = NULL;
205 static TreeInfo *game_speed_current = NULL;
207 static TreeInfo *volumes_simple = NULL;
208 static TreeInfo *volume_simple_current = NULL;
210 static TreeInfo *volumes_loops = NULL;
211 static TreeInfo *volume_loops_current = NULL;
213 static TreeInfo *volumes_music = NULL;
214 static TreeInfo *volume_music_current = NULL;
216 static TreeInfo *touch_controls = NULL;
217 static TreeInfo *touch_control_current = NULL;
219 static TreeInfo *move_distances = NULL;
220 static TreeInfo *move_distance_current = NULL;
222 static TreeInfo *drop_distances = NULL;
223 static TreeInfo *drop_distance_current = NULL;
225 static TreeInfo *level_number = NULL;
226 static TreeInfo *level_number_current = NULL;
232 } window_sizes_list[] =
237 { 100, "100 % (Default)" },
254 } scaling_types_list[] =
256 { SCALING_QUALITY_NEAREST, "None" },
257 { SCALING_QUALITY_LINEAR, "Linear" },
258 { SCALING_QUALITY_BEST, "Anisotropic" },
267 } game_speeds_list[] =
276 { 1000, "1/1s (Extremely Slow)" },
281 { 29, "1/35s (Original Supaplex)" },
283 { 20, "1/50s (Normal Speed)" },
284 { 14, "1/70s (Maximum Supaplex)" },
288 { 1, "1/1000s (Extremely Fast)" },
298 } scroll_delays_list[] =
300 { 0, "0 Tiles (No Scroll Delay)" },
303 { 3, "3 Tiles (Default)" },
308 { 8, "8 Tiles (Maximum Scroll Delay)"},
338 } touch_controls_list[] =
340 { TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" },
341 { TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" },
365 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
366 (s) <= GAME_MODE_SETUP ? (s) : \
367 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
368 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
370 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
371 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
372 (i) <= INFO_MODE_LEVELSET ? (i) : \
375 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
376 (i) <= SETUP_MODE_SHORTCUTS_5 ? (i) : \
377 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
378 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
379 SETUP_MODE_CHOOSE_ARTWORK : \
380 SETUP_MODE_CHOOSE_OTHER)
382 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
383 menu.draw_xoffset[GAME_MODE_INFO] : \
384 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
385 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
386 menu.draw_yoffset[GAME_MODE_INFO] : \
387 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
389 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
390 menu.draw_xoffset[GAME_MODE_SETUP] : \
391 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
392 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
393 menu.draw_yoffset[GAME_MODE_SETUP] : \
394 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
396 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
397 DRAW_XOFFSET_INFO(info_mode) : \
398 (s) == GAME_MODE_SETUP ? \
399 DRAW_XOFFSET_SETUP(setup_mode) : \
400 menu.draw_xoffset[DRAW_MODE(s)])
401 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
402 DRAW_YOFFSET_INFO(info_mode) : \
403 (s) == GAME_MODE_SETUP ? \
404 DRAW_YOFFSET_SETUP(setup_mode) : \
405 menu.draw_yoffset[DRAW_MODE(s)])
407 #define mSX (SX + DRAW_XOFFSET(game_status))
408 #define mSY (SY + DRAW_YOFFSET(game_status))
410 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
411 menu.list_size[game_status] : \
412 MAX_MENU_ENTRIES_ON_SCREEN)
414 #define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \
415 NUM_MENU_ENTRIES_ON_SCREEN)
418 /* title display and control definitions */
420 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
421 2 * MAX_NUM_TITLE_MESSAGES)
423 #define NO_DIRECT_LEVEL_SELECT (-1)
426 static int num_title_screens = 0;
428 struct TitleControlInfo
436 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
438 /* main menu display and control definitions */
440 #define MAIN_CONTROL_NAME 0
441 #define MAIN_CONTROL_LEVELS 1
442 #define MAIN_CONTROL_SCORES 2
443 #define MAIN_CONTROL_EDITOR 3
444 #define MAIN_CONTROL_INFO 4
445 #define MAIN_CONTROL_GAME 5
446 #define MAIN_CONTROL_SETUP 6
447 #define MAIN_CONTROL_QUIT 7
448 #define MAIN_CONTROL_PREV_LEVEL 8
449 #define MAIN_CONTROL_NEXT_LEVEL 9
450 #define MAIN_CONTROL_FIRST_LEVEL 10
451 #define MAIN_CONTROL_LAST_LEVEL 11
452 #define MAIN_CONTROL_LEVEL_NUMBER 12
453 #define MAIN_CONTROL_LEVEL_INFO_1 13
454 #define MAIN_CONTROL_LEVEL_INFO_2 14
455 #define MAIN_CONTROL_LEVEL_NAME 15
456 #define MAIN_CONTROL_LEVEL_AUTHOR 16
457 #define MAIN_CONTROL_LEVEL_YEAR 17
458 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
459 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
460 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
461 #define MAIN_CONTROL_TITLE_1 21
462 #define MAIN_CONTROL_TITLE_2 22
463 #define MAIN_CONTROL_TITLE_3 23
465 static char str_main_text_name[10];
466 static char str_main_text_first_level[10];
467 static char str_main_text_last_level[10];
468 static char str_main_text_level_number[10];
470 static char *main_text_name = str_main_text_name;
471 static char *main_text_first_level = str_main_text_first_level;
472 static char *main_text_last_level = str_main_text_last_level;
473 static char *main_text_level_number = str_main_text_level_number;
474 static char *main_text_levels = "Levelset";
475 static char *main_text_scores = "Hall Of Fame";
476 static char *main_text_editor = "Level Creator";
477 static char *main_text_info = "Info Screen";
478 static char *main_text_game = "Start Game";
479 static char *main_text_setup = "Setup";
480 static char *main_text_quit = "Quit";
481 static char *main_text_level_name = level.name;
482 static char *main_text_level_author = level.author;
483 static char *main_text_level_year = NULL;
484 static char *main_text_level_imported_from = NULL;
485 static char *main_text_level_imported_by = NULL;
486 static char *main_text_level_tested_by = NULL;
487 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
488 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
489 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
491 struct MainControlInfo
495 struct MenuPosInfo *pos_button;
498 struct TextPosInfo *pos_text;
501 struct TextPosInfo *pos_input;
505 static struct MainControlInfo main_controls[] =
509 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
510 &menu.main.text.name, &main_text_name,
511 &menu.main.input.name, &setup.player_name,
515 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
516 &menu.main.text.levels, &main_text_levels,
521 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
522 &menu.main.text.scores, &main_text_scores,
527 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
528 &menu.main.text.editor, &main_text_editor,
533 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
534 &menu.main.text.info, &main_text_info,
539 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
540 &menu.main.text.game, &main_text_game,
545 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
546 &menu.main.text.setup, &main_text_setup,
551 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
552 &menu.main.text.quit, &main_text_quit,
556 /* (these two buttons are real gadgets) */
558 MAIN_CONTROL_PREV_LEVEL,
559 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
564 MAIN_CONTROL_NEXT_LEVEL,
565 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
571 MAIN_CONTROL_FIRST_LEVEL,
573 &menu.main.text.first_level, &main_text_first_level,
577 MAIN_CONTROL_LAST_LEVEL,
579 &menu.main.text.last_level, &main_text_last_level,
583 MAIN_CONTROL_LEVEL_NUMBER,
585 &menu.main.text.level_number, &main_text_level_number,
589 MAIN_CONTROL_LEVEL_INFO_1,
591 &menu.main.text.level_info_1, NULL,
595 MAIN_CONTROL_LEVEL_INFO_2,
597 &menu.main.text.level_info_2, NULL,
601 MAIN_CONTROL_LEVEL_NAME,
603 &menu.main.text.level_name, &main_text_level_name,
607 MAIN_CONTROL_LEVEL_AUTHOR,
609 &menu.main.text.level_author, &main_text_level_author,
613 MAIN_CONTROL_LEVEL_YEAR,
615 &menu.main.text.level_year, &main_text_level_year,
619 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
621 &menu.main.text.level_imported_from, &main_text_level_imported_from,
625 MAIN_CONTROL_LEVEL_IMPORTED_BY,
627 &menu.main.text.level_imported_by, &main_text_level_imported_by,
631 MAIN_CONTROL_LEVEL_TESTED_BY,
633 &menu.main.text.level_tested_by, &main_text_level_tested_by,
637 MAIN_CONTROL_TITLE_1,
639 &menu.main.text.title_1, &main_text_title_1,
643 MAIN_CONTROL_TITLE_2,
645 &menu.main.text.title_2, &main_text_title_2,
649 MAIN_CONTROL_TITLE_3,
651 &menu.main.text.title_3, &main_text_title_3,
664 static int getTitleScreenGraphic(int nr, boolean initial)
666 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
669 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
671 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
675 static int getTitleScreenGameMode(boolean initial)
677 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
681 static int getTitleMessageGameMode(boolean initial)
683 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
687 static int getTitleScreenBackground(boolean initial)
689 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
694 static int getTitleMessageBackground(int nr, boolean initial)
696 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
700 static int getTitleBackground(int nr, boolean initial, boolean is_image)
702 int base = (is_image ?
703 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
704 IMG_BACKGROUND_TITLESCREEN_1) :
705 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
706 IMG_BACKGROUND_TITLEMESSAGE_1));
707 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
708 IMG_BACKGROUND_TITLE);
709 int graphic_local = base + nr;
711 if (graphic_info[graphic_local].bitmap != NULL)
712 return graphic_local;
714 if (graphic_info[graphic_global].bitmap != NULL)
715 return graphic_global;
717 return IMG_UNDEFINED;
720 static int getTitleSound(struct TitleControlInfo *tci)
722 boolean is_image = tci->is_image;
723 int initial = tci->initial;
724 int nr = tci->local_nr;
725 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
726 int base = (is_image ?
727 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
728 SND_BACKGROUND_TITLESCREEN_1) :
729 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
730 SND_BACKGROUND_TITLEMESSAGE_1));
731 int sound_global = menu.sound[mode];
732 int sound_local = base + nr;
735 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
736 nr, initial, is_image,
737 sound_global, getSoundListEntry(sound_global)->filename,
738 sound_local, getSoundListEntry(sound_local)->filename);
741 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
744 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
747 return SND_UNDEFINED;
750 static int getTitleMusic(struct TitleControlInfo *tci)
752 boolean is_image = tci->is_image;
753 int initial = tci->initial;
754 int nr = tci->local_nr;
755 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
756 int base = (is_image ?
757 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
758 MUS_BACKGROUND_TITLESCREEN_1) :
759 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
760 MUS_BACKGROUND_TITLEMESSAGE_1));
761 int music_global = menu.music[mode];
762 int music_local = base + nr;
765 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
766 nr, initial, is_image,
767 music_global, getMusicListEntry(music_global)->filename,
768 music_local, getMusicListEntry(music_local)->filename);
771 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
774 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
777 return MUS_UNDEFINED;
780 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
782 boolean is_image = tci->is_image;
783 int initial = tci->initial;
784 int nr = tci->local_nr;
785 struct TitleFadingInfo ti;
789 int graphic = getTitleScreenGraphic(nr, initial);
791 /* initialize fading control values to default title config settings */
792 ti = (initial ? title_initial_default : title_default);
794 /* override default settings with image config settings, if defined */
795 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
796 ti.fade_mode = graphic_info[graphic].fade_mode;
797 if (graphic_info[graphic].fade_delay > -1)
798 ti.fade_delay = graphic_info[graphic].fade_delay;
799 if (graphic_info[graphic].post_delay > -1)
800 ti.post_delay = graphic_info[graphic].post_delay;
801 if (graphic_info[graphic].auto_delay > -1)
802 ti.auto_delay = graphic_info[graphic].auto_delay;
808 ti.fade_mode = titlemessage_initial[nr].fade_mode;
809 ti.fade_delay = titlemessage_initial[nr].fade_delay;
810 ti.post_delay = titlemessage_initial[nr].post_delay;
811 ti.auto_delay = titlemessage_initial[nr].auto_delay;
815 ti.fade_mode = titlemessage[nr].fade_mode;
816 ti.fade_delay = titlemessage[nr].fade_delay;
817 ti.post_delay = titlemessage[nr].post_delay;
818 ti.auto_delay = titlemessage[nr].auto_delay;
825 static int compareTitleControlInfo(const void *object1, const void *object2)
827 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
828 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
831 if (tci1->initial != tci2->initial)
832 compare_result = (tci1->initial ? -1 : +1);
833 else if (tci1->sort_priority != tci2->sort_priority)
834 compare_result = tci1->sort_priority - tci2->sort_priority;
835 else if (tci1->is_image != tci2->is_image)
836 compare_result = (tci1->is_image ? -1 : +1);
838 compare_result = tci1->local_nr - tci2->local_nr;
840 return compare_result;
843 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
845 int nr, int sort_priority)
847 title_controls[num_title_screens].is_image = is_image;
848 title_controls[num_title_screens].initial = initial;
849 title_controls[num_title_screens].local_nr = nr;
850 title_controls[num_title_screens].sort_priority = sort_priority;
855 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
859 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
861 int graphic = getTitleScreenGraphic(i, initial);
862 Bitmap *bitmap = graphic_info[graphic].bitmap;
863 int sort_priority = graphic_info[graphic].sort_priority;
866 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
869 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
871 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
872 char *filename = getLevelSetTitleMessageFilename(i, initial);
873 int sort_priority = tmi->sort_priority;
875 if (filename != NULL)
876 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
880 static void InitializeTitleControls(boolean show_title_initial)
882 num_title_screens = 0;
884 /* 1st step: initialize title screens for game start (only when starting) */
885 if (show_title_initial)
886 InitializeTitleControls_CheckTitleInfo(TRUE);
888 /* 2nd step: initialize title screens for current level set */
889 InitializeTitleControls_CheckTitleInfo(FALSE);
891 /* sort title screens according to sort_priority and title number */
892 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
893 compareTitleControlInfo);
896 static boolean visibleMenuPos(struct MenuPosInfo *pos)
898 return (pos != NULL && pos->x != -1 && pos->y != -1);
901 static boolean visibleTextPos(struct TextPosInfo *pos)
903 return (pos != NULL && pos->x != -1 && pos->y != -1);
906 static void InitializeMainControls()
908 boolean local_team_mode = (!options.network && setup.team_mode);
911 /* set main control text values to dynamically determined values */
912 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
914 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
915 menu.main.text.first_level.size));
916 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
917 menu.main.text.last_level.size));
918 strcpy(main_text_level_number, int2str(level_nr,
919 menu.main.text.level_number.size));
921 main_text_level_year = leveldir_current->year;
922 main_text_level_imported_from = leveldir_current->imported_from;
923 main_text_level_imported_by = leveldir_current->imported_by;
924 main_text_level_tested_by = leveldir_current->tested_by;
926 /* set main control screen positions to dynamically determined values */
927 for (i = 0; main_controls[i].nr != -1; i++)
929 struct MainControlInfo *mci = &main_controls[i];
931 struct MenuPosInfo *pos_button = mci->pos_button;
932 struct TextPosInfo *pos_text = mci->pos_text;
933 struct TextPosInfo *pos_input = mci->pos_input;
934 char *text = (mci->text ? *mci->text : NULL);
935 char *input = (mci->input ? *mci->input : NULL);
936 int button_graphic = mci->button_graphic;
937 int font_text = (pos_text ? pos_text->font : -1);
938 int font_input = (pos_input ? pos_input->font : -1);
940 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
941 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
942 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
943 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
944 int text_chars = (text != NULL ? strlen(text) : 0);
945 int input_chars = (input != NULL ? strlen(input) : 0);
948 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
950 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
951 int text_width = font_text_width * text_chars;
952 int text_height = font_text_height;
953 int input_width = font_input_width * input_chars;
954 int input_height = font_input_height;
956 if (nr == MAIN_CONTROL_NAME)
958 menu.main.input.name.width = input_width;
959 menu.main.input.name.height = input_height;
962 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
964 if (pos_button->width == 0)
965 pos_button->width = button_width;
966 if (pos_button->height == 0)
967 pos_button->height = button_height;
970 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
972 /* calculate size for non-clickable text -- needed for text alignment */
973 boolean calculate_text_size = (pos_button == NULL && text != NULL);
975 if (visibleMenuPos(pos_button))
977 if (pos_text->x == -1)
978 pos_text->x = pos_button->x + pos_button->width;
979 if (pos_text->y == -1)
980 pos_text->y = pos_button->y;
983 if (pos_text->width == -1 || calculate_text_size)
984 pos_text->width = text_width;
985 if (pos_text->height == -1 || calculate_text_size)
986 pos_text->height = text_height;
989 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
991 if (visibleTextPos(pos_text))
993 if (pos_input->x == -1)
994 pos_input->x = pos_text->x + pos_text->width;
995 if (pos_input->y == -1)
996 pos_input->y = pos_text->y;
999 if (pos_input->width == -1)
1000 pos_input->width = input_width;
1001 if (pos_input->height == -1)
1002 pos_input->height = input_height;
1007 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1008 boolean active_input)
1012 for (i = 0; main_controls[i].nr != -1; i++)
1014 struct MainControlInfo *mci = &main_controls[i];
1016 if (mci->nr == nr || nr == -1)
1018 struct MenuPosInfo *pos_button = mci->pos_button;
1019 struct TextPosInfo *pos_text = mci->pos_text;
1020 struct TextPosInfo *pos_input = mci->pos_input;
1021 char *text = (mci->text ? *mci->text : NULL);
1022 char *input = (mci->input ? *mci->input : NULL);
1023 int button_graphic = mci->button_graphic;
1024 int font_text = (pos_text ? pos_text->font : -1);
1025 int font_input = (pos_input ? pos_input->font : -1);
1029 button_graphic = BUTTON_ACTIVE(button_graphic);
1030 font_text = FONT_ACTIVE(font_text);
1035 font_input = FONT_ACTIVE(font_input);
1038 if (visibleMenuPos(pos_button))
1040 struct MenuPosInfo *pos = pos_button;
1041 int x = mSX + pos->x;
1042 int y = mSY + pos->y;
1044 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1045 DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
1048 if (visibleTextPos(pos_text) && text != NULL)
1050 struct TextPosInfo *pos = pos_text;
1051 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1052 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1055 /* (check why/if this is needed) */
1056 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1058 DrawText(x, y, text, font_text);
1061 if (visibleTextPos(pos_input) && input != NULL)
1063 struct TextPosInfo *pos = pos_input;
1064 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1065 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1068 /* (check why/if this is needed) */
1069 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1071 DrawText(x, y, input, font_input);
1077 static void DrawCursorAndText_Main(int nr, boolean active_text)
1079 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1083 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1085 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1089 static struct MainControlInfo *getMainControlInfo(int nr)
1093 for (i = 0; main_controls[i].nr != -1; i++)
1094 if (main_controls[i].nr == nr)
1095 return &main_controls[i];
1100 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1105 int rect_x = ALIGNED_TEXT_XPOS(rect);
1106 int rect_y = ALIGNED_TEXT_YPOS(rect);
1108 return (x >= rect_x && x < rect_x + rect->width &&
1109 y >= rect_y && y < rect_y + rect->height);
1112 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1117 int rect_x = ALIGNED_TEXT_XPOS(rect);
1118 int rect_y = ALIGNED_TEXT_YPOS(rect);
1121 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1122 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1123 (x >= rect_x && x < rect_x + rect->width &&
1124 y >= rect_y && y < rect_y + rect->height));
1127 return (x >= rect_x && x < rect_x + rect->width &&
1128 y >= rect_y && y < rect_y + rect->height);
1131 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1133 static int cursor_array[MAX_LEV_FIELDY];
1134 int x = mSX + TILEX * xpos;
1135 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1140 cursor_array[ypos] = graphic;
1142 graphic = cursor_array[ypos];
1146 graphic = BUTTON_ACTIVE(graphic);
1148 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1149 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1152 static void initCursor(int ypos, int graphic)
1154 drawCursorExt(0, ypos, FALSE, graphic);
1157 static void drawCursor(int ypos, boolean active)
1159 drawCursorExt(0, ypos, active, -1);
1162 static void drawCursorXY(int xpos, int ypos, int graphic)
1164 drawCursorExt(xpos, ypos, FALSE, graphic);
1167 static void drawChooseTreeCursor(int ypos, boolean active)
1169 int last_game_status = game_status; /* save current game status */
1171 drawCursorExt(0, ypos, active, -1);
1173 game_status = last_game_status; /* restore current game status */
1178 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1179 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1182 int effectiveGameStatus()
1184 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1185 return GAME_MODE_TITLE;
1190 void DrawTitleScreenImage(int nr, boolean initial)
1192 int graphic = getTitleScreenGraphic(nr, initial);
1193 Bitmap *bitmap = graphic_info[graphic].bitmap;
1194 int width = graphic_info[graphic].width;
1195 int height = graphic_info[graphic].height;
1196 int src_x = graphic_info[graphic].src_x;
1197 int src_y = graphic_info[graphic].src_y;
1203 if (width > WIN_XSIZE)
1205 /* image width too large for window => center image horizontally */
1206 src_x = (width - WIN_XSIZE) / 2;
1210 if (height > WIN_YSIZE)
1212 /* image height too large for window => center image vertically */
1213 src_y = (height - WIN_YSIZE) / 2;
1217 /* always display title screens centered */
1218 dst_x = (WIN_XSIZE - width) / 2;
1219 dst_y = (WIN_YSIZE - height) / 2;
1221 SetDrawBackgroundMask(REDRAW_ALL);
1222 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1224 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1226 if (DrawingOnBackground(dst_x, dst_y))
1227 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1229 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1231 redraw_mask = REDRAW_ALL;
1234 void DrawTitleScreenMessage(int nr, boolean initial)
1236 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1237 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1238 int last_game_status = game_status; /* save current game status */
1240 if (filename == NULL)
1243 /* force TITLE font on title message screen */
1244 game_status = getTitleMessageGameMode(initial);
1246 /* if chars set to "-1", automatically determine by text and font width */
1247 if (tmi->chars == -1)
1248 tmi->chars = tmi->width / getFontWidth(tmi->font);
1250 tmi->width = tmi->chars * getFontWidth(tmi->font);
1252 /* if lines set to "-1", automatically determine by text and font height */
1253 if (tmi->lines == -1)
1254 tmi->lines = tmi->height / getFontHeight(tmi->font);
1256 tmi->height = tmi->lines * getFontHeight(tmi->font);
1258 SetDrawBackgroundMask(REDRAW_ALL);
1259 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1261 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1263 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1264 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1265 tmi->autowrap, tmi->centered, tmi->parse_comments);
1267 game_status = last_game_status; /* restore current game status */
1270 void DrawTitleScreen()
1272 KeyboardAutoRepeatOff();
1274 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1279 boolean CheckTitleScreen(boolean levelset_has_changed)
1281 static boolean show_title_initial = TRUE;
1282 boolean show_titlescreen = FALSE;
1284 /* needed to be able to skip title screen, if no image or message defined */
1285 InitializeTitleControls(show_title_initial);
1287 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1288 show_titlescreen = TRUE;
1290 /* show initial title images and messages only once at program start */
1291 show_title_initial = FALSE;
1293 return (show_titlescreen && num_title_screens > 0);
1296 void DrawMainMenuExt(int fade_mask, boolean do_fading)
1298 static LevelDirTree *leveldir_last_valid = NULL;
1299 boolean levelset_has_changed = FALSE;
1301 LimitScreenUpdates(FALSE);
1303 FadeSetLeaveScreen();
1305 /* do not fade out here -- function may continue and fade on editor screen */
1308 FadeSoundsAndMusic();
1310 KeyboardAutoRepeatOn();
1313 SetDrawDeactivationMask(REDRAW_NONE);
1314 SetDrawBackgroundMask(REDRAW_FIELD);
1316 audio.sound_deactivated = FALSE;
1320 /* needed if last screen was the playing screen, invoked from level editor */
1321 if (level_editor_test_game)
1323 game_status = GAME_MODE_EDITOR;
1329 /* needed if last screen was the setup screen and fullscreen state changed */
1330 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1331 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1333 /* leveldir_current may be invalid (level group, parent link) */
1334 if (!validLevelSeries(leveldir_current))
1335 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1337 if (leveldir_current != leveldir_last_valid)
1338 levelset_has_changed = TRUE;
1340 /* store valid level series information */
1341 leveldir_last_valid = leveldir_current;
1343 init_last = init; /* switch to new busy animation */
1345 /* needed if last screen (level choice) changed graphics, sounds or music */
1346 ReloadCustomArtwork(0);
1348 if (redraw_mask & REDRAW_ALL)
1349 fade_mask = REDRAW_ALL;
1353 /* needed if different viewport properties defined for menues */
1354 ChangeViewportPropertiesIfNeeded();
1356 /* needed if last screen was the editor screen */
1357 UndrawSpecialEditorDoor();
1359 SetDrawtoField(DRAW_BACKBUFFER);
1361 if (CheckTitleScreen(levelset_has_changed))
1363 game_status = GAME_MODE_TITLE;
1370 /* level_nr may have been set to value over handicap with level editor */
1371 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1372 level_nr = leveldir_current->handicap_level;
1374 LoadLevel(level_nr);
1375 LoadScore(level_nr);
1377 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1379 if (fade_mask == REDRAW_ALL)
1384 InitializeMainControls();
1386 DrawCursorAndText_Main(-1, FALSE);
1387 DrawPreviewLevelInitial();
1389 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1392 if (TAPE_IS_EMPTY(tape))
1394 DrawCompleteVideoDisplay();
1399 /* create gadgets for main menu screen */
1400 FreeScreenGadgets();
1401 CreateScreenGadgets();
1403 /* map gadgets for main menu screen */
1405 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1407 /* copy actual game door content to door double buffer for OpenDoor() */
1408 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1410 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1412 DrawMaskedBorder(REDRAW_ALL);
1417 /* update screen area with special editor door */
1418 redraw_mask |= REDRAW_ALL;
1421 SetMouseCursor(CURSOR_DEFAULT);
1425 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1428 void DrawAndFadeInMainMenu(int fade_mask)
1430 DrawMainMenuExt(fade_mask, TRUE);
1435 DrawMainMenuExt(REDRAW_ALL, FALSE);
1438 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1439 static void gotoTopLevelDir()
1441 /* move upwards to top level directory */
1442 while (leveldir_current->node_parent)
1444 /* write a "path" into level tree for easy navigation to last level */
1445 if (leveldir_current->node_parent->node_group->cl_first == -1)
1447 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1448 int leveldir_pos = posTreeInfo(leveldir_current);
1449 int num_page_entries;
1450 int cl_first, cl_cursor;
1452 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1453 num_page_entries = num_leveldirs;
1455 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1457 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1458 cl_cursor = leveldir_pos - cl_first;
1460 leveldir_current->node_parent->node_group->cl_first = cl_first;
1461 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1464 leveldir_current = leveldir_current->node_parent;
1469 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1471 static unsigned int title_delay = 0;
1472 static int title_screen_nr = 0;
1473 static int last_sound = -1, last_music = -1;
1474 boolean return_to_main_menu = FALSE;
1475 boolean use_fading_main_menu = TRUE;
1476 struct TitleControlInfo *tci;
1477 struct TitleFadingInfo fading_default;
1478 struct TitleFadingInfo fading_last = fading;
1479 struct TitleFadingInfo fading_next;
1482 if (button == MB_MENU_INITIALIZE)
1485 title_screen_nr = 0;
1486 tci = &title_controls[title_screen_nr];
1488 last_sound = SND_UNDEFINED;
1489 last_music = MUS_UNDEFINED;
1491 if (game_status == GAME_MODE_INFO)
1493 if (num_title_screens == 0)
1495 DrawInfoScreen_NotAvailable("Title screen information:",
1496 "No title screen for this level set.");
1501 FadeSoundsAndMusic();
1503 FadeOut(REDRAW_ALL);
1507 DrawTitleScreenImage(tci->local_nr, tci->initial);
1509 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1511 fading_default = (tci->initial ? title_initial_default : title_default);
1513 fading = fading_next = getTitleFading(tci);
1515 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1516 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1518 fading.fade_mode = FADE_MODE_FADE;
1519 fading.fade_delay = fading_default.fade_delay;
1522 sound = getTitleSound(tci);
1523 music = getTitleMusic(tci);
1525 if (sound != last_sound)
1526 PlayMenuSoundExt(sound);
1527 if (music != last_music)
1528 PlayMenuMusicExt(music);
1533 SetMouseCursor(CURSOR_NONE);
1537 fading = fading_next;
1539 DelayReached(&title_delay, 0); /* reset delay counter */
1544 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1545 button = MB_MENU_CHOICE;
1547 if (button == MB_MENU_LEAVE)
1549 return_to_main_menu = TRUE;
1550 use_fading_main_menu = FALSE;
1552 else if (button == MB_MENU_CHOICE)
1554 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1556 FadeSetEnterScreen();
1558 info_mode = INFO_MODE_MAIN;
1559 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1565 tci = &title_controls[title_screen_nr];
1567 if (title_screen_nr < num_title_screens)
1569 sound = getTitleSound(tci);
1570 music = getTitleMusic(tci);
1572 if (sound == SND_UNDEFINED || sound != last_sound)
1574 if (music == MUS_UNDEFINED || music != last_music)
1577 FadeOut(REDRAW_ALL);
1580 DrawTitleScreenImage(tci->local_nr, tci->initial);
1582 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1584 fading_next = getTitleFading(tci);
1586 sound = getTitleSound(tci);
1587 music = getTitleMusic(tci);
1589 if (sound != last_sound)
1590 PlayMenuSoundExt(sound);
1591 if (music != last_music)
1592 PlayMenuMusicExt(music);
1597 /* last screen already faded out, next screen has no animation */
1598 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1599 fading_next.fade_mode == FADE_MODE_NONE)
1600 fading = fading_next;
1604 fading = fading_next;
1606 DelayReached(&title_delay, 0); /* reset delay counter */
1610 FadeSoundsAndMusic();
1612 return_to_main_menu = TRUE;
1616 if (return_to_main_menu)
1618 SetMouseCursor(CURSOR_DEFAULT);
1620 if (game_status == GAME_MODE_INFO)
1622 info_mode = INFO_MODE_MAIN;
1624 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1626 else /* default: return to main menu */
1628 game_status = GAME_MODE_MAIN;
1630 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1635 void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
1637 int old_level_nr = level_nr;
1640 if (selected_level_nr != NO_DIRECT_LEVEL_SELECT)
1641 new_level_nr = selected_level_nr;
1643 new_level_nr = old_level_nr + step * direction;
1645 if (new_level_nr < leveldir_current->first_level)
1646 new_level_nr = leveldir_current->first_level;
1647 if (new_level_nr > leveldir_current->last_level)
1648 new_level_nr = leveldir_current->last_level;
1650 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1652 /* skipping levels is only allowed when trying to skip single level */
1653 if (setup.skip_levels && new_level_nr == old_level_nr + 1 &&
1654 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1656 leveldir_current->handicap_level++;
1657 SaveLevelSetup_SeriesInfo();
1660 new_level_nr = leveldir_current->handicap_level;
1663 if (new_level_nr != old_level_nr)
1665 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1667 PlaySound(SND_MENU_ITEM_SELECTING);
1669 level_nr = new_level_nr;
1671 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1672 int2str(level_nr, menu.main.text.level_number.size),
1673 mci->pos_text->font);
1675 LoadLevel(level_nr);
1676 DrawPreviewLevelInitial();
1680 DrawCompleteVideoDisplay();
1682 /* needed because DrawPreviewLevelInitial() takes some time */
1684 /* SyncDisplay(); */
1688 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1690 static int choice = MAIN_CONTROL_GAME;
1694 if (button == MB_MENU_INITIALIZE)
1696 DrawCursorAndText_Main(choice, TRUE);
1701 if (mx || my) /* mouse input */
1705 for (i = 0; main_controls[i].nr != -1; i++)
1707 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1708 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1709 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1711 pos = main_controls[i].nr;
1717 else if (dx || dy) /* keyboard input */
1719 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1720 choice == MAIN_CONTROL_SETUP))
1721 button = MB_MENU_CHOICE;
1726 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1728 HandleMainMenu_SelectLevel(1, (dx < 0 ? -1 : +1), NO_DIRECT_LEVEL_SELECT);
1730 else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1732 HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
1734 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1736 HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT);
1738 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1740 game_status = GAME_MODE_LEVELNR;
1742 ChangeViewportPropertiesIfNeeded();
1744 DrawChooseLevelNr();
1746 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1752 PlaySound(SND_MENU_ITEM_ACTIVATING);
1754 DrawCursorAndText_Main(choice, FALSE);
1755 DrawCursorAndText_Main(pos, TRUE);
1762 PlaySound(SND_MENU_ITEM_SELECTING);
1764 if (pos == MAIN_CONTROL_NAME)
1766 game_status = GAME_MODE_PSEUDO_TYPENAME;
1768 HandleTypeName(strlen(setup.player_name), 0);
1770 else if (pos == MAIN_CONTROL_LEVELS)
1774 game_status = GAME_MODE_LEVELS;
1776 SaveLevelSetup_LastSeries();
1777 SaveLevelSetup_SeriesInfo();
1779 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1783 ChangeViewportPropertiesIfNeeded();
1785 DrawChooseLevelSet();
1788 else if (pos == MAIN_CONTROL_SCORES)
1790 game_status = GAME_MODE_SCORES;
1792 ChangeViewportPropertiesIfNeeded();
1796 else if (pos == MAIN_CONTROL_EDITOR)
1798 if (leveldir_current->readonly &&
1799 !strEqual(setup.player_name, "Artsoft"))
1800 Request("This level is read only!", REQ_CONFIRM);
1802 CloseDoor(DOOR_CLOSE_2);
1804 game_status = GAME_MODE_EDITOR;
1806 FadeSetEnterScreen();
1810 else if (pos == MAIN_CONTROL_INFO)
1812 game_status = GAME_MODE_INFO;
1813 info_mode = INFO_MODE_MAIN;
1815 ChangeViewportPropertiesIfNeeded();
1819 else if (pos == MAIN_CONTROL_GAME)
1821 StartGameActions(options.network, setup.autorecord, level.random_seed);
1823 else if (pos == MAIN_CONTROL_SETUP)
1825 game_status = GAME_MODE_SETUP;
1826 setup_mode = SETUP_MODE_MAIN;
1828 ChangeViewportPropertiesIfNeeded();
1832 else if (pos == MAIN_CONTROL_QUIT)
1834 SaveLevelSetup_LastSeries();
1835 SaveLevelSetup_SeriesInfo();
1837 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1838 game_status = GAME_MODE_QUIT;
1845 /* ========================================================================= */
1846 /* info screen functions */
1847 /* ========================================================================= */
1849 static struct TokenInfo *info_info;
1850 static int num_info_info;
1852 static void execInfoTitleScreen()
1854 info_mode = INFO_MODE_TITLE;
1859 static void execInfoElements()
1861 info_mode = INFO_MODE_ELEMENTS;
1866 static void execInfoMusic()
1868 info_mode = INFO_MODE_MUSIC;
1873 static void execInfoCredits()
1875 info_mode = INFO_MODE_CREDITS;
1880 static void execInfoProgram()
1882 info_mode = INFO_MODE_PROGRAM;
1887 static void execInfoVersion()
1889 info_mode = INFO_MODE_VERSION;
1894 static void execInfoLevelSet()
1896 info_mode = INFO_MODE_LEVELSET;
1901 static void execExitInfo()
1903 game_status = GAME_MODE_MAIN;
1905 DrawMainMenuExt(REDRAW_FIELD, FALSE);
1908 static struct TokenInfo info_info_main[] =
1910 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
1911 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
1912 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
1913 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
1914 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
1915 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
1916 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
1917 { TYPE_EMPTY, NULL, "" },
1918 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
1923 static void DrawCursorAndText_Info(int pos, boolean active)
1925 int xpos = MENU_SCREEN_START_XPOS;
1926 int ypos = MENU_SCREEN_START_YPOS + pos;
1927 int font_nr = FONT_MENU_1;
1930 font_nr = FONT_ACTIVE(font_nr);
1932 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
1934 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
1935 drawCursor(pos, active);
1938 static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
1943 CloseDoor(DOOR_CLOSE_2);
1945 /* (needed after displaying title screens which disable auto repeat) */
1946 KeyboardAutoRepeatOn();
1948 FadeSetLeaveScreen();
1952 if (fade_mask == REDRAW_ALL)
1956 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1961 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
1963 info_info = info_info_main;
1966 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1968 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
1969 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
1970 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
1971 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
1972 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
1973 initCursor(i, IMG_MENU_BUTTON);
1975 DrawCursorAndText_Info(i, FALSE);
1980 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
1985 DrawMaskedBorder(fade_mask);
1992 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
1994 static int choice_store[MAX_INFO_MODES];
1995 int choice = choice_store[info_mode]; /* always starts with 0 */
1999 if (button == MB_MENU_INITIALIZE)
2001 /* advance to first valid menu entry */
2002 while (choice < num_info_info &&
2003 info_info[choice].type & TYPE_SKIP_ENTRY)
2005 choice_store[info_mode] = choice;
2007 DrawCursorAndText_Info(choice, TRUE);
2011 else if (button == MB_MENU_LEAVE)
2013 for (y = 0; y < num_info_info; y++)
2015 if (info_info[y].type & TYPE_LEAVE_MENU)
2017 void (*menu_callback_function)(void) = info_info[y].value;
2021 menu_callback_function();
2023 break; /* absolutely needed because function changes 'info_info'! */
2030 if (mx || my) /* mouse input */
2032 x = (mx - mSX) / 32;
2033 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2035 else if (dx || dy) /* keyboard input */
2039 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2041 if (info_info[choice].type & menu_navigation_type ||
2042 info_info[choice].type & TYPE_ENTER_SCREEN ||
2043 info_info[choice].type & TYPE_BOOLEAN_STYLE ||
2044 info_info[choice].type & TYPE_YES_NO_AUTO)
2045 button = MB_MENU_CHOICE;
2050 /* jump to next non-empty menu entry (up or down) */
2051 while (y > 0 && y < num_info_info - 1 &&
2052 info_info[y].type & TYPE_SKIP_ENTRY)
2056 if (IN_VIS_MENU(x, y) &&
2057 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2063 PlaySound(SND_MENU_ITEM_ACTIVATING);
2065 DrawCursorAndText_Info(choice, FALSE);
2066 DrawCursorAndText_Info(y, TRUE);
2068 choice = choice_store[info_mode] = y;
2071 else if (!(info_info[y].type & TYPE_GHOSTED))
2073 PlaySound(SND_MENU_ITEM_SELECTING);
2075 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2077 void (*menu_callback_function)(void) = info_info[choice].value;
2079 FadeSetFromType(info_info[y].type);
2081 menu_callback_function();
2087 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2089 int ystart1 = mSY - SY + 100;
2090 int ystart2 = mSY - SY + 150;
2091 int ybottom = mSY - SY + SYSIZE - 20;
2093 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2095 FadeOut(REDRAW_FIELD);
2100 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2101 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2103 DrawTextSCentered(ybottom, FONT_TEXT_4,
2104 "Press any key or button for info menu");
2106 FadeIn(REDRAW_FIELD);
2109 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2111 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2112 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2113 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2114 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2115 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2116 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2117 int ystep = MENU_SCREEN_INFO_YSTEP;
2118 int element, action, direction;
2126 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2127 infoscreen_step[i] = infoscreen_frame[i] = 0;
2132 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2134 DrawTextSCentered(ybottom, FONT_TEXT_4,
2135 "Press any key or button for next page");
2141 while (helpanim_info[j].element != HELPANIM_LIST_END)
2143 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2148 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2157 j += infoscreen_step[i - start];
2159 element = helpanim_info[j].element;
2160 action = helpanim_info[j].action;
2161 direction = helpanim_info[j].direction;
2164 element = EL_UNKNOWN;
2166 if (action != -1 && direction != -1)
2167 graphic = el_act_dir2img(element, action, direction);
2168 else if (action != -1)
2169 graphic = el_act2img(element, action);
2170 else if (direction != -1)
2171 graphic = el_dir2img(element, direction);
2173 graphic = el2img(element);
2175 delay = helpanim_info[j++].delay;
2180 if (infoscreen_frame[i - start] == 0)
2183 infoscreen_frame[i - start] = delay - 1;
2187 sync_frame = delay - infoscreen_frame[i - start];
2188 infoscreen_frame[i - start]--;
2191 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2193 if (!infoscreen_frame[i - start])
2194 infoscreen_step[i - start] = 0;
2198 if (!infoscreen_frame[i - start])
2199 infoscreen_step[i - start]++;
2200 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2206 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2208 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2209 graphic, sync_frame, USE_MASKING);
2212 DrawInfoScreen_HelpText(element, action, direction, i - start);
2217 redraw_mask |= REDRAW_FIELD;
2222 static char *getHelpText(int element, int action, int direction)
2224 char token[MAX_LINE_LEN];
2226 strcpy(token, element_info[element].token_name);
2229 strcat(token, element_action_info[action].suffix);
2231 if (direction != -1)
2232 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2234 return getHashEntry(helptext_info, token);
2237 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2239 int font_nr = FONT_INFO_ELEMENTS;
2240 int font_width = getFontWidth(font_nr);
2241 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2242 int sy = mSY + 65 + 2 * 32 + 1;
2243 int ystep = TILEY + 4;
2244 int pad_x = sx - SX;
2245 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2246 int max_lines_per_text = 2;
2249 if (action != -1 && direction != -1) /* element.action.direction */
2250 text = getHelpText(element, action, direction);
2252 if (text == NULL && action != -1) /* element.action */
2253 text = getHelpText(element, action, -1);
2255 if (text == NULL && direction != -1) /* element.direction */
2256 text = getHelpText(element, -1, direction);
2258 if (text == NULL) /* base element */
2259 text = getHelpText(element, -1, -1);
2261 if (text == NULL) /* not found */
2262 text = "No description available";
2264 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2265 sy += getFontHeight(font_nr) / 2;
2267 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2268 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2269 TRUE, FALSE, FALSE);
2272 void DrawInfoScreen_TitleScreen()
2277 void HandleInfoScreen_TitleScreen(int button)
2279 HandleTitleScreen(0, 0, 0, 0, button);
2282 void DrawInfoScreen_Elements()
2284 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2286 FadeOut(REDRAW_FIELD);
2291 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2293 FadeIn(REDRAW_FIELD);
2298 void HandleInfoScreen_Elements(int button)
2300 static unsigned int info_delay = 0;
2301 static int num_anims;
2302 static int num_pages;
2304 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2307 if (button == MB_MENU_INITIALIZE)
2309 boolean new_element = TRUE;
2313 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2315 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2317 else if (new_element)
2320 new_element = FALSE;
2324 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2328 if (button == MB_MENU_LEAVE)
2330 PlaySound(SND_MENU_ITEM_SELECTING);
2332 info_mode = INFO_MODE_MAIN;
2337 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2339 if (button != MB_MENU_INITIALIZE)
2341 PlaySound(SND_MENU_ITEM_SELECTING);
2346 if (page >= num_pages)
2348 FadeSoundsAndMusic();
2350 info_mode = INFO_MODE_MAIN;
2351 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2357 FadeSetNextScreen();
2359 if (button != MB_MENU_INITIALIZE)
2360 FadeOut(REDRAW_FIELD);
2362 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2364 if (button != MB_MENU_INITIALIZE)
2365 FadeIn(REDRAW_FIELD);
2369 if (DelayReached(&info_delay, GameFrameDelay))
2370 if (page < num_pages)
2371 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2373 PlayMenuSoundIfLoop();
2377 void DrawInfoScreen_Music()
2379 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2381 FadeOut(REDRAW_FIELD);
2388 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2390 FadeIn(REDRAW_FIELD);
2393 void HandleInfoScreen_Music(int button)
2395 static struct MusicFileInfo *list = NULL;
2396 int ystart1 = mSY - SY + 100;
2397 int ystart2 = mSY - SY + 150;
2398 int ybottom = mSY - SY + SYSIZE - 20;
2401 if (button == MB_MENU_INITIALIZE)
2403 list = music_file_info;
2407 FadeSoundsAndMusic();
2412 DrawTextSCentered(ystart1, FONT_TEXT_1,
2413 "No music info for this level set.");
2415 DrawTextSCentered(ybottom, FONT_TEXT_4,
2416 "Press any key or button for info menu");
2422 if (button == MB_MENU_LEAVE)
2424 PlaySound(SND_MENU_ITEM_SELECTING);
2426 FadeSoundsAndMusic();
2428 info_mode = INFO_MODE_MAIN;
2433 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2437 if (button != MB_MENU_INITIALIZE)
2439 PlaySound(SND_MENU_ITEM_SELECTING);
2447 FadeSoundsAndMusic();
2449 info_mode = INFO_MODE_MAIN;
2450 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2455 FadeSoundsAndMusic();
2457 if (list != music_file_info)
2458 FadeSetNextScreen();
2460 if (button != MB_MENU_INITIALIZE)
2461 FadeOut(REDRAW_FIELD);
2468 int sound = list->music;
2470 if (sound_info[sound].loop)
2471 PlaySoundLoop(sound);
2475 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2479 PlayMusic(list->music);
2481 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2484 if (!strEqual(list->title, UNKNOWN_NAME))
2486 if (!strEqual(list->title_header, UNKNOWN_NAME))
2487 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2489 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2492 if (!strEqual(list->artist, UNKNOWN_NAME))
2494 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2495 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2497 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2499 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2502 if (!strEqual(list->album, UNKNOWN_NAME))
2504 if (!strEqual(list->album_header, UNKNOWN_NAME))
2505 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2507 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2509 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2512 if (!strEqual(list->year, UNKNOWN_NAME))
2514 if (!strEqual(list->year_header, UNKNOWN_NAME))
2515 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2517 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2519 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2522 DrawTextSCentered(ybottom, FONT_TEXT_4,
2523 "Press any key or button for next page");
2525 if (button != MB_MENU_INITIALIZE)
2526 FadeIn(REDRAW_FIELD);
2529 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2530 PlaySoundLoop(list->music);
2533 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2535 int ystart1 = mSY - SY + 100;
2536 int ystart2 = mSY - SY + 150;
2537 int ybottom = mSY - SY + SYSIZE - 20;
2543 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2547 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2548 "Special thanks to");
2549 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2551 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2553 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2554 "\"Boulder Dash\"");
2555 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2557 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2559 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2561 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2562 "First Star Software");
2564 else if (screen_nr == 1)
2566 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2567 "Special thanks to");
2568 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2569 "Klaus Heinz & Volker Wertich");
2570 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2572 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2573 "\"Emerald Mine\"");
2574 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2576 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2578 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2580 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2583 else if (screen_nr == 2)
2585 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2586 "Special thanks to");
2587 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2588 "Michael Stopp & Philip Jespersen");
2589 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2591 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2593 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2595 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2597 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2599 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2600 "Digital Integration");
2602 else if (screen_nr == 3)
2604 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2605 "Special thanks to");
2606 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2607 "Hiroyuki Imabayashi");
2608 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2610 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2612 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2614 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2616 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2618 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2621 else if (screen_nr == 4)
2623 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2624 "Special thanks to");
2625 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2627 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2629 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2630 "J\xfcrgen Bonhagen");
2631 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2632 "for the continuous creation");
2633 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2634 "of outstanding level sets");
2636 else if (screen_nr == 5)
2638 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2640 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2642 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2643 "for ideas and inspiration by");
2644 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2647 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2649 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2651 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2652 "for ideas and inspiration by");
2653 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2656 else if (screen_nr == 6)
2658 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2660 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2663 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2664 "for the code base used for the");
2665 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
2666 "native Emerald Mine engine");
2668 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2669 "for the new Emerald Mine engine");
2672 else if (screen_nr == 7)
2674 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2676 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2678 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2679 "for the initial DOS port");
2681 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2683 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2685 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2686 "for some additional toons");
2688 else if (screen_nr == 8)
2690 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2691 "And not to forget:");
2692 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2694 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2695 "All those who contributed");
2696 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2697 "levels to this game");
2698 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2702 DrawTextSCentered(ybottom, FONT_TEXT_4,
2703 "Press any key or button for next page");
2706 void DrawInfoScreen_Credits()
2708 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2710 FadeSoundsAndMusic();
2712 FadeOut(REDRAW_FIELD);
2714 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
2716 FadeIn(REDRAW_FIELD);
2719 void HandleInfoScreen_Credits(int button)
2721 static int screen_nr = 0;
2722 int num_screens = 9;
2724 if (button == MB_MENU_INITIALIZE)
2728 // DrawInfoScreen_CreditsScreen(screen_nr);
2731 if (button == MB_MENU_LEAVE)
2733 PlaySound(SND_MENU_ITEM_SELECTING);
2735 info_mode = INFO_MODE_MAIN;
2740 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2742 if (button != MB_MENU_INITIALIZE)
2744 PlaySound(SND_MENU_ITEM_SELECTING);
2749 if (screen_nr >= num_screens)
2751 FadeSoundsAndMusic();
2753 info_mode = INFO_MODE_MAIN;
2754 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2760 FadeSetNextScreen();
2762 if (button != MB_MENU_INITIALIZE)
2763 FadeOut(REDRAW_FIELD);
2765 DrawInfoScreen_CreditsScreen(screen_nr);
2767 if (button != MB_MENU_INITIALIZE)
2768 FadeIn(REDRAW_FIELD);
2772 PlayMenuSoundIfLoop();
2776 void DrawInfoScreen_Program()
2778 int ystart1 = mSY - SY + 100;
2779 int ystart2 = mSY - SY + 150;
2780 int ybottom = mSY - SY + SYSIZE - 20;
2783 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
2785 FadeOut(REDRAW_FIELD);
2790 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
2792 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2793 "This game is Freeware!");
2794 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2795 "If you like it, send e-mail to:");
2796 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2797 PROGRAM_EMAIL_STRING);
2798 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2799 "More information and levels:");
2800 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2801 PROGRAM_WEBSITE_STRING);
2802 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2803 "If you have created new levels,");
2804 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
2805 "send them to me to include them!");
2806 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
2809 DrawTextSCentered(ybottom, FONT_TEXT_4,
2810 "Press any key or button for info menu");
2812 FadeIn(REDRAW_FIELD);
2815 void HandleInfoScreen_Program(int button)
2817 if (button == MB_MENU_LEAVE)
2819 PlaySound(SND_MENU_ITEM_SELECTING);
2821 info_mode = INFO_MODE_MAIN;
2826 else if (button == MB_MENU_CHOICE)
2828 PlaySound(SND_MENU_ITEM_SELECTING);
2830 FadeSoundsAndMusic();
2832 info_mode = INFO_MODE_MAIN;
2833 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2837 PlayMenuSoundIfLoop();
2841 void DrawInfoScreen_Version()
2843 int font_header = FONT_TEXT_3;
2844 int font_text = FONT_TEXT_2;
2845 int xstep = getFontWidth(font_text);
2846 int ystep = getFontHeight(font_text);
2847 int ystart1 = mSY - SY + 100;
2848 int ystart2 = mSY - SY + 150;
2849 int ybottom = mSY - SY + SYSIZE - 20;
2850 int xstart1 = mSX - SX + 2 * xstep;
2851 int xstart2 = mSX - SX + 18 * xstep;
2852 int xstart3 = mSX - SX + 28 * xstep;
2853 SDL_version sdl_version_compiled;
2854 const SDL_version *sdl_version_linked;
2855 int driver_name_len = 10;
2856 #if defined(TARGET_SDL2)
2857 SDL_version sdl_version_linked_ext;
2858 const char *driver_name = NULL;
2860 char driver_name[driver_name_len];
2863 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
2865 FadeOut(REDRAW_FIELD);
2870 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
2872 DrawTextF(xstart1, ystart2, font_header, "Name");
2873 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
2876 DrawTextF(xstart1, ystart2, font_header, "Version");
2877 DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
2880 DrawTextF(xstart1, ystart2, font_header, "Platform");
2881 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
2884 DrawTextF(xstart1, ystart2, font_header, "Target");
2885 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
2888 DrawTextF(xstart1, ystart2, font_header, "Compile time");
2889 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
2891 ystart2 += 3 * ystep;
2892 DrawTextF(xstart1, ystart2, font_header, "Library");
2893 DrawTextF(xstart2, ystart2, font_header, "compiled");
2894 DrawTextF(xstart3, ystart2, font_header, "linked");
2896 SDL_VERSION(&sdl_version_compiled);
2897 #if defined(TARGET_SDL2)
2898 SDL_GetVersion(&sdl_version_linked_ext);
2899 sdl_version_linked = &sdl_version_linked_ext;
2901 sdl_version_linked = SDL_Linked_Version();
2904 ystart2 += 2 * ystep;
2905 DrawTextF(xstart1, ystart2, font_text, "SDL");
2906 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2907 sdl_version_compiled.major,
2908 sdl_version_compiled.minor,
2909 sdl_version_compiled.patch);
2910 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2911 sdl_version_linked->major,
2912 sdl_version_linked->minor,
2913 sdl_version_linked->patch);
2915 SDL_IMAGE_VERSION(&sdl_version_compiled);
2916 sdl_version_linked = IMG_Linked_Version();
2919 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
2920 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2921 sdl_version_compiled.major,
2922 sdl_version_compiled.minor,
2923 sdl_version_compiled.patch);
2924 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2925 sdl_version_linked->major,
2926 sdl_version_linked->minor,
2927 sdl_version_linked->patch);
2929 SDL_MIXER_VERSION(&sdl_version_compiled);
2930 sdl_version_linked = Mix_Linked_Version();
2933 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
2934 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2935 sdl_version_compiled.major,
2936 sdl_version_compiled.minor,
2937 sdl_version_compiled.patch);
2938 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2939 sdl_version_linked->major,
2940 sdl_version_linked->minor,
2941 sdl_version_linked->patch);
2943 SDL_NET_VERSION(&sdl_version_compiled);
2944 sdl_version_linked = SDLNet_Linked_Version();
2947 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
2948 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2949 sdl_version_compiled.major,
2950 sdl_version_compiled.minor,
2951 sdl_version_compiled.patch);
2952 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2953 sdl_version_linked->major,
2954 sdl_version_linked->minor,
2955 sdl_version_linked->patch);
2957 ystart2 += 3 * ystep;
2958 DrawTextF(xstart1, ystart2, font_header, "Driver");
2959 DrawTextF(xstart2, ystart2, font_header, "Requested");
2960 DrawTextF(xstart3, ystart2, font_header, "Used");
2962 #if defined(TARGET_SDL2)
2963 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
2965 SDL_VideoDriverName(driver_name, driver_name_len);
2968 ystart2 += 2 * ystep;
2969 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
2970 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
2971 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2973 #if defined(TARGET_SDL2)
2974 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
2976 SDL_AudioDriverName(driver_name, driver_name_len);
2980 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
2981 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
2982 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2984 DrawTextSCentered(ybottom, FONT_TEXT_4,
2985 "Press any key or button for info menu");
2987 FadeIn(REDRAW_FIELD);
2990 void HandleInfoScreen_Version(int button)
2992 if (button == MB_MENU_LEAVE)
2994 PlaySound(SND_MENU_ITEM_SELECTING);
2996 info_mode = INFO_MODE_MAIN;
3001 else if (button == MB_MENU_CHOICE)
3003 PlaySound(SND_MENU_ITEM_SELECTING);
3005 FadeSoundsAndMusic();
3007 info_mode = INFO_MODE_MAIN;
3008 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3012 PlayMenuSoundIfLoop();
3016 void DrawInfoScreen_LevelSet()
3018 struct TitleMessageInfo *tmi = &readme;
3019 char *filename = getLevelSetInfoFilename();
3021 /* if chars set to "-1", automatically determine by text and font width */
3022 if (tmi->chars == -1)
3023 tmi->chars = tmi->width / getFontWidth(tmi->font);
3025 tmi->width = tmi->chars * getFontWidth(tmi->font);
3027 /* if lines set to "-1", automatically determine by text and font height */
3028 if (tmi->lines == -1)
3029 tmi->lines = tmi->height / getFontHeight(tmi->font);
3031 tmi->height = tmi->lines * getFontHeight(tmi->font);
3033 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3035 FadeOut(REDRAW_FIELD);
3040 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3042 if (filename != NULL)
3043 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3044 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3045 tmi->autowrap, tmi->centered, tmi->parse_comments);
3047 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3048 "No information for this level set.");
3050 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3051 "Press any key or button for info menu");
3053 FadeIn(REDRAW_FIELD);
3056 void HandleInfoScreen_LevelSet(int button)
3058 if (button == MB_MENU_LEAVE)
3060 PlaySound(SND_MENU_ITEM_SELECTING);
3062 info_mode = INFO_MODE_MAIN;
3067 else if (button == MB_MENU_CHOICE)
3069 PlaySound(SND_MENU_ITEM_SELECTING);
3071 FadeSoundsAndMusic();
3073 info_mode = INFO_MODE_MAIN;
3074 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3078 PlayMenuSoundIfLoop();
3082 static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
3084 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3086 if (info_mode == INFO_MODE_TITLE)
3087 DrawInfoScreen_TitleScreen();
3088 else if (info_mode == INFO_MODE_ELEMENTS)
3089 DrawInfoScreen_Elements();
3090 else if (info_mode == INFO_MODE_MUSIC)
3091 DrawInfoScreen_Music();
3092 else if (info_mode == INFO_MODE_CREDITS)
3093 DrawInfoScreen_Credits();
3094 else if (info_mode == INFO_MODE_PROGRAM)
3095 DrawInfoScreen_Program();
3096 else if (info_mode == INFO_MODE_VERSION)
3097 DrawInfoScreen_Version();
3098 else if (info_mode == INFO_MODE_LEVELSET)
3099 DrawInfoScreen_LevelSet();
3101 DrawInfoScreen_Main(fade_mask, do_fading);
3103 if (info_mode != INFO_MODE_MAIN &&
3104 info_mode != INFO_MODE_TITLE &&
3105 info_mode != INFO_MODE_MUSIC)
3112 void DrawAndFadeInInfoScreen(int fade_mask)
3114 DrawInfoScreenExt(fade_mask, TRUE);
3117 void DrawInfoScreen()
3119 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3122 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3124 if (info_mode == INFO_MODE_TITLE)
3125 HandleInfoScreen_TitleScreen(button);
3126 else if (info_mode == INFO_MODE_ELEMENTS)
3127 HandleInfoScreen_Elements(button);
3128 else if (info_mode == INFO_MODE_MUSIC)
3129 HandleInfoScreen_Music(button);
3130 else if (info_mode == INFO_MODE_CREDITS)
3131 HandleInfoScreen_Credits(button);
3132 else if (info_mode == INFO_MODE_PROGRAM)
3133 HandleInfoScreen_Program(button);
3134 else if (info_mode == INFO_MODE_VERSION)
3135 HandleInfoScreen_Version(button);
3136 else if (info_mode == INFO_MODE_LEVELSET)
3137 HandleInfoScreen_LevelSet(button);
3139 HandleInfoScreen_Main(mx, my, dx, dy, button);
3143 /* ========================================================================= */
3144 /* type name functions */
3145 /* ========================================================================= */
3147 void HandleTypeName(int newxpos, Key key)
3149 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3150 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3151 struct TextPosInfo *pos = mci->pos_input;
3152 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3153 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3154 static int xpos = 0;
3155 int font_nr = pos->font;
3156 int font_active_nr = FONT_ACTIVE(font_nr);
3157 int font_width = getFontWidth(font_active_nr);
3158 char key_char = getValidConfigValueChar(getCharFromKey(key));
3159 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3160 boolean is_active = TRUE;
3162 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3166 strcpy(last_player_name, setup.player_name);
3170 #if defined(TARGET_SDL2)
3171 SDL_StartTextInput();
3174 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3176 setup.player_name[xpos] = key_char;
3177 setup.player_name[xpos + 1] = 0;
3181 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3185 setup.player_name[xpos] = 0;
3187 else if (key == KSYM_Return && xpos > 0)
3193 game_status = GAME_MODE_MAIN;
3195 else if (key == KSYM_Escape)
3197 strcpy(setup.player_name, last_player_name);
3201 game_status = GAME_MODE_MAIN;
3206 pos->width = (strlen(setup.player_name) + 1) * font_width;
3207 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3209 DrawText(startx, starty, setup.player_name, font_active_nr);
3210 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3214 pos->width = strlen(setup.player_name) * font_width;
3215 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3217 DrawText(startx, starty, setup.player_name, font_nr);
3219 #if defined(TARGET_SDL2)
3220 SDL_StopTextInput();
3226 /* ========================================================================= */
3227 /* tree menu functions */
3228 /* ========================================================================= */
3230 static void DrawChooseTree(TreeInfo **ti_ptr)
3234 FreeScreenGadgets();
3235 CreateScreenGadgets();
3237 CloseDoor(DOOR_CLOSE_2);
3239 FadeOut(REDRAW_FIELD);
3243 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3244 MapScreenTreeGadgets(*ti_ptr);
3246 FadeIn(REDRAW_FIELD);
3251 static void AdjustScrollbar(int id, int items_max, int items_visible,
3254 struct GadgetInfo *gi = screen_gadget[id];
3256 if (item_position > items_max - items_visible)
3257 item_position = items_max - items_visible;
3259 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3260 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3261 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3264 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3266 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3270 static void clearMenuListArea()
3272 int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3274 /* correct scrollbar position if placed outside menu (playfield) area */
3275 if (scrollbar_xpos > SC_SCROLLBAR_XPOS)
3276 scrollbar_xpos = SC_SCROLLBAR_XPOS;
3278 /* clear menu list area, but not title or scrollbar */
3279 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3280 scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
3283 static void drawChooseTreeList(int first_entry, int num_page_entries,
3287 char *title_string = NULL;
3288 int yoffset_sets = MENU_TITLE1_YPOS;
3289 int yoffset_setup = 16;
3290 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3291 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3292 int last_game_status = game_status; /* save current game status */
3294 title_string = ti->infotext;
3296 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3298 clearMenuListArea();
3300 for (i = 0; i < num_page_entries; i++)
3302 TreeInfo *node, *node_first;
3303 int entry_pos = first_entry + i;
3304 int xpos = MENU_SCREEN_START_XPOS;
3305 int ypos = MENU_SCREEN_START_YPOS + i;
3306 int startx = mSX + xpos * 32;
3307 int starty = mSY + ypos * 32;
3308 int font_nr = FONT_TEXT_1;
3309 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3310 int startx_text = startx + font_xoffset;
3311 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3312 int text_size = startx_scrollbar - startx_text;
3313 int max_buffer_len = text_size / getFontWidth(font_nr);
3314 char buffer[max_buffer_len + 1];
3316 node_first = getTreeInfoFirstGroupEntry(ti);
3317 node = getTreeInfoFromPos(node_first, entry_pos);
3319 strncpy(buffer, node->name, max_buffer_len);
3320 buffer[max_buffer_len] = '\0';
3322 DrawText(startx, starty, buffer, font_nr + node->color);
3324 if (node->parent_link)
3325 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3326 else if (node->level_group)
3327 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3329 initCursor(i, IMG_MENU_BUTTON);
3332 game_status = last_game_status; /* restore current game status */
3334 redraw_mask |= REDRAW_FIELD;
3337 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3339 TreeInfo *node, *node_first;
3340 int x, last_redraw_mask = redraw_mask;
3341 int ypos = MENU_TITLE2_YPOS;
3342 int font_nr = FONT_TITLE_2;
3344 if (ti->type == TREE_TYPE_LEVEL_NR)
3345 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3347 if (ti->type != TREE_TYPE_LEVEL_DIR)
3350 node_first = getTreeInfoFirstGroupEntry(ti);
3351 node = getTreeInfoFromPos(node_first, entry_pos);
3353 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3355 if (node->parent_link)
3356 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3357 node->node_parent->name);
3358 else if (node->level_group)
3359 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3361 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3362 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3363 node->levels, (node->levels > 1 ? "levels" : "level"),
3366 /* let BackToFront() redraw only what is needed */
3367 redraw_mask = last_redraw_mask | REDRAW_TILES;
3368 for (x = 0; x < SCR_FIELDX; x++)
3369 MarkTileDirty(x, 1);
3372 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3375 TreeInfo *ti = *ti_ptr;
3377 int y = ti->cl_cursor;
3378 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3379 int num_entries = numTreeInfoInGroup(ti);
3380 int num_page_entries;
3381 int last_game_status = game_status; /* save current game status */
3382 boolean position_set_by_scrollbar = (dx == 999);
3384 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3385 num_page_entries = num_entries;
3387 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3389 game_status = last_game_status; /* restore current game status */
3391 if (button == MB_MENU_INITIALIZE)
3393 int num_entries = numTreeInfoInGroup(ti);
3394 int entry_pos = posTreeInfo(ti);
3396 if (ti->cl_first == -1)
3398 /* only on initialization */
3399 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3400 ti->cl_cursor = entry_pos - ti->cl_first;
3402 else if (ti->cl_cursor >= num_page_entries ||
3403 (num_entries > num_page_entries &&
3404 num_entries - ti->cl_first < num_page_entries))
3406 /* only after change of list size (by custom graphic configuration) */
3407 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3408 ti->cl_cursor = entry_pos - ti->cl_first;
3411 if (position_set_by_scrollbar)
3414 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3417 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3418 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3419 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3423 else if (button == MB_MENU_LEAVE)
3427 PlaySound(SND_MENU_ITEM_SELECTING);
3429 if (ti->node_parent)
3431 *ti_ptr = ti->node_parent;
3432 DrawChooseTree(ti_ptr);
3434 else if (game_status == GAME_MODE_SETUP)
3436 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3437 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3439 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3440 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3441 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3442 execSetupGraphics();
3443 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3444 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3445 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3447 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3448 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3449 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3456 if (game_status == GAME_MODE_LEVELNR)
3458 int new_level_nr = atoi(level_number_current->identifier);
3460 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
3463 game_status = GAME_MODE_MAIN;
3465 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3471 if (mx || my) /* mouse input */
3473 int last_game_status = game_status; /* save current game status */
3475 x = (mx - mSX) / 32;
3476 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3478 game_status = last_game_status; /* restore current game status */
3480 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3482 /* move cursor instead of scrolling when already at start/end of list */
3483 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3485 else if (dy == +1 * SCROLL_LINE &&
3486 ti->cl_first + num_page_entries == num_entries)
3489 /* handle scrolling screen one line or page */
3490 if (ti->cl_cursor + dy < 0 ||
3491 ti->cl_cursor + dy > num_page_entries - 1)
3493 boolean redraw = FALSE;
3495 if (ABS(dy) == SCROLL_PAGE)
3496 step = num_page_entries - 1;
3498 if (dy < 0 && ti->cl_first > 0)
3500 /* scroll page/line up */
3502 ti->cl_first -= step;
3503 if (ti->cl_first < 0)
3508 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3510 /* scroll page/line down */
3512 ti->cl_first += step;
3513 if (ti->cl_first + num_page_entries > num_entries)
3514 ti->cl_first = MAX(0, num_entries - num_page_entries);
3521 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3522 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3523 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3525 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3533 /* handle moving cursor one line */
3534 y = ti->cl_cursor + dy;
3539 TreeInfo *node_first, *node_cursor;
3540 int entry_pos = ti->cl_first + y;
3542 node_first = getTreeInfoFirstGroupEntry(ti);
3543 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3545 if (node_cursor->node_group)
3549 PlaySound(SND_MENU_ITEM_SELECTING);
3551 node_cursor->cl_first = ti->cl_first;
3552 node_cursor->cl_cursor = ti->cl_cursor;
3553 *ti_ptr = node_cursor->node_group;
3554 DrawChooseTree(ti_ptr);
3559 else if (dx == -1 && ti->node_parent)
3563 PlaySound(SND_MENU_ITEM_SELECTING);
3565 *ti_ptr = ti->node_parent;
3566 DrawChooseTree(ti_ptr);
3571 if (!anyScrollbarGadgetActive() &&
3572 IN_VIS_MENU(x, y) &&
3573 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3574 y >= 0 && y < num_page_entries)
3578 if (y != ti->cl_cursor)
3580 PlaySound(SND_MENU_ITEM_ACTIVATING);
3582 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3583 drawChooseTreeCursor(y, TRUE);
3584 drawChooseTreeInfo(ti->cl_first + y, ti);
3591 TreeInfo *node_first, *node_cursor;
3592 int entry_pos = ti->cl_first + y;
3594 PlaySound(SND_MENU_ITEM_SELECTING);
3596 node_first = getTreeInfoFirstGroupEntry(ti);
3597 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3599 if (node_cursor->node_group)
3603 node_cursor->cl_first = ti->cl_first;
3604 node_cursor->cl_cursor = ti->cl_cursor;
3605 *ti_ptr = node_cursor->node_group;
3606 DrawChooseTree(ti_ptr);
3608 else if (node_cursor->parent_link)
3612 *ti_ptr = node_cursor->node_parent;
3613 DrawChooseTree(ti_ptr);
3619 node_cursor->cl_first = ti->cl_first;
3620 node_cursor->cl_cursor = ti->cl_cursor;
3621 *ti_ptr = node_cursor;
3623 if (ti->type == TREE_TYPE_LEVEL_DIR)
3625 LoadLevelSetup_SeriesInfo();
3627 SaveLevelSetup_LastSeries();
3628 SaveLevelSetup_SeriesInfo();
3632 if (game_status == GAME_MODE_SETUP)
3634 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3635 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3637 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3638 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3639 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3640 execSetupGraphics();
3641 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3642 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3643 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3645 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3646 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3647 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3654 if (game_status == GAME_MODE_LEVELNR)
3656 int new_level_nr = atoi(level_number_current->identifier);
3658 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
3661 game_status = GAME_MODE_MAIN;
3670 void DrawChooseLevelSet()
3672 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3674 DrawChooseTree(&leveldir_current);
3680 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
3682 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
3685 void DrawChooseLevelNr()
3689 if (level_number != NULL)
3691 freeTreeInfo(level_number);
3693 level_number = NULL;
3696 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
3698 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
3699 char identifier[32], name[32];
3702 /* temporarily load level info to get level name */
3703 LoadLevelInfoOnly(i);
3705 ti->node_top = &level_number;
3706 ti->sort_priority = 10000 + value;
3707 ti->color = (level.no_valid_file ? FC_BLUE :
3708 LevelStats_getSolved(i) ? FC_GREEN :
3709 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
3711 sprintf(identifier, "%d", value);
3712 sprintf(name, "%03d: %s", value,
3713 (level.no_valid_file ? "(no file)" : level.name));
3715 setString(&ti->identifier, identifier);
3716 setString(&ti->name, name);
3717 setString(&ti->name_sorting, name);
3719 pushTreeInfo(&level_number, ti);
3722 /* sort level number values to start with lowest level number */
3723 sortTreeInfo(&level_number);
3725 /* set current level number to current level number */
3726 level_number_current =
3727 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
3729 /* if that also fails, set current level number to first available level */
3730 if (level_number_current == NULL)
3731 level_number_current = level_number;
3733 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3735 DrawChooseTree(&level_number_current);
3741 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
3743 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
3746 void DrawHallOfFame(int highlight_position)
3749 FadeSoundsAndMusic();
3751 /* (this is needed when called from GameEnd() after winning a game) */
3752 KeyboardAutoRepeatOn();
3755 /* (this is needed when called from GameEnd() after winning a game) */
3756 SetDrawDeactivationMask(REDRAW_NONE);
3757 SetDrawBackgroundMask(REDRAW_FIELD);
3759 CloseDoor(DOOR_CLOSE_2);
3761 if (highlight_position < 0)
3762 LoadScore(level_nr);
3764 FadeSetEnterScreen();
3766 FadeOut(REDRAW_FIELD);
3773 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
3775 FadeIn(REDRAW_FIELD);
3778 static void drawHallOfFameList(int first_entry, int highlight_position)
3782 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
3785 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
3786 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
3787 "HighScores of Level %d", level_nr);
3789 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
3791 int entry = first_entry + i;
3792 boolean active = (entry == highlight_position);
3793 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
3794 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
3795 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
3796 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
3797 int dx1 = 3 * getFontWidth(font_nr1);
3798 int dx2 = dx1 + getFontWidth(font_nr1);
3799 int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
3800 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
3801 int sy = mSY + 64 + i * 32;
3803 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
3804 DrawText(mSX + dx1, sy, ".", font_nr1);
3806 for (j = 0; j < num_dots; j++)
3807 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
3809 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
3810 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
3812 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
3815 redraw_mask |= REDRAW_FIELD;
3818 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
3820 static int first_entry = 0;
3821 static int highlight_position = 0;
3822 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3824 if (button == MB_MENU_INITIALIZE)
3827 highlight_position = mx;
3828 drawHallOfFameList(first_entry, highlight_position);
3833 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
3834 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
3838 if (first_entry > 0)
3840 first_entry -= step;
3841 if (first_entry < 0)
3844 drawHallOfFameList(first_entry, highlight_position);
3849 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
3851 first_entry += step;
3852 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
3853 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
3855 drawHallOfFameList(first_entry, highlight_position);
3858 else if (button == MB_MENU_LEAVE)
3860 PlaySound(SND_MENU_ITEM_SELECTING);
3862 FadeSound(SND_BACKGROUND_SCORES);
3864 game_status = GAME_MODE_MAIN;
3868 else if (button == MB_MENU_CHOICE)
3870 PlaySound(SND_MENU_ITEM_SELECTING);
3872 FadeSound(SND_BACKGROUND_SCORES);
3874 game_status = GAME_MODE_MAIN;
3876 DrawAndFadeInMainMenu(REDRAW_FIELD);
3879 if (game_status == GAME_MODE_SCORES)
3880 PlayMenuSoundIfLoop();
3884 /* ========================================================================= */
3885 /* setup screen functions */
3886 /* ========================================================================= */
3888 static struct TokenInfo *setup_info;
3889 static int num_setup_info; /* number of setup entries shown on screen */
3890 static int max_setup_info; /* total number of setup entries in list */
3892 static char *screen_mode_text;
3893 static char *window_size_text;
3894 static char *scaling_type_text;
3895 static char *scroll_delay_text;
3896 static char *game_speed_text;
3897 static char *graphics_set_name;
3898 static char *sounds_set_name;
3899 static char *music_set_name;
3900 static char *volume_simple_text;
3901 static char *volume_loops_text;
3902 static char *volume_music_text;
3903 static char *touch_controls_text;
3904 static char *move_distance_text;
3905 static char *drop_distance_text;
3907 static void execSetupMain()
3909 setup_mode = SETUP_MODE_MAIN;
3914 static void execSetupGame_setGameSpeeds()
3916 if (game_speeds == NULL)
3920 for (i = 0; game_speeds_list[i].value != -1; i++)
3922 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3923 char identifier[32], name[32];
3924 int value = game_speeds_list[i].value;
3925 char *text = game_speeds_list[i].text;
3927 ti->node_top = &game_speeds;
3928 ti->sort_priority = 10000 - value;
3930 sprintf(identifier, "%d", value);
3931 sprintf(name, "%s", text);
3933 setString(&ti->identifier, identifier);
3934 setString(&ti->name, name);
3935 setString(&ti->name_sorting, name);
3936 setString(&ti->infotext, "Game Speed");
3938 pushTreeInfo(&game_speeds, ti);
3941 /* sort game speed values to start with slowest game speed */
3942 sortTreeInfo(&game_speeds);
3944 /* set current game speed to configured game speed value */
3945 game_speed_current =
3946 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
3948 /* if that fails, set current game speed to reliable default value */
3949 if (game_speed_current == NULL)
3950 game_speed_current =
3951 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
3953 /* if that also fails, set current game speed to first available speed */
3954 if (game_speed_current == NULL)
3955 game_speed_current = game_speeds;
3958 setup.game_frame_delay = atoi(game_speed_current->identifier);
3960 /* needed for displaying game speed text instead of identifier */
3961 game_speed_text = game_speed_current->name;
3964 static void execSetupGame_setScrollDelays()
3966 if (scroll_delays == NULL)
3970 for (i = 0; scroll_delays_list[i].value != -1; i++)
3972 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3973 char identifier[32], name[32];
3974 int value = scroll_delays_list[i].value;
3975 char *text = scroll_delays_list[i].text;
3977 ti->node_top = &scroll_delays;
3978 ti->sort_priority = value;
3980 sprintf(identifier, "%d", value);
3981 sprintf(name, "%s", text);
3983 setString(&ti->identifier, identifier);
3984 setString(&ti->name, name);
3985 setString(&ti->name_sorting, name);
3986 setString(&ti->infotext, "Scaling Type");
3988 pushTreeInfo(&scroll_delays, ti);
3991 /* sort scaling type values to start with lowest scaling type value */
3992 sortTreeInfo(&scroll_delays);
3994 /* set current scaling type value to configured scaling type value */
3995 scroll_delay_current =
3996 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
3998 /* if that fails, set current scaling type to reliable default value */
3999 if (scroll_delay_current == NULL)
4000 scroll_delay_current =
4001 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4003 /* if that also fails, set current scaling type to first available value */
4004 if (scroll_delay_current == NULL)
4005 scroll_delay_current = scroll_delays;
4008 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4010 /* needed for displaying scaling type text instead of identifier */
4011 scroll_delay_text = scroll_delay_current->name;
4014 static void execSetupGame()
4016 execSetupGame_setGameSpeeds();
4017 execSetupGame_setScrollDelays();
4019 setup_mode = SETUP_MODE_GAME;
4024 static void execSetupChooseGameSpeed()
4026 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4031 static void execSetupChooseScrollDelay()
4033 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4038 static void execSetupEditor()
4040 setup_mode = SETUP_MODE_EDITOR;
4045 static void execSetupGraphics_setWindowSizes(boolean update_list)
4047 if (window_sizes != NULL && update_list)
4049 freeTreeInfo(window_sizes);
4051 window_sizes = NULL;
4054 if (window_sizes == NULL)
4056 boolean current_window_size_found = FALSE;
4059 for (i = 0; window_sizes_list[i].value != -1; i++)
4061 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4062 char identifier[32], name[32];
4063 int value = window_sizes_list[i].value;
4064 char *text = window_sizes_list[i].text;
4066 ti->node_top = &window_sizes;
4067 ti->sort_priority = value;
4069 sprintf(identifier, "%d", value);
4070 sprintf(name, "%s", text);
4072 setString(&ti->identifier, identifier);
4073 setString(&ti->name, name);
4074 setString(&ti->name_sorting, name);
4075 setString(&ti->infotext, "Window Scaling");
4077 pushTreeInfo(&window_sizes, ti);
4079 if (value == setup.window_scaling_percent)
4080 current_window_size_found = TRUE;
4083 if (!current_window_size_found)
4085 // add entry for non-preset window scaling value
4087 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4088 char identifier[32], name[32];
4089 int value = setup.window_scaling_percent;
4091 ti->node_top = &window_sizes;
4092 ti->sort_priority = value;
4094 sprintf(identifier, "%d", value);
4095 sprintf(name, "%d %% (Current)", value);
4097 setString(&ti->identifier, identifier);
4098 setString(&ti->name, name);
4099 setString(&ti->name_sorting, name);
4100 setString(&ti->infotext, "Window Scaling");
4102 pushTreeInfo(&window_sizes, ti);
4105 /* sort window size values to start with lowest window size value */
4106 sortTreeInfo(&window_sizes);
4108 /* set current window size value to configured window size value */
4109 window_size_current =
4110 getTreeInfoFromIdentifier(window_sizes,
4111 i_to_a(setup.window_scaling_percent));
4113 /* if that fails, set current window size to reliable default value */
4114 if (window_size_current == NULL)
4115 window_size_current =
4116 getTreeInfoFromIdentifier(window_sizes,
4117 i_to_a(STD_WINDOW_SCALING_PERCENT));
4119 /* if that also fails, set current window size to first available value */
4120 if (window_size_current == NULL)
4121 window_size_current = window_sizes;
4124 setup.window_scaling_percent = atoi(window_size_current->identifier);
4126 /* needed for displaying window size text instead of identifier */
4127 window_size_text = window_size_current->name;
4130 static void execSetupGraphics_setScalingTypes()
4132 if (scaling_types == NULL)
4136 for (i = 0; scaling_types_list[i].value != NULL; i++)
4138 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4139 char identifier[32], name[32];
4140 char *value = scaling_types_list[i].value;
4141 char *text = scaling_types_list[i].text;
4143 ti->node_top = &scaling_types;
4144 ti->sort_priority = i;
4146 sprintf(identifier, "%s", value);
4147 sprintf(name, "%s", text);
4149 setString(&ti->identifier, identifier);
4150 setString(&ti->name, name);
4151 setString(&ti->name_sorting, name);
4152 setString(&ti->infotext, "Anti-Aliasing");
4154 pushTreeInfo(&scaling_types, ti);
4157 /* sort scaling type values to start with lowest scaling type value */
4158 sortTreeInfo(&scaling_types);
4160 /* set current scaling type value to configured scaling type value */
4161 scaling_type_current =
4162 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4164 /* if that fails, set current scaling type to reliable default value */
4165 if (scaling_type_current == NULL)
4166 scaling_type_current =
4167 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4169 /* if that also fails, set current scaling type to first available value */
4170 if (scaling_type_current == NULL)
4171 scaling_type_current = scaling_types;
4174 setup.window_scaling_quality = scaling_type_current->identifier;
4176 /* needed for displaying scaling type text instead of identifier */
4177 scaling_type_text = scaling_type_current->name;
4180 static void execSetupGraphics_setScreenModes()
4182 // if (screen_modes == NULL && video.fullscreen_available)
4183 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4187 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4189 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4190 char identifier[32], name[32];
4191 int x = video.fullscreen_modes[i].width;
4192 int y = video.fullscreen_modes[i].height;
4195 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4197 ti->node_top = &screen_modes;
4198 ti->sort_priority = x * 10000 + y;
4200 sprintf(identifier, "%dx%d", x, y);
4201 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4203 setString(&ti->identifier, identifier);
4204 setString(&ti->name, name);
4205 setString(&ti->name_sorting, name);
4206 setString(&ti->infotext, "Fullscreen Mode");
4208 pushTreeInfo(&screen_modes, ti);
4211 /* sort fullscreen modes to start with lowest available screen resolution */
4212 sortTreeInfo(&screen_modes);
4214 /* set current screen mode for fullscreen mode to configured setup value */
4215 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4216 setup.fullscreen_mode);
4218 /* if that fails, set current screen mode to reliable default value */
4219 if (screen_mode_current == NULL)
4220 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4221 DEFAULT_FULLSCREEN_MODE);
4223 /* if that also fails, set current screen mode to first available mode */
4224 if (screen_mode_current == NULL)
4225 screen_mode_current = screen_modes;
4227 if (screen_mode_current == NULL)
4228 video.fullscreen_available = FALSE;
4231 // if (video.fullscreen_available)
4232 if (screen_mode_current != NULL)
4234 setup.fullscreen_mode = screen_mode_current->identifier;
4236 /* needed for displaying screen mode name instead of identifier */
4237 screen_mode_text = screen_mode_current->name;
4241 static void execSetupGraphics()
4243 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4245 // update "setup.window_scaling_percent" from list selection
4246 execSetupGraphics_setWindowSizes(FALSE);
4250 // update list selection from "setup.window_scaling_percent"
4251 execSetupGraphics_setWindowSizes(TRUE);
4254 execSetupGraphics_setScalingTypes();
4255 execSetupGraphics_setScreenModes();
4257 setup_mode = SETUP_MODE_GRAPHICS;
4261 #if defined(TARGET_SDL2)
4262 // window scaling may have changed at this point
4263 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4265 // window scaling quality may have changed at this point
4266 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4267 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4271 #if !defined(PLATFORM_ANDROID)
4272 #if defined(TARGET_SDL2)
4273 static void execSetupChooseWindowSize()
4275 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4280 static void execSetupChooseScalingType()
4282 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4287 static void execSetupChooseScreenMode()
4289 if (!video.fullscreen_available)
4292 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4299 static void execSetupChooseVolumeSimple()
4301 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4306 static void execSetupChooseVolumeLoops()
4308 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4313 static void execSetupChooseVolumeMusic()
4315 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4320 static void execSetupSound()
4322 if (volumes_simple == NULL)
4326 for (i = 0; volumes_list[i].value != -1; i++)
4328 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4329 char identifier[32], name[32];
4330 int value = volumes_list[i].value;
4331 char *text = volumes_list[i].text;
4333 ti->node_top = &volumes_simple;
4334 ti->sort_priority = value;
4336 sprintf(identifier, "%d", value);
4337 sprintf(name, "%s", text);
4339 setString(&ti->identifier, identifier);
4340 setString(&ti->name, name);
4341 setString(&ti->name_sorting, name);
4342 setString(&ti->infotext, "Sound Volume");
4344 pushTreeInfo(&volumes_simple, ti);
4347 /* sort volume values to start with lowest volume value */
4348 sortTreeInfo(&volumes_simple);
4350 /* set current volume value to configured volume value */
4351 volume_simple_current =
4352 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4354 /* if that fails, set current volume to reliable default value */
4355 if (volume_simple_current == NULL)
4356 volume_simple_current =
4357 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4359 /* if that also fails, set current volume to first available value */
4360 if (volume_simple_current == NULL)
4361 volume_simple_current = volumes_simple;
4364 if (volumes_loops == NULL)
4368 for (i = 0; volumes_list[i].value != -1; i++)
4370 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4371 char identifier[32], name[32];
4372 int value = volumes_list[i].value;
4373 char *text = volumes_list[i].text;
4375 ti->node_top = &volumes_loops;
4376 ti->sort_priority = value;
4378 sprintf(identifier, "%d", value);
4379 sprintf(name, "%s", text);
4381 setString(&ti->identifier, identifier);
4382 setString(&ti->name, name);
4383 setString(&ti->name_sorting, name);
4384 setString(&ti->infotext, "Loops Volume");
4386 pushTreeInfo(&volumes_loops, ti);
4389 /* sort volume values to start with lowest volume value */
4390 sortTreeInfo(&volumes_loops);
4392 /* set current volume value to configured volume value */
4393 volume_loops_current =
4394 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4396 /* if that fails, set current volume to reliable default value */
4397 if (volume_loops_current == NULL)
4398 volume_loops_current =
4399 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4401 /* if that also fails, set current volume to first available value */
4402 if (volume_loops_current == NULL)
4403 volume_loops_current = volumes_loops;
4406 if (volumes_music == NULL)
4410 for (i = 0; volumes_list[i].value != -1; i++)
4412 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4413 char identifier[32], name[32];
4414 int value = volumes_list[i].value;
4415 char *text = volumes_list[i].text;
4417 ti->node_top = &volumes_music;
4418 ti->sort_priority = value;
4420 sprintf(identifier, "%d", value);
4421 sprintf(name, "%s", text);
4423 setString(&ti->identifier, identifier);
4424 setString(&ti->name, name);
4425 setString(&ti->name_sorting, name);
4426 setString(&ti->infotext, "Music Volume");
4428 pushTreeInfo(&volumes_music, ti);
4431 /* sort volume values to start with lowest volume value */
4432 sortTreeInfo(&volumes_music);
4434 /* set current volume value to configured volume value */
4435 volume_music_current =
4436 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4438 /* if that fails, set current volume to reliable default value */
4439 if (volume_music_current == NULL)
4440 volume_music_current =
4441 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4443 /* if that also fails, set current volume to first available value */
4444 if (volume_music_current == NULL)
4445 volume_music_current = volumes_music;
4448 setup.volume_simple = atoi(volume_simple_current->identifier);
4449 setup.volume_loops = atoi(volume_loops_current->identifier);
4450 setup.volume_music = atoi(volume_music_current->identifier);
4452 /* needed for displaying volume text instead of identifier */
4453 volume_simple_text = volume_simple_current->name;
4454 volume_loops_text = volume_loops_current->name;
4455 volume_music_text = volume_music_current->name;
4457 setup_mode = SETUP_MODE_SOUND;
4462 static void execSetupChooseTouchControls()
4464 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4469 static void execSetupChooseMoveDistance()
4471 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4476 static void execSetupChooseDropDistance()
4478 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4483 static void execSetupTouch()
4485 if (touch_controls == NULL)
4489 for (i = 0; touch_controls_list[i].value != NULL; i++)
4491 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4492 char identifier[32], name[32];
4493 char *value = touch_controls_list[i].value;
4494 char *text = touch_controls_list[i].text;
4496 ti->node_top = &touch_controls;
4497 ti->sort_priority = i;
4499 sprintf(identifier, "%s", value);
4500 sprintf(name, "%s", text);
4502 setString(&ti->identifier, identifier);
4503 setString(&ti->name, name);
4504 setString(&ti->name_sorting, name);
4505 setString(&ti->infotext, "Control Type");
4507 pushTreeInfo(&touch_controls, ti);
4510 /* sort touch control values to start with lowest touch control value */
4511 sortTreeInfo(&touch_controls);
4513 /* set current touch control value to configured touch control value */
4514 touch_control_current =
4515 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4517 /* if that fails, set current touch control to reliable default value */
4518 if (touch_control_current == NULL)
4519 touch_control_current =
4520 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4522 /* if that also fails, set current touch control to first available value */
4523 if (touch_control_current == NULL)
4524 touch_control_current = touch_controls;
4527 if (move_distances == NULL)
4531 for (i = 0; distances_list[i].value != -1; i++)
4533 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4534 char identifier[32], name[32];
4535 int value = distances_list[i].value;
4536 char *text = distances_list[i].text;
4538 ti->node_top = &move_distances;
4539 ti->sort_priority = value;
4541 sprintf(identifier, "%d", value);
4542 sprintf(name, "%s", text);
4544 setString(&ti->identifier, identifier);
4545 setString(&ti->name, name);
4546 setString(&ti->name_sorting, name);
4547 setString(&ti->infotext, "Move Distance");
4549 pushTreeInfo(&move_distances, ti);
4552 /* sort distance values to start with lowest distance value */
4553 sortTreeInfo(&move_distances);
4555 /* set current distance value to configured distance value */
4556 move_distance_current =
4557 getTreeInfoFromIdentifier(move_distances,
4558 i_to_a(setup.touch.move_distance));
4560 /* if that fails, set current distance to reliable default value */
4561 if (move_distance_current == NULL)
4562 move_distance_current =
4563 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4565 /* if that also fails, set current distance to first available value */
4566 if (move_distance_current == NULL)
4567 move_distance_current = move_distances;
4570 if (drop_distances == NULL)
4574 for (i = 0; distances_list[i].value != -1; i++)
4576 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4577 char identifier[32], name[32];
4578 int value = distances_list[i].value;
4579 char *text = distances_list[i].text;
4581 ti->node_top = &drop_distances;
4582 ti->sort_priority = value;
4584 sprintf(identifier, "%d", value);
4585 sprintf(name, "%s", text);
4587 setString(&ti->identifier, identifier);
4588 setString(&ti->name, name);
4589 setString(&ti->name_sorting, name);
4590 setString(&ti->infotext, "Drop Distance");
4592 pushTreeInfo(&drop_distances, ti);
4595 /* sort distance values to start with lowest distance value */
4596 sortTreeInfo(&drop_distances);
4598 /* set current distance value to configured distance value */
4599 drop_distance_current =
4600 getTreeInfoFromIdentifier(drop_distances,
4601 i_to_a(setup.touch.drop_distance));
4603 /* if that fails, set current distance to reliable default value */
4604 if (drop_distance_current == NULL)
4605 drop_distance_current =
4606 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
4608 /* if that also fails, set current distance to first available value */
4609 if (drop_distance_current == NULL)
4610 drop_distance_current = drop_distances;
4613 setup.touch.control_type = touch_control_current->identifier;
4614 setup.touch.move_distance = atoi(move_distance_current->identifier);
4615 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
4617 /* needed for displaying volume text instead of identifier */
4618 touch_controls_text = touch_control_current->name;
4619 move_distance_text = move_distance_current->name;
4620 drop_distance_text = drop_distance_current->name;
4622 setup_mode = SETUP_MODE_TOUCH;
4627 static void execSetupArtwork()
4630 printf("::: '%s', '%s', '%s'\n",
4631 artwork.gfx_current->subdir,
4632 artwork.gfx_current->fullpath,
4633 artwork.gfx_current->basepath);
4636 setup.graphics_set = artwork.gfx_current->identifier;
4637 setup.sounds_set = artwork.snd_current->identifier;
4638 setup.music_set = artwork.mus_current->identifier;
4640 /* needed if last screen (setup choice) changed graphics, sounds or music */
4641 ReloadCustomArtwork(0);
4643 /* needed for displaying artwork name instead of artwork identifier */
4644 graphics_set_name = artwork.gfx_current->name;
4645 sounds_set_name = artwork.snd_current->name;
4646 music_set_name = artwork.mus_current->name;
4648 setup_mode = SETUP_MODE_ARTWORK;
4653 static void execSetupChooseGraphics()
4655 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4660 static void execSetupChooseSounds()
4662 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4667 static void execSetupChooseMusic()
4669 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4674 #if !defined(PLATFORM_ANDROID)
4675 static void execSetupInput()
4677 setup_mode = SETUP_MODE_INPUT;
4683 static void execSetupShortcuts()
4685 setup_mode = SETUP_MODE_SHORTCUTS;
4690 static void execSetupShortcuts1()
4692 setup_mode = SETUP_MODE_SHORTCUTS_1;
4697 static void execSetupShortcuts2()
4699 setup_mode = SETUP_MODE_SHORTCUTS_2;
4704 static void execSetupShortcuts3()
4706 setup_mode = SETUP_MODE_SHORTCUTS_3;
4711 static void execSetupShortcuts4()
4713 setup_mode = SETUP_MODE_SHORTCUTS_4;
4718 static void execSetupShortcuts5()
4720 setup_mode = SETUP_MODE_SHORTCUTS_5;
4725 static void execExitSetup()
4727 game_status = GAME_MODE_MAIN;
4729 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4732 static void execSaveAndExitSetup()
4738 static struct TokenInfo setup_info_main[] =
4740 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4741 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4742 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4743 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4744 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4745 #if !defined(PLATFORM_ANDROID)
4746 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4747 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4749 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4751 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
4752 { TYPE_EMPTY, NULL, "" },
4753 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4754 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4759 static struct TokenInfo setup_info_game[] =
4761 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4762 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4763 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4764 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4765 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4766 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4767 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4768 { TYPE_STRING, &game_speed_text, "" },
4770 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4771 { TYPE_STRING, &scroll_delay_text, "" },
4773 { TYPE_EMPTY, NULL, "" },
4774 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4779 static struct TokenInfo setup_info_editor[] =
4782 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4783 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4784 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4785 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4786 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4787 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4788 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4789 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4791 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4792 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4793 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4795 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4797 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4798 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4799 { TYPE_EMPTY, NULL, "" },
4801 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4802 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4803 { TYPE_EMPTY, NULL, "" },
4805 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4806 { TYPE_EMPTY, NULL, "" },
4807 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4812 static struct TokenInfo setup_info_graphics[] =
4814 #if !defined(PLATFORM_ANDROID)
4815 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4816 #if defined(TARGET_SDL2)
4817 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
4818 { TYPE_STRING, &window_size_text, "" },
4819 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
4820 { TYPE_STRING, &scaling_type_text, "" },
4822 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4823 { TYPE_STRING, &screen_mode_text, "" },
4827 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4828 { TYPE_STRING, &scroll_delay_text, "" },
4830 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4831 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4832 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4833 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4834 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4835 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4836 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
4837 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
4838 { TYPE_EMPTY, NULL, "" },
4839 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4844 static struct TokenInfo setup_info_sound[] =
4846 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4847 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4848 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4849 { TYPE_EMPTY, NULL, "" },
4850 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
4851 { TYPE_STRING, &volume_simple_text, "" },
4852 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
4853 { TYPE_STRING, &volume_loops_text, "" },
4854 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
4855 { TYPE_STRING, &volume_music_text, "" },
4856 { TYPE_EMPTY, NULL, "" },
4857 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4862 static struct TokenInfo setup_info_artwork[] =
4864 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4865 { TYPE_STRING, &graphics_set_name, "" },
4866 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4867 { TYPE_STRING, &sounds_set_name, "" },
4868 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4869 { TYPE_STRING, &music_set_name, "" },
4870 { TYPE_EMPTY, NULL, "" },
4871 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
4872 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
4873 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
4874 { TYPE_EMPTY, NULL, "" },
4875 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4880 static struct TokenInfo setup_info_input[] =
4882 { TYPE_SWITCH, NULL, "Player:" },
4883 { TYPE_SWITCH, NULL, "Device:" },
4884 { TYPE_ENTER_MENU, NULL, "" },
4885 { TYPE_EMPTY, NULL, "" },
4886 { TYPE_EMPTY, NULL, "" },
4887 { TYPE_EMPTY, NULL, "" },
4888 { TYPE_EMPTY, NULL, "" },
4889 { TYPE_EMPTY, NULL, "" },
4890 { TYPE_EMPTY, NULL, "" },
4891 { TYPE_EMPTY, NULL, "" },
4892 { TYPE_EMPTY, NULL, "" },
4893 { TYPE_EMPTY, NULL, "" },
4894 { TYPE_EMPTY, NULL, "" },
4895 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4900 static struct TokenInfo setup_info_touch[] =
4902 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
4903 { TYPE_STRING, &touch_controls_text, "" },
4904 { TYPE_EMPTY, NULL, "" },
4905 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
4906 { TYPE_STRING, &move_distance_text, "" },
4907 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
4908 { TYPE_STRING, &drop_distance_text, "" },
4909 { TYPE_EMPTY, NULL, "" },
4910 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4915 static struct TokenInfo setup_info_shortcuts[] =
4917 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
4918 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
4919 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
4920 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
4921 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
4922 { TYPE_EMPTY, NULL, "" },
4923 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4928 static struct TokenInfo setup_info_shortcuts_1[] =
4930 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4931 { TYPE_KEY, &setup.shortcut.save_game, "" },
4932 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4933 { TYPE_KEY, &setup.shortcut.load_game, "" },
4934 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4935 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4936 { TYPE_EMPTY, NULL, "" },
4937 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4938 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4939 { TYPE_EMPTY, NULL, "" },
4940 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4945 static struct TokenInfo setup_info_shortcuts_2[] =
4947 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4948 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4949 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4950 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4951 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4952 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4953 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4954 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4955 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4956 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4957 { TYPE_EMPTY, NULL, "" },
4958 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4963 static struct TokenInfo setup_info_shortcuts_3[] =
4965 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
4966 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
4967 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
4968 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
4969 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
4970 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
4971 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
4972 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
4973 { TYPE_KEYTEXT, NULL, "Record Tape:", },
4974 { TYPE_KEY, &setup.shortcut.tape_record, "" },
4975 { TYPE_KEYTEXT, NULL, "Play Tape:", },
4976 { TYPE_KEY, &setup.shortcut.tape_play, "" },
4977 { TYPE_EMPTY, NULL, "" },
4978 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4983 static struct TokenInfo setup_info_shortcuts_4[] =
4985 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
4986 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
4987 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
4988 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
4989 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
4990 { TYPE_KEY, &setup.shortcut.sound_music, "" },
4991 { TYPE_EMPTY, NULL, "" },
4992 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4997 static struct TokenInfo setup_info_shortcuts_5[] =
4999 { TYPE_KEYTEXT, NULL, "Snap Left:", },
5000 { TYPE_KEY, &setup.shortcut.snap_left, "" },
5001 { TYPE_KEYTEXT, NULL, "Snap Right:", },
5002 { TYPE_KEY, &setup.shortcut.snap_right, "" },
5003 { TYPE_KEYTEXT, NULL, "Snap Up:", },
5004 { TYPE_KEY, &setup.shortcut.snap_up, "" },
5005 { TYPE_KEYTEXT, NULL, "Snap Down:", },
5006 { TYPE_KEY, &setup.shortcut.snap_down, "" },
5007 { TYPE_EMPTY, NULL, "" },
5008 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5013 static Key getSetupKey()
5015 Key key = KSYM_UNDEFINED;
5016 boolean got_key_event = FALSE;
5018 while (!got_key_event)
5020 if (PendingEvent()) /* got event */
5028 case EVENT_KEYPRESS:
5030 key = GetEventKey((KeyEvent *)&event, TRUE);
5032 /* press 'Escape' or 'Enter' to keep the existing key binding */
5033 if (key == KSYM_Escape || key == KSYM_Return)
5034 key = KSYM_UNDEFINED; /* keep old value */
5036 got_key_event = TRUE;
5040 case EVENT_KEYRELEASE:
5041 key_joystick_mapping = 0;
5045 HandleOtherEvents(&event);
5053 /* don't eat all CPU time */
5060 static int getSetupTextFont(int type)
5062 if (type & (TYPE_SWITCH |
5074 static int getSetupValueFont(int type, void *value)
5076 if (type & TYPE_KEY)
5077 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5078 else if (type & TYPE_STRING)
5079 return FONT_VALUE_2;
5080 else if (type & TYPE_ECS_AGA)
5081 return FONT_VALUE_1;
5082 else if (type & TYPE_BOOLEAN_STYLE)
5083 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5084 else if (type & TYPE_YES_NO_AUTO)
5085 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5086 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5088 return FONT_VALUE_1;
5091 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5093 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5094 struct TokenInfo *si = &setup_info[si_pos];
5095 boolean font_draw_xoffset_modified = FALSE;
5096 int font_draw_xoffset_old = -1;
5097 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5098 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5099 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5100 int xpos = menu_screen_value_xpos;
5101 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5102 int startx = mSX + xpos * 32;
5103 int starty = mSY + ypos * 32;
5104 int font_nr, font_width;
5105 int type = si->type;
5106 void *value = si->value;
5107 char *value_string = getSetupValue(type, value);
5110 if (value_string == NULL)
5113 if (type & TYPE_KEY)
5115 xpos = MENU_SCREEN_START_XPOS;
5117 if (type & TYPE_QUERY)
5118 value_string = "<press key>";
5120 else if (type & TYPE_STRING)
5122 int max_value_len = (SCR_FIELDX - 2) * 2;
5124 xpos = MENU_SCREEN_START_XPOS;
5126 if (strlen(value_string) > max_value_len)
5127 value_string[max_value_len] = '\0';
5129 else if (type & TYPE_YES_NO_AUTO)
5131 xpos = menu_screen_value_xpos - 1;
5134 startx = mSX + xpos * 32;
5135 starty = mSY + ypos * 32;
5136 font_nr = getSetupValueFont(type, value);
5137 font_width = getFontWidth(font_nr);
5139 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5140 if (setup_mode != SETUP_MODE_INPUT)
5142 int max_menu_text_length_big = (menu_screen_value_xpos -
5143 MENU_SCREEN_START_XPOS);
5144 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5145 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5146 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5147 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5148 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5149 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5150 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5151 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5152 boolean correct_font_draw_xoffset = FALSE;
5154 if (xpos == MENU_SCREEN_START_XPOS &&
5155 startx + font1_xoffset < text_startx + text_font_xoffset)
5156 correct_font_draw_xoffset = TRUE;
5158 if (xpos == menu_screen_value_xpos &&
5159 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5160 correct_font_draw_xoffset = TRUE;
5162 /* check if setup value would overlap with setup text when printed */
5163 /* (this can happen for extreme/wrong values for font draw offset) */
5164 if (correct_font_draw_xoffset)
5166 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5167 font_draw_xoffset_modified = TRUE;
5169 if (type & TYPE_KEY)
5170 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5171 else if (!(type & TYPE_STRING))
5172 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5173 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5177 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5178 DrawText(startx + i * font_width, starty, " ", font_nr);
5180 DrawText(startx, starty, value_string, font_nr);
5182 if (font_draw_xoffset_modified)
5183 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5186 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5188 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5189 struct TokenInfo *si = &setup_info[si_pos];
5191 if (si->type & TYPE_BOOLEAN_STYLE)
5193 *(boolean *)si->value ^= TRUE;
5195 else if (si->type & TYPE_YES_NO_AUTO)
5199 (*(int *)si->value == AUTO ? TRUE :
5200 *(int *)si->value == TRUE ? FALSE : AUTO) :
5201 (*(int *)si->value == TRUE ? AUTO :
5202 *(int *)si->value == AUTO ? FALSE : TRUE));
5204 else if (si->type & TYPE_KEY)
5208 si->type |= TYPE_QUERY;
5209 drawSetupValue(screen_pos, setup_info_pos_raw);
5210 si->type &= ~TYPE_QUERY;
5212 key = getSetupKey();
5213 if (key != KSYM_UNDEFINED)
5214 *(Key *)si->value = key;
5217 drawSetupValue(screen_pos, setup_info_pos_raw);
5219 // fullscreen state may have changed at this point
5220 if (si->value == &setup.fullscreen)
5221 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5224 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5227 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5228 struct TokenInfo *si = &setup_info[si_pos];
5229 int xpos = MENU_SCREEN_START_XPOS;
5230 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5231 int font_nr = getSetupTextFont(si->type);
5233 if (setup_info == setup_info_input)
5234 font_nr = FONT_MENU_1;
5237 font_nr = FONT_ACTIVE(font_nr);
5239 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5241 if (si->type & ~TYPE_SKIP_ENTRY)
5242 drawCursor(screen_pos, active);
5245 static void drawSetupInfoList(struct TokenInfo *setup_info,
5246 int first_entry, int num_page_entries)
5250 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5251 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5253 if (num_page_entries > max_setup_info)
5254 num_page_entries = max_setup_info;
5256 if (first_entry + num_page_entries > max_setup_info)
5259 clearMenuListArea();
5261 for (i = 0; i < num_page_entries; i++)
5263 int setup_info_pos = first_entry + i;
5264 struct TokenInfo *si = &setup_info[setup_info_pos];
5265 void *value_ptr = si->value;
5267 /* set some entries to "unchangeable" according to other variables */
5268 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5269 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5270 (value_ptr == &setup.sound_music && !audio.music_available) ||
5271 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5272 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5273 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5274 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5275 si->type |= TYPE_GHOSTED;
5277 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5278 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5279 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5280 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5281 else if (si->type & ~TYPE_SKIP_ENTRY)
5282 initCursor(i, IMG_MENU_BUTTON);
5284 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5286 if (si->type & TYPE_VALUE)
5287 drawSetupValue(i, setup_info_pos);
5291 static void DrawSetupScreen_Generic()
5293 boolean redraw_all = FALSE;
5294 char *title_string = NULL;
5299 FreeScreenGadgets();
5300 CreateScreenGadgets();
5302 CloseDoor(DOOR_CLOSE_2);
5304 if (redraw_mask & REDRAW_ALL)
5307 FadeOut(REDRAW_FIELD);
5311 if (setup_mode == SETUP_MODE_MAIN)
5313 setup_info = setup_info_main;
5314 title_string = "Setup";
5316 else if (setup_mode == SETUP_MODE_GAME)
5318 setup_info = setup_info_game;
5319 title_string = "Setup Game";
5321 else if (setup_mode == SETUP_MODE_EDITOR)
5323 setup_info = setup_info_editor;
5324 title_string = "Setup Editor";
5326 else if (setup_mode == SETUP_MODE_GRAPHICS)
5328 setup_info = setup_info_graphics;
5329 title_string = "Setup Graphics";
5331 else if (setup_mode == SETUP_MODE_SOUND)
5333 setup_info = setup_info_sound;
5334 title_string = "Setup Sound";
5336 else if (setup_mode == SETUP_MODE_ARTWORK)
5338 setup_info = setup_info_artwork;
5339 title_string = "Custom Artwork";
5341 else if (setup_mode == SETUP_MODE_TOUCH)
5343 setup_info = setup_info_touch;
5344 title_string = "Setup Touch Ctrls";
5346 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5348 setup_info = setup_info_shortcuts;
5349 title_string = "Setup Shortcuts";
5351 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5353 setup_info = setup_info_shortcuts_1;
5354 title_string = "Setup Shortcuts";
5356 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5358 setup_info = setup_info_shortcuts_2;
5359 title_string = "Setup Shortcuts";
5361 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
5363 setup_info = setup_info_shortcuts_3;
5364 title_string = "Setup Shortcuts";
5366 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
5368 setup_info = setup_info_shortcuts_4;
5369 title_string = "Setup Shortcuts";
5371 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
5373 setup_info = setup_info_shortcuts_5;
5374 title_string = "Setup Shortcuts";
5377 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5379 // determine maximal number of setup entries that can be displayed on screen
5381 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5384 // determine maximal number of setup entries available for this setup screen
5386 for (i = 0; setup_info[i].type != 0; i++)
5389 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5391 MapScreenGadgets(max_setup_info);
5394 redraw_mask = REDRAW_ALL;
5396 FadeIn(redraw_mask);
5401 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5403 static int choice_store[MAX_SETUP_MODES];
5404 static int first_entry_store[MAX_SETUP_MODES];
5405 int choice = choice_store[setup_mode]; /* starts with 0 */
5406 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
5408 int y = choice - first_entry;
5410 boolean position_set_by_scrollbar = (dx == 999);
5411 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
5412 int num_page_entries;
5414 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
5416 if (button == MB_MENU_INITIALIZE)
5418 /* advance to first valid menu entry */
5419 while (choice < num_setup_info &&
5420 setup_info[choice].type & TYPE_SKIP_ENTRY)
5423 if (position_set_by_scrollbar)
5424 first_entry = first_entry_store[setup_mode] = dy;
5426 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5427 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5429 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5431 if (choice < first_entry)
5433 choice = first_entry;
5435 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5438 else if (choice > first_entry + num_page_entries - 1)
5440 choice = first_entry + num_page_entries - 1;
5442 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5446 choice_store[setup_mode] = choice;
5448 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5452 else if (button == MB_MENU_LEAVE)
5456 PlaySound(SND_MENU_ITEM_SELECTING);
5458 for (i = 0; setup_info[i].type != 0; i++)
5460 if (setup_info[i].type & TYPE_LEAVE_MENU)
5462 void (*menu_callback_function)(void) = setup_info[i].value;
5466 menu_callback_function();
5468 break; /* absolutely needed because function changes 'setup_info'! */
5475 if (mx || my) /* mouse input */
5477 x = (mx - mSX) / 32;
5478 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5480 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
5482 /* move cursor instead of scrolling when already at start/end of list */
5483 if (dy == -1 * SCROLL_LINE && first_entry == 0)
5485 else if (dy == +1 * SCROLL_LINE &&
5486 first_entry + num_page_entries == max_setup_info)
5489 /* handle scrolling screen one line or page */
5491 y + dy > num_page_entries - 1)
5493 boolean redraw = FALSE;
5495 if (ABS(dy) == SCROLL_PAGE)
5496 step = num_page_entries - 1;
5498 if (dy < 0 && first_entry > 0)
5500 /* scroll page/line up */
5502 first_entry -= step;
5503 if (first_entry < 0)
5508 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
5510 /* scroll page/line down */
5512 first_entry += step;
5513 if (first_entry + num_page_entries > max_setup_info)
5514 first_entry = MAX(0, max_setup_info - num_page_entries);
5521 choice += first_entry - first_entry_store[setup_mode];
5523 if (choice < first_entry)
5525 choice = first_entry;
5527 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5530 else if (choice > first_entry + num_page_entries - 1)
5532 choice = first_entry + num_page_entries - 1;
5534 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5537 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5541 if (choice < first_entry ||
5542 choice > first_entry + num_page_entries - 1)
5543 first_entry += SIGN(dy);
5546 first_entry_store[setup_mode] = first_entry;
5547 choice_store[setup_mode] = choice;
5549 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5551 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5553 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5554 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5562 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5564 if (setup_info[choice].type & menu_navigation_type ||
5565 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
5566 setup_info[choice].type & TYPE_YES_NO_AUTO)
5567 button = MB_MENU_CHOICE;
5572 /* jump to next non-empty menu entry (up or down) */
5573 while (first_entry + y > 0 &&
5574 first_entry + y < max_setup_info - 1 &&
5575 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
5578 if (!IN_VIS_MENU(x, y))
5580 choice += y - y_old;
5582 if (choice < first_entry)
5583 first_entry = choice;
5584 else if (choice > first_entry + num_page_entries - 1)
5585 first_entry = choice - num_page_entries + 1;
5587 if (first_entry >= 0 &&
5588 first_entry + num_page_entries <= max_setup_info)
5590 first_entry_store[setup_mode] = first_entry;
5592 if (choice < first_entry)
5593 choice = first_entry;
5594 else if (choice > first_entry + num_page_entries - 1)
5595 choice = first_entry + num_page_entries - 1;
5597 choice_store[setup_mode] = choice;
5599 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5601 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5603 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5604 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5611 if (!anyScrollbarGadgetActive() &&
5612 IN_VIS_MENU(x, y) &&
5613 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
5614 y >= 0 && y < num_page_entries)
5618 if (first_entry + y != choice &&
5619 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
5621 PlaySound(SND_MENU_ITEM_ACTIVATING);
5623 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
5624 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
5626 choice = choice_store[setup_mode] = first_entry + y;
5629 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
5631 PlaySound(SND_MENU_ITEM_SELECTING);
5633 /* when selecting key headline, execute function for key value change */
5634 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
5635 setup_info[first_entry + y + 1].type & TYPE_KEY)
5638 /* when selecting string value, execute function for list selection */
5639 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
5640 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
5643 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
5645 void (*menu_callback_function)(void) =
5646 setup_info[first_entry + y].value;
5648 FadeSetFromType(setup_info[first_entry + y].type);
5650 menu_callback_function();
5654 if (setup_info[first_entry + y].type & TYPE_VALUE)
5655 changeSetupValue(y, first_entry + y, dx);
5661 void DrawSetupScreen_Input()
5665 FadeOut(REDRAW_FIELD);
5669 setup_info = setup_info_input;
5671 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5673 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5674 "Joysticks deactivated on this screen");
5676 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5678 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5679 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5680 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5681 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5682 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5683 initCursor(i, IMG_MENU_BUTTON);
5685 DrawCursorAndText_Setup(i, -1, FALSE);
5688 /* create gadgets for setup input menu screen */
5689 FreeScreenGadgets();
5690 CreateScreenGadgets();
5692 /* map gadgets for setup input menu screen */
5693 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5695 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5697 FadeIn(REDRAW_FIELD);
5702 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5704 if (device_name == NULL)
5707 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5710 if (strlen(device_name) > 1)
5712 char c1 = device_name[strlen(device_name) - 1];
5713 char c2 = device_name[strlen(device_name) - 2];
5715 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5716 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5719 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5720 strlen(device_name));
5723 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5726 static struct SetupKeyboardInfo custom_key;
5733 { &custom_key.left, "Joystick Left" },
5734 { &custom_key.right, "Joystick Right" },
5735 { &custom_key.up, "Joystick Up" },
5736 { &custom_key.down, "Joystick Down" },
5737 { &custom_key.snap, "Button 1" },
5738 { &custom_key.drop, "Button 2" }
5740 static char *joystick_name[MAX_PLAYERS] =
5747 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5751 custom_key = setup.input[player_nr].key;
5753 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5754 FONT_INPUT_1_ACTIVE);
5756 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5758 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5759 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5761 if (setup.input[player_nr].use_joystick)
5763 char *device_name = setup.input[player_nr].joy.device_name;
5764 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5765 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5767 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5768 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5772 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5773 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5776 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5778 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5779 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5780 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5781 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5783 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5784 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5785 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5786 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5787 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5788 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5790 for (i = 0; i < 6; i++)
5792 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5794 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5796 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5797 (setup.input[player_nr].use_joystick ?
5799 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5803 static int input_player_nr = 0;
5805 void HandleSetupScreen_Input_Player(int step, int direction)
5807 int old_player_nr = input_player_nr;
5810 new_player_nr = old_player_nr + step * direction;
5811 if (new_player_nr < 0)
5813 if (new_player_nr > MAX_PLAYERS - 1)
5814 new_player_nr = MAX_PLAYERS - 1;
5816 if (new_player_nr != old_player_nr)
5818 input_player_nr = new_player_nr;
5820 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5824 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5826 static int choice = 0;
5829 int pos_start = SETUPINPUT_SCREEN_POS_START;
5830 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5831 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5832 int pos_end = SETUPINPUT_SCREEN_POS_END;
5834 if (button == MB_MENU_INITIALIZE)
5836 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5838 DrawCursorAndText_Setup(choice, -1, TRUE);
5842 else if (button == MB_MENU_LEAVE)
5844 setup_mode = SETUP_MODE_MAIN;
5851 if (mx || my) /* mouse input */
5853 x = (mx - mSX) / 32;
5854 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5856 else if (dx || dy) /* keyboard input */
5858 if (dx && choice == 0)
5859 x = (dx < 0 ? 10 : 12);
5860 else if ((dx && choice == 1) ||
5861 (dx == +1 && choice == 2) ||
5862 (dx == -1 && choice == pos_end))
5863 button = MB_MENU_CHOICE;
5867 if (y >= pos_empty1 && y <= pos_empty2)
5868 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5871 if (y == 0 && dx != 0 && button)
5873 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5875 else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
5876 y >= pos_start && y <= pos_end &&
5877 !(y >= pos_empty1 && y <= pos_empty2))
5883 DrawCursorAndText_Setup(choice, -1, FALSE);
5884 DrawCursorAndText_Setup(y, -1, TRUE);
5886 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5895 char *device_name = setup.input[input_player_nr].joy.device_name;
5897 if (!setup.input[input_player_nr].use_joystick)
5899 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5901 setJoystickDeviceToNr(device_name, new_device_nr);
5902 setup.input[input_player_nr].use_joystick = TRUE;
5906 int device_nr = getJoystickNrFromDeviceName(device_name);
5907 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5909 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5910 setup.input[input_player_nr].use_joystick = FALSE;
5912 setJoystickDeviceToNr(device_name, new_device_nr);
5915 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5919 if (setup.input[input_player_nr].use_joystick)
5922 CalibrateJoystick(input_player_nr);
5925 CustomizeKeyboard(input_player_nr);
5927 else if (y == pos_end)
5933 setup_mode = SETUP_MODE_MAIN;
5940 void CustomizeKeyboard(int player_nr)
5944 boolean finished = FALSE;
5945 static struct SetupKeyboardInfo custom_key;
5950 } customize_step[] =
5952 { &custom_key.left, "Move Left" },
5953 { &custom_key.right, "Move Right" },
5954 { &custom_key.up, "Move Up" },
5955 { &custom_key.down, "Move Down" },
5956 { &custom_key.snap, "Snap Field" },
5957 { &custom_key.drop, "Drop Element" }
5960 /* read existing key bindings from player setup */
5961 custom_key = setup.input[player_nr].key;
5964 FadeOut(REDRAW_FIELD);
5968 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5971 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5972 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5973 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5974 "Key:", FONT_INPUT_1_ACTIVE);
5975 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5976 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5978 FadeIn(REDRAW_FIELD);
5984 if (PendingEvent()) /* got event */
5992 case EVENT_KEYPRESS:
5994 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5996 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5998 if (key == KSYM_Escape)
5999 FadeSkipNextFadeIn();
6005 /* all keys configured -- wait for "Escape" or "Return" key */
6009 /* press 'Enter' to keep the existing key binding */
6010 if (key == KSYM_Return)
6011 key = *customize_step[step_nr].key;
6013 /* check if key already used */
6014 for (i = 0; i < step_nr; i++)
6015 if (*customize_step[i].key == key)
6020 /* got new key binding */
6021 *customize_step[step_nr].key = key;
6022 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6024 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6025 getKeyNameFromKey(key), FONT_VALUE_1);
6028 /* un-highlight last query */
6029 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6030 customize_step[step_nr - 1].text, FONT_MENU_1);
6031 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6032 "Key:", FONT_MENU_1);
6034 /* press 'Enter' to leave */
6037 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6038 "Press Enter", FONT_TITLE_1);
6042 /* query next key binding */
6043 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6044 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6045 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6046 "Key:", FONT_INPUT_1_ACTIVE);
6047 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6048 getKeyNameFromKey(*customize_step[step_nr].key),
6053 case EVENT_KEYRELEASE:
6054 key_joystick_mapping = 0;
6058 HandleOtherEvents(&event);
6066 /* don't eat all CPU time */
6070 /* write new key bindings back to player setup */
6071 setup.input[player_nr].key = custom_key;
6074 DrawSetupScreen_Input();
6077 static boolean CalibrateJoystickMain(int player_nr)
6079 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6080 int new_joystick_xright = JOYSTICK_XMIDDLE;
6081 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6082 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6083 int new_joystick_xmiddle, new_joystick_ymiddle;
6085 int joystick_fd = joystick.fd[player_nr];
6086 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6087 boolean check[3][3];
6088 int check_remaining = 3 * 3;
6093 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6096 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6100 FadeOut(REDRAW_FIELD);
6104 for (y = 0; y < 3; y++)
6106 for (x = 0; x < 3; x++)
6108 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6109 check[x][y] = FALSE;
6113 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6114 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6115 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6116 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6117 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6118 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6119 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6121 joy_value = Joystick(player_nr);
6122 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6123 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6125 /* eventually uncalibrated center position (joystick could be uncentered) */
6126 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6129 new_joystick_xmiddle = joy_x;
6130 new_joystick_ymiddle = joy_y;
6132 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6134 FadeIn(REDRAW_FIELD);
6136 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6141 if (PendingEvent()) /* got event */
6149 case EVENT_KEYPRESS:
6150 switch (GetEventKey((KeyEvent *)&event, TRUE))
6153 if (check_remaining == 0)
6158 FadeSkipNextFadeIn();
6167 case EVENT_KEYRELEASE:
6168 key_joystick_mapping = 0;
6172 HandleOtherEvents(&event);
6177 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6180 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
6181 new_joystick_xright = MAX(new_joystick_xright, joy_x);
6182 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
6183 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
6185 setup.input[player_nr].joy.xleft = new_joystick_xleft;
6186 setup.input[player_nr].joy.yupper = new_joystick_yupper;
6187 setup.input[player_nr].joy.xright = new_joystick_xright;
6188 setup.input[player_nr].joy.ylower = new_joystick_ylower;
6189 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
6190 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
6192 CheckJoystickData();
6194 joy_value = Joystick(player_nr);
6196 if (joy_value & JOY_BUTTON && check_remaining == 0)
6199 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6200 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6202 if (x != last_x || y != last_y)
6204 DrawFixedGraphic(xpos + last_x, ypos + last_y,
6205 IMG_MENU_CALIBRATE_YELLOW, 0);
6206 DrawFixedGraphic(xpos + x, ypos + y,
6207 IMG_MENU_CALIBRATE_RED, 0);
6212 if (check_remaining > 0 && !check[x+1][y+1])
6214 check[x+1][y+1] = TRUE;
6222 /* don't eat all CPU time */
6226 /* calibrated center position (joystick should now be centered) */
6227 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6230 new_joystick_xmiddle = joy_x;
6231 new_joystick_ymiddle = joy_y;
6235 /* wait until the last pressed button was released */
6236 while (Joystick(player_nr) & JOY_BUTTON)
6238 if (PendingEvent()) /* got event */
6243 HandleOtherEvents(&event);
6252 void CalibrateJoystick(int player_nr)
6254 if (!CalibrateJoystickMain(player_nr))
6256 char *device_name = setup.input[player_nr].joy.device_name;
6257 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6258 int xpos = mSX - SX;
6259 int ypos = mSY - SY;
6263 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6264 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
6267 Delay(2000); /* show error message for a short time */
6272 DrawSetupScreen_Input();
6275 void DrawSetupScreen()
6277 DeactivateJoystick();
6279 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6281 if (setup_mode == SETUP_MODE_INPUT)
6282 DrawSetupScreen_Input();
6283 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6284 DrawChooseTree(&game_speed_current);
6285 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6286 DrawChooseTree(&scroll_delay_current);
6287 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6288 DrawChooseTree(&screen_mode_current);
6289 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6290 DrawChooseTree(&window_size_current);
6291 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6292 DrawChooseTree(&scaling_type_current);
6293 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6294 DrawChooseTree(&artwork.gfx_current);
6295 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6296 DrawChooseTree(&artwork.snd_current);
6297 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6298 DrawChooseTree(&artwork.mus_current);
6299 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6300 DrawChooseTree(&volume_simple_current);
6301 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6302 DrawChooseTree(&volume_loops_current);
6303 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6304 DrawChooseTree(&volume_music_current);
6305 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6306 DrawChooseTree(&touch_control_current);
6307 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6308 DrawChooseTree(&move_distance_current);
6309 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6310 DrawChooseTree(&drop_distance_current);
6312 DrawSetupScreen_Generic();
6318 void RedrawSetupScreenAfterFullscreenToggle()
6320 if (setup_mode == SETUP_MODE_GRAPHICS ||
6321 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6323 // update list selection from "setup.window_scaling_percent"
6324 execSetupGraphics_setWindowSizes(TRUE);
6330 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
6332 if (setup_mode == SETUP_MODE_INPUT)
6333 HandleSetupScreen_Input(mx, my, dx, dy, button);
6334 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6335 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
6336 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6337 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
6338 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6339 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
6340 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6341 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
6342 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6343 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
6344 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6345 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
6346 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6347 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
6348 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6349 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
6350 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6351 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
6352 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6353 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
6354 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6355 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
6356 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6357 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
6358 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6359 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
6360 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6361 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
6363 HandleSetupScreen_Generic(mx, my, dx, dy, button);
6366 void HandleGameActions()
6368 if (game_status != GAME_MODE_PLAYING)
6371 GameActions(); /* main game loop */
6373 if (tape.auto_play && !tape.playing)
6374 AutoPlayTape(); /* continue automatically playing next tape */
6378 /* ---------- new screen button stuff -------------------------------------- */
6380 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6384 case SCREEN_CTRL_ID_PREV_LEVEL:
6385 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
6386 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
6389 case SCREEN_CTRL_ID_NEXT_LEVEL:
6390 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
6391 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
6394 case SCREEN_CTRL_ID_PREV_PLAYER:
6395 *x = mSX + TILEX * 10;
6396 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6399 case SCREEN_CTRL_ID_NEXT_PLAYER:
6400 *x = mSX + TILEX * 12;
6401 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6405 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6411 int gfx_unpressed, gfx_pressed;
6412 void (*get_gadget_position)(int *, int *, int);
6416 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6419 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6420 getScreenMenuButtonPos,
6421 SCREEN_CTRL_ID_PREV_LEVEL,
6426 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6427 getScreenMenuButtonPos,
6428 SCREEN_CTRL_ID_NEXT_LEVEL,
6433 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6434 getScreenMenuButtonPos,
6435 SCREEN_CTRL_ID_PREV_PLAYER,
6440 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6441 getScreenMenuButtonPos,
6442 SCREEN_CTRL_ID_NEXT_PLAYER,
6450 int gfx_unpressed, gfx_pressed;
6454 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6457 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6458 -1, -1, /* these values are not constant, but can change at runtime */
6459 SCREEN_CTRL_ID_SCROLL_UP,
6463 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6464 -1, -1, /* these values are not constant, but can change at runtime */
6465 SCREEN_CTRL_ID_SCROLL_DOWN,
6472 int gfx_unpressed, gfx_pressed;
6478 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6481 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6482 -1, -1, /* these values are not constant, but can change at runtime */
6483 -1, -1, /* these values are not constant, but can change at runtime */
6484 GD_TYPE_SCROLLBAR_VERTICAL,
6485 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6486 "scroll level series vertically"
6490 static void CreateScreenMenubuttons()
6492 struct GadgetInfo *gi;
6493 unsigned int event_mask;
6496 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6498 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6499 int gfx_unpressed, gfx_pressed;
6500 int x, y, width, height;
6501 int gd_x1, gd_x2, gd_y1, gd_y2;
6502 int id = menubutton_info[i].gadget_id;
6504 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6506 menubutton_info[i].get_gadget_position(&x, &y, id);
6508 width = SC_MENUBUTTON_XSIZE;
6509 height = SC_MENUBUTTON_YSIZE;
6511 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6512 gfx_pressed = menubutton_info[i].gfx_pressed;
6513 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6514 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6515 gd_x1 = graphic_info[gfx_unpressed].src_x;
6516 gd_y1 = graphic_info[gfx_unpressed].src_y;
6517 gd_x2 = graphic_info[gfx_pressed].src_x;
6518 gd_y2 = graphic_info[gfx_pressed].src_y;
6520 gi = CreateGadget(GDI_CUSTOM_ID, id,
6521 GDI_CUSTOM_TYPE_ID, i,
6522 GDI_INFO_TEXT, menubutton_info[i].infotext,
6527 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6528 GDI_STATE, GD_BUTTON_UNPRESSED,
6529 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6530 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6531 GDI_DIRECT_DRAW, FALSE,
6532 GDI_EVENT_MASK, event_mask,
6533 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6537 Error(ERR_EXIT, "cannot create gadget");
6539 screen_gadget[id] = gi;
6543 static void CreateScreenScrollbuttons()
6545 struct GadgetInfo *gi;
6546 unsigned int event_mask;
6549 /* these values are not constant, but can change at runtime */
6550 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
6551 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
6552 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
6553 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
6555 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6557 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6558 int gfx_unpressed, gfx_pressed;
6559 int x, y, width, height;
6560 int gd_x1, gd_x2, gd_y1, gd_y2;
6561 int id = scrollbutton_info[i].gadget_id;
6563 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6565 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6566 y = mSY + scrollbutton_info[i].y;
6567 width = SC_SCROLLBUTTON_XSIZE;
6568 height = SC_SCROLLBUTTON_YSIZE;
6570 /* correct scrollbar position if placed outside menu (playfield) area */
6571 if (x > SC_SCROLL_UP_XPOS)
6572 x = SC_SCROLL_UP_XPOS;
6574 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6575 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6576 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6578 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6579 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6580 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6581 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6582 gd_x1 = graphic_info[gfx_unpressed].src_x;
6583 gd_y1 = graphic_info[gfx_unpressed].src_y;
6584 gd_x2 = graphic_info[gfx_pressed].src_x;
6585 gd_y2 = graphic_info[gfx_pressed].src_y;
6587 gi = CreateGadget(GDI_CUSTOM_ID, id,
6588 GDI_CUSTOM_TYPE_ID, i,
6589 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6594 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6595 GDI_STATE, GD_BUTTON_UNPRESSED,
6596 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6597 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6598 GDI_DIRECT_DRAW, FALSE,
6599 GDI_EVENT_MASK, event_mask,
6600 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6604 Error(ERR_EXIT, "cannot create gadget");
6606 screen_gadget[id] = gi;
6610 static void CreateScreenScrollbars()
6614 /* these values are not constant, but can change at runtime */
6615 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
6616 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
6617 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
6618 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
6620 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6622 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6623 int gfx_unpressed, gfx_pressed;
6624 int x, y, width, height;
6625 int gd_x1, gd_x2, gd_y1, gd_y2;
6626 struct GadgetInfo *gi;
6627 int items_max, items_visible, item_position;
6628 unsigned int event_mask;
6629 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6630 int id = scrollbar_info[i].gadget_id;
6632 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6634 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6635 y = mSY + scrollbar_info[i].y;
6636 width = scrollbar_info[i].width;
6637 height = scrollbar_info[i].height;
6639 /* correct scrollbar position if placed outside menu (playfield) area */
6640 if (x > SC_SCROLL_VERTICAL_XPOS)
6641 x = SC_SCROLL_VERTICAL_XPOS;
6643 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6644 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6646 items_max = num_page_entries;
6647 items_visible = num_page_entries;
6650 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6651 gfx_pressed = scrollbar_info[i].gfx_pressed;
6652 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6653 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6654 gd_x1 = graphic_info[gfx_unpressed].src_x;
6655 gd_y1 = graphic_info[gfx_unpressed].src_y;
6656 gd_x2 = graphic_info[gfx_pressed].src_x;
6657 gd_y2 = graphic_info[gfx_pressed].src_y;
6659 gi = CreateGadget(GDI_CUSTOM_ID, id,
6660 GDI_CUSTOM_TYPE_ID, i,
6661 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6666 GDI_TYPE, scrollbar_info[i].type,
6667 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6668 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6669 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6670 GDI_WHEEL_AREA_X, SX,
6671 GDI_WHEEL_AREA_Y, SY,
6672 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6673 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6674 GDI_STATE, GD_BUTTON_UNPRESSED,
6675 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6676 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6677 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6678 GDI_DIRECT_DRAW, FALSE,
6679 GDI_EVENT_MASK, event_mask,
6680 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6684 Error(ERR_EXIT, "cannot create gadget");
6686 screen_gadget[id] = gi;
6690 void CreateScreenGadgets()
6692 int last_game_status = game_status; /* save current game status */
6694 CreateScreenMenubuttons();
6696 CreateScreenScrollbuttons();
6697 CreateScreenScrollbars();
6699 game_status = last_game_status; /* restore current game status */
6702 void FreeScreenGadgets()
6706 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6707 FreeGadget(screen_gadget[i]);
6710 void MapScreenMenuGadgets(int screen_mask)
6714 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6715 if (screen_mask & menubutton_info[i].screen_mask)
6716 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6719 void MapScreenGadgets(int num_entries)
6723 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6726 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6727 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6729 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6730 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6733 void MapScreenTreeGadgets(TreeInfo *ti)
6735 MapScreenGadgets(numTreeInfoInGroup(ti));
6738 static void HandleScreenGadgets(struct GadgetInfo *gi)
6740 int id = gi->custom_id;
6741 int button = gi->event.button;
6742 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6746 case SCREEN_CTRL_ID_PREV_LEVEL:
6747 HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT);
6750 case SCREEN_CTRL_ID_NEXT_LEVEL:
6751 HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT);
6754 case SCREEN_CTRL_ID_PREV_PLAYER:
6755 HandleSetupScreen_Input_Player(step, -1);
6758 case SCREEN_CTRL_ID_NEXT_PLAYER:
6759 HandleSetupScreen_Input_Player(step, +1);
6762 case SCREEN_CTRL_ID_SCROLL_UP:
6763 if (game_status == GAME_MODE_LEVELS)
6764 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6765 else if (game_status == GAME_MODE_LEVELNR)
6766 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6767 else if (game_status == GAME_MODE_SETUP)
6768 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6771 case SCREEN_CTRL_ID_SCROLL_DOWN:
6772 if (game_status == GAME_MODE_LEVELS)
6773 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6774 else if (game_status == GAME_MODE_LEVELNR)
6775 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6776 else if (game_status == GAME_MODE_SETUP)
6777 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6780 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6781 if (game_status == GAME_MODE_LEVELS)
6782 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6783 else if (game_status == GAME_MODE_LEVELNR)
6784 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6785 else if (game_status == GAME_MODE_SETUP)
6786 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);