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 pos_button->width = button_width;
965 pos_button->height = button_height;
968 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
970 /* calculate size for non-clickable text -- needed for text alignment */
971 boolean calculate_text_size = (pos_button == NULL && text != NULL);
973 if (pos_text->width == -1 || calculate_text_size)
974 pos_text->width = text_width;
975 if (pos_text->height == -1 || calculate_text_size)
976 pos_text->height = text_height;
978 if (visibleMenuPos(pos_button))
980 if (pos_text->x == -1)
981 pos_text->x = pos_button->x + pos_button->width;
982 if (pos_text->y == -1)
984 pos_button->y + (pos_button->height - pos_text->height) / 2;
988 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
990 if (visibleTextPos(pos_text))
992 if (pos_input->x == -1)
993 pos_input->x = pos_text->x + pos_text->width;
994 if (pos_input->y == -1)
995 pos_input->y = pos_text->y;
998 if (pos_input->width == -1)
999 pos_input->width = input_width;
1000 if (pos_input->height == -1)
1001 pos_input->height = input_height;
1006 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1007 boolean active_input)
1011 for (i = 0; main_controls[i].nr != -1; i++)
1013 struct MainControlInfo *mci = &main_controls[i];
1015 if (mci->nr == nr || nr == -1)
1017 struct MenuPosInfo *pos_button = mci->pos_button;
1018 struct TextPosInfo *pos_text = mci->pos_text;
1019 struct TextPosInfo *pos_input = mci->pos_input;
1020 char *text = (mci->text ? *mci->text : NULL);
1021 char *input = (mci->input ? *mci->input : NULL);
1022 int button_graphic = mci->button_graphic;
1023 int font_text = (pos_text ? pos_text->font : -1);
1024 int font_input = (pos_input ? pos_input->font : -1);
1028 button_graphic = BUTTON_ACTIVE(button_graphic);
1029 font_text = FONT_ACTIVE(font_text);
1034 font_input = FONT_ACTIVE(font_input);
1037 if (visibleMenuPos(pos_button))
1039 struct MenuPosInfo *pos = pos_button;
1040 int x = mSX + pos->x;
1041 int y = mSY + pos->y;
1043 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1044 DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
1047 if (visibleTextPos(pos_text) && text != NULL)
1049 struct TextPosInfo *pos = pos_text;
1050 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1051 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1054 /* (check why/if this is needed) */
1055 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1057 DrawText(x, y, text, font_text);
1060 if (visibleTextPos(pos_input) && input != NULL)
1062 struct TextPosInfo *pos = pos_input;
1063 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1064 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1067 /* (check why/if this is needed) */
1068 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1070 DrawText(x, y, input, font_input);
1076 static void DrawCursorAndText_Main(int nr, boolean active_text)
1078 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1082 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1084 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1088 static struct MainControlInfo *getMainControlInfo(int nr)
1092 for (i = 0; main_controls[i].nr != -1; i++)
1093 if (main_controls[i].nr == nr)
1094 return &main_controls[i];
1099 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1104 int rect_x = ALIGNED_TEXT_XPOS(rect);
1105 int rect_y = ALIGNED_TEXT_YPOS(rect);
1107 return (x >= rect_x && x < rect_x + rect->width &&
1108 y >= rect_y && y < rect_y + rect->height);
1111 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1116 int rect_x = ALIGNED_TEXT_XPOS(rect);
1117 int rect_y = ALIGNED_TEXT_YPOS(rect);
1120 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1121 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1122 (x >= rect_x && x < rect_x + rect->width &&
1123 y >= rect_y && y < rect_y + rect->height));
1126 return (x >= rect_x && x < rect_x + rect->width &&
1127 y >= rect_y && y < rect_y + rect->height);
1130 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1132 static int cursor_array[MAX_LEV_FIELDY];
1133 int x = mSX + TILEX * xpos;
1134 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1139 cursor_array[ypos] = graphic;
1141 graphic = cursor_array[ypos];
1145 graphic = BUTTON_ACTIVE(graphic);
1147 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1148 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1151 static void initCursor(int ypos, int graphic)
1153 drawCursorExt(0, ypos, FALSE, graphic);
1156 static void drawCursor(int ypos, boolean active)
1158 drawCursorExt(0, ypos, active, -1);
1161 static void drawCursorXY(int xpos, int ypos, int graphic)
1163 drawCursorExt(xpos, ypos, FALSE, graphic);
1166 static void drawChooseTreeCursor(int ypos, boolean active)
1168 int last_game_status = game_status; /* save current game status */
1170 drawCursorExt(0, ypos, active, -1);
1172 game_status = last_game_status; /* restore current game status */
1177 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1178 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1181 int effectiveGameStatus()
1183 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1184 return GAME_MODE_TITLE;
1189 void DrawTitleScreenImage(int nr, boolean initial)
1191 int graphic = getTitleScreenGraphic(nr, initial);
1192 Bitmap *bitmap = graphic_info[graphic].bitmap;
1193 int width = graphic_info[graphic].width;
1194 int height = graphic_info[graphic].height;
1195 int src_x = graphic_info[graphic].src_x;
1196 int src_y = graphic_info[graphic].src_y;
1202 if (width > WIN_XSIZE)
1204 /* image width too large for window => center image horizontally */
1205 src_x = (width - WIN_XSIZE) / 2;
1209 if (height > WIN_YSIZE)
1211 /* image height too large for window => center image vertically */
1212 src_y = (height - WIN_YSIZE) / 2;
1216 /* always display title screens centered */
1217 dst_x = (WIN_XSIZE - width) / 2;
1218 dst_y = (WIN_YSIZE - height) / 2;
1220 SetDrawBackgroundMask(REDRAW_ALL);
1221 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1223 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1225 if (DrawingOnBackground(dst_x, dst_y))
1226 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1228 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1230 redraw_mask = REDRAW_ALL;
1233 void DrawTitleScreenMessage(int nr, boolean initial)
1235 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1236 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1237 int last_game_status = game_status; /* save current game status */
1239 if (filename == NULL)
1242 /* force TITLE font on title message screen */
1243 game_status = getTitleMessageGameMode(initial);
1245 /* if chars set to "-1", automatically determine by text and font width */
1246 if (tmi->chars == -1)
1247 tmi->chars = tmi->width / getFontWidth(tmi->font);
1249 tmi->width = tmi->chars * getFontWidth(tmi->font);
1251 /* if lines set to "-1", automatically determine by text and font height */
1252 if (tmi->lines == -1)
1253 tmi->lines = tmi->height / getFontHeight(tmi->font);
1255 tmi->height = tmi->lines * getFontHeight(tmi->font);
1257 SetDrawBackgroundMask(REDRAW_ALL);
1258 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1260 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1262 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1263 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1264 tmi->autowrap, tmi->centered, tmi->parse_comments);
1266 game_status = last_game_status; /* restore current game status */
1269 void DrawTitleScreen()
1271 KeyboardAutoRepeatOff();
1273 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1278 boolean CheckTitleScreen(boolean levelset_has_changed)
1280 static boolean show_title_initial = TRUE;
1281 boolean show_titlescreen = FALSE;
1283 /* needed to be able to skip title screen, if no image or message defined */
1284 InitializeTitleControls(show_title_initial);
1286 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1287 show_titlescreen = TRUE;
1289 /* show initial title images and messages only once at program start */
1290 show_title_initial = FALSE;
1292 return (show_titlescreen && num_title_screens > 0);
1295 void DrawMainMenuExt(int fade_mask, boolean do_fading)
1297 static LevelDirTree *leveldir_last_valid = NULL;
1298 boolean levelset_has_changed = FALSE;
1300 LimitScreenUpdates(FALSE);
1302 FadeSetLeaveScreen();
1304 /* do not fade out here -- function may continue and fade on editor screen */
1307 FadeSoundsAndMusic();
1309 KeyboardAutoRepeatOn();
1312 SetDrawDeactivationMask(REDRAW_NONE);
1313 SetDrawBackgroundMask(REDRAW_FIELD);
1315 audio.sound_deactivated = FALSE;
1319 /* needed if last screen was the playing screen, invoked from level editor */
1320 if (level_editor_test_game)
1322 game_status = GAME_MODE_EDITOR;
1328 /* needed if last screen was the setup screen and fullscreen state changed */
1329 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1330 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1332 /* leveldir_current may be invalid (level group, parent link) */
1333 if (!validLevelSeries(leveldir_current))
1334 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1336 if (leveldir_current != leveldir_last_valid)
1337 levelset_has_changed = TRUE;
1339 /* store valid level series information */
1340 leveldir_last_valid = leveldir_current;
1342 init_last = init; /* switch to new busy animation */
1344 /* needed if last screen (level choice) changed graphics, sounds or music */
1345 ReloadCustomArtwork(0);
1347 if (redraw_mask & REDRAW_ALL)
1348 fade_mask = REDRAW_ALL;
1352 /* needed if different viewport properties defined for menues */
1353 ChangeViewportPropertiesIfNeeded();
1355 /* needed if last screen was the editor screen */
1356 UndrawSpecialEditorDoor();
1358 SetDrawtoField(DRAW_BACKBUFFER);
1360 if (CheckTitleScreen(levelset_has_changed))
1362 game_status = GAME_MODE_TITLE;
1369 /* level_nr may have been set to value over handicap with level editor */
1370 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1371 level_nr = leveldir_current->handicap_level;
1373 LoadLevel(level_nr);
1374 LoadScore(level_nr);
1376 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1378 if (fade_mask == REDRAW_ALL)
1383 InitializeMainControls();
1385 DrawCursorAndText_Main(-1, FALSE);
1386 DrawPreviewLevelInitial();
1388 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1391 if (TAPE_IS_EMPTY(tape))
1393 DrawCompleteVideoDisplay();
1398 /* create gadgets for main menu screen */
1399 FreeScreenGadgets();
1400 CreateScreenGadgets();
1402 /* map gadgets for main menu screen */
1404 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1406 /* copy actual game door content to door double buffer for OpenDoor() */
1407 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1409 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1411 DrawMaskedBorder(REDRAW_ALL);
1416 /* update screen area with special editor door */
1417 redraw_mask |= REDRAW_ALL;
1420 SetMouseCursor(CURSOR_DEFAULT);
1424 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1427 void DrawAndFadeInMainMenu(int fade_mask)
1429 DrawMainMenuExt(fade_mask, TRUE);
1434 DrawMainMenuExt(REDRAW_ALL, FALSE);
1437 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1438 static void gotoTopLevelDir()
1440 /* move upwards to top level directory */
1441 while (leveldir_current->node_parent)
1443 /* write a "path" into level tree for easy navigation to last level */
1444 if (leveldir_current->node_parent->node_group->cl_first == -1)
1446 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1447 int leveldir_pos = posTreeInfo(leveldir_current);
1448 int num_page_entries;
1449 int cl_first, cl_cursor;
1451 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1452 num_page_entries = num_leveldirs;
1454 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1456 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1457 cl_cursor = leveldir_pos - cl_first;
1459 leveldir_current->node_parent->node_group->cl_first = cl_first;
1460 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1463 leveldir_current = leveldir_current->node_parent;
1468 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1470 static unsigned int title_delay = 0;
1471 static int title_screen_nr = 0;
1472 static int last_sound = -1, last_music = -1;
1473 boolean return_to_main_menu = FALSE;
1474 boolean use_fading_main_menu = TRUE;
1475 struct TitleControlInfo *tci;
1476 struct TitleFadingInfo fading_default;
1477 struct TitleFadingInfo fading_last = fading;
1478 struct TitleFadingInfo fading_next;
1481 if (button == MB_MENU_INITIALIZE)
1484 title_screen_nr = 0;
1485 tci = &title_controls[title_screen_nr];
1487 last_sound = SND_UNDEFINED;
1488 last_music = MUS_UNDEFINED;
1490 if (game_status == GAME_MODE_INFO)
1492 if (num_title_screens == 0)
1494 DrawInfoScreen_NotAvailable("Title screen information:",
1495 "No title screen for this level set.");
1500 FadeSoundsAndMusic();
1502 FadeOut(REDRAW_ALL);
1506 DrawTitleScreenImage(tci->local_nr, tci->initial);
1508 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1510 fading_default = (tci->initial ? title_initial_default : title_default);
1512 fading = fading_next = getTitleFading(tci);
1514 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1515 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1517 fading.fade_mode = FADE_MODE_FADE;
1518 fading.fade_delay = fading_default.fade_delay;
1521 sound = getTitleSound(tci);
1522 music = getTitleMusic(tci);
1524 if (sound != last_sound)
1525 PlayMenuSoundExt(sound);
1526 if (music != last_music)
1527 PlayMenuMusicExt(music);
1532 SetMouseCursor(CURSOR_NONE);
1536 fading = fading_next;
1538 DelayReached(&title_delay, 0); /* reset delay counter */
1543 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1544 button = MB_MENU_CHOICE;
1546 if (button == MB_MENU_LEAVE)
1548 return_to_main_menu = TRUE;
1549 use_fading_main_menu = FALSE;
1551 else if (button == MB_MENU_CHOICE)
1553 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1555 FadeSetEnterScreen();
1557 info_mode = INFO_MODE_MAIN;
1558 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1564 tci = &title_controls[title_screen_nr];
1566 if (title_screen_nr < num_title_screens)
1568 sound = getTitleSound(tci);
1569 music = getTitleMusic(tci);
1571 if (sound == SND_UNDEFINED || sound != last_sound)
1573 if (music == MUS_UNDEFINED || music != last_music)
1576 FadeOut(REDRAW_ALL);
1579 DrawTitleScreenImage(tci->local_nr, tci->initial);
1581 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1583 fading_next = getTitleFading(tci);
1585 sound = getTitleSound(tci);
1586 music = getTitleMusic(tci);
1588 if (sound != last_sound)
1589 PlayMenuSoundExt(sound);
1590 if (music != last_music)
1591 PlayMenuMusicExt(music);
1596 /* last screen already faded out, next screen has no animation */
1597 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1598 fading_next.fade_mode == FADE_MODE_NONE)
1599 fading = fading_next;
1603 fading = fading_next;
1605 DelayReached(&title_delay, 0); /* reset delay counter */
1609 FadeSoundsAndMusic();
1611 return_to_main_menu = TRUE;
1615 if (return_to_main_menu)
1617 SetMouseCursor(CURSOR_DEFAULT);
1619 if (game_status == GAME_MODE_INFO)
1621 info_mode = INFO_MODE_MAIN;
1623 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1625 else /* default: return to main menu */
1627 game_status = GAME_MODE_MAIN;
1629 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1634 void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
1636 int old_level_nr = level_nr;
1639 if (selected_level_nr != NO_DIRECT_LEVEL_SELECT)
1640 new_level_nr = selected_level_nr;
1642 new_level_nr = old_level_nr + step * direction;
1644 if (new_level_nr < leveldir_current->first_level)
1645 new_level_nr = leveldir_current->first_level;
1646 if (new_level_nr > leveldir_current->last_level)
1647 new_level_nr = leveldir_current->last_level;
1649 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1651 /* skipping levels is only allowed when trying to skip single level */
1652 if (setup.skip_levels && new_level_nr == old_level_nr + 1 &&
1653 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1655 leveldir_current->handicap_level++;
1656 SaveLevelSetup_SeriesInfo();
1659 new_level_nr = leveldir_current->handicap_level;
1662 if (new_level_nr != old_level_nr)
1664 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1666 PlaySound(SND_MENU_ITEM_SELECTING);
1668 level_nr = new_level_nr;
1670 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1671 int2str(level_nr, menu.main.text.level_number.size),
1672 mci->pos_text->font);
1674 LoadLevel(level_nr);
1675 DrawPreviewLevelInitial();
1679 DrawCompleteVideoDisplay();
1681 /* needed because DrawPreviewLevelInitial() takes some time */
1683 /* SyncDisplay(); */
1687 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1689 static int choice = MAIN_CONTROL_GAME;
1693 if (button == MB_MENU_INITIALIZE)
1695 DrawCursorAndText_Main(choice, TRUE);
1700 if (mx || my) /* mouse input */
1704 for (i = 0; main_controls[i].nr != -1; i++)
1706 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1707 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1708 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1710 pos = main_controls[i].nr;
1716 else if (dx || dy) /* keyboard input */
1718 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1719 choice == MAIN_CONTROL_SETUP))
1720 button = MB_MENU_CHOICE;
1725 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1727 HandleMainMenu_SelectLevel(1, (dx < 0 ? -1 : +1), NO_DIRECT_LEVEL_SELECT);
1729 else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1731 HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
1733 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1735 HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT);
1737 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1739 game_status = GAME_MODE_LEVELNR;
1741 ChangeViewportPropertiesIfNeeded();
1743 DrawChooseLevelNr();
1745 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1751 PlaySound(SND_MENU_ITEM_ACTIVATING);
1753 DrawCursorAndText_Main(choice, FALSE);
1754 DrawCursorAndText_Main(pos, TRUE);
1761 PlaySound(SND_MENU_ITEM_SELECTING);
1763 if (pos == MAIN_CONTROL_NAME)
1765 game_status = GAME_MODE_PSEUDO_TYPENAME;
1767 HandleTypeName(strlen(setup.player_name), 0);
1769 else if (pos == MAIN_CONTROL_LEVELS)
1773 game_status = GAME_MODE_LEVELS;
1775 SaveLevelSetup_LastSeries();
1776 SaveLevelSetup_SeriesInfo();
1778 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1782 ChangeViewportPropertiesIfNeeded();
1784 DrawChooseLevelSet();
1787 else if (pos == MAIN_CONTROL_SCORES)
1789 game_status = GAME_MODE_SCORES;
1791 ChangeViewportPropertiesIfNeeded();
1795 else if (pos == MAIN_CONTROL_EDITOR)
1797 if (leveldir_current->readonly &&
1798 !strEqual(setup.player_name, "Artsoft"))
1799 Request("This level is read only!", REQ_CONFIRM);
1801 CloseDoor(DOOR_CLOSE_2);
1803 game_status = GAME_MODE_EDITOR;
1805 FadeSetEnterScreen();
1809 else if (pos == MAIN_CONTROL_INFO)
1811 game_status = GAME_MODE_INFO;
1812 info_mode = INFO_MODE_MAIN;
1814 ChangeViewportPropertiesIfNeeded();
1818 else if (pos == MAIN_CONTROL_GAME)
1820 StartGameActions(options.network, setup.autorecord, level.random_seed);
1822 else if (pos == MAIN_CONTROL_SETUP)
1824 game_status = GAME_MODE_SETUP;
1825 setup_mode = SETUP_MODE_MAIN;
1827 ChangeViewportPropertiesIfNeeded();
1831 else if (pos == MAIN_CONTROL_QUIT)
1833 SaveLevelSetup_LastSeries();
1834 SaveLevelSetup_SeriesInfo();
1836 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1837 game_status = GAME_MODE_QUIT;
1844 /* ========================================================================= */
1845 /* info screen functions */
1846 /* ========================================================================= */
1848 static struct TokenInfo *info_info;
1849 static int num_info_info;
1851 static void execInfoTitleScreen()
1853 info_mode = INFO_MODE_TITLE;
1858 static void execInfoElements()
1860 info_mode = INFO_MODE_ELEMENTS;
1865 static void execInfoMusic()
1867 info_mode = INFO_MODE_MUSIC;
1872 static void execInfoCredits()
1874 info_mode = INFO_MODE_CREDITS;
1879 static void execInfoProgram()
1881 info_mode = INFO_MODE_PROGRAM;
1886 static void execInfoVersion()
1888 info_mode = INFO_MODE_VERSION;
1893 static void execInfoLevelSet()
1895 info_mode = INFO_MODE_LEVELSET;
1900 static void execExitInfo()
1902 game_status = GAME_MODE_MAIN;
1904 DrawMainMenuExt(REDRAW_FIELD, FALSE);
1907 static struct TokenInfo info_info_main[] =
1909 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
1910 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
1911 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
1912 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
1913 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
1914 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
1915 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
1916 { TYPE_EMPTY, NULL, "" },
1917 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
1922 static void DrawCursorAndText_Info(int pos, boolean active)
1924 int xpos = MENU_SCREEN_START_XPOS;
1925 int ypos = MENU_SCREEN_START_YPOS + pos;
1926 int font_nr = FONT_MENU_1;
1929 font_nr = FONT_ACTIVE(font_nr);
1931 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
1933 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
1934 drawCursor(pos, active);
1937 static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
1942 CloseDoor(DOOR_CLOSE_2);
1944 /* (needed after displaying title screens which disable auto repeat) */
1945 KeyboardAutoRepeatOn();
1947 FadeSetLeaveScreen();
1951 if (fade_mask == REDRAW_ALL)
1955 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1960 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
1962 info_info = info_info_main;
1965 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1967 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
1968 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
1969 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
1970 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
1971 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
1972 initCursor(i, IMG_MENU_BUTTON);
1974 DrawCursorAndText_Info(i, FALSE);
1979 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
1984 DrawMaskedBorder(fade_mask);
1991 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
1993 static int choice_store[MAX_INFO_MODES];
1994 int choice = choice_store[info_mode]; /* always starts with 0 */
1998 if (button == MB_MENU_INITIALIZE)
2000 /* advance to first valid menu entry */
2001 while (choice < num_info_info &&
2002 info_info[choice].type & TYPE_SKIP_ENTRY)
2004 choice_store[info_mode] = choice;
2006 DrawCursorAndText_Info(choice, TRUE);
2010 else if (button == MB_MENU_LEAVE)
2012 for (y = 0; y < num_info_info; y++)
2014 if (info_info[y].type & TYPE_LEAVE_MENU)
2016 void (*menu_callback_function)(void) = info_info[y].value;
2020 menu_callback_function();
2022 break; /* absolutely needed because function changes 'info_info'! */
2029 if (mx || my) /* mouse input */
2031 x = (mx - mSX) / 32;
2032 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2034 else if (dx || dy) /* keyboard input */
2038 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2040 if (info_info[choice].type & menu_navigation_type ||
2041 info_info[choice].type & TYPE_ENTER_SCREEN ||
2042 info_info[choice].type & TYPE_BOOLEAN_STYLE ||
2043 info_info[choice].type & TYPE_YES_NO_AUTO)
2044 button = MB_MENU_CHOICE;
2049 /* jump to next non-empty menu entry (up or down) */
2050 while (y > 0 && y < num_info_info - 1 &&
2051 info_info[y].type & TYPE_SKIP_ENTRY)
2055 if (IN_VIS_MENU(x, y) &&
2056 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2062 PlaySound(SND_MENU_ITEM_ACTIVATING);
2064 DrawCursorAndText_Info(choice, FALSE);
2065 DrawCursorAndText_Info(y, TRUE);
2067 choice = choice_store[info_mode] = y;
2070 else if (!(info_info[y].type & TYPE_GHOSTED))
2072 PlaySound(SND_MENU_ITEM_SELECTING);
2074 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2076 void (*menu_callback_function)(void) = info_info[choice].value;
2078 FadeSetFromType(info_info[y].type);
2080 menu_callback_function();
2086 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2088 int ystart1 = mSY - SY + 100;
2089 int ystart2 = mSY - SY + 150;
2090 int ybottom = mSY - SY + SYSIZE - 20;
2092 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2094 FadeOut(REDRAW_FIELD);
2099 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2100 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2102 DrawTextSCentered(ybottom, FONT_TEXT_4,
2103 "Press any key or button for info menu");
2105 FadeIn(REDRAW_FIELD);
2108 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2110 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2111 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2112 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2113 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2114 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2115 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2116 int ystep = MENU_SCREEN_INFO_YSTEP;
2117 int element, action, direction;
2125 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2126 infoscreen_step[i] = infoscreen_frame[i] = 0;
2131 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2133 DrawTextSCentered(ybottom, FONT_TEXT_4,
2134 "Press any key or button for next page");
2140 while (helpanim_info[j].element != HELPANIM_LIST_END)
2142 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2147 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2156 j += infoscreen_step[i - start];
2158 element = helpanim_info[j].element;
2159 action = helpanim_info[j].action;
2160 direction = helpanim_info[j].direction;
2163 element = EL_UNKNOWN;
2165 if (action != -1 && direction != -1)
2166 graphic = el_act_dir2img(element, action, direction);
2167 else if (action != -1)
2168 graphic = el_act2img(element, action);
2169 else if (direction != -1)
2170 graphic = el_dir2img(element, direction);
2172 graphic = el2img(element);
2174 delay = helpanim_info[j++].delay;
2179 if (infoscreen_frame[i - start] == 0)
2182 infoscreen_frame[i - start] = delay - 1;
2186 sync_frame = delay - infoscreen_frame[i - start];
2187 infoscreen_frame[i - start]--;
2190 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2192 if (!infoscreen_frame[i - start])
2193 infoscreen_step[i - start] = 0;
2197 if (!infoscreen_frame[i - start])
2198 infoscreen_step[i - start]++;
2199 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2205 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2207 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2208 graphic, sync_frame, USE_MASKING);
2211 DrawInfoScreen_HelpText(element, action, direction, i - start);
2216 redraw_mask |= REDRAW_FIELD;
2221 static char *getHelpText(int element, int action, int direction)
2223 char token[MAX_LINE_LEN];
2225 strcpy(token, element_info[element].token_name);
2228 strcat(token, element_action_info[action].suffix);
2230 if (direction != -1)
2231 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2233 return getHashEntry(helptext_info, token);
2236 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2238 int font_nr = FONT_INFO_ELEMENTS;
2239 int font_width = getFontWidth(font_nr);
2240 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2241 int sy = mSY + 65 + 2 * 32 + 1;
2242 int ystep = TILEY + 4;
2243 int pad_x = sx - SX;
2244 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2245 int max_lines_per_text = 2;
2248 if (action != -1 && direction != -1) /* element.action.direction */
2249 text = getHelpText(element, action, direction);
2251 if (text == NULL && action != -1) /* element.action */
2252 text = getHelpText(element, action, -1);
2254 if (text == NULL && direction != -1) /* element.direction */
2255 text = getHelpText(element, -1, direction);
2257 if (text == NULL) /* base element */
2258 text = getHelpText(element, -1, -1);
2260 if (text == NULL) /* not found */
2261 text = "No description available";
2263 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2264 sy += getFontHeight(font_nr) / 2;
2266 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2267 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2268 TRUE, FALSE, FALSE);
2271 void DrawInfoScreen_TitleScreen()
2276 void HandleInfoScreen_TitleScreen(int button)
2278 HandleTitleScreen(0, 0, 0, 0, button);
2281 void DrawInfoScreen_Elements()
2283 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2285 FadeOut(REDRAW_FIELD);
2290 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2292 FadeIn(REDRAW_FIELD);
2297 void HandleInfoScreen_Elements(int button)
2299 static unsigned int info_delay = 0;
2300 static int num_anims;
2301 static int num_pages;
2303 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2306 if (button == MB_MENU_INITIALIZE)
2308 boolean new_element = TRUE;
2312 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2314 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2316 else if (new_element)
2319 new_element = FALSE;
2323 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2327 if (button == MB_MENU_LEAVE)
2329 PlaySound(SND_MENU_ITEM_SELECTING);
2331 info_mode = INFO_MODE_MAIN;
2336 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2338 if (button != MB_MENU_INITIALIZE)
2340 PlaySound(SND_MENU_ITEM_SELECTING);
2345 if (page >= num_pages)
2347 FadeSoundsAndMusic();
2349 info_mode = INFO_MODE_MAIN;
2350 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2356 FadeSetNextScreen();
2358 if (button != MB_MENU_INITIALIZE)
2359 FadeOut(REDRAW_FIELD);
2361 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2363 if (button != MB_MENU_INITIALIZE)
2364 FadeIn(REDRAW_FIELD);
2368 if (DelayReached(&info_delay, GameFrameDelay))
2369 if (page < num_pages)
2370 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2372 PlayMenuSoundIfLoop();
2376 void DrawInfoScreen_Music()
2378 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2380 FadeOut(REDRAW_FIELD);
2387 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2389 FadeIn(REDRAW_FIELD);
2392 void HandleInfoScreen_Music(int button)
2394 static struct MusicFileInfo *list = NULL;
2395 int ystart1 = mSY - SY + 100;
2396 int ystart2 = mSY - SY + 150;
2397 int ybottom = mSY - SY + SYSIZE - 20;
2400 if (button == MB_MENU_INITIALIZE)
2402 list = music_file_info;
2406 FadeSoundsAndMusic();
2411 DrawTextSCentered(ystart1, FONT_TEXT_1,
2412 "No music info for this level set.");
2414 DrawTextSCentered(ybottom, FONT_TEXT_4,
2415 "Press any key or button for info menu");
2421 if (button == MB_MENU_LEAVE)
2423 PlaySound(SND_MENU_ITEM_SELECTING);
2425 FadeSoundsAndMusic();
2427 info_mode = INFO_MODE_MAIN;
2432 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2436 if (button != MB_MENU_INITIALIZE)
2438 PlaySound(SND_MENU_ITEM_SELECTING);
2446 FadeSoundsAndMusic();
2448 info_mode = INFO_MODE_MAIN;
2449 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2454 FadeSoundsAndMusic();
2456 if (list != music_file_info)
2457 FadeSetNextScreen();
2459 if (button != MB_MENU_INITIALIZE)
2460 FadeOut(REDRAW_FIELD);
2467 int sound = list->music;
2469 if (sound_info[sound].loop)
2470 PlaySoundLoop(sound);
2474 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2478 PlayMusic(list->music);
2480 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2483 if (!strEqual(list->title, UNKNOWN_NAME))
2485 if (!strEqual(list->title_header, UNKNOWN_NAME))
2486 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2488 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2491 if (!strEqual(list->artist, UNKNOWN_NAME))
2493 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2494 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2496 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2498 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2501 if (!strEqual(list->album, UNKNOWN_NAME))
2503 if (!strEqual(list->album_header, UNKNOWN_NAME))
2504 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2506 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2508 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2511 if (!strEqual(list->year, UNKNOWN_NAME))
2513 if (!strEqual(list->year_header, UNKNOWN_NAME))
2514 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2516 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2518 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2521 DrawTextSCentered(ybottom, FONT_TEXT_4,
2522 "Press any key or button for next page");
2524 if (button != MB_MENU_INITIALIZE)
2525 FadeIn(REDRAW_FIELD);
2528 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2529 PlaySoundLoop(list->music);
2532 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2534 int ystart1 = mSY - SY + 100;
2535 int ystart2 = mSY - SY + 150;
2536 int ybottom = mSY - SY + SYSIZE - 20;
2542 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2546 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2547 "Special thanks to");
2548 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2550 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2552 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2553 "\"Boulder Dash\"");
2554 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2556 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2558 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2560 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2561 "First Star Software");
2563 else if (screen_nr == 1)
2565 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2566 "Special thanks to");
2567 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2568 "Klaus Heinz & Volker Wertich");
2569 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2571 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2572 "\"Emerald Mine\"");
2573 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2575 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2577 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2579 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2582 else if (screen_nr == 2)
2584 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2585 "Special thanks to");
2586 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2587 "Michael Stopp & Philip Jespersen");
2588 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2590 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2592 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2594 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2596 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2598 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2599 "Digital Integration");
2601 else if (screen_nr == 3)
2603 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2604 "Special thanks to");
2605 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2606 "Hiroyuki Imabayashi");
2607 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2609 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2611 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2613 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2615 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2617 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2620 else if (screen_nr == 4)
2622 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2623 "Special thanks to");
2624 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2626 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2628 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2629 "J\xfcrgen Bonhagen");
2630 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2631 "for the continuous creation");
2632 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2633 "of outstanding level sets");
2635 else if (screen_nr == 5)
2637 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2639 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2641 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2642 "for ideas and inspiration by");
2643 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2646 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2648 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2650 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2651 "for ideas and inspiration by");
2652 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2655 else if (screen_nr == 6)
2657 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2659 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2662 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2663 "for the code base used for the");
2664 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
2665 "native Emerald Mine engine");
2667 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2668 "for the new Emerald Mine engine");
2671 else if (screen_nr == 7)
2673 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2675 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2677 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2678 "for the initial DOS port");
2680 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2682 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2684 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2685 "for some additional toons");
2687 else if (screen_nr == 8)
2689 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2690 "And not to forget:");
2691 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2693 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2694 "All those who contributed");
2695 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2696 "levels to this game");
2697 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2701 DrawTextSCentered(ybottom, FONT_TEXT_4,
2702 "Press any key or button for next page");
2705 void DrawInfoScreen_Credits()
2707 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2709 FadeSoundsAndMusic();
2711 FadeOut(REDRAW_FIELD);
2713 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
2715 FadeIn(REDRAW_FIELD);
2718 void HandleInfoScreen_Credits(int button)
2720 static int screen_nr = 0;
2721 int num_screens = 9;
2723 if (button == MB_MENU_INITIALIZE)
2727 // DrawInfoScreen_CreditsScreen(screen_nr);
2730 if (button == MB_MENU_LEAVE)
2732 PlaySound(SND_MENU_ITEM_SELECTING);
2734 info_mode = INFO_MODE_MAIN;
2739 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2741 if (button != MB_MENU_INITIALIZE)
2743 PlaySound(SND_MENU_ITEM_SELECTING);
2748 if (screen_nr >= num_screens)
2750 FadeSoundsAndMusic();
2752 info_mode = INFO_MODE_MAIN;
2753 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2759 FadeSetNextScreen();
2761 if (button != MB_MENU_INITIALIZE)
2762 FadeOut(REDRAW_FIELD);
2764 DrawInfoScreen_CreditsScreen(screen_nr);
2766 if (button != MB_MENU_INITIALIZE)
2767 FadeIn(REDRAW_FIELD);
2771 PlayMenuSoundIfLoop();
2775 void DrawInfoScreen_Program()
2777 int ystart1 = mSY - SY + 100;
2778 int ystart2 = mSY - SY + 150;
2779 int ybottom = mSY - SY + SYSIZE - 20;
2782 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
2784 FadeOut(REDRAW_FIELD);
2789 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
2791 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2792 "This game is Freeware!");
2793 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2794 "If you like it, send e-mail to:");
2795 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2796 PROGRAM_EMAIL_STRING);
2797 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2798 "More information and levels:");
2799 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2800 PROGRAM_WEBSITE_STRING);
2801 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2802 "If you have created new levels,");
2803 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
2804 "send them to me to include them!");
2805 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
2808 DrawTextSCentered(ybottom, FONT_TEXT_4,
2809 "Press any key or button for info menu");
2811 FadeIn(REDRAW_FIELD);
2814 void HandleInfoScreen_Program(int button)
2816 if (button == MB_MENU_LEAVE)
2818 PlaySound(SND_MENU_ITEM_SELECTING);
2820 info_mode = INFO_MODE_MAIN;
2825 else if (button == MB_MENU_CHOICE)
2827 PlaySound(SND_MENU_ITEM_SELECTING);
2829 FadeSoundsAndMusic();
2831 info_mode = INFO_MODE_MAIN;
2832 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2836 PlayMenuSoundIfLoop();
2840 void DrawInfoScreen_Version()
2842 int font_header = FONT_TEXT_3;
2843 int font_text = FONT_TEXT_2;
2844 int xstep = getFontWidth(font_text);
2845 int ystep = getFontHeight(font_text);
2846 int ystart1 = mSY - SY + 100;
2847 int ystart2 = mSY - SY + 150;
2848 int ybottom = mSY - SY + SYSIZE - 20;
2849 int xstart1 = mSX - SX + 2 * xstep;
2850 int xstart2 = mSX - SX + 18 * xstep;
2851 int xstart3 = mSX - SX + 28 * xstep;
2852 SDL_version sdl_version_compiled;
2853 const SDL_version *sdl_version_linked;
2854 int driver_name_len = 10;
2855 #if defined(TARGET_SDL2)
2856 SDL_version sdl_version_linked_ext;
2857 const char *driver_name = NULL;
2859 char driver_name[driver_name_len];
2862 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
2864 FadeOut(REDRAW_FIELD);
2869 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
2871 DrawTextF(xstart1, ystart2, font_header, "Name");
2872 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
2875 DrawTextF(xstart1, ystart2, font_header, "Version");
2876 DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
2879 DrawTextF(xstart1, ystart2, font_header, "Platform");
2880 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
2883 DrawTextF(xstart1, ystart2, font_header, "Target");
2884 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
2887 DrawTextF(xstart1, ystart2, font_header, "Compile time");
2888 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
2890 ystart2 += 3 * ystep;
2891 DrawTextF(xstart1, ystart2, font_header, "Library");
2892 DrawTextF(xstart2, ystart2, font_header, "compiled");
2893 DrawTextF(xstart3, ystart2, font_header, "linked");
2895 SDL_VERSION(&sdl_version_compiled);
2896 #if defined(TARGET_SDL2)
2897 SDL_GetVersion(&sdl_version_linked_ext);
2898 sdl_version_linked = &sdl_version_linked_ext;
2900 sdl_version_linked = SDL_Linked_Version();
2903 ystart2 += 2 * ystep;
2904 DrawTextF(xstart1, ystart2, font_text, "SDL");
2905 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2906 sdl_version_compiled.major,
2907 sdl_version_compiled.minor,
2908 sdl_version_compiled.patch);
2909 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2910 sdl_version_linked->major,
2911 sdl_version_linked->minor,
2912 sdl_version_linked->patch);
2914 SDL_IMAGE_VERSION(&sdl_version_compiled);
2915 sdl_version_linked = IMG_Linked_Version();
2918 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
2919 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2920 sdl_version_compiled.major,
2921 sdl_version_compiled.minor,
2922 sdl_version_compiled.patch);
2923 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2924 sdl_version_linked->major,
2925 sdl_version_linked->minor,
2926 sdl_version_linked->patch);
2928 SDL_MIXER_VERSION(&sdl_version_compiled);
2929 sdl_version_linked = Mix_Linked_Version();
2932 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
2933 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2934 sdl_version_compiled.major,
2935 sdl_version_compiled.minor,
2936 sdl_version_compiled.patch);
2937 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2938 sdl_version_linked->major,
2939 sdl_version_linked->minor,
2940 sdl_version_linked->patch);
2942 SDL_NET_VERSION(&sdl_version_compiled);
2943 sdl_version_linked = SDLNet_Linked_Version();
2946 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
2947 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2948 sdl_version_compiled.major,
2949 sdl_version_compiled.minor,
2950 sdl_version_compiled.patch);
2951 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2952 sdl_version_linked->major,
2953 sdl_version_linked->minor,
2954 sdl_version_linked->patch);
2956 ystart2 += 3 * ystep;
2957 DrawTextF(xstart1, ystart2, font_header, "Driver");
2958 DrawTextF(xstart2, ystart2, font_header, "Requested");
2959 DrawTextF(xstart3, ystart2, font_header, "Used");
2961 #if defined(TARGET_SDL2)
2962 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
2964 SDL_VideoDriverName(driver_name, driver_name_len);
2967 ystart2 += 2 * ystep;
2968 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
2969 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
2970 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2972 #if defined(TARGET_SDL2)
2973 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
2975 SDL_AudioDriverName(driver_name, driver_name_len);
2979 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
2980 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
2981 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2983 DrawTextSCentered(ybottom, FONT_TEXT_4,
2984 "Press any key or button for info menu");
2986 FadeIn(REDRAW_FIELD);
2989 void HandleInfoScreen_Version(int button)
2991 if (button == MB_MENU_LEAVE)
2993 PlaySound(SND_MENU_ITEM_SELECTING);
2995 info_mode = INFO_MODE_MAIN;
3000 else if (button == MB_MENU_CHOICE)
3002 PlaySound(SND_MENU_ITEM_SELECTING);
3004 FadeSoundsAndMusic();
3006 info_mode = INFO_MODE_MAIN;
3007 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3011 PlayMenuSoundIfLoop();
3015 void DrawInfoScreen_LevelSet()
3017 struct TitleMessageInfo *tmi = &readme;
3018 char *filename = getLevelSetInfoFilename();
3020 /* if chars set to "-1", automatically determine by text and font width */
3021 if (tmi->chars == -1)
3022 tmi->chars = tmi->width / getFontWidth(tmi->font);
3024 tmi->width = tmi->chars * getFontWidth(tmi->font);
3026 /* if lines set to "-1", automatically determine by text and font height */
3027 if (tmi->lines == -1)
3028 tmi->lines = tmi->height / getFontHeight(tmi->font);
3030 tmi->height = tmi->lines * getFontHeight(tmi->font);
3032 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3034 FadeOut(REDRAW_FIELD);
3039 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3041 if (filename != NULL)
3042 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3043 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3044 tmi->autowrap, tmi->centered, tmi->parse_comments);
3046 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3047 "No information for this level set.");
3049 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3050 "Press any key or button for info menu");
3052 FadeIn(REDRAW_FIELD);
3055 void HandleInfoScreen_LevelSet(int button)
3057 if (button == MB_MENU_LEAVE)
3059 PlaySound(SND_MENU_ITEM_SELECTING);
3061 info_mode = INFO_MODE_MAIN;
3066 else if (button == MB_MENU_CHOICE)
3068 PlaySound(SND_MENU_ITEM_SELECTING);
3070 FadeSoundsAndMusic();
3072 info_mode = INFO_MODE_MAIN;
3073 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3077 PlayMenuSoundIfLoop();
3081 static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
3083 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3085 if (info_mode == INFO_MODE_TITLE)
3086 DrawInfoScreen_TitleScreen();
3087 else if (info_mode == INFO_MODE_ELEMENTS)
3088 DrawInfoScreen_Elements();
3089 else if (info_mode == INFO_MODE_MUSIC)
3090 DrawInfoScreen_Music();
3091 else if (info_mode == INFO_MODE_CREDITS)
3092 DrawInfoScreen_Credits();
3093 else if (info_mode == INFO_MODE_PROGRAM)
3094 DrawInfoScreen_Program();
3095 else if (info_mode == INFO_MODE_VERSION)
3096 DrawInfoScreen_Version();
3097 else if (info_mode == INFO_MODE_LEVELSET)
3098 DrawInfoScreen_LevelSet();
3100 DrawInfoScreen_Main(fade_mask, do_fading);
3102 if (info_mode != INFO_MODE_MAIN &&
3103 info_mode != INFO_MODE_TITLE &&
3104 info_mode != INFO_MODE_MUSIC)
3111 void DrawAndFadeInInfoScreen(int fade_mask)
3113 DrawInfoScreenExt(fade_mask, TRUE);
3116 void DrawInfoScreen()
3118 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3121 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3123 if (info_mode == INFO_MODE_TITLE)
3124 HandleInfoScreen_TitleScreen(button);
3125 else if (info_mode == INFO_MODE_ELEMENTS)
3126 HandleInfoScreen_Elements(button);
3127 else if (info_mode == INFO_MODE_MUSIC)
3128 HandleInfoScreen_Music(button);
3129 else if (info_mode == INFO_MODE_CREDITS)
3130 HandleInfoScreen_Credits(button);
3131 else if (info_mode == INFO_MODE_PROGRAM)
3132 HandleInfoScreen_Program(button);
3133 else if (info_mode == INFO_MODE_VERSION)
3134 HandleInfoScreen_Version(button);
3135 else if (info_mode == INFO_MODE_LEVELSET)
3136 HandleInfoScreen_LevelSet(button);
3138 HandleInfoScreen_Main(mx, my, dx, dy, button);
3142 /* ========================================================================= */
3143 /* type name functions */
3144 /* ========================================================================= */
3146 void HandleTypeName(int newxpos, Key key)
3148 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3149 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3150 struct TextPosInfo *pos = mci->pos_input;
3151 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3152 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3153 static int xpos = 0;
3154 int font_nr = pos->font;
3155 int font_active_nr = FONT_ACTIVE(font_nr);
3156 int font_width = getFontWidth(font_active_nr);
3157 char key_char = getValidConfigValueChar(getCharFromKey(key));
3158 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3159 boolean is_active = TRUE;
3161 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3165 strcpy(last_player_name, setup.player_name);
3169 #if defined(TARGET_SDL2)
3170 SDL_StartTextInput();
3173 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3175 setup.player_name[xpos] = key_char;
3176 setup.player_name[xpos + 1] = 0;
3180 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3184 setup.player_name[xpos] = 0;
3186 else if (key == KSYM_Return && xpos > 0)
3192 game_status = GAME_MODE_MAIN;
3194 else if (key == KSYM_Escape)
3196 strcpy(setup.player_name, last_player_name);
3200 game_status = GAME_MODE_MAIN;
3205 pos->width = (strlen(setup.player_name) + 1) * font_width;
3206 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3208 DrawText(startx, starty, setup.player_name, font_active_nr);
3209 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3213 pos->width = strlen(setup.player_name) * font_width;
3214 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3216 DrawText(startx, starty, setup.player_name, font_nr);
3218 #if defined(TARGET_SDL2)
3219 SDL_StopTextInput();
3225 /* ========================================================================= */
3226 /* tree menu functions */
3227 /* ========================================================================= */
3229 static void DrawChooseTree(TreeInfo **ti_ptr)
3233 FreeScreenGadgets();
3234 CreateScreenGadgets();
3236 CloseDoor(DOOR_CLOSE_2);
3238 FadeOut(REDRAW_FIELD);
3242 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3243 MapScreenTreeGadgets(*ti_ptr);
3245 FadeIn(REDRAW_FIELD);
3250 static void AdjustScrollbar(int id, int items_max, int items_visible,
3253 struct GadgetInfo *gi = screen_gadget[id];
3255 if (item_position > items_max - items_visible)
3256 item_position = items_max - items_visible;
3258 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3259 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3260 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3263 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3265 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3269 static void clearMenuListArea()
3271 int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3273 /* correct scrollbar position if placed outside menu (playfield) area */
3274 if (scrollbar_xpos > mSX + SC_SCROLLBAR_XPOS)
3275 scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS;
3277 /* clear menu list area, but not title or scrollbar */
3278 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3279 scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
3282 static void drawChooseTreeList(int first_entry, int num_page_entries,
3286 char *title_string = NULL;
3287 int yoffset_sets = MENU_TITLE1_YPOS;
3288 int yoffset_setup = 16;
3289 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3290 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3291 int last_game_status = game_status; /* save current game status */
3293 title_string = ti->infotext;
3295 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3297 clearMenuListArea();
3299 for (i = 0; i < num_page_entries; i++)
3301 TreeInfo *node, *node_first;
3302 int entry_pos = first_entry + i;
3303 int xpos = MENU_SCREEN_START_XPOS;
3304 int ypos = MENU_SCREEN_START_YPOS + i;
3305 int startx = mSX + xpos * 32;
3306 int starty = mSY + ypos * 32;
3307 int font_nr = FONT_TEXT_1;
3308 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3309 int startx_text = startx + font_xoffset;
3310 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3311 int text_size = startx_scrollbar - startx_text;
3312 int max_buffer_len = text_size / getFontWidth(font_nr);
3313 char buffer[max_buffer_len + 1];
3315 node_first = getTreeInfoFirstGroupEntry(ti);
3316 node = getTreeInfoFromPos(node_first, entry_pos);
3318 strncpy(buffer, node->name, max_buffer_len);
3319 buffer[max_buffer_len] = '\0';
3321 DrawText(startx, starty, buffer, font_nr + node->color);
3323 if (node->parent_link)
3324 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3325 else if (node->level_group)
3326 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3328 initCursor(i, IMG_MENU_BUTTON);
3331 game_status = last_game_status; /* restore current game status */
3333 redraw_mask |= REDRAW_FIELD;
3336 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3338 TreeInfo *node, *node_first;
3339 int x, last_redraw_mask = redraw_mask;
3340 int ypos = MENU_TITLE2_YPOS;
3341 int font_nr = FONT_TITLE_2;
3343 if (ti->type == TREE_TYPE_LEVEL_NR)
3344 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3346 if (ti->type != TREE_TYPE_LEVEL_DIR)
3349 node_first = getTreeInfoFirstGroupEntry(ti);
3350 node = getTreeInfoFromPos(node_first, entry_pos);
3352 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3354 if (node->parent_link)
3355 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3356 node->node_parent->name);
3357 else if (node->level_group)
3358 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3360 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3361 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3362 node->levels, (node->levels > 1 ? "levels" : "level"),
3365 /* let BackToFront() redraw only what is needed */
3366 redraw_mask = last_redraw_mask | REDRAW_TILES;
3367 for (x = 0; x < SCR_FIELDX; x++)
3368 MarkTileDirty(x, 1);
3371 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3374 TreeInfo *ti = *ti_ptr;
3376 int y = ti->cl_cursor;
3377 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3378 int num_entries = numTreeInfoInGroup(ti);
3379 int num_page_entries;
3380 int last_game_status = game_status; /* save current game status */
3381 boolean position_set_by_scrollbar = (dx == 999);
3383 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3384 num_page_entries = num_entries;
3386 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3388 game_status = last_game_status; /* restore current game status */
3390 if (button == MB_MENU_INITIALIZE)
3392 int num_entries = numTreeInfoInGroup(ti);
3393 int entry_pos = posTreeInfo(ti);
3395 if (ti->cl_first == -1)
3397 /* only on initialization */
3398 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3399 ti->cl_cursor = entry_pos - ti->cl_first;
3401 else if (ti->cl_cursor >= num_page_entries ||
3402 (num_entries > num_page_entries &&
3403 num_entries - ti->cl_first < num_page_entries))
3405 /* only after change of list size (by custom graphic configuration) */
3406 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3407 ti->cl_cursor = entry_pos - ti->cl_first;
3410 if (position_set_by_scrollbar)
3413 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3416 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3417 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3418 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3422 else if (button == MB_MENU_LEAVE)
3426 PlaySound(SND_MENU_ITEM_SELECTING);
3428 if (ti->node_parent)
3430 *ti_ptr = ti->node_parent;
3431 DrawChooseTree(ti_ptr);
3433 else if (game_status == GAME_MODE_SETUP)
3435 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3436 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3438 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3439 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3440 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3441 execSetupGraphics();
3442 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3443 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3444 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3446 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3447 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3448 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3455 if (game_status == GAME_MODE_LEVELNR)
3457 int new_level_nr = atoi(level_number_current->identifier);
3459 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
3462 game_status = GAME_MODE_MAIN;
3464 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3470 if (mx || my) /* mouse input */
3472 int last_game_status = game_status; /* save current game status */
3474 x = (mx - mSX) / 32;
3475 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3477 game_status = last_game_status; /* restore current game status */
3479 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3481 /* move cursor instead of scrolling when already at start/end of list */
3482 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3484 else if (dy == +1 * SCROLL_LINE &&
3485 ti->cl_first + num_page_entries == num_entries)
3488 /* handle scrolling screen one line or page */
3489 if (ti->cl_cursor + dy < 0 ||
3490 ti->cl_cursor + dy > num_page_entries - 1)
3492 boolean redraw = FALSE;
3494 if (ABS(dy) == SCROLL_PAGE)
3495 step = num_page_entries - 1;
3497 if (dy < 0 && ti->cl_first > 0)
3499 /* scroll page/line up */
3501 ti->cl_first -= step;
3502 if (ti->cl_first < 0)
3507 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3509 /* scroll page/line down */
3511 ti->cl_first += step;
3512 if (ti->cl_first + num_page_entries > num_entries)
3513 ti->cl_first = MAX(0, num_entries - num_page_entries);
3520 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3521 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3522 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3524 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3532 /* handle moving cursor one line */
3533 y = ti->cl_cursor + dy;
3538 TreeInfo *node_first, *node_cursor;
3539 int entry_pos = ti->cl_first + y;
3541 node_first = getTreeInfoFirstGroupEntry(ti);
3542 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3544 if (node_cursor->node_group)
3548 PlaySound(SND_MENU_ITEM_SELECTING);
3550 node_cursor->cl_first = ti->cl_first;
3551 node_cursor->cl_cursor = ti->cl_cursor;
3552 *ti_ptr = node_cursor->node_group;
3553 DrawChooseTree(ti_ptr);
3558 else if (dx == -1 && ti->node_parent)
3562 PlaySound(SND_MENU_ITEM_SELECTING);
3564 *ti_ptr = ti->node_parent;
3565 DrawChooseTree(ti_ptr);
3570 if (!anyScrollbarGadgetActive() &&
3571 IN_VIS_MENU(x, y) &&
3572 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3573 y >= 0 && y < num_page_entries)
3577 if (y != ti->cl_cursor)
3579 PlaySound(SND_MENU_ITEM_ACTIVATING);
3581 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3582 drawChooseTreeCursor(y, TRUE);
3583 drawChooseTreeInfo(ti->cl_first + y, ti);
3590 TreeInfo *node_first, *node_cursor;
3591 int entry_pos = ti->cl_first + y;
3593 PlaySound(SND_MENU_ITEM_SELECTING);
3595 node_first = getTreeInfoFirstGroupEntry(ti);
3596 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3598 if (node_cursor->node_group)
3602 node_cursor->cl_first = ti->cl_first;
3603 node_cursor->cl_cursor = ti->cl_cursor;
3604 *ti_ptr = node_cursor->node_group;
3605 DrawChooseTree(ti_ptr);
3607 else if (node_cursor->parent_link)
3611 *ti_ptr = node_cursor->node_parent;
3612 DrawChooseTree(ti_ptr);
3618 node_cursor->cl_first = ti->cl_first;
3619 node_cursor->cl_cursor = ti->cl_cursor;
3620 *ti_ptr = node_cursor;
3622 if (ti->type == TREE_TYPE_LEVEL_DIR)
3624 LoadLevelSetup_SeriesInfo();
3626 SaveLevelSetup_LastSeries();
3627 SaveLevelSetup_SeriesInfo();
3631 if (game_status == GAME_MODE_SETUP)
3633 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3634 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3636 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3637 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3638 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3639 execSetupGraphics();
3640 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3641 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3642 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3644 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3645 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3646 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3653 if (game_status == GAME_MODE_LEVELNR)
3655 int new_level_nr = atoi(level_number_current->identifier);
3657 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
3660 game_status = GAME_MODE_MAIN;
3669 void DrawChooseLevelSet()
3671 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3673 DrawChooseTree(&leveldir_current);
3679 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
3681 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
3684 void DrawChooseLevelNr()
3688 if (level_number != NULL)
3690 freeTreeInfo(level_number);
3692 level_number = NULL;
3695 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
3697 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
3698 char identifier[32], name[32];
3701 /* temporarily load level info to get level name */
3702 LoadLevelInfoOnly(i);
3704 ti->node_top = &level_number;
3705 ti->sort_priority = 10000 + value;
3706 ti->color = (level.no_valid_file ? FC_BLUE :
3707 LevelStats_getSolved(i) ? FC_GREEN :
3708 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
3710 sprintf(identifier, "%d", value);
3711 sprintf(name, "%03d: %s", value,
3712 (level.no_valid_file ? "(no file)" : level.name));
3714 setString(&ti->identifier, identifier);
3715 setString(&ti->name, name);
3716 setString(&ti->name_sorting, name);
3718 pushTreeInfo(&level_number, ti);
3721 /* sort level number values to start with lowest level number */
3722 sortTreeInfo(&level_number);
3724 /* set current level number to current level number */
3725 level_number_current =
3726 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
3728 /* if that also fails, set current level number to first available level */
3729 if (level_number_current == NULL)
3730 level_number_current = level_number;
3732 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3734 DrawChooseTree(&level_number_current);
3740 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
3742 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
3745 void DrawHallOfFame(int highlight_position)
3748 FadeSoundsAndMusic();
3750 /* (this is needed when called from GameEnd() after winning a game) */
3751 KeyboardAutoRepeatOn();
3754 /* (this is needed when called from GameEnd() after winning a game) */
3755 SetDrawDeactivationMask(REDRAW_NONE);
3756 SetDrawBackgroundMask(REDRAW_FIELD);
3758 CloseDoor(DOOR_CLOSE_2);
3760 if (highlight_position < 0)
3761 LoadScore(level_nr);
3763 FadeSetEnterScreen();
3765 FadeOut(REDRAW_FIELD);
3772 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
3774 FadeIn(REDRAW_FIELD);
3777 static void drawHallOfFameList(int first_entry, int highlight_position)
3781 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
3784 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
3785 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
3786 "HighScores of Level %d", level_nr);
3788 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
3790 int entry = first_entry + i;
3791 boolean active = (entry == highlight_position);
3792 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
3793 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
3794 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
3795 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
3796 int dx1 = 3 * getFontWidth(font_nr1);
3797 int dx2 = dx1 + getFontWidth(font_nr1);
3798 int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
3799 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
3800 int sy = mSY + 64 + i * 32;
3802 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
3803 DrawText(mSX + dx1, sy, ".", font_nr1);
3805 for (j = 0; j < num_dots; j++)
3806 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
3808 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
3809 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
3811 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
3814 redraw_mask |= REDRAW_FIELD;
3817 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
3819 static int first_entry = 0;
3820 static int highlight_position = 0;
3821 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3823 if (button == MB_MENU_INITIALIZE)
3826 highlight_position = mx;
3827 drawHallOfFameList(first_entry, highlight_position);
3832 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
3833 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
3837 if (first_entry > 0)
3839 first_entry -= step;
3840 if (first_entry < 0)
3843 drawHallOfFameList(first_entry, highlight_position);
3848 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
3850 first_entry += step;
3851 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
3852 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
3854 drawHallOfFameList(first_entry, highlight_position);
3857 else if (button == MB_MENU_LEAVE)
3859 PlaySound(SND_MENU_ITEM_SELECTING);
3861 FadeSound(SND_BACKGROUND_SCORES);
3863 game_status = GAME_MODE_MAIN;
3867 else if (button == MB_MENU_CHOICE)
3869 PlaySound(SND_MENU_ITEM_SELECTING);
3871 FadeSound(SND_BACKGROUND_SCORES);
3873 game_status = GAME_MODE_MAIN;
3875 DrawAndFadeInMainMenu(REDRAW_FIELD);
3878 if (game_status == GAME_MODE_SCORES)
3879 PlayMenuSoundIfLoop();
3883 /* ========================================================================= */
3884 /* setup screen functions */
3885 /* ========================================================================= */
3887 static struct TokenInfo *setup_info;
3888 static int num_setup_info; /* number of setup entries shown on screen */
3889 static int max_setup_info; /* total number of setup entries in list */
3891 static char *screen_mode_text;
3892 static char *window_size_text;
3893 static char *scaling_type_text;
3894 static char *scroll_delay_text;
3895 static char *game_speed_text;
3896 static char *graphics_set_name;
3897 static char *sounds_set_name;
3898 static char *music_set_name;
3899 static char *volume_simple_text;
3900 static char *volume_loops_text;
3901 static char *volume_music_text;
3902 static char *touch_controls_text;
3903 static char *move_distance_text;
3904 static char *drop_distance_text;
3906 static void execSetupMain()
3908 setup_mode = SETUP_MODE_MAIN;
3913 static void execSetupGame_setGameSpeeds()
3915 if (game_speeds == NULL)
3919 for (i = 0; game_speeds_list[i].value != -1; i++)
3921 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3922 char identifier[32], name[32];
3923 int value = game_speeds_list[i].value;
3924 char *text = game_speeds_list[i].text;
3926 ti->node_top = &game_speeds;
3927 ti->sort_priority = 10000 - value;
3929 sprintf(identifier, "%d", value);
3930 sprintf(name, "%s", text);
3932 setString(&ti->identifier, identifier);
3933 setString(&ti->name, name);
3934 setString(&ti->name_sorting, name);
3935 setString(&ti->infotext, "Game Speed");
3937 pushTreeInfo(&game_speeds, ti);
3940 /* sort game speed values to start with slowest game speed */
3941 sortTreeInfo(&game_speeds);
3943 /* set current game speed to configured game speed value */
3944 game_speed_current =
3945 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
3947 /* if that fails, set current game speed to reliable default value */
3948 if (game_speed_current == NULL)
3949 game_speed_current =
3950 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
3952 /* if that also fails, set current game speed to first available speed */
3953 if (game_speed_current == NULL)
3954 game_speed_current = game_speeds;
3957 setup.game_frame_delay = atoi(game_speed_current->identifier);
3959 /* needed for displaying game speed text instead of identifier */
3960 game_speed_text = game_speed_current->name;
3963 static void execSetupGame_setScrollDelays()
3965 if (scroll_delays == NULL)
3969 for (i = 0; scroll_delays_list[i].value != -1; i++)
3971 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3972 char identifier[32], name[32];
3973 int value = scroll_delays_list[i].value;
3974 char *text = scroll_delays_list[i].text;
3976 ti->node_top = &scroll_delays;
3977 ti->sort_priority = value;
3979 sprintf(identifier, "%d", value);
3980 sprintf(name, "%s", text);
3982 setString(&ti->identifier, identifier);
3983 setString(&ti->name, name);
3984 setString(&ti->name_sorting, name);
3985 setString(&ti->infotext, "Scaling Type");
3987 pushTreeInfo(&scroll_delays, ti);
3990 /* sort scaling type values to start with lowest scaling type value */
3991 sortTreeInfo(&scroll_delays);
3993 /* set current scaling type value to configured scaling type value */
3994 scroll_delay_current =
3995 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
3997 /* if that fails, set current scaling type to reliable default value */
3998 if (scroll_delay_current == NULL)
3999 scroll_delay_current =
4000 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4002 /* if that also fails, set current scaling type to first available value */
4003 if (scroll_delay_current == NULL)
4004 scroll_delay_current = scroll_delays;
4007 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4009 /* needed for displaying scaling type text instead of identifier */
4010 scroll_delay_text = scroll_delay_current->name;
4013 static void execSetupGame()
4015 execSetupGame_setGameSpeeds();
4016 execSetupGame_setScrollDelays();
4018 setup_mode = SETUP_MODE_GAME;
4023 static void execSetupChooseGameSpeed()
4025 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4030 static void execSetupChooseScrollDelay()
4032 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4037 static void execSetupEditor()
4039 setup_mode = SETUP_MODE_EDITOR;
4044 static void execSetupGraphics_setWindowSizes(boolean update_list)
4046 if (window_sizes != NULL && update_list)
4048 freeTreeInfo(window_sizes);
4050 window_sizes = NULL;
4053 if (window_sizes == NULL)
4055 boolean current_window_size_found = FALSE;
4058 for (i = 0; window_sizes_list[i].value != -1; i++)
4060 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4061 char identifier[32], name[32];
4062 int value = window_sizes_list[i].value;
4063 char *text = window_sizes_list[i].text;
4065 ti->node_top = &window_sizes;
4066 ti->sort_priority = value;
4068 sprintf(identifier, "%d", value);
4069 sprintf(name, "%s", text);
4071 setString(&ti->identifier, identifier);
4072 setString(&ti->name, name);
4073 setString(&ti->name_sorting, name);
4074 setString(&ti->infotext, "Window Scaling");
4076 pushTreeInfo(&window_sizes, ti);
4078 if (value == setup.window_scaling_percent)
4079 current_window_size_found = TRUE;
4082 if (!current_window_size_found)
4084 // add entry for non-preset window scaling value
4086 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4087 char identifier[32], name[32];
4088 int value = setup.window_scaling_percent;
4090 ti->node_top = &window_sizes;
4091 ti->sort_priority = value;
4093 sprintf(identifier, "%d", value);
4094 sprintf(name, "%d %% (Current)", value);
4096 setString(&ti->identifier, identifier);
4097 setString(&ti->name, name);
4098 setString(&ti->name_sorting, name);
4099 setString(&ti->infotext, "Window Scaling");
4101 pushTreeInfo(&window_sizes, ti);
4104 /* sort window size values to start with lowest window size value */
4105 sortTreeInfo(&window_sizes);
4107 /* set current window size value to configured window size value */
4108 window_size_current =
4109 getTreeInfoFromIdentifier(window_sizes,
4110 i_to_a(setup.window_scaling_percent));
4112 /* if that fails, set current window size to reliable default value */
4113 if (window_size_current == NULL)
4114 window_size_current =
4115 getTreeInfoFromIdentifier(window_sizes,
4116 i_to_a(STD_WINDOW_SCALING_PERCENT));
4118 /* if that also fails, set current window size to first available value */
4119 if (window_size_current == NULL)
4120 window_size_current = window_sizes;
4123 setup.window_scaling_percent = atoi(window_size_current->identifier);
4125 /* needed for displaying window size text instead of identifier */
4126 window_size_text = window_size_current->name;
4129 static void execSetupGraphics_setScalingTypes()
4131 if (scaling_types == NULL)
4135 for (i = 0; scaling_types_list[i].value != NULL; i++)
4137 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4138 char identifier[32], name[32];
4139 char *value = scaling_types_list[i].value;
4140 char *text = scaling_types_list[i].text;
4142 ti->node_top = &scaling_types;
4143 ti->sort_priority = i;
4145 sprintf(identifier, "%s", value);
4146 sprintf(name, "%s", text);
4148 setString(&ti->identifier, identifier);
4149 setString(&ti->name, name);
4150 setString(&ti->name_sorting, name);
4151 setString(&ti->infotext, "Anti-Aliasing");
4153 pushTreeInfo(&scaling_types, ti);
4156 /* sort scaling type values to start with lowest scaling type value */
4157 sortTreeInfo(&scaling_types);
4159 /* set current scaling type value to configured scaling type value */
4160 scaling_type_current =
4161 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4163 /* if that fails, set current scaling type to reliable default value */
4164 if (scaling_type_current == NULL)
4165 scaling_type_current =
4166 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4168 /* if that also fails, set current scaling type to first available value */
4169 if (scaling_type_current == NULL)
4170 scaling_type_current = scaling_types;
4173 setup.window_scaling_quality = scaling_type_current->identifier;
4175 /* needed for displaying scaling type text instead of identifier */
4176 scaling_type_text = scaling_type_current->name;
4179 static void execSetupGraphics_setScreenModes()
4181 // if (screen_modes == NULL && video.fullscreen_available)
4182 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4186 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4188 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4189 char identifier[32], name[32];
4190 int x = video.fullscreen_modes[i].width;
4191 int y = video.fullscreen_modes[i].height;
4194 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4196 ti->node_top = &screen_modes;
4197 ti->sort_priority = x * 10000 + y;
4199 sprintf(identifier, "%dx%d", x, y);
4200 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4202 setString(&ti->identifier, identifier);
4203 setString(&ti->name, name);
4204 setString(&ti->name_sorting, name);
4205 setString(&ti->infotext, "Fullscreen Mode");
4207 pushTreeInfo(&screen_modes, ti);
4210 /* sort fullscreen modes to start with lowest available screen resolution */
4211 sortTreeInfo(&screen_modes);
4213 /* set current screen mode for fullscreen mode to configured setup value */
4214 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4215 setup.fullscreen_mode);
4217 /* if that fails, set current screen mode to reliable default value */
4218 if (screen_mode_current == NULL)
4219 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4220 DEFAULT_FULLSCREEN_MODE);
4222 /* if that also fails, set current screen mode to first available mode */
4223 if (screen_mode_current == NULL)
4224 screen_mode_current = screen_modes;
4226 if (screen_mode_current == NULL)
4227 video.fullscreen_available = FALSE;
4230 // if (video.fullscreen_available)
4231 if (screen_mode_current != NULL)
4233 setup.fullscreen_mode = screen_mode_current->identifier;
4235 /* needed for displaying screen mode name instead of identifier */
4236 screen_mode_text = screen_mode_current->name;
4240 static void execSetupGraphics()
4242 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4244 // update "setup.window_scaling_percent" from list selection
4245 execSetupGraphics_setWindowSizes(FALSE);
4249 // update list selection from "setup.window_scaling_percent"
4250 execSetupGraphics_setWindowSizes(TRUE);
4253 execSetupGraphics_setScalingTypes();
4254 execSetupGraphics_setScreenModes();
4256 setup_mode = SETUP_MODE_GRAPHICS;
4260 #if defined(TARGET_SDL2)
4261 // window scaling may have changed at this point
4262 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4264 // window scaling quality may have changed at this point
4265 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4266 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4270 #if !defined(PLATFORM_ANDROID)
4271 #if defined(TARGET_SDL2)
4272 static void execSetupChooseWindowSize()
4274 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4279 static void execSetupChooseScalingType()
4281 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4286 static void execSetupChooseScreenMode()
4288 if (!video.fullscreen_available)
4291 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4298 static void execSetupChooseVolumeSimple()
4300 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4305 static void execSetupChooseVolumeLoops()
4307 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4312 static void execSetupChooseVolumeMusic()
4314 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4319 static void execSetupSound()
4321 if (volumes_simple == NULL)
4325 for (i = 0; volumes_list[i].value != -1; i++)
4327 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4328 char identifier[32], name[32];
4329 int value = volumes_list[i].value;
4330 char *text = volumes_list[i].text;
4332 ti->node_top = &volumes_simple;
4333 ti->sort_priority = value;
4335 sprintf(identifier, "%d", value);
4336 sprintf(name, "%s", text);
4338 setString(&ti->identifier, identifier);
4339 setString(&ti->name, name);
4340 setString(&ti->name_sorting, name);
4341 setString(&ti->infotext, "Sound Volume");
4343 pushTreeInfo(&volumes_simple, ti);
4346 /* sort volume values to start with lowest volume value */
4347 sortTreeInfo(&volumes_simple);
4349 /* set current volume value to configured volume value */
4350 volume_simple_current =
4351 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4353 /* if that fails, set current volume to reliable default value */
4354 if (volume_simple_current == NULL)
4355 volume_simple_current =
4356 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4358 /* if that also fails, set current volume to first available value */
4359 if (volume_simple_current == NULL)
4360 volume_simple_current = volumes_simple;
4363 if (volumes_loops == NULL)
4367 for (i = 0; volumes_list[i].value != -1; i++)
4369 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4370 char identifier[32], name[32];
4371 int value = volumes_list[i].value;
4372 char *text = volumes_list[i].text;
4374 ti->node_top = &volumes_loops;
4375 ti->sort_priority = value;
4377 sprintf(identifier, "%d", value);
4378 sprintf(name, "%s", text);
4380 setString(&ti->identifier, identifier);
4381 setString(&ti->name, name);
4382 setString(&ti->name_sorting, name);
4383 setString(&ti->infotext, "Loops Volume");
4385 pushTreeInfo(&volumes_loops, ti);
4388 /* sort volume values to start with lowest volume value */
4389 sortTreeInfo(&volumes_loops);
4391 /* set current volume value to configured volume value */
4392 volume_loops_current =
4393 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4395 /* if that fails, set current volume to reliable default value */
4396 if (volume_loops_current == NULL)
4397 volume_loops_current =
4398 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4400 /* if that also fails, set current volume to first available value */
4401 if (volume_loops_current == NULL)
4402 volume_loops_current = volumes_loops;
4405 if (volumes_music == NULL)
4409 for (i = 0; volumes_list[i].value != -1; i++)
4411 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4412 char identifier[32], name[32];
4413 int value = volumes_list[i].value;
4414 char *text = volumes_list[i].text;
4416 ti->node_top = &volumes_music;
4417 ti->sort_priority = value;
4419 sprintf(identifier, "%d", value);
4420 sprintf(name, "%s", text);
4422 setString(&ti->identifier, identifier);
4423 setString(&ti->name, name);
4424 setString(&ti->name_sorting, name);
4425 setString(&ti->infotext, "Music Volume");
4427 pushTreeInfo(&volumes_music, ti);
4430 /* sort volume values to start with lowest volume value */
4431 sortTreeInfo(&volumes_music);
4433 /* set current volume value to configured volume value */
4434 volume_music_current =
4435 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4437 /* if that fails, set current volume to reliable default value */
4438 if (volume_music_current == NULL)
4439 volume_music_current =
4440 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4442 /* if that also fails, set current volume to first available value */
4443 if (volume_music_current == NULL)
4444 volume_music_current = volumes_music;
4447 setup.volume_simple = atoi(volume_simple_current->identifier);
4448 setup.volume_loops = atoi(volume_loops_current->identifier);
4449 setup.volume_music = atoi(volume_music_current->identifier);
4451 /* needed for displaying volume text instead of identifier */
4452 volume_simple_text = volume_simple_current->name;
4453 volume_loops_text = volume_loops_current->name;
4454 volume_music_text = volume_music_current->name;
4456 setup_mode = SETUP_MODE_SOUND;
4461 static void execSetupChooseTouchControls()
4463 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4468 static void execSetupChooseMoveDistance()
4470 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4475 static void execSetupChooseDropDistance()
4477 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4482 static void execSetupTouch()
4484 if (touch_controls == NULL)
4488 for (i = 0; touch_controls_list[i].value != NULL; i++)
4490 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4491 char identifier[32], name[32];
4492 char *value = touch_controls_list[i].value;
4493 char *text = touch_controls_list[i].text;
4495 ti->node_top = &touch_controls;
4496 ti->sort_priority = i;
4498 sprintf(identifier, "%s", value);
4499 sprintf(name, "%s", text);
4501 setString(&ti->identifier, identifier);
4502 setString(&ti->name, name);
4503 setString(&ti->name_sorting, name);
4504 setString(&ti->infotext, "Control Type");
4506 pushTreeInfo(&touch_controls, ti);
4509 /* sort touch control values to start with lowest touch control value */
4510 sortTreeInfo(&touch_controls);
4512 /* set current touch control value to configured touch control value */
4513 touch_control_current =
4514 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4516 /* if that fails, set current touch control to reliable default value */
4517 if (touch_control_current == NULL)
4518 touch_control_current =
4519 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4521 /* if that also fails, set current touch control to first available value */
4522 if (touch_control_current == NULL)
4523 touch_control_current = touch_controls;
4526 if (move_distances == NULL)
4530 for (i = 0; distances_list[i].value != -1; i++)
4532 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4533 char identifier[32], name[32];
4534 int value = distances_list[i].value;
4535 char *text = distances_list[i].text;
4537 ti->node_top = &move_distances;
4538 ti->sort_priority = value;
4540 sprintf(identifier, "%d", value);
4541 sprintf(name, "%s", text);
4543 setString(&ti->identifier, identifier);
4544 setString(&ti->name, name);
4545 setString(&ti->name_sorting, name);
4546 setString(&ti->infotext, "Move Distance");
4548 pushTreeInfo(&move_distances, ti);
4551 /* sort distance values to start with lowest distance value */
4552 sortTreeInfo(&move_distances);
4554 /* set current distance value to configured distance value */
4555 move_distance_current =
4556 getTreeInfoFromIdentifier(move_distances,
4557 i_to_a(setup.touch.move_distance));
4559 /* if that fails, set current distance to reliable default value */
4560 if (move_distance_current == NULL)
4561 move_distance_current =
4562 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4564 /* if that also fails, set current distance to first available value */
4565 if (move_distance_current == NULL)
4566 move_distance_current = move_distances;
4569 if (drop_distances == NULL)
4573 for (i = 0; distances_list[i].value != -1; i++)
4575 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4576 char identifier[32], name[32];
4577 int value = distances_list[i].value;
4578 char *text = distances_list[i].text;
4580 ti->node_top = &drop_distances;
4581 ti->sort_priority = value;
4583 sprintf(identifier, "%d", value);
4584 sprintf(name, "%s", text);
4586 setString(&ti->identifier, identifier);
4587 setString(&ti->name, name);
4588 setString(&ti->name_sorting, name);
4589 setString(&ti->infotext, "Drop Distance");
4591 pushTreeInfo(&drop_distances, ti);
4594 /* sort distance values to start with lowest distance value */
4595 sortTreeInfo(&drop_distances);
4597 /* set current distance value to configured distance value */
4598 drop_distance_current =
4599 getTreeInfoFromIdentifier(drop_distances,
4600 i_to_a(setup.touch.drop_distance));
4602 /* if that fails, set current distance to reliable default value */
4603 if (drop_distance_current == NULL)
4604 drop_distance_current =
4605 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
4607 /* if that also fails, set current distance to first available value */
4608 if (drop_distance_current == NULL)
4609 drop_distance_current = drop_distances;
4612 setup.touch.control_type = touch_control_current->identifier;
4613 setup.touch.move_distance = atoi(move_distance_current->identifier);
4614 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
4616 /* needed for displaying volume text instead of identifier */
4617 touch_controls_text = touch_control_current->name;
4618 move_distance_text = move_distance_current->name;
4619 drop_distance_text = drop_distance_current->name;
4621 setup_mode = SETUP_MODE_TOUCH;
4626 static void execSetupArtwork()
4629 printf("::: '%s', '%s', '%s'\n",
4630 artwork.gfx_current->subdir,
4631 artwork.gfx_current->fullpath,
4632 artwork.gfx_current->basepath);
4635 setup.graphics_set = artwork.gfx_current->identifier;
4636 setup.sounds_set = artwork.snd_current->identifier;
4637 setup.music_set = artwork.mus_current->identifier;
4639 /* needed if last screen (setup choice) changed graphics, sounds or music */
4640 ReloadCustomArtwork(0);
4642 /* needed for displaying artwork name instead of artwork identifier */
4643 graphics_set_name = artwork.gfx_current->name;
4644 sounds_set_name = artwork.snd_current->name;
4645 music_set_name = artwork.mus_current->name;
4647 setup_mode = SETUP_MODE_ARTWORK;
4652 static void execSetupChooseGraphics()
4654 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4659 static void execSetupChooseSounds()
4661 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4666 static void execSetupChooseMusic()
4668 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4673 #if !defined(PLATFORM_ANDROID)
4674 static void execSetupInput()
4676 setup_mode = SETUP_MODE_INPUT;
4682 static void execSetupShortcuts()
4684 setup_mode = SETUP_MODE_SHORTCUTS;
4689 static void execSetupShortcuts1()
4691 setup_mode = SETUP_MODE_SHORTCUTS_1;
4696 static void execSetupShortcuts2()
4698 setup_mode = SETUP_MODE_SHORTCUTS_2;
4703 static void execSetupShortcuts3()
4705 setup_mode = SETUP_MODE_SHORTCUTS_3;
4710 static void execSetupShortcuts4()
4712 setup_mode = SETUP_MODE_SHORTCUTS_4;
4717 static void execSetupShortcuts5()
4719 setup_mode = SETUP_MODE_SHORTCUTS_5;
4724 static void execExitSetup()
4726 game_status = GAME_MODE_MAIN;
4728 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4731 static void execSaveAndExitSetup()
4737 static struct TokenInfo setup_info_main[] =
4739 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4740 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4741 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4742 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4743 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4744 #if !defined(PLATFORM_ANDROID)
4745 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4746 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4748 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4750 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
4751 { TYPE_EMPTY, NULL, "" },
4752 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4753 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4758 static struct TokenInfo setup_info_game[] =
4760 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4761 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4762 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4763 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4764 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4765 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4766 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4767 { TYPE_STRING, &game_speed_text, "" },
4769 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4770 { TYPE_STRING, &scroll_delay_text, "" },
4772 { TYPE_EMPTY, NULL, "" },
4773 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4778 static struct TokenInfo setup_info_editor[] =
4781 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4782 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4783 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4784 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4785 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4786 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4787 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4788 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4790 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4791 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4792 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4794 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4796 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4797 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4798 { TYPE_EMPTY, NULL, "" },
4800 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4801 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4802 { TYPE_EMPTY, NULL, "" },
4804 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4805 { TYPE_EMPTY, NULL, "" },
4806 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4811 static struct TokenInfo setup_info_graphics[] =
4813 #if !defined(PLATFORM_ANDROID)
4814 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4815 #if defined(TARGET_SDL2)
4816 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
4817 { TYPE_STRING, &window_size_text, "" },
4818 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
4819 { TYPE_STRING, &scaling_type_text, "" },
4821 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4822 { TYPE_STRING, &screen_mode_text, "" },
4826 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4827 { TYPE_STRING, &scroll_delay_text, "" },
4829 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4830 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4831 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4832 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4833 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4834 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4835 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
4836 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
4837 { TYPE_EMPTY, NULL, "" },
4838 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4843 static struct TokenInfo setup_info_sound[] =
4845 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4846 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4847 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4848 { TYPE_EMPTY, NULL, "" },
4849 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
4850 { TYPE_STRING, &volume_simple_text, "" },
4851 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
4852 { TYPE_STRING, &volume_loops_text, "" },
4853 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
4854 { TYPE_STRING, &volume_music_text, "" },
4855 { TYPE_EMPTY, NULL, "" },
4856 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4861 static struct TokenInfo setup_info_artwork[] =
4863 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4864 { TYPE_STRING, &graphics_set_name, "" },
4865 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4866 { TYPE_STRING, &sounds_set_name, "" },
4867 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4868 { TYPE_STRING, &music_set_name, "" },
4869 { TYPE_EMPTY, NULL, "" },
4870 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
4871 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
4872 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
4873 { TYPE_EMPTY, NULL, "" },
4874 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4879 static struct TokenInfo setup_info_input[] =
4881 { TYPE_SWITCH, NULL, "Player:" },
4882 { TYPE_SWITCH, NULL, "Device:" },
4883 { TYPE_ENTER_MENU, NULL, "" },
4884 { TYPE_EMPTY, 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_LEAVE_MENU, execSetupMain, "Back" },
4899 static struct TokenInfo setup_info_touch[] =
4901 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
4902 { TYPE_STRING, &touch_controls_text, "" },
4903 { TYPE_EMPTY, NULL, "" },
4904 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
4905 { TYPE_STRING, &move_distance_text, "" },
4906 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
4907 { TYPE_STRING, &drop_distance_text, "" },
4908 { TYPE_EMPTY, NULL, "" },
4909 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4914 static struct TokenInfo setup_info_shortcuts[] =
4916 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
4917 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
4918 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
4919 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
4920 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
4921 { TYPE_EMPTY, NULL, "" },
4922 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4927 static struct TokenInfo setup_info_shortcuts_1[] =
4929 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4930 { TYPE_KEY, &setup.shortcut.save_game, "" },
4931 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4932 { TYPE_KEY, &setup.shortcut.load_game, "" },
4933 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4934 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4935 { TYPE_EMPTY, NULL, "" },
4936 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4937 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4938 { TYPE_EMPTY, NULL, "" },
4939 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4944 static struct TokenInfo setup_info_shortcuts_2[] =
4946 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4947 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4948 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4949 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4950 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4951 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4952 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4953 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4954 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4955 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4956 { TYPE_EMPTY, NULL, "" },
4957 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4962 static struct TokenInfo setup_info_shortcuts_3[] =
4964 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
4965 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
4966 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
4967 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
4968 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
4969 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
4970 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
4971 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
4972 { TYPE_KEYTEXT, NULL, "Record Tape:", },
4973 { TYPE_KEY, &setup.shortcut.tape_record, "" },
4974 { TYPE_KEYTEXT, NULL, "Play Tape:", },
4975 { TYPE_KEY, &setup.shortcut.tape_play, "" },
4976 { TYPE_EMPTY, NULL, "" },
4977 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4982 static struct TokenInfo setup_info_shortcuts_4[] =
4984 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
4985 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
4986 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
4987 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
4988 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
4989 { TYPE_KEY, &setup.shortcut.sound_music, "" },
4990 { TYPE_EMPTY, NULL, "" },
4991 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4996 static struct TokenInfo setup_info_shortcuts_5[] =
4998 { TYPE_KEYTEXT, NULL, "Snap Left:", },
4999 { TYPE_KEY, &setup.shortcut.snap_left, "" },
5000 { TYPE_KEYTEXT, NULL, "Snap Right:", },
5001 { TYPE_KEY, &setup.shortcut.snap_right, "" },
5002 { TYPE_KEYTEXT, NULL, "Snap Up:", },
5003 { TYPE_KEY, &setup.shortcut.snap_up, "" },
5004 { TYPE_KEYTEXT, NULL, "Snap Down:", },
5005 { TYPE_KEY, &setup.shortcut.snap_down, "" },
5006 { TYPE_EMPTY, NULL, "" },
5007 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5012 static Key getSetupKey()
5014 Key key = KSYM_UNDEFINED;
5015 boolean got_key_event = FALSE;
5017 while (!got_key_event)
5019 if (PendingEvent()) /* got event */
5027 case EVENT_KEYPRESS:
5029 key = GetEventKey((KeyEvent *)&event, TRUE);
5031 /* press 'Escape' or 'Enter' to keep the existing key binding */
5032 if (key == KSYM_Escape || key == KSYM_Return)
5033 key = KSYM_UNDEFINED; /* keep old value */
5035 got_key_event = TRUE;
5039 case EVENT_KEYRELEASE:
5040 key_joystick_mapping = 0;
5044 HandleOtherEvents(&event);
5052 /* don't eat all CPU time */
5059 static int getSetupTextFont(int type)
5061 if (type & (TYPE_SWITCH |
5073 static int getSetupValueFont(int type, void *value)
5075 if (type & TYPE_KEY)
5076 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5077 else if (type & TYPE_STRING)
5078 return FONT_VALUE_2;
5079 else if (type & TYPE_ECS_AGA)
5080 return FONT_VALUE_1;
5081 else if (type & TYPE_BOOLEAN_STYLE)
5082 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5083 else if (type & TYPE_YES_NO_AUTO)
5084 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5085 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5087 return FONT_VALUE_1;
5090 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5092 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5093 struct TokenInfo *si = &setup_info[si_pos];
5094 boolean font_draw_xoffset_modified = FALSE;
5095 int font_draw_xoffset_old = -1;
5096 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5097 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5098 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5099 int xpos = menu_screen_value_xpos;
5100 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5101 int startx = mSX + xpos * 32;
5102 int starty = mSY + ypos * 32;
5103 int font_nr, font_width;
5104 int type = si->type;
5105 void *value = si->value;
5106 char *value_string = getSetupValue(type, value);
5109 if (value_string == NULL)
5112 if (type & TYPE_KEY)
5114 xpos = MENU_SCREEN_START_XPOS;
5116 if (type & TYPE_QUERY)
5117 value_string = "<press key>";
5119 else if (type & TYPE_STRING)
5121 int max_value_len = (SCR_FIELDX - 2) * 2;
5123 xpos = MENU_SCREEN_START_XPOS;
5125 if (strlen(value_string) > max_value_len)
5126 value_string[max_value_len] = '\0';
5128 else if (type & TYPE_YES_NO_AUTO)
5130 xpos = menu_screen_value_xpos - 1;
5133 startx = mSX + xpos * 32;
5134 starty = mSY + ypos * 32;
5135 font_nr = getSetupValueFont(type, value);
5136 font_width = getFontWidth(font_nr);
5138 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5139 if (setup_mode != SETUP_MODE_INPUT)
5141 int max_menu_text_length_big = (menu_screen_value_xpos -
5142 MENU_SCREEN_START_XPOS);
5143 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5144 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5145 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5146 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5147 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5148 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5149 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5150 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5151 boolean correct_font_draw_xoffset = FALSE;
5153 if (xpos == MENU_SCREEN_START_XPOS &&
5154 startx + font1_xoffset < text_startx + text_font_xoffset)
5155 correct_font_draw_xoffset = TRUE;
5157 if (xpos == menu_screen_value_xpos &&
5158 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5159 correct_font_draw_xoffset = TRUE;
5161 /* check if setup value would overlap with setup text when printed */
5162 /* (this can happen for extreme/wrong values for font draw offset) */
5163 if (correct_font_draw_xoffset)
5165 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5166 font_draw_xoffset_modified = TRUE;
5168 if (type & TYPE_KEY)
5169 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5170 else if (!(type & TYPE_STRING))
5171 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5172 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5176 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5177 DrawText(startx + i * font_width, starty, " ", font_nr);
5179 DrawText(startx, starty, value_string, font_nr);
5181 if (font_draw_xoffset_modified)
5182 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5185 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5187 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5188 struct TokenInfo *si = &setup_info[si_pos];
5190 if (si->type & TYPE_BOOLEAN_STYLE)
5192 *(boolean *)si->value ^= TRUE;
5194 else if (si->type & TYPE_YES_NO_AUTO)
5198 (*(int *)si->value == AUTO ? TRUE :
5199 *(int *)si->value == TRUE ? FALSE : AUTO) :
5200 (*(int *)si->value == TRUE ? AUTO :
5201 *(int *)si->value == AUTO ? FALSE : TRUE));
5203 else if (si->type & TYPE_KEY)
5207 si->type |= TYPE_QUERY;
5208 drawSetupValue(screen_pos, setup_info_pos_raw);
5209 si->type &= ~TYPE_QUERY;
5211 key = getSetupKey();
5212 if (key != KSYM_UNDEFINED)
5213 *(Key *)si->value = key;
5216 drawSetupValue(screen_pos, setup_info_pos_raw);
5218 // fullscreen state may have changed at this point
5219 if (si->value == &setup.fullscreen)
5220 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5223 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5226 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5227 struct TokenInfo *si = &setup_info[si_pos];
5228 int xpos = MENU_SCREEN_START_XPOS;
5229 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5230 int font_nr = getSetupTextFont(si->type);
5232 if (setup_info == setup_info_input)
5233 font_nr = FONT_MENU_1;
5236 font_nr = FONT_ACTIVE(font_nr);
5238 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5240 if (si->type & ~TYPE_SKIP_ENTRY)
5241 drawCursor(screen_pos, active);
5244 static void drawSetupInfoList(struct TokenInfo *setup_info,
5245 int first_entry, int num_page_entries)
5249 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5250 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5252 if (num_page_entries > max_setup_info)
5253 num_page_entries = max_setup_info;
5255 if (first_entry + num_page_entries > max_setup_info)
5258 clearMenuListArea();
5260 for (i = 0; i < num_page_entries; i++)
5262 int setup_info_pos = first_entry + i;
5263 struct TokenInfo *si = &setup_info[setup_info_pos];
5264 void *value_ptr = si->value;
5266 /* set some entries to "unchangeable" according to other variables */
5267 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5268 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5269 (value_ptr == &setup.sound_music && !audio.music_available) ||
5270 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5271 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5272 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5273 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5274 si->type |= TYPE_GHOSTED;
5276 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5277 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5278 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5279 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5280 else if (si->type & ~TYPE_SKIP_ENTRY)
5281 initCursor(i, IMG_MENU_BUTTON);
5283 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5285 if (si->type & TYPE_VALUE)
5286 drawSetupValue(i, setup_info_pos);
5290 static void DrawSetupScreen_Generic()
5292 boolean redraw_all = FALSE;
5293 char *title_string = NULL;
5298 FreeScreenGadgets();
5299 CreateScreenGadgets();
5301 CloseDoor(DOOR_CLOSE_2);
5303 if (redraw_mask & REDRAW_ALL)
5306 FadeOut(REDRAW_FIELD);
5310 if (setup_mode == SETUP_MODE_MAIN)
5312 setup_info = setup_info_main;
5313 title_string = "Setup";
5315 else if (setup_mode == SETUP_MODE_GAME)
5317 setup_info = setup_info_game;
5318 title_string = "Setup Game";
5320 else if (setup_mode == SETUP_MODE_EDITOR)
5322 setup_info = setup_info_editor;
5323 title_string = "Setup Editor";
5325 else if (setup_mode == SETUP_MODE_GRAPHICS)
5327 setup_info = setup_info_graphics;
5328 title_string = "Setup Graphics";
5330 else if (setup_mode == SETUP_MODE_SOUND)
5332 setup_info = setup_info_sound;
5333 title_string = "Setup Sound";
5335 else if (setup_mode == SETUP_MODE_ARTWORK)
5337 setup_info = setup_info_artwork;
5338 title_string = "Custom Artwork";
5340 else if (setup_mode == SETUP_MODE_TOUCH)
5342 setup_info = setup_info_touch;
5343 title_string = "Setup Touch Ctrls";
5345 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5347 setup_info = setup_info_shortcuts;
5348 title_string = "Setup Shortcuts";
5350 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5352 setup_info = setup_info_shortcuts_1;
5353 title_string = "Setup Shortcuts";
5355 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5357 setup_info = setup_info_shortcuts_2;
5358 title_string = "Setup Shortcuts";
5360 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
5362 setup_info = setup_info_shortcuts_3;
5363 title_string = "Setup Shortcuts";
5365 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
5367 setup_info = setup_info_shortcuts_4;
5368 title_string = "Setup Shortcuts";
5370 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
5372 setup_info = setup_info_shortcuts_5;
5373 title_string = "Setup Shortcuts";
5376 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5378 // determine maximal number of setup entries that can be displayed on screen
5380 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5383 // determine maximal number of setup entries available for this setup screen
5385 for (i = 0; setup_info[i].type != 0; i++)
5388 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5390 MapScreenGadgets(max_setup_info);
5393 redraw_mask = REDRAW_ALL;
5395 FadeIn(redraw_mask);
5400 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5402 static int choice_store[MAX_SETUP_MODES];
5403 static int first_entry_store[MAX_SETUP_MODES];
5404 int choice = choice_store[setup_mode]; /* starts with 0 */
5405 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
5407 int y = choice - first_entry;
5409 boolean position_set_by_scrollbar = (dx == 999);
5410 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
5411 int num_page_entries;
5413 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
5415 if (button == MB_MENU_INITIALIZE)
5417 /* advance to first valid menu entry */
5418 while (choice < num_setup_info &&
5419 setup_info[choice].type & TYPE_SKIP_ENTRY)
5422 if (position_set_by_scrollbar)
5423 first_entry = first_entry_store[setup_mode] = dy;
5425 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5426 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5428 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5430 if (choice < first_entry)
5432 choice = first_entry;
5434 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5437 else if (choice > first_entry + num_page_entries - 1)
5439 choice = first_entry + num_page_entries - 1;
5441 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5445 choice_store[setup_mode] = choice;
5447 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5451 else if (button == MB_MENU_LEAVE)
5455 PlaySound(SND_MENU_ITEM_SELECTING);
5457 for (i = 0; setup_info[i].type != 0; i++)
5459 if (setup_info[i].type & TYPE_LEAVE_MENU)
5461 void (*menu_callback_function)(void) = setup_info[i].value;
5465 menu_callback_function();
5467 break; /* absolutely needed because function changes 'setup_info'! */
5474 if (mx || my) /* mouse input */
5476 x = (mx - mSX) / 32;
5477 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5479 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
5481 /* move cursor instead of scrolling when already at start/end of list */
5482 if (dy == -1 * SCROLL_LINE && first_entry == 0)
5484 else if (dy == +1 * SCROLL_LINE &&
5485 first_entry + num_page_entries == max_setup_info)
5488 /* handle scrolling screen one line or page */
5490 y + dy > num_page_entries - 1)
5492 boolean redraw = FALSE;
5494 if (ABS(dy) == SCROLL_PAGE)
5495 step = num_page_entries - 1;
5497 if (dy < 0 && first_entry > 0)
5499 /* scroll page/line up */
5501 first_entry -= step;
5502 if (first_entry < 0)
5507 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
5509 /* scroll page/line down */
5511 first_entry += step;
5512 if (first_entry + num_page_entries > max_setup_info)
5513 first_entry = MAX(0, max_setup_info - num_page_entries);
5520 choice += first_entry - first_entry_store[setup_mode];
5522 if (choice < first_entry)
5524 choice = first_entry;
5526 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5529 else if (choice > first_entry + num_page_entries - 1)
5531 choice = first_entry + num_page_entries - 1;
5533 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5536 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5540 if (choice < first_entry ||
5541 choice > first_entry + num_page_entries - 1)
5542 first_entry += SIGN(dy);
5545 first_entry_store[setup_mode] = first_entry;
5546 choice_store[setup_mode] = choice;
5548 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5550 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5552 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5553 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5561 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5563 if (setup_info[choice].type & menu_navigation_type ||
5564 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
5565 setup_info[choice].type & TYPE_YES_NO_AUTO)
5566 button = MB_MENU_CHOICE;
5571 /* jump to next non-empty menu entry (up or down) */
5572 while (first_entry + y > 0 &&
5573 first_entry + y < max_setup_info - 1 &&
5574 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
5577 if (!IN_VIS_MENU(x, y))
5579 choice += y - y_old;
5581 if (choice < first_entry)
5582 first_entry = choice;
5583 else if (choice > first_entry + num_page_entries - 1)
5584 first_entry = choice - num_page_entries + 1;
5586 if (first_entry >= 0 &&
5587 first_entry + num_page_entries <= max_setup_info)
5589 first_entry_store[setup_mode] = first_entry;
5591 if (choice < first_entry)
5592 choice = first_entry;
5593 else if (choice > first_entry + num_page_entries - 1)
5594 choice = first_entry + num_page_entries - 1;
5596 choice_store[setup_mode] = choice;
5598 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5600 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5602 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5603 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5610 if (!anyScrollbarGadgetActive() &&
5611 IN_VIS_MENU(x, y) &&
5612 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
5613 y >= 0 && y < num_page_entries)
5617 if (first_entry + y != choice &&
5618 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
5620 PlaySound(SND_MENU_ITEM_ACTIVATING);
5622 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
5623 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
5625 choice = choice_store[setup_mode] = first_entry + y;
5628 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
5630 PlaySound(SND_MENU_ITEM_SELECTING);
5632 /* when selecting key headline, execute function for key value change */
5633 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
5634 setup_info[first_entry + y + 1].type & TYPE_KEY)
5637 /* when selecting string value, execute function for list selection */
5638 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
5639 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
5642 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
5644 void (*menu_callback_function)(void) =
5645 setup_info[first_entry + y].value;
5647 FadeSetFromType(setup_info[first_entry + y].type);
5649 menu_callback_function();
5653 if (setup_info[first_entry + y].type & TYPE_VALUE)
5654 changeSetupValue(y, first_entry + y, dx);
5660 void DrawSetupScreen_Input()
5664 FadeOut(REDRAW_FIELD);
5668 setup_info = setup_info_input;
5670 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5672 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5673 "Joysticks deactivated on this screen");
5675 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5677 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5678 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5679 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5680 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5681 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5682 initCursor(i, IMG_MENU_BUTTON);
5684 DrawCursorAndText_Setup(i, -1, FALSE);
5687 /* create gadgets for setup input menu screen */
5688 FreeScreenGadgets();
5689 CreateScreenGadgets();
5691 /* map gadgets for setup input menu screen */
5692 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5694 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5696 FadeIn(REDRAW_FIELD);
5701 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5703 if (device_name == NULL)
5706 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5709 if (strlen(device_name) > 1)
5711 char c1 = device_name[strlen(device_name) - 1];
5712 char c2 = device_name[strlen(device_name) - 2];
5714 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5715 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5718 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5719 strlen(device_name));
5722 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5725 static struct SetupKeyboardInfo custom_key;
5732 { &custom_key.left, "Joystick Left" },
5733 { &custom_key.right, "Joystick Right" },
5734 { &custom_key.up, "Joystick Up" },
5735 { &custom_key.down, "Joystick Down" },
5736 { &custom_key.snap, "Button 1" },
5737 { &custom_key.drop, "Button 2" }
5739 static char *joystick_name[MAX_PLAYERS] =
5746 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5750 custom_key = setup.input[player_nr].key;
5752 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5753 FONT_INPUT_1_ACTIVE);
5755 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5757 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5758 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5760 if (setup.input[player_nr].use_joystick)
5762 char *device_name = setup.input[player_nr].joy.device_name;
5763 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5764 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5766 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5767 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5771 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5772 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5775 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5777 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5778 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5779 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5780 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5782 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5783 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5784 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5785 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5786 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5787 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5789 for (i = 0; i < 6; i++)
5791 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5793 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5795 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5796 (setup.input[player_nr].use_joystick ?
5798 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5802 static int input_player_nr = 0;
5804 void HandleSetupScreen_Input_Player(int step, int direction)
5806 int old_player_nr = input_player_nr;
5809 new_player_nr = old_player_nr + step * direction;
5810 if (new_player_nr < 0)
5812 if (new_player_nr > MAX_PLAYERS - 1)
5813 new_player_nr = MAX_PLAYERS - 1;
5815 if (new_player_nr != old_player_nr)
5817 input_player_nr = new_player_nr;
5819 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5823 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5825 static int choice = 0;
5828 int pos_start = SETUPINPUT_SCREEN_POS_START;
5829 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5830 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5831 int pos_end = SETUPINPUT_SCREEN_POS_END;
5833 if (button == MB_MENU_INITIALIZE)
5835 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5837 DrawCursorAndText_Setup(choice, -1, TRUE);
5841 else if (button == MB_MENU_LEAVE)
5843 setup_mode = SETUP_MODE_MAIN;
5850 if (mx || my) /* mouse input */
5852 x = (mx - mSX) / 32;
5853 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5855 else if (dx || dy) /* keyboard input */
5857 if (dx && choice == 0)
5858 x = (dx < 0 ? 10 : 12);
5859 else if ((dx && choice == 1) ||
5860 (dx == +1 && choice == 2) ||
5861 (dx == -1 && choice == pos_end))
5862 button = MB_MENU_CHOICE;
5866 if (y >= pos_empty1 && y <= pos_empty2)
5867 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5870 if (y == 0 && dx != 0 && button)
5872 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5874 else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
5875 y >= pos_start && y <= pos_end &&
5876 !(y >= pos_empty1 && y <= pos_empty2))
5882 DrawCursorAndText_Setup(choice, -1, FALSE);
5883 DrawCursorAndText_Setup(y, -1, TRUE);
5885 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5894 char *device_name = setup.input[input_player_nr].joy.device_name;
5896 if (!setup.input[input_player_nr].use_joystick)
5898 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5900 setJoystickDeviceToNr(device_name, new_device_nr);
5901 setup.input[input_player_nr].use_joystick = TRUE;
5905 int device_nr = getJoystickNrFromDeviceName(device_name);
5906 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5908 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5909 setup.input[input_player_nr].use_joystick = FALSE;
5911 setJoystickDeviceToNr(device_name, new_device_nr);
5914 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5918 if (setup.input[input_player_nr].use_joystick)
5921 CalibrateJoystick(input_player_nr);
5924 CustomizeKeyboard(input_player_nr);
5926 else if (y == pos_end)
5932 setup_mode = SETUP_MODE_MAIN;
5939 void CustomizeKeyboard(int player_nr)
5943 boolean finished = FALSE;
5944 static struct SetupKeyboardInfo custom_key;
5949 } customize_step[] =
5951 { &custom_key.left, "Move Left" },
5952 { &custom_key.right, "Move Right" },
5953 { &custom_key.up, "Move Up" },
5954 { &custom_key.down, "Move Down" },
5955 { &custom_key.snap, "Snap Field" },
5956 { &custom_key.drop, "Drop Element" }
5959 /* read existing key bindings from player setup */
5960 custom_key = setup.input[player_nr].key;
5963 FadeOut(REDRAW_FIELD);
5967 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5970 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5971 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5972 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5973 "Key:", FONT_INPUT_1_ACTIVE);
5974 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5975 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5977 FadeIn(REDRAW_FIELD);
5983 if (PendingEvent()) /* got event */
5991 case EVENT_KEYPRESS:
5993 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5995 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5997 if (key == KSYM_Escape)
5998 FadeSkipNextFadeIn();
6004 /* all keys configured -- wait for "Escape" or "Return" key */
6008 /* press 'Enter' to keep the existing key binding */
6009 if (key == KSYM_Return)
6010 key = *customize_step[step_nr].key;
6012 /* check if key already used */
6013 for (i = 0; i < step_nr; i++)
6014 if (*customize_step[i].key == key)
6019 /* got new key binding */
6020 *customize_step[step_nr].key = key;
6021 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6023 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6024 getKeyNameFromKey(key), FONT_VALUE_1);
6027 /* un-highlight last query */
6028 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6029 customize_step[step_nr - 1].text, FONT_MENU_1);
6030 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6031 "Key:", FONT_MENU_1);
6033 /* press 'Enter' to leave */
6036 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6037 "Press Enter", FONT_TITLE_1);
6041 /* query next key binding */
6042 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6043 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6044 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6045 "Key:", FONT_INPUT_1_ACTIVE);
6046 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6047 getKeyNameFromKey(*customize_step[step_nr].key),
6052 case EVENT_KEYRELEASE:
6053 key_joystick_mapping = 0;
6057 HandleOtherEvents(&event);
6065 /* don't eat all CPU time */
6069 /* write new key bindings back to player setup */
6070 setup.input[player_nr].key = custom_key;
6073 DrawSetupScreen_Input();
6076 static boolean CalibrateJoystickMain(int player_nr)
6078 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6079 int new_joystick_xright = JOYSTICK_XMIDDLE;
6080 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6081 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6082 int new_joystick_xmiddle, new_joystick_ymiddle;
6084 int joystick_fd = joystick.fd[player_nr];
6085 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6086 boolean check[3][3];
6087 int check_remaining = 3 * 3;
6092 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6095 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6099 FadeOut(REDRAW_FIELD);
6103 for (y = 0; y < 3; y++)
6105 for (x = 0; x < 3; x++)
6107 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6108 check[x][y] = FALSE;
6112 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6113 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6114 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6115 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6116 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6117 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6118 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6120 joy_value = Joystick(player_nr);
6121 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6122 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6124 /* eventually uncalibrated center position (joystick could be uncentered) */
6125 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6128 new_joystick_xmiddle = joy_x;
6129 new_joystick_ymiddle = joy_y;
6131 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6133 FadeIn(REDRAW_FIELD);
6135 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6140 if (PendingEvent()) /* got event */
6148 case EVENT_KEYPRESS:
6149 switch (GetEventKey((KeyEvent *)&event, TRUE))
6152 if (check_remaining == 0)
6157 FadeSkipNextFadeIn();
6166 case EVENT_KEYRELEASE:
6167 key_joystick_mapping = 0;
6171 HandleOtherEvents(&event);
6176 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6179 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
6180 new_joystick_xright = MAX(new_joystick_xright, joy_x);
6181 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
6182 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
6184 setup.input[player_nr].joy.xleft = new_joystick_xleft;
6185 setup.input[player_nr].joy.yupper = new_joystick_yupper;
6186 setup.input[player_nr].joy.xright = new_joystick_xright;
6187 setup.input[player_nr].joy.ylower = new_joystick_ylower;
6188 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
6189 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
6191 CheckJoystickData();
6193 joy_value = Joystick(player_nr);
6195 if (joy_value & JOY_BUTTON && check_remaining == 0)
6198 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6199 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6201 if (x != last_x || y != last_y)
6203 DrawFixedGraphic(xpos + last_x, ypos + last_y,
6204 IMG_MENU_CALIBRATE_YELLOW, 0);
6205 DrawFixedGraphic(xpos + x, ypos + y,
6206 IMG_MENU_CALIBRATE_RED, 0);
6211 if (check_remaining > 0 && !check[x+1][y+1])
6213 check[x+1][y+1] = TRUE;
6221 /* don't eat all CPU time */
6225 /* calibrated center position (joystick should now be centered) */
6226 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6229 new_joystick_xmiddle = joy_x;
6230 new_joystick_ymiddle = joy_y;
6234 /* wait until the last pressed button was released */
6235 while (Joystick(player_nr) & JOY_BUTTON)
6237 if (PendingEvent()) /* got event */
6242 HandleOtherEvents(&event);
6251 void CalibrateJoystick(int player_nr)
6253 if (!CalibrateJoystickMain(player_nr))
6255 char *device_name = setup.input[player_nr].joy.device_name;
6256 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6257 int xpos = mSX - SX;
6258 int ypos = mSY - SY;
6262 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6263 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
6266 Delay(2000); /* show error message for a short time */
6271 DrawSetupScreen_Input();
6274 void DrawSetupScreen()
6276 DeactivateJoystick();
6278 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6280 if (setup_mode == SETUP_MODE_INPUT)
6281 DrawSetupScreen_Input();
6282 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6283 DrawChooseTree(&game_speed_current);
6284 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6285 DrawChooseTree(&scroll_delay_current);
6286 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6287 DrawChooseTree(&screen_mode_current);
6288 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6289 DrawChooseTree(&window_size_current);
6290 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6291 DrawChooseTree(&scaling_type_current);
6292 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6293 DrawChooseTree(&artwork.gfx_current);
6294 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6295 DrawChooseTree(&artwork.snd_current);
6296 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6297 DrawChooseTree(&artwork.mus_current);
6298 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6299 DrawChooseTree(&volume_simple_current);
6300 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6301 DrawChooseTree(&volume_loops_current);
6302 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6303 DrawChooseTree(&volume_music_current);
6304 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6305 DrawChooseTree(&touch_control_current);
6306 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6307 DrawChooseTree(&move_distance_current);
6308 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6309 DrawChooseTree(&drop_distance_current);
6311 DrawSetupScreen_Generic();
6317 void RedrawSetupScreenAfterFullscreenToggle()
6319 if (setup_mode == SETUP_MODE_GRAPHICS ||
6320 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6322 // update list selection from "setup.window_scaling_percent"
6323 execSetupGraphics_setWindowSizes(TRUE);
6329 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
6331 if (setup_mode == SETUP_MODE_INPUT)
6332 HandleSetupScreen_Input(mx, my, dx, dy, button);
6333 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6334 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
6335 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6336 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
6337 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6338 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
6339 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6340 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
6341 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6342 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
6343 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6344 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
6345 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6346 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
6347 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6348 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
6349 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6350 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
6351 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6352 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
6353 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6354 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
6355 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6356 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
6357 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6358 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
6359 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6360 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
6362 HandleSetupScreen_Generic(mx, my, dx, dy, button);
6365 void HandleGameActions()
6367 if (game_status != GAME_MODE_PLAYING)
6370 GameActions(); /* main game loop */
6372 if (tape.auto_play && !tape.playing)
6373 AutoPlayTape(); /* continue automatically playing next tape */
6377 /* ---------- new screen button stuff -------------------------------------- */
6379 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6383 case SCREEN_CTRL_ID_PREV_LEVEL:
6384 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
6385 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
6388 case SCREEN_CTRL_ID_NEXT_LEVEL:
6389 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
6390 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
6393 case SCREEN_CTRL_ID_PREV_PLAYER:
6394 *x = mSX + TILEX * 10;
6395 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6398 case SCREEN_CTRL_ID_NEXT_PLAYER:
6399 *x = mSX + TILEX * 12;
6400 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6404 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6410 int gfx_unpressed, gfx_pressed;
6411 void (*get_gadget_position)(int *, int *, int);
6415 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6418 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6419 getScreenMenuButtonPos,
6420 SCREEN_CTRL_ID_PREV_LEVEL,
6425 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6426 getScreenMenuButtonPos,
6427 SCREEN_CTRL_ID_NEXT_LEVEL,
6432 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6433 getScreenMenuButtonPos,
6434 SCREEN_CTRL_ID_PREV_PLAYER,
6439 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6440 getScreenMenuButtonPos,
6441 SCREEN_CTRL_ID_NEXT_PLAYER,
6449 int gfx_unpressed, gfx_pressed;
6453 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6456 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6457 -1, -1, /* these values are not constant, but can change at runtime */
6458 SCREEN_CTRL_ID_SCROLL_UP,
6462 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6463 -1, -1, /* these values are not constant, but can change at runtime */
6464 SCREEN_CTRL_ID_SCROLL_DOWN,
6471 int gfx_unpressed, gfx_pressed;
6477 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6480 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6481 -1, -1, /* these values are not constant, but can change at runtime */
6482 -1, -1, /* these values are not constant, but can change at runtime */
6483 GD_TYPE_SCROLLBAR_VERTICAL,
6484 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6485 "scroll level series vertically"
6489 static void CreateScreenMenubuttons()
6491 struct GadgetInfo *gi;
6492 unsigned int event_mask;
6495 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6497 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6498 int gfx_unpressed, gfx_pressed;
6499 int x, y, width, height;
6500 int gd_x1, gd_x2, gd_y1, gd_y2;
6501 int id = menubutton_info[i].gadget_id;
6503 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6505 menubutton_info[i].get_gadget_position(&x, &y, id);
6507 width = SC_MENUBUTTON_XSIZE;
6508 height = SC_MENUBUTTON_YSIZE;
6510 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6511 gfx_pressed = menubutton_info[i].gfx_pressed;
6512 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6513 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6514 gd_x1 = graphic_info[gfx_unpressed].src_x;
6515 gd_y1 = graphic_info[gfx_unpressed].src_y;
6516 gd_x2 = graphic_info[gfx_pressed].src_x;
6517 gd_y2 = graphic_info[gfx_pressed].src_y;
6519 gi = CreateGadget(GDI_CUSTOM_ID, id,
6520 GDI_CUSTOM_TYPE_ID, i,
6521 GDI_INFO_TEXT, menubutton_info[i].infotext,
6526 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6527 GDI_STATE, GD_BUTTON_UNPRESSED,
6528 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6529 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6530 GDI_DIRECT_DRAW, FALSE,
6531 GDI_EVENT_MASK, event_mask,
6532 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6536 Error(ERR_EXIT, "cannot create gadget");
6538 screen_gadget[id] = gi;
6542 static void CreateScreenScrollbuttons()
6544 struct GadgetInfo *gi;
6545 unsigned int event_mask;
6548 /* these values are not constant, but can change at runtime */
6549 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
6550 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
6551 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
6552 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
6554 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6556 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6557 int gfx_unpressed, gfx_pressed;
6558 int x, y, width, height;
6559 int gd_x1, gd_x2, gd_y1, gd_y2;
6560 int id = scrollbutton_info[i].gadget_id;
6562 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6564 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6565 y = mSY + scrollbutton_info[i].y;
6566 width = SC_SCROLLBUTTON_XSIZE;
6567 height = SC_SCROLLBUTTON_YSIZE;
6569 /* correct scrollbar position if placed outside menu (playfield) area */
6570 if (x > SX + SC_SCROLL_UP_XPOS)
6571 x = SX + SC_SCROLL_UP_XPOS;
6573 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6574 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6575 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6577 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6578 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6579 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6580 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6581 gd_x1 = graphic_info[gfx_unpressed].src_x;
6582 gd_y1 = graphic_info[gfx_unpressed].src_y;
6583 gd_x2 = graphic_info[gfx_pressed].src_x;
6584 gd_y2 = graphic_info[gfx_pressed].src_y;
6586 gi = CreateGadget(GDI_CUSTOM_ID, id,
6587 GDI_CUSTOM_TYPE_ID, i,
6588 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6593 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6594 GDI_STATE, GD_BUTTON_UNPRESSED,
6595 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6596 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6597 GDI_DIRECT_DRAW, FALSE,
6598 GDI_EVENT_MASK, event_mask,
6599 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6603 Error(ERR_EXIT, "cannot create gadget");
6605 screen_gadget[id] = gi;
6609 static void CreateScreenScrollbars()
6613 /* these values are not constant, but can change at runtime */
6614 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
6615 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
6616 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
6617 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
6619 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6621 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6622 int gfx_unpressed, gfx_pressed;
6623 int x, y, width, height;
6624 int gd_x1, gd_x2, gd_y1, gd_y2;
6625 struct GadgetInfo *gi;
6626 int items_max, items_visible, item_position;
6627 unsigned int event_mask;
6628 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6629 int id = scrollbar_info[i].gadget_id;
6631 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6633 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6634 y = mSY + scrollbar_info[i].y;
6635 width = scrollbar_info[i].width;
6636 height = scrollbar_info[i].height;
6638 /* correct scrollbar position if placed outside menu (playfield) area */
6639 if (x > SX + SC_SCROLL_VERTICAL_XPOS)
6640 x = SX + SC_SCROLL_VERTICAL_XPOS;
6642 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6643 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6645 items_max = num_page_entries;
6646 items_visible = num_page_entries;
6649 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6650 gfx_pressed = scrollbar_info[i].gfx_pressed;
6651 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6652 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6653 gd_x1 = graphic_info[gfx_unpressed].src_x;
6654 gd_y1 = graphic_info[gfx_unpressed].src_y;
6655 gd_x2 = graphic_info[gfx_pressed].src_x;
6656 gd_y2 = graphic_info[gfx_pressed].src_y;
6658 gi = CreateGadget(GDI_CUSTOM_ID, id,
6659 GDI_CUSTOM_TYPE_ID, i,
6660 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6665 GDI_TYPE, scrollbar_info[i].type,
6666 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6667 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6668 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6669 GDI_WHEEL_AREA_X, SX,
6670 GDI_WHEEL_AREA_Y, SY,
6671 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6672 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6673 GDI_STATE, GD_BUTTON_UNPRESSED,
6674 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6675 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6676 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6677 GDI_DIRECT_DRAW, FALSE,
6678 GDI_EVENT_MASK, event_mask,
6679 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6683 Error(ERR_EXIT, "cannot create gadget");
6685 screen_gadget[id] = gi;
6689 void CreateScreenGadgets()
6691 int last_game_status = game_status; /* save current game status */
6693 CreateScreenMenubuttons();
6695 CreateScreenScrollbuttons();
6696 CreateScreenScrollbars();
6698 game_status = last_game_status; /* restore current game status */
6701 void FreeScreenGadgets()
6705 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6706 FreeGadget(screen_gadget[i]);
6709 void MapScreenMenuGadgets(int screen_mask)
6713 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6714 if (screen_mask & menubutton_info[i].screen_mask)
6715 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6718 void MapScreenGadgets(int num_entries)
6722 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6725 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6726 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6728 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6729 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6732 void MapScreenTreeGadgets(TreeInfo *ti)
6734 MapScreenGadgets(numTreeInfoInGroup(ti));
6737 static void HandleScreenGadgets(struct GadgetInfo *gi)
6739 int id = gi->custom_id;
6740 int button = gi->event.button;
6741 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6745 case SCREEN_CTRL_ID_PREV_LEVEL:
6746 HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT);
6749 case SCREEN_CTRL_ID_NEXT_LEVEL:
6750 HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT);
6753 case SCREEN_CTRL_ID_PREV_PLAYER:
6754 HandleSetupScreen_Input_Player(step, -1);
6757 case SCREEN_CTRL_ID_NEXT_PLAYER:
6758 HandleSetupScreen_Input_Player(step, +1);
6761 case SCREEN_CTRL_ID_SCROLL_UP:
6762 if (game_status == GAME_MODE_LEVELS)
6763 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6764 else if (game_status == GAME_MODE_LEVELNR)
6765 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6766 else if (game_status == GAME_MODE_SETUP)
6767 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6770 case SCREEN_CTRL_ID_SCROLL_DOWN:
6771 if (game_status == GAME_MODE_LEVELS)
6772 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6773 else if (game_status == GAME_MODE_LEVELNR)
6774 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6775 else if (game_status == GAME_MODE_SETUP)
6776 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6779 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6780 if (game_status == GAME_MODE_LEVELS)
6781 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6782 else if (game_status == GAME_MODE_LEVELNR)
6783 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6784 else if (game_status == GAME_MODE_SETUP)
6785 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);