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)
415 /* title display and control definitions */
417 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
418 2 * MAX_NUM_TITLE_MESSAGES)
420 static int num_title_screens = 0;
422 struct TitleControlInfo
430 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
432 /* main menu display and control definitions */
434 #define MAIN_CONTROL_NAME 0
435 #define MAIN_CONTROL_LEVELS 1
436 #define MAIN_CONTROL_SCORES 2
437 #define MAIN_CONTROL_EDITOR 3
438 #define MAIN_CONTROL_INFO 4
439 #define MAIN_CONTROL_GAME 5
440 #define MAIN_CONTROL_SETUP 6
441 #define MAIN_CONTROL_QUIT 7
442 #define MAIN_CONTROL_PREV_LEVEL 8
443 #define MAIN_CONTROL_NEXT_LEVEL 9
444 #define MAIN_CONTROL_FIRST_LEVEL 10
445 #define MAIN_CONTROL_LAST_LEVEL 11
446 #define MAIN_CONTROL_LEVEL_NUMBER 12
447 #define MAIN_CONTROL_LEVEL_INFO_1 13
448 #define MAIN_CONTROL_LEVEL_INFO_2 14
449 #define MAIN_CONTROL_LEVEL_NAME 15
450 #define MAIN_CONTROL_LEVEL_AUTHOR 16
451 #define MAIN_CONTROL_LEVEL_YEAR 17
452 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
453 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
454 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
455 #define MAIN_CONTROL_TITLE_1 21
456 #define MAIN_CONTROL_TITLE_2 22
457 #define MAIN_CONTROL_TITLE_3 23
459 static char str_main_text_name[10];
460 static char str_main_text_first_level[10];
461 static char str_main_text_last_level[10];
462 static char str_main_text_level_number[10];
464 static char *main_text_name = str_main_text_name;
465 static char *main_text_first_level = str_main_text_first_level;
466 static char *main_text_last_level = str_main_text_last_level;
467 static char *main_text_level_number = str_main_text_level_number;
468 static char *main_text_levels = "Levelset";
469 static char *main_text_scores = "Hall Of Fame";
470 static char *main_text_editor = "Level Creator";
471 static char *main_text_info = "Info Screen";
472 static char *main_text_game = "Start Game";
473 static char *main_text_setup = "Setup";
474 static char *main_text_quit = "Quit";
475 static char *main_text_level_name = level.name;
476 static char *main_text_level_author = level.author;
477 static char *main_text_level_year = NULL;
478 static char *main_text_level_imported_from = NULL;
479 static char *main_text_level_imported_by = NULL;
480 static char *main_text_level_tested_by = NULL;
481 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
482 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
483 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
485 struct MainControlInfo
489 struct MenuPosInfo *pos_button;
492 struct TextPosInfo *pos_text;
495 struct TextPosInfo *pos_input;
499 static struct MainControlInfo main_controls[] =
503 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
504 &menu.main.text.name, &main_text_name,
505 &menu.main.input.name, &setup.player_name,
509 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
510 &menu.main.text.levels, &main_text_levels,
515 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
516 &menu.main.text.scores, &main_text_scores,
521 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
522 &menu.main.text.editor, &main_text_editor,
527 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
528 &menu.main.text.info, &main_text_info,
533 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
534 &menu.main.text.game, &main_text_game,
539 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
540 &menu.main.text.setup, &main_text_setup,
545 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
546 &menu.main.text.quit, &main_text_quit,
550 /* (these two buttons are real gadgets) */
552 MAIN_CONTROL_PREV_LEVEL,
553 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
558 MAIN_CONTROL_NEXT_LEVEL,
559 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
565 MAIN_CONTROL_FIRST_LEVEL,
567 &menu.main.text.first_level, &main_text_first_level,
571 MAIN_CONTROL_LAST_LEVEL,
573 &menu.main.text.last_level, &main_text_last_level,
577 MAIN_CONTROL_LEVEL_NUMBER,
579 &menu.main.text.level_number, &main_text_level_number,
583 MAIN_CONTROL_LEVEL_INFO_1,
585 &menu.main.text.level_info_1, NULL,
589 MAIN_CONTROL_LEVEL_INFO_2,
591 &menu.main.text.level_info_2, NULL,
595 MAIN_CONTROL_LEVEL_NAME,
597 &menu.main.text.level_name, &main_text_level_name,
601 MAIN_CONTROL_LEVEL_AUTHOR,
603 &menu.main.text.level_author, &main_text_level_author,
607 MAIN_CONTROL_LEVEL_YEAR,
609 &menu.main.text.level_year, &main_text_level_year,
613 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
615 &menu.main.text.level_imported_from, &main_text_level_imported_from,
619 MAIN_CONTROL_LEVEL_IMPORTED_BY,
621 &menu.main.text.level_imported_by, &main_text_level_imported_by,
625 MAIN_CONTROL_LEVEL_TESTED_BY,
627 &menu.main.text.level_tested_by, &main_text_level_tested_by,
631 MAIN_CONTROL_TITLE_1,
633 &menu.main.text.title_1, &main_text_title_1,
637 MAIN_CONTROL_TITLE_2,
639 &menu.main.text.title_2, &main_text_title_2,
643 MAIN_CONTROL_TITLE_3,
645 &menu.main.text.title_3, &main_text_title_3,
658 static int getTitleScreenGraphic(int nr, boolean initial)
660 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
663 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
665 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
669 static int getTitleScreenGameMode(boolean initial)
671 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
675 static int getTitleMessageGameMode(boolean initial)
677 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
681 static int getTitleScreenBackground(boolean initial)
683 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
688 static int getTitleMessageBackground(int nr, boolean initial)
690 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
694 static int getTitleBackground(int nr, boolean initial, boolean is_image)
696 int base = (is_image ?
697 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
698 IMG_BACKGROUND_TITLESCREEN_1) :
699 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
700 IMG_BACKGROUND_TITLEMESSAGE_1));
701 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
702 IMG_BACKGROUND_TITLE);
703 int graphic_local = base + nr;
705 if (graphic_info[graphic_local].bitmap != NULL)
706 return graphic_local;
708 if (graphic_info[graphic_global].bitmap != NULL)
709 return graphic_global;
711 return IMG_UNDEFINED;
714 static int getTitleSound(struct TitleControlInfo *tci)
716 boolean is_image = tci->is_image;
717 int initial = tci->initial;
718 int nr = tci->local_nr;
719 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
720 int base = (is_image ?
721 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
722 SND_BACKGROUND_TITLESCREEN_1) :
723 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
724 SND_BACKGROUND_TITLEMESSAGE_1));
725 int sound_global = menu.sound[mode];
726 int sound_local = base + nr;
729 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
730 nr, initial, is_image,
731 sound_global, getSoundListEntry(sound_global)->filename,
732 sound_local, getSoundListEntry(sound_local)->filename);
735 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
738 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
741 return SND_UNDEFINED;
744 static int getTitleMusic(struct TitleControlInfo *tci)
746 boolean is_image = tci->is_image;
747 int initial = tci->initial;
748 int nr = tci->local_nr;
749 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
750 int base = (is_image ?
751 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
752 MUS_BACKGROUND_TITLESCREEN_1) :
753 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
754 MUS_BACKGROUND_TITLEMESSAGE_1));
755 int music_global = menu.music[mode];
756 int music_local = base + nr;
759 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
760 nr, initial, is_image,
761 music_global, getMusicListEntry(music_global)->filename,
762 music_local, getMusicListEntry(music_local)->filename);
765 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
768 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
771 return MUS_UNDEFINED;
774 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
776 boolean is_image = tci->is_image;
777 int initial = tci->initial;
778 int nr = tci->local_nr;
779 struct TitleFadingInfo ti;
783 int graphic = getTitleScreenGraphic(nr, initial);
785 /* initialize fading control values to default title config settings */
786 ti = (initial ? title_initial_default : title_default);
788 /* override default settings with image config settings, if defined */
789 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
790 ti.fade_mode = graphic_info[graphic].fade_mode;
791 if (graphic_info[graphic].fade_delay > -1)
792 ti.fade_delay = graphic_info[graphic].fade_delay;
793 if (graphic_info[graphic].post_delay > -1)
794 ti.post_delay = graphic_info[graphic].post_delay;
795 if (graphic_info[graphic].auto_delay > -1)
796 ti.auto_delay = graphic_info[graphic].auto_delay;
802 ti.fade_mode = titlemessage_initial[nr].fade_mode;
803 ti.fade_delay = titlemessage_initial[nr].fade_delay;
804 ti.post_delay = titlemessage_initial[nr].post_delay;
805 ti.auto_delay = titlemessage_initial[nr].auto_delay;
809 ti.fade_mode = titlemessage[nr].fade_mode;
810 ti.fade_delay = titlemessage[nr].fade_delay;
811 ti.post_delay = titlemessage[nr].post_delay;
812 ti.auto_delay = titlemessage[nr].auto_delay;
819 static int compareTitleControlInfo(const void *object1, const void *object2)
821 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
822 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
825 if (tci1->initial != tci2->initial)
826 compare_result = (tci1->initial ? -1 : +1);
827 else if (tci1->sort_priority != tci2->sort_priority)
828 compare_result = tci1->sort_priority - tci2->sort_priority;
829 else if (tci1->is_image != tci2->is_image)
830 compare_result = (tci1->is_image ? -1 : +1);
832 compare_result = tci1->local_nr - tci2->local_nr;
834 return compare_result;
837 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
839 int nr, int sort_priority)
841 title_controls[num_title_screens].is_image = is_image;
842 title_controls[num_title_screens].initial = initial;
843 title_controls[num_title_screens].local_nr = nr;
844 title_controls[num_title_screens].sort_priority = sort_priority;
849 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
853 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
855 int graphic = getTitleScreenGraphic(i, initial);
856 Bitmap *bitmap = graphic_info[graphic].bitmap;
857 int sort_priority = graphic_info[graphic].sort_priority;
860 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
863 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
865 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
866 char *filename = getLevelSetTitleMessageFilename(i, initial);
867 int sort_priority = tmi->sort_priority;
869 if (filename != NULL)
870 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
874 static void InitializeTitleControls(boolean show_title_initial)
876 num_title_screens = 0;
878 /* 1st step: initialize title screens for game start (only when starting) */
879 if (show_title_initial)
880 InitializeTitleControls_CheckTitleInfo(TRUE);
882 /* 2nd step: initialize title screens for current level set */
883 InitializeTitleControls_CheckTitleInfo(FALSE);
885 /* sort title screens according to sort_priority and title number */
886 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
887 compareTitleControlInfo);
890 static boolean visibleMenuPos(struct MenuPosInfo *pos)
892 return (pos != NULL && pos->x != -1 && pos->y != -1);
895 static boolean visibleTextPos(struct TextPosInfo *pos)
897 return (pos != NULL && pos->x != -1 && pos->y != -1);
900 static void InitializeMainControls()
902 boolean local_team_mode = (!options.network && setup.team_mode);
905 /* set main control text values to dynamically determined values */
906 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
908 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
909 menu.main.text.first_level.size));
910 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
911 menu.main.text.last_level.size));
912 strcpy(main_text_level_number, int2str(level_nr,
913 menu.main.text.level_number.size));
915 main_text_level_year = leveldir_current->year;
916 main_text_level_imported_from = leveldir_current->imported_from;
917 main_text_level_imported_by = leveldir_current->imported_by;
918 main_text_level_tested_by = leveldir_current->tested_by;
920 /* set main control screen positions to dynamically determined values */
921 for (i = 0; main_controls[i].nr != -1; i++)
923 struct MainControlInfo *mci = &main_controls[i];
925 struct MenuPosInfo *pos_button = mci->pos_button;
926 struct TextPosInfo *pos_text = mci->pos_text;
927 struct TextPosInfo *pos_input = mci->pos_input;
928 char *text = (mci->text ? *mci->text : NULL);
929 char *input = (mci->input ? *mci->input : NULL);
930 int button_graphic = mci->button_graphic;
931 int font_text = (pos_text ? pos_text->font : -1);
932 int font_input = (pos_input ? pos_input->font : -1);
934 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
935 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
936 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
937 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
938 int text_chars = (text != NULL ? strlen(text) : 0);
939 int input_chars = (input != NULL ? strlen(input) : 0);
942 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
944 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
945 int text_width = font_text_width * text_chars;
946 int text_height = font_text_height;
947 int input_width = font_input_width * input_chars;
948 int input_height = font_input_height;
950 if (nr == MAIN_CONTROL_NAME)
952 menu.main.input.name.width = input_width;
953 menu.main.input.name.height = input_height;
956 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
958 if (pos_button->width == 0)
959 pos_button->width = button_width;
960 if (pos_button->height == 0)
961 pos_button->height = button_height;
964 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
966 /* calculate size for non-clickable text -- needed for text alignment */
967 boolean calculate_text_size = (pos_button == NULL && text != NULL);
969 if (visibleMenuPos(pos_button))
971 if (pos_text->x == -1)
972 pos_text->x = pos_button->x + pos_button->width;
973 if (pos_text->y == -1)
974 pos_text->y = pos_button->y;
977 if (pos_text->width == -1 || calculate_text_size)
978 pos_text->width = text_width;
979 if (pos_text->height == -1 || calculate_text_size)
980 pos_text->height = text_height;
983 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
985 if (visibleTextPos(pos_text))
987 if (pos_input->x == -1)
988 pos_input->x = pos_text->x + pos_text->width;
989 if (pos_input->y == -1)
990 pos_input->y = pos_text->y;
993 if (pos_input->width == -1)
994 pos_input->width = input_width;
995 if (pos_input->height == -1)
996 pos_input->height = input_height;
1001 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1002 boolean active_input)
1006 for (i = 0; main_controls[i].nr != -1; i++)
1008 struct MainControlInfo *mci = &main_controls[i];
1010 if (mci->nr == nr || nr == -1)
1012 struct MenuPosInfo *pos_button = mci->pos_button;
1013 struct TextPosInfo *pos_text = mci->pos_text;
1014 struct TextPosInfo *pos_input = mci->pos_input;
1015 char *text = (mci->text ? *mci->text : NULL);
1016 char *input = (mci->input ? *mci->input : NULL);
1017 int button_graphic = mci->button_graphic;
1018 int font_text = (pos_text ? pos_text->font : -1);
1019 int font_input = (pos_input ? pos_input->font : -1);
1023 button_graphic = BUTTON_ACTIVE(button_graphic);
1024 font_text = FONT_ACTIVE(font_text);
1029 font_input = FONT_ACTIVE(font_input);
1032 if (visibleMenuPos(pos_button))
1034 struct MenuPosInfo *pos = pos_button;
1035 int x = mSX + pos->x;
1036 int y = mSY + pos->y;
1038 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1039 DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
1042 if (visibleTextPos(pos_text) && text != NULL)
1044 struct TextPosInfo *pos = pos_text;
1045 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1046 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1049 /* (check why/if this is needed) */
1050 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1052 DrawText(x, y, text, font_text);
1055 if (visibleTextPos(pos_input) && input != NULL)
1057 struct TextPosInfo *pos = pos_input;
1058 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1059 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1062 /* (check why/if this is needed) */
1063 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1065 DrawText(x, y, input, font_input);
1071 static void DrawCursorAndText_Main(int nr, boolean active_text)
1073 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1077 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1079 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1083 static struct MainControlInfo *getMainControlInfo(int nr)
1087 for (i = 0; main_controls[i].nr != -1; i++)
1088 if (main_controls[i].nr == nr)
1089 return &main_controls[i];
1094 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1099 int rect_x = ALIGNED_TEXT_XPOS(rect);
1100 int rect_y = ALIGNED_TEXT_YPOS(rect);
1102 return (x >= rect_x && x < rect_x + rect->width &&
1103 y >= rect_y && y < rect_y + rect->height);
1106 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1111 int rect_x = ALIGNED_TEXT_XPOS(rect);
1112 int rect_y = ALIGNED_TEXT_YPOS(rect);
1115 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1116 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1117 (x >= rect_x && x < rect_x + rect->width &&
1118 y >= rect_y && y < rect_y + rect->height));
1121 return (x >= rect_x && x < rect_x + rect->width &&
1122 y >= rect_y && y < rect_y + rect->height);
1125 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1127 static int cursor_array[MAX_LEV_FIELDY];
1128 int x = mSX + TILEX * xpos;
1129 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1134 cursor_array[ypos] = graphic;
1136 graphic = cursor_array[ypos];
1140 graphic = BUTTON_ACTIVE(graphic);
1142 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1143 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1146 static void initCursor(int ypos, int graphic)
1148 drawCursorExt(0, ypos, FALSE, graphic);
1151 static void drawCursor(int ypos, boolean active)
1153 drawCursorExt(0, ypos, active, -1);
1156 static void drawCursorXY(int xpos, int ypos, int graphic)
1158 drawCursorExt(xpos, ypos, FALSE, graphic);
1161 static void drawChooseTreeCursor(int ypos, boolean active)
1163 int last_game_status = game_status; /* save current game status */
1165 drawCursorExt(0, ypos, active, -1);
1167 game_status = last_game_status; /* restore current game status */
1172 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1173 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1176 int effectiveGameStatus()
1178 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1179 return GAME_MODE_TITLE;
1184 void DrawTitleScreenImage(int nr, boolean initial)
1186 int graphic = getTitleScreenGraphic(nr, initial);
1187 Bitmap *bitmap = graphic_info[graphic].bitmap;
1188 int width = graphic_info[graphic].width;
1189 int height = graphic_info[graphic].height;
1190 int src_x = graphic_info[graphic].src_x;
1191 int src_y = graphic_info[graphic].src_y;
1197 if (width > WIN_XSIZE)
1199 /* image width too large for window => center image horizontally */
1200 src_x = (width - WIN_XSIZE) / 2;
1204 if (height > WIN_YSIZE)
1206 /* image height too large for window => center image vertically */
1207 src_y = (height - WIN_YSIZE) / 2;
1211 /* always display title screens centered */
1212 dst_x = (WIN_XSIZE - width) / 2;
1213 dst_y = (WIN_YSIZE - height) / 2;
1215 SetDrawBackgroundMask(REDRAW_ALL);
1216 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1218 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1220 if (DrawingOnBackground(dst_x, dst_y))
1222 SetClipOrigin(bitmap, bitmap->stored_clip_gc, dst_x - src_x, dst_y - src_y);
1223 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1226 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1228 redraw_mask = REDRAW_ALL;
1231 void DrawTitleScreenMessage(int nr, boolean initial)
1233 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1234 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1235 int last_game_status = game_status; /* save current game status */
1237 if (filename == NULL)
1240 /* force TITLE font on title message screen */
1241 game_status = getTitleMessageGameMode(initial);
1243 /* if chars set to "-1", automatically determine by text and font width */
1244 if (tmi->chars == -1)
1245 tmi->chars = tmi->width / getFontWidth(tmi->font);
1247 tmi->width = tmi->chars * getFontWidth(tmi->font);
1249 /* if lines set to "-1", automatically determine by text and font height */
1250 if (tmi->lines == -1)
1251 tmi->lines = tmi->height / getFontHeight(tmi->font);
1253 tmi->height = tmi->lines * getFontHeight(tmi->font);
1255 SetDrawBackgroundMask(REDRAW_ALL);
1256 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1258 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1260 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1261 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1262 tmi->autowrap, tmi->centered, tmi->parse_comments);
1264 game_status = last_game_status; /* restore current game status */
1267 void DrawTitleScreen()
1269 KeyboardAutoRepeatOff();
1271 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1276 boolean CheckTitleScreen(boolean levelset_has_changed)
1278 static boolean show_title_initial = TRUE;
1279 boolean show_titlescreen = FALSE;
1281 /* needed to be able to skip title screen, if no image or message defined */
1282 InitializeTitleControls(show_title_initial);
1284 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1285 show_titlescreen = TRUE;
1287 /* show initial title images and messages only once at program start */
1288 show_title_initial = FALSE;
1290 return (show_titlescreen && num_title_screens > 0);
1293 void DrawMainMenuExt(int fade_mask, boolean do_fading)
1295 static LevelDirTree *leveldir_last_valid = NULL;
1296 boolean levelset_has_changed = FALSE;
1298 LimitScreenUpdates(FALSE);
1300 FadeSetLeaveScreen();
1302 /* do not fade out here -- function may continue and fade on editor screen */
1305 FadeSoundsAndMusic();
1307 KeyboardAutoRepeatOn();
1310 SetDrawDeactivationMask(REDRAW_NONE);
1311 SetDrawBackgroundMask(REDRAW_FIELD);
1313 audio.sound_deactivated = FALSE;
1317 /* needed if last screen was the playing screen, invoked from level editor */
1318 if (level_editor_test_game)
1320 game_status = GAME_MODE_EDITOR;
1326 /* needed if last screen was the setup screen and fullscreen state changed */
1327 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1328 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1330 /* leveldir_current may be invalid (level group, parent link) */
1331 if (!validLevelSeries(leveldir_current))
1332 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1334 if (leveldir_current != leveldir_last_valid)
1335 levelset_has_changed = TRUE;
1337 /* store valid level series information */
1338 leveldir_last_valid = leveldir_current;
1340 init_last = init; /* switch to new busy animation */
1342 /* needed if last screen (level choice) changed graphics, sounds or music */
1343 ReloadCustomArtwork(0);
1345 if (redraw_mask & REDRAW_ALL)
1346 fade_mask = REDRAW_ALL;
1350 /* needed if different viewport properties defined for menues */
1351 ChangeViewportPropertiesIfNeeded();
1353 /* needed if last screen was the editor screen */
1354 UndrawSpecialEditorDoor();
1356 SetDrawtoField(DRAW_BACKBUFFER);
1358 if (CheckTitleScreen(levelset_has_changed))
1360 game_status = GAME_MODE_TITLE;
1367 /* level_nr may have been set to value over handicap with level editor */
1368 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1369 level_nr = leveldir_current->handicap_level;
1371 LoadLevel(level_nr);
1372 LoadScore(level_nr);
1374 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1376 if (fade_mask == REDRAW_ALL)
1381 InitializeMainControls();
1383 DrawCursorAndText_Main(-1, FALSE);
1384 DrawPreviewLevelInitial();
1386 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1389 if (TAPE_IS_EMPTY(tape))
1391 DrawCompleteVideoDisplay();
1396 /* create gadgets for main menu screen */
1397 FreeScreenGadgets();
1398 CreateScreenGadgets();
1400 /* map gadgets for main menu screen */
1402 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1404 /* copy actual game door content to door double buffer for OpenDoor() */
1405 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1407 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1409 DrawMaskedBorder(REDRAW_ALL);
1414 /* update screen area with special editor door */
1415 redraw_mask |= REDRAW_ALL;
1418 SetMouseCursor(CURSOR_DEFAULT);
1422 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1425 void DrawAndFadeInMainMenu(int fade_mask)
1427 DrawMainMenuExt(fade_mask, TRUE);
1432 DrawMainMenuExt(REDRAW_ALL, FALSE);
1435 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1436 static void gotoTopLevelDir()
1438 /* move upwards to top level directory */
1439 while (leveldir_current->node_parent)
1441 /* write a "path" into level tree for easy navigation to last level */
1442 if (leveldir_current->node_parent->node_group->cl_first == -1)
1444 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1445 int leveldir_pos = posTreeInfo(leveldir_current);
1446 int num_page_entries;
1447 int cl_first, cl_cursor;
1449 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1450 num_page_entries = num_leveldirs;
1452 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1454 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1455 cl_cursor = leveldir_pos - cl_first;
1457 leveldir_current->node_parent->node_group->cl_first = cl_first;
1458 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1461 leveldir_current = leveldir_current->node_parent;
1466 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1468 static unsigned int title_delay = 0;
1469 static int title_screen_nr = 0;
1470 static int last_sound = -1, last_music = -1;
1471 boolean return_to_main_menu = FALSE;
1472 boolean use_fading_main_menu = TRUE;
1473 struct TitleControlInfo *tci;
1474 struct TitleFadingInfo fading_default;
1475 struct TitleFadingInfo fading_last = fading;
1476 struct TitleFadingInfo fading_next;
1479 if (button == MB_MENU_INITIALIZE)
1482 title_screen_nr = 0;
1483 tci = &title_controls[title_screen_nr];
1485 last_sound = SND_UNDEFINED;
1486 last_music = MUS_UNDEFINED;
1488 if (game_status == GAME_MODE_INFO)
1490 if (num_title_screens == 0)
1492 DrawInfoScreen_NotAvailable("Title screen information:",
1493 "No title screen for this level set.");
1498 FadeSoundsAndMusic();
1500 FadeOut(REDRAW_ALL);
1504 DrawTitleScreenImage(tci->local_nr, tci->initial);
1506 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1508 fading_default = (tci->initial ? title_initial_default : title_default);
1510 fading = fading_next = getTitleFading(tci);
1512 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1513 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1515 fading.fade_mode = FADE_MODE_FADE;
1516 fading.fade_delay = fading_default.fade_delay;
1519 sound = getTitleSound(tci);
1520 music = getTitleMusic(tci);
1522 if (sound != last_sound)
1523 PlayMenuSoundExt(sound);
1524 if (music != last_music)
1525 PlayMenuMusicExt(music);
1530 SetMouseCursor(CURSOR_NONE);
1534 fading = fading_next;
1536 DelayReached(&title_delay, 0); /* reset delay counter */
1541 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1542 button = MB_MENU_CHOICE;
1544 if (button == MB_MENU_LEAVE)
1546 return_to_main_menu = TRUE;
1547 use_fading_main_menu = FALSE;
1549 else if (button == MB_MENU_CHOICE)
1551 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1553 FadeSetEnterScreen();
1555 info_mode = INFO_MODE_MAIN;
1556 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1562 tci = &title_controls[title_screen_nr];
1564 if (title_screen_nr < num_title_screens)
1566 sound = getTitleSound(tci);
1567 music = getTitleMusic(tci);
1569 if (sound == SND_UNDEFINED || sound != last_sound)
1571 if (music == MUS_UNDEFINED || music != last_music)
1574 FadeOut(REDRAW_ALL);
1577 DrawTitleScreenImage(tci->local_nr, tci->initial);
1579 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1581 fading_next = getTitleFading(tci);
1583 sound = getTitleSound(tci);
1584 music = getTitleMusic(tci);
1586 if (sound != last_sound)
1587 PlayMenuSoundExt(sound);
1588 if (music != last_music)
1589 PlayMenuMusicExt(music);
1594 /* last screen already faded out, next screen has no animation */
1595 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1596 fading_next.fade_mode == FADE_MODE_NONE)
1597 fading = fading_next;
1601 fading = fading_next;
1603 DelayReached(&title_delay, 0); /* reset delay counter */
1607 FadeSoundsAndMusic();
1609 return_to_main_menu = TRUE;
1613 if (return_to_main_menu)
1615 SetMouseCursor(CURSOR_DEFAULT);
1617 if (game_status == GAME_MODE_INFO)
1619 info_mode = INFO_MODE_MAIN;
1621 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1623 else /* default: return to main menu */
1625 game_status = GAME_MODE_MAIN;
1627 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1632 void HandleMainMenu_SelectLevel(int step, int direction)
1634 int old_level_nr = level_nr;
1637 new_level_nr = old_level_nr + step * direction;
1638 if (new_level_nr < leveldir_current->first_level)
1639 new_level_nr = leveldir_current->first_level;
1640 if (new_level_nr > leveldir_current->last_level)
1641 new_level_nr = leveldir_current->last_level;
1643 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1645 /* skipping levels is only allowed when trying to skip single level */
1646 if (setup.skip_levels && step == 1 &&
1647 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1649 leveldir_current->handicap_level++;
1650 SaveLevelSetup_SeriesInfo();
1653 new_level_nr = leveldir_current->handicap_level;
1656 if (new_level_nr != old_level_nr)
1658 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1660 PlaySound(SND_MENU_ITEM_SELECTING);
1662 level_nr = new_level_nr;
1664 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1665 int2str(level_nr, menu.main.text.level_number.size),
1666 mci->pos_text->font);
1668 LoadLevel(level_nr);
1669 DrawPreviewLevelInitial();
1673 DrawCompleteVideoDisplay();
1675 /* needed because DrawPreviewLevelInitial() takes some time */
1681 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1683 static int choice = MAIN_CONTROL_GAME;
1687 if (button == MB_MENU_INITIALIZE)
1689 DrawCursorAndText_Main(choice, TRUE);
1694 if (mx || my) /* mouse input */
1698 for (i = 0; main_controls[i].nr != -1; i++)
1700 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1701 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1702 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1704 pos = main_controls[i].nr;
1710 else if (dx || dy) /* keyboard input */
1712 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1713 choice == MAIN_CONTROL_SETUP))
1714 button = MB_MENU_CHOICE;
1719 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1721 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1723 else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1725 HandleMainMenu_SelectLevel(MAX_LEVELS, -1);
1727 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1729 HandleMainMenu_SelectLevel(MAX_LEVELS, +1);
1731 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1733 game_status = GAME_MODE_LEVELNR;
1735 ChangeViewportPropertiesIfNeeded();
1737 DrawChooseLevelNr();
1739 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1745 PlaySound(SND_MENU_ITEM_ACTIVATING);
1747 DrawCursorAndText_Main(choice, FALSE);
1748 DrawCursorAndText_Main(pos, TRUE);
1755 PlaySound(SND_MENU_ITEM_SELECTING);
1757 if (pos == MAIN_CONTROL_NAME)
1759 game_status = GAME_MODE_PSEUDO_TYPENAME;
1761 HandleTypeName(strlen(setup.player_name), 0);
1763 else if (pos == MAIN_CONTROL_LEVELS)
1767 game_status = GAME_MODE_LEVELS;
1769 SaveLevelSetup_LastSeries();
1770 SaveLevelSetup_SeriesInfo();
1772 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1776 ChangeViewportPropertiesIfNeeded();
1778 DrawChooseLevelSet();
1781 else if (pos == MAIN_CONTROL_SCORES)
1783 game_status = GAME_MODE_SCORES;
1785 ChangeViewportPropertiesIfNeeded();
1789 else if (pos == MAIN_CONTROL_EDITOR)
1791 if (leveldir_current->readonly &&
1792 !strEqual(setup.player_name, "Artsoft"))
1793 Request("This level is read only!", REQ_CONFIRM);
1795 CloseDoor(DOOR_CLOSE_2);
1797 game_status = GAME_MODE_EDITOR;
1799 FadeSetEnterScreen();
1803 else if (pos == MAIN_CONTROL_INFO)
1805 game_status = GAME_MODE_INFO;
1806 info_mode = INFO_MODE_MAIN;
1808 ChangeViewportPropertiesIfNeeded();
1812 else if (pos == MAIN_CONTROL_GAME)
1814 StartGameActions(options.network, setup.autorecord, level.random_seed);
1816 else if (pos == MAIN_CONTROL_SETUP)
1818 game_status = GAME_MODE_SETUP;
1819 setup_mode = SETUP_MODE_MAIN;
1821 ChangeViewportPropertiesIfNeeded();
1825 else if (pos == MAIN_CONTROL_QUIT)
1827 SaveLevelSetup_LastSeries();
1828 SaveLevelSetup_SeriesInfo();
1830 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1831 game_status = GAME_MODE_QUIT;
1838 /* ========================================================================= */
1839 /* info screen functions */
1840 /* ========================================================================= */
1842 static struct TokenInfo *info_info;
1843 static int num_info_info;
1845 static void execInfoTitleScreen()
1847 info_mode = INFO_MODE_TITLE;
1852 static void execInfoElements()
1854 info_mode = INFO_MODE_ELEMENTS;
1859 static void execInfoMusic()
1861 info_mode = INFO_MODE_MUSIC;
1866 static void execInfoCredits()
1868 info_mode = INFO_MODE_CREDITS;
1873 static void execInfoProgram()
1875 info_mode = INFO_MODE_PROGRAM;
1880 static void execInfoVersion()
1882 info_mode = INFO_MODE_VERSION;
1887 static void execInfoLevelSet()
1889 info_mode = INFO_MODE_LEVELSET;
1894 static void execExitInfo()
1896 game_status = GAME_MODE_MAIN;
1898 DrawMainMenuExt(REDRAW_FIELD, FALSE);
1901 static struct TokenInfo info_info_main[] =
1903 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
1904 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
1905 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
1906 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
1907 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
1908 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
1909 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
1910 { TYPE_EMPTY, NULL, "" },
1911 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
1916 static void DrawCursorAndText_Info(int pos, boolean active)
1918 int xpos = MENU_SCREEN_START_XPOS;
1919 int ypos = MENU_SCREEN_START_YPOS + pos;
1920 int font_nr = FONT_MENU_1;
1923 font_nr = FONT_ACTIVE(font_nr);
1925 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
1927 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
1928 drawCursor(pos, active);
1931 static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
1936 CloseDoor(DOOR_CLOSE_2);
1938 /* (needed after displaying title screens which disable auto repeat) */
1939 KeyboardAutoRepeatOn();
1941 FadeSetLeaveScreen();
1945 if (fade_mask == REDRAW_ALL)
1949 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1954 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
1956 info_info = info_info_main;
1959 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1961 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
1962 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
1963 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
1964 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
1965 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
1966 initCursor(i, IMG_MENU_BUTTON);
1968 DrawCursorAndText_Info(i, FALSE);
1973 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
1978 DrawMaskedBorder(fade_mask);
1985 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
1987 static int choice_store[MAX_INFO_MODES];
1988 int choice = choice_store[info_mode]; /* always starts with 0 */
1992 if (button == MB_MENU_INITIALIZE)
1994 /* advance to first valid menu entry */
1995 while (choice < num_info_info &&
1996 info_info[choice].type & TYPE_SKIP_ENTRY)
1998 choice_store[info_mode] = choice;
2000 DrawCursorAndText_Info(choice, TRUE);
2004 else if (button == MB_MENU_LEAVE)
2006 for (y = 0; y < num_info_info; y++)
2008 if (info_info[y].type & TYPE_LEAVE_MENU)
2010 void (*menu_callback_function)(void) = info_info[y].value;
2014 menu_callback_function();
2016 break; /* absolutely needed because function changes 'info_info'! */
2023 if (mx || my) /* mouse input */
2025 x = (mx - mSX) / 32;
2026 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2028 else if (dx || dy) /* keyboard input */
2032 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2034 if (info_info[choice].type & menu_navigation_type ||
2035 info_info[choice].type & TYPE_ENTER_SCREEN ||
2036 info_info[choice].type & TYPE_BOOLEAN_STYLE ||
2037 info_info[choice].type & TYPE_YES_NO_AUTO)
2038 button = MB_MENU_CHOICE;
2043 /* jump to next non-empty menu entry (up or down) */
2044 while (y > 0 && y < num_info_info - 1 &&
2045 info_info[y].type & TYPE_SKIP_ENTRY)
2049 if (IN_VIS_FIELD(x, y) &&
2050 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2056 PlaySound(SND_MENU_ITEM_ACTIVATING);
2058 DrawCursorAndText_Info(choice, FALSE);
2059 DrawCursorAndText_Info(y, TRUE);
2061 choice = choice_store[info_mode] = y;
2064 else if (!(info_info[y].type & TYPE_GHOSTED))
2066 PlaySound(SND_MENU_ITEM_SELECTING);
2068 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2070 void (*menu_callback_function)(void) = info_info[choice].value;
2072 FadeSetFromType(info_info[y].type);
2074 menu_callback_function();
2080 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2082 int ystart1 = mSY - SY + 100;
2083 int ystart2 = mSY - SY + 150;
2084 int ybottom = mSY - SY + SYSIZE - 20;
2086 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2088 FadeOut(REDRAW_FIELD);
2093 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2094 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2096 DrawTextSCentered(ybottom, FONT_TEXT_4,
2097 "Press any key or button for info menu");
2099 FadeIn(REDRAW_FIELD);
2102 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2104 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2105 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2106 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2107 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2108 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2109 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2110 int ystep = MENU_SCREEN_INFO_YSTEP;
2111 int element, action, direction;
2119 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2120 infoscreen_step[i] = infoscreen_frame[i] = 0;
2125 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2127 DrawTextSCentered(ybottom, FONT_TEXT_4,
2128 "Press any key or button for next page");
2134 while (helpanim_info[j].element != HELPANIM_LIST_END)
2136 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2141 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2150 j += infoscreen_step[i - start];
2152 element = helpanim_info[j].element;
2153 action = helpanim_info[j].action;
2154 direction = helpanim_info[j].direction;
2157 element = EL_UNKNOWN;
2159 if (action != -1 && direction != -1)
2160 graphic = el_act_dir2img(element, action, direction);
2161 else if (action != -1)
2162 graphic = el_act2img(element, action);
2163 else if (direction != -1)
2164 graphic = el_dir2img(element, direction);
2166 graphic = el2img(element);
2168 delay = helpanim_info[j++].delay;
2173 if (infoscreen_frame[i - start] == 0)
2176 infoscreen_frame[i - start] = delay - 1;
2180 sync_frame = delay - infoscreen_frame[i - start];
2181 infoscreen_frame[i - start]--;
2184 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2186 if (!infoscreen_frame[i - start])
2187 infoscreen_step[i - start] = 0;
2191 if (!infoscreen_frame[i - start])
2192 infoscreen_step[i - start]++;
2193 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2199 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2201 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2202 graphic, sync_frame, USE_MASKING);
2205 DrawInfoScreen_HelpText(element, action, direction, i - start);
2210 redraw_mask |= REDRAW_FIELD;
2215 static char *getHelpText(int element, int action, int direction)
2217 char token[MAX_LINE_LEN];
2219 strcpy(token, element_info[element].token_name);
2222 strcat(token, element_action_info[action].suffix);
2224 if (direction != -1)
2225 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2227 return getHashEntry(helptext_info, token);
2230 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2232 int font_nr = FONT_INFO_ELEMENTS;
2233 int font_width = getFontWidth(font_nr);
2234 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2235 int sy = mSY + 65 + 2 * 32 + 1;
2236 int ystep = TILEY + 4;
2237 int pad_x = sx - SX;
2238 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2239 int max_lines_per_text = 2;
2242 if (action != -1 && direction != -1) /* element.action.direction */
2243 text = getHelpText(element, action, direction);
2245 if (text == NULL && action != -1) /* element.action */
2246 text = getHelpText(element, action, -1);
2248 if (text == NULL && direction != -1) /* element.direction */
2249 text = getHelpText(element, -1, direction);
2251 if (text == NULL) /* base element */
2252 text = getHelpText(element, -1, -1);
2254 if (text == NULL) /* not found */
2255 text = "No description available";
2257 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2258 sy += getFontHeight(font_nr) / 2;
2260 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2261 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2262 TRUE, FALSE, FALSE);
2265 void DrawInfoScreen_TitleScreen()
2270 void HandleInfoScreen_TitleScreen(int button)
2272 HandleTitleScreen(0, 0, 0, 0, button);
2275 void DrawInfoScreen_Elements()
2277 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2279 FadeOut(REDRAW_FIELD);
2284 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2286 FadeIn(REDRAW_FIELD);
2291 void HandleInfoScreen_Elements(int button)
2293 static unsigned int info_delay = 0;
2294 static int num_anims;
2295 static int num_pages;
2297 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2300 if (button == MB_MENU_INITIALIZE)
2302 boolean new_element = TRUE;
2306 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2308 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2310 else if (new_element)
2313 new_element = FALSE;
2317 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2321 if (button == MB_MENU_LEAVE)
2323 PlaySound(SND_MENU_ITEM_SELECTING);
2325 info_mode = INFO_MODE_MAIN;
2330 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2332 if (button != MB_MENU_INITIALIZE)
2334 PlaySound(SND_MENU_ITEM_SELECTING);
2339 if (page >= num_pages)
2341 FadeSoundsAndMusic();
2343 info_mode = INFO_MODE_MAIN;
2344 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2350 FadeSetNextScreen();
2352 if (button != MB_MENU_INITIALIZE)
2353 FadeOut(REDRAW_FIELD);
2355 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2357 if (button != MB_MENU_INITIALIZE)
2358 FadeIn(REDRAW_FIELD);
2362 if (DelayReached(&info_delay, GameFrameDelay))
2363 if (page < num_pages)
2364 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2366 PlayMenuSoundIfLoop();
2370 void DrawInfoScreen_Music()
2372 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2374 FadeOut(REDRAW_FIELD);
2381 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2383 FadeIn(REDRAW_FIELD);
2386 void HandleInfoScreen_Music(int button)
2388 static struct MusicFileInfo *list = NULL;
2389 int ystart1 = mSY - SY + 100;
2390 int ystart2 = mSY - SY + 150;
2391 int ybottom = mSY - SY + SYSIZE - 20;
2394 if (button == MB_MENU_INITIALIZE)
2396 list = music_file_info;
2400 FadeSoundsAndMusic();
2405 DrawTextSCentered(ystart1, FONT_TEXT_1,
2406 "No music info for this level set.");
2408 DrawTextSCentered(ybottom, FONT_TEXT_4,
2409 "Press any key or button for info menu");
2415 if (button == MB_MENU_LEAVE)
2417 PlaySound(SND_MENU_ITEM_SELECTING);
2419 FadeSoundsAndMusic();
2421 info_mode = INFO_MODE_MAIN;
2426 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2430 if (button != MB_MENU_INITIALIZE)
2432 PlaySound(SND_MENU_ITEM_SELECTING);
2440 FadeSoundsAndMusic();
2442 info_mode = INFO_MODE_MAIN;
2443 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2448 FadeSoundsAndMusic();
2450 if (list != music_file_info)
2451 FadeSetNextScreen();
2453 if (button != MB_MENU_INITIALIZE)
2454 FadeOut(REDRAW_FIELD);
2461 int sound = list->music;
2463 if (sound_info[sound].loop)
2464 PlaySoundLoop(sound);
2468 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2472 PlayMusic(list->music);
2474 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2477 if (!strEqual(list->title, UNKNOWN_NAME))
2479 if (!strEqual(list->title_header, UNKNOWN_NAME))
2480 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2482 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2485 if (!strEqual(list->artist, UNKNOWN_NAME))
2487 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2488 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2490 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2492 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2495 if (!strEqual(list->album, UNKNOWN_NAME))
2497 if (!strEqual(list->album_header, UNKNOWN_NAME))
2498 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2500 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2502 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2505 if (!strEqual(list->year, UNKNOWN_NAME))
2507 if (!strEqual(list->year_header, UNKNOWN_NAME))
2508 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2510 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2512 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2515 DrawTextSCentered(ybottom, FONT_TEXT_4,
2516 "Press any key or button for next page");
2518 if (button != MB_MENU_INITIALIZE)
2519 FadeIn(REDRAW_FIELD);
2522 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2523 PlaySoundLoop(list->music);
2526 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2528 int ystart1 = mSY - SY + 100;
2529 int ystart2 = mSY - SY + 150;
2530 int ybottom = mSY - SY + SYSIZE - 20;
2536 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2540 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2541 "Special thanks to");
2542 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2544 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2546 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2547 "\"Boulder Dash\"");
2548 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2550 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2552 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2554 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2555 "First Star Software");
2557 else if (screen_nr == 1)
2559 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2560 "Special thanks to");
2561 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2562 "Klaus Heinz & Volker Wertich");
2563 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2565 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2566 "\"Emerald Mine\"");
2567 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2569 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2571 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2573 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2576 else if (screen_nr == 2)
2578 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2579 "Special thanks to");
2580 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2581 "Michael Stopp & Philip Jespersen");
2582 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2584 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2586 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2588 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2590 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2592 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2593 "Digital Integration");
2595 else if (screen_nr == 3)
2597 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2598 "Special thanks to");
2599 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2600 "Hiroyuki Imabayashi");
2601 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2603 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2605 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2607 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2609 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2611 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2614 else if (screen_nr == 4)
2616 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2617 "Special thanks to");
2618 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2620 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2622 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2623 "Jürgen Bonhagen");
2624 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2625 "for the continuous creation");
2626 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2627 "of outstanding level sets");
2629 else if (screen_nr == 5)
2631 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2633 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2635 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2636 "for ideas and inspiration by");
2637 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2640 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2642 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2644 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2645 "for ideas and inspiration by");
2646 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2649 else if (screen_nr == 6)
2651 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2653 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2656 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2657 "for the code base used for the");
2658 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
2659 "native Emerald Mine engine");
2661 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2662 "for the new Emerald Mine engine");
2665 else if (screen_nr == 7)
2667 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2669 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2671 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2672 "for the initial DOS port");
2674 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2676 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2678 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2679 "for some additional toons");
2681 else if (screen_nr == 8)
2683 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2684 "And not to forget:");
2685 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2687 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2688 "All those who contributed");
2689 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2690 "levels to this game");
2691 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2695 DrawTextSCentered(ybottom, FONT_TEXT_4,
2696 "Press any key or button for next page");
2699 void DrawInfoScreen_Credits()
2701 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2703 FadeSoundsAndMusic();
2705 FadeOut(REDRAW_FIELD);
2707 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
2709 FadeIn(REDRAW_FIELD);
2712 void HandleInfoScreen_Credits(int button)
2714 static int screen_nr = 0;
2715 int num_screens = 9;
2717 if (button == MB_MENU_INITIALIZE)
2721 // DrawInfoScreen_CreditsScreen(screen_nr);
2724 if (button == MB_MENU_LEAVE)
2726 PlaySound(SND_MENU_ITEM_SELECTING);
2728 info_mode = INFO_MODE_MAIN;
2733 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2735 if (button != MB_MENU_INITIALIZE)
2737 PlaySound(SND_MENU_ITEM_SELECTING);
2742 if (screen_nr >= num_screens)
2744 FadeSoundsAndMusic();
2746 info_mode = INFO_MODE_MAIN;
2747 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2753 FadeSetNextScreen();
2755 if (button != MB_MENU_INITIALIZE)
2756 FadeOut(REDRAW_FIELD);
2758 DrawInfoScreen_CreditsScreen(screen_nr);
2760 if (button != MB_MENU_INITIALIZE)
2761 FadeIn(REDRAW_FIELD);
2765 PlayMenuSoundIfLoop();
2769 void DrawInfoScreen_Program()
2771 int ystart1 = mSY - SY + 100;
2772 int ystart2 = mSY - SY + 150;
2773 int ybottom = mSY - SY + SYSIZE - 20;
2776 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
2778 FadeOut(REDRAW_FIELD);
2783 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
2785 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2786 "This game is Freeware!");
2787 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2788 "If you like it, send e-mail to:");
2789 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2790 PROGRAM_EMAIL_STRING);
2791 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2792 "More information and levels:");
2793 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2794 PROGRAM_WEBSITE_STRING);
2795 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2796 "If you have created new levels,");
2797 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
2798 "send them to me to include them!");
2799 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
2802 DrawTextSCentered(ybottom, FONT_TEXT_4,
2803 "Press any key or button for info menu");
2805 FadeIn(REDRAW_FIELD);
2808 void HandleInfoScreen_Program(int button)
2810 if (button == MB_MENU_LEAVE)
2812 PlaySound(SND_MENU_ITEM_SELECTING);
2814 info_mode = INFO_MODE_MAIN;
2819 else if (button == MB_MENU_CHOICE)
2821 PlaySound(SND_MENU_ITEM_SELECTING);
2823 FadeSoundsAndMusic();
2825 info_mode = INFO_MODE_MAIN;
2826 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2830 PlayMenuSoundIfLoop();
2834 void DrawInfoScreen_Version()
2836 int font_header = FONT_TEXT_3;
2837 int font_text = FONT_TEXT_2;
2838 int xstep = getFontWidth(font_text);
2839 int ystep = getFontHeight(font_text);
2840 int ystart1 = mSY - SY + 100;
2841 int ystart2 = mSY - SY + 150;
2842 int ybottom = mSY - SY + SYSIZE - 20;
2843 int xstart1 = mSX - SX + 2 * xstep;
2844 int xstart2 = mSX - SX + 18 * xstep;
2845 int xstart3 = mSX - SX + 28 * xstep;
2846 SDL_version sdl_version_compiled;
2847 const SDL_version *sdl_version_linked;
2848 int driver_name_len = 10;
2849 #if defined(TARGET_SDL2)
2850 SDL_version sdl_version_linked_ext;
2851 const char *driver_name = NULL;
2853 char driver_name[driver_name_len];
2856 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
2858 FadeOut(REDRAW_FIELD);
2863 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
2865 DrawTextF(xstart1, ystart2, font_header, "Name");
2866 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
2869 DrawTextF(xstart1, ystart2, font_header, "Version");
2870 DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
2873 DrawTextF(xstart1, ystart2, font_header, "Platform");
2874 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
2877 DrawTextF(xstart1, ystart2, font_header, "Target");
2878 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
2881 DrawTextF(xstart1, ystart2, font_header, "Compile time");
2882 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
2884 ystart2 += 3 * ystep;
2885 DrawTextF(xstart1, ystart2, font_header, "Library");
2886 DrawTextF(xstart2, ystart2, font_header, "compiled");
2887 DrawTextF(xstart3, ystart2, font_header, "linked");
2889 SDL_VERSION(&sdl_version_compiled);
2890 #if defined(TARGET_SDL2)
2891 SDL_GetVersion(&sdl_version_linked_ext);
2892 sdl_version_linked = &sdl_version_linked_ext;
2894 sdl_version_linked = SDL_Linked_Version();
2897 ystart2 += 2 * ystep;
2898 DrawTextF(xstart1, ystart2, font_text, "SDL");
2899 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2900 sdl_version_compiled.major,
2901 sdl_version_compiled.minor,
2902 sdl_version_compiled.patch);
2903 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2904 sdl_version_linked->major,
2905 sdl_version_linked->minor,
2906 sdl_version_linked->patch);
2908 SDL_IMAGE_VERSION(&sdl_version_compiled);
2909 sdl_version_linked = IMG_Linked_Version();
2912 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
2913 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2914 sdl_version_compiled.major,
2915 sdl_version_compiled.minor,
2916 sdl_version_compiled.patch);
2917 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2918 sdl_version_linked->major,
2919 sdl_version_linked->minor,
2920 sdl_version_linked->patch);
2922 SDL_MIXER_VERSION(&sdl_version_compiled);
2923 sdl_version_linked = Mix_Linked_Version();
2926 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
2927 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2928 sdl_version_compiled.major,
2929 sdl_version_compiled.minor,
2930 sdl_version_compiled.patch);
2931 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2932 sdl_version_linked->major,
2933 sdl_version_linked->minor,
2934 sdl_version_linked->patch);
2936 SDL_NET_VERSION(&sdl_version_compiled);
2937 sdl_version_linked = SDLNet_Linked_Version();
2940 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
2941 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2942 sdl_version_compiled.major,
2943 sdl_version_compiled.minor,
2944 sdl_version_compiled.patch);
2945 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2946 sdl_version_linked->major,
2947 sdl_version_linked->minor,
2948 sdl_version_linked->patch);
2950 ystart2 += 3 * ystep;
2951 DrawTextF(xstart1, ystart2, font_header, "Driver");
2952 DrawTextF(xstart2, ystart2, font_header, "Requested");
2953 DrawTextF(xstart3, ystart2, font_header, "Used");
2955 #if defined(TARGET_SDL2)
2956 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
2958 SDL_VideoDriverName(driver_name, driver_name_len);
2961 ystart2 += 2 * ystep;
2962 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
2963 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
2964 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2966 #if defined(TARGET_SDL2)
2967 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
2969 SDL_AudioDriverName(driver_name, driver_name_len);
2973 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
2974 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
2975 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2977 DrawTextSCentered(ybottom, FONT_TEXT_4,
2978 "Press any key or button for info menu");
2980 FadeIn(REDRAW_FIELD);
2983 void HandleInfoScreen_Version(int button)
2985 if (button == MB_MENU_LEAVE)
2987 PlaySound(SND_MENU_ITEM_SELECTING);
2989 info_mode = INFO_MODE_MAIN;
2994 else if (button == MB_MENU_CHOICE)
2996 PlaySound(SND_MENU_ITEM_SELECTING);
2998 FadeSoundsAndMusic();
3000 info_mode = INFO_MODE_MAIN;
3001 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3005 PlayMenuSoundIfLoop();
3009 void DrawInfoScreen_LevelSet()
3011 struct TitleMessageInfo *tmi = &readme;
3012 char *filename = getLevelSetInfoFilename();
3014 /* if chars set to "-1", automatically determine by text and font width */
3015 if (tmi->chars == -1)
3016 tmi->chars = tmi->width / getFontWidth(tmi->font);
3018 tmi->width = tmi->chars * getFontWidth(tmi->font);
3020 /* if lines set to "-1", automatically determine by text and font height */
3021 if (tmi->lines == -1)
3022 tmi->lines = tmi->height / getFontHeight(tmi->font);
3024 tmi->height = tmi->lines * getFontHeight(tmi->font);
3026 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3028 FadeOut(REDRAW_FIELD);
3033 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3035 if (filename != NULL)
3036 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3037 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3038 tmi->autowrap, tmi->centered, tmi->parse_comments);
3040 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3041 "No information for this level set.");
3043 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3044 "Press any key or button for info menu");
3046 FadeIn(REDRAW_FIELD);
3049 void HandleInfoScreen_LevelSet(int button)
3051 if (button == MB_MENU_LEAVE)
3053 PlaySound(SND_MENU_ITEM_SELECTING);
3055 info_mode = INFO_MODE_MAIN;
3060 else if (button == MB_MENU_CHOICE)
3062 PlaySound(SND_MENU_ITEM_SELECTING);
3064 FadeSoundsAndMusic();
3066 info_mode = INFO_MODE_MAIN;
3067 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3071 PlayMenuSoundIfLoop();
3075 static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
3077 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3079 if (info_mode == INFO_MODE_TITLE)
3080 DrawInfoScreen_TitleScreen();
3081 else if (info_mode == INFO_MODE_ELEMENTS)
3082 DrawInfoScreen_Elements();
3083 else if (info_mode == INFO_MODE_MUSIC)
3084 DrawInfoScreen_Music();
3085 else if (info_mode == INFO_MODE_CREDITS)
3086 DrawInfoScreen_Credits();
3087 else if (info_mode == INFO_MODE_PROGRAM)
3088 DrawInfoScreen_Program();
3089 else if (info_mode == INFO_MODE_VERSION)
3090 DrawInfoScreen_Version();
3091 else if (info_mode == INFO_MODE_LEVELSET)
3092 DrawInfoScreen_LevelSet();
3094 DrawInfoScreen_Main(fade_mask, do_fading);
3096 if (info_mode != INFO_MODE_MAIN &&
3097 info_mode != INFO_MODE_TITLE &&
3098 info_mode != INFO_MODE_MUSIC)
3105 void DrawAndFadeInInfoScreen(int fade_mask)
3107 DrawInfoScreenExt(fade_mask, TRUE);
3110 void DrawInfoScreen()
3112 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3115 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3117 if (info_mode == INFO_MODE_TITLE)
3118 HandleInfoScreen_TitleScreen(button);
3119 else if (info_mode == INFO_MODE_ELEMENTS)
3120 HandleInfoScreen_Elements(button);
3121 else if (info_mode == INFO_MODE_MUSIC)
3122 HandleInfoScreen_Music(button);
3123 else if (info_mode == INFO_MODE_CREDITS)
3124 HandleInfoScreen_Credits(button);
3125 else if (info_mode == INFO_MODE_PROGRAM)
3126 HandleInfoScreen_Program(button);
3127 else if (info_mode == INFO_MODE_VERSION)
3128 HandleInfoScreen_Version(button);
3129 else if (info_mode == INFO_MODE_LEVELSET)
3130 HandleInfoScreen_LevelSet(button);
3132 HandleInfoScreen_Main(mx, my, dx, dy, button);
3136 /* ========================================================================= */
3137 /* type name functions */
3138 /* ========================================================================= */
3140 void HandleTypeName(int newxpos, Key key)
3142 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3143 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3144 struct TextPosInfo *pos = mci->pos_input;
3145 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3146 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3147 static int xpos = 0;
3148 int font_nr = pos->font;
3149 int font_active_nr = FONT_ACTIVE(font_nr);
3150 int font_width = getFontWidth(font_active_nr);
3151 char key_char = getValidConfigValueChar(getCharFromKey(key));
3152 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3153 boolean is_active = TRUE;
3155 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3159 strcpy(last_player_name, setup.player_name);
3163 #if defined(TARGET_SDL2)
3164 SDL_StartTextInput();
3167 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3169 setup.player_name[xpos] = key_char;
3170 setup.player_name[xpos + 1] = 0;
3174 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3178 setup.player_name[xpos] = 0;
3180 else if (key == KSYM_Return && xpos > 0)
3186 game_status = GAME_MODE_MAIN;
3188 else if (key == KSYM_Escape)
3190 strcpy(setup.player_name, last_player_name);
3194 game_status = GAME_MODE_MAIN;
3199 pos->width = (strlen(setup.player_name) + 1) * font_width;
3200 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3202 DrawText(startx, starty, setup.player_name, font_active_nr);
3203 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3207 pos->width = strlen(setup.player_name) * font_width;
3208 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3210 DrawText(startx, starty, setup.player_name, font_nr);
3212 #if defined(TARGET_SDL2)
3213 SDL_StopTextInput();
3219 /* ========================================================================= */
3220 /* tree menu functions */
3221 /* ========================================================================= */
3223 static void DrawChooseTree(TreeInfo **ti_ptr)
3227 FreeScreenGadgets();
3228 CreateScreenGadgets();
3230 CloseDoor(DOOR_CLOSE_2);
3232 FadeOut(REDRAW_FIELD);
3236 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3237 MapScreenTreeGadgets(*ti_ptr);
3239 FadeIn(REDRAW_FIELD);
3244 static void AdjustScrollbar(int id, int items_max, int items_visible,
3247 struct GadgetInfo *gi = screen_gadget[id];
3249 if (item_position > items_max - items_visible)
3250 item_position = items_max - items_visible;
3252 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3253 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3254 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3257 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3259 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3263 static void drawChooseTreeList(int first_entry, int num_page_entries,
3267 char *title_string = NULL;
3268 int yoffset_sets = MENU_TITLE1_YPOS;
3269 int yoffset_setup = 16;
3270 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3271 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3272 int last_game_status = game_status; /* save current game status */
3274 title_string = ti->infotext;
3276 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3278 /* clear tree list area, but not title or scrollbar */
3279 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3280 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3281 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3283 for (i = 0; i < num_page_entries; i++)
3285 TreeInfo *node, *node_first;
3286 int entry_pos = first_entry + i;
3287 int xpos = MENU_SCREEN_START_XPOS;
3288 int ypos = MENU_SCREEN_START_YPOS + i;
3289 int startx = mSX + xpos * 32;
3290 int starty = mSY + ypos * 32;
3291 int font_nr = FONT_TEXT_1;
3292 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3293 int startx_text = startx + font_xoffset;
3294 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3295 int text_size = startx_scrollbar - startx_text;
3296 int max_buffer_len = text_size / getFontWidth(font_nr);
3297 char buffer[max_buffer_len + 1];
3299 node_first = getTreeInfoFirstGroupEntry(ti);
3300 node = getTreeInfoFromPos(node_first, entry_pos);
3302 strncpy(buffer, node->name, max_buffer_len);
3303 buffer[max_buffer_len] = '\0';
3305 DrawText(startx, starty, buffer, font_nr + node->color);
3307 if (node->parent_link)
3308 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3309 else if (node->level_group)
3310 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3312 initCursor(i, IMG_MENU_BUTTON);
3315 game_status = last_game_status; /* restore current game status */
3317 redraw_mask |= REDRAW_FIELD;
3320 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3322 TreeInfo *node, *node_first;
3323 int x, last_redraw_mask = redraw_mask;
3324 int ypos = MENU_TITLE2_YPOS;
3325 int font_nr = FONT_TITLE_2;
3327 if (ti->type == TREE_TYPE_LEVEL_NR)
3328 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3330 if (ti->type != TREE_TYPE_LEVEL_DIR)
3333 node_first = getTreeInfoFirstGroupEntry(ti);
3334 node = getTreeInfoFromPos(node_first, entry_pos);
3336 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3338 if (node->parent_link)
3339 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3340 node->node_parent->name);
3341 else if (node->level_group)
3342 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3344 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3345 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3346 node->levels, (node->levels > 1 ? "levels" : "level"),
3349 /* let BackToFront() redraw only what is needed */
3350 redraw_mask = last_redraw_mask | REDRAW_TILES;
3351 for (x = 0; x < SCR_FIELDX; x++)
3352 MarkTileDirty(x, 1);
3355 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3358 TreeInfo *ti = *ti_ptr;
3360 int y = ti->cl_cursor;
3361 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3362 int num_entries = numTreeInfoInGroup(ti);
3363 int num_page_entries;
3364 int last_game_status = game_status; /* save current game status */
3365 boolean position_set_by_scrollbar = (dx == 999);
3367 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3368 num_page_entries = num_entries;
3370 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3372 game_status = last_game_status; /* restore current game status */
3374 if (button == MB_MENU_INITIALIZE)
3376 int num_entries = numTreeInfoInGroup(ti);
3377 int entry_pos = posTreeInfo(ti);
3379 if (ti->cl_first == -1)
3381 /* only on initialization */
3382 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3383 ti->cl_cursor = entry_pos - ti->cl_first;
3385 else if (ti->cl_cursor >= num_page_entries ||
3386 (num_entries > num_page_entries &&
3387 num_entries - ti->cl_first < num_page_entries))
3389 /* only after change of list size (by custom graphic configuration) */
3390 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3391 ti->cl_cursor = entry_pos - ti->cl_first;
3394 if (position_set_by_scrollbar)
3397 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3400 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3401 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3402 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3406 else if (button == MB_MENU_LEAVE)
3410 PlaySound(SND_MENU_ITEM_SELECTING);
3412 if (ti->node_parent)
3414 *ti_ptr = ti->node_parent;
3415 DrawChooseTree(ti_ptr);
3417 else if (game_status == GAME_MODE_SETUP)
3419 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3420 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3422 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3423 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3424 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3425 execSetupGraphics();
3426 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3427 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3428 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3430 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3431 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3432 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3439 if (game_status == GAME_MODE_LEVELNR)
3440 level_nr = atoi(level_number_current->identifier);
3442 game_status = GAME_MODE_MAIN;
3444 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3450 if (mx || my) /* mouse input */
3452 int last_game_status = game_status; /* save current game status */
3454 x = (mx - mSX) / 32;
3455 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3457 game_status = last_game_status; /* restore current game status */
3459 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3461 /* move cursor instead of scrolling when already at start/end of list */
3462 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3464 else if (dy == +1 * SCROLL_LINE &&
3465 ti->cl_first + num_page_entries == num_entries)
3468 /* handle scrolling screen one line or page */
3469 if (ti->cl_cursor + dy < 0 ||
3470 ti->cl_cursor + dy > num_page_entries - 1)
3472 boolean redraw = FALSE;
3474 if (ABS(dy) == SCROLL_PAGE)
3475 step = num_page_entries - 1;
3477 if (dy < 0 && ti->cl_first > 0)
3479 /* scroll page/line up */
3481 ti->cl_first -= step;
3482 if (ti->cl_first < 0)
3487 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3489 /* scroll page/line down */
3491 ti->cl_first += step;
3492 if (ti->cl_first + num_page_entries > num_entries)
3493 ti->cl_first = MAX(0, num_entries - num_page_entries);
3500 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3501 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3502 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3504 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3512 /* handle moving cursor one line */
3513 y = ti->cl_cursor + dy;
3518 TreeInfo *node_first, *node_cursor;
3519 int entry_pos = ti->cl_first + y;
3521 node_first = getTreeInfoFirstGroupEntry(ti);
3522 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3524 if (node_cursor->node_group)
3528 PlaySound(SND_MENU_ITEM_SELECTING);
3530 node_cursor->cl_first = ti->cl_first;
3531 node_cursor->cl_cursor = ti->cl_cursor;
3532 *ti_ptr = node_cursor->node_group;
3533 DrawChooseTree(ti_ptr);
3538 else if (dx == -1 && ti->node_parent)
3542 PlaySound(SND_MENU_ITEM_SELECTING);
3544 *ti_ptr = ti->node_parent;
3545 DrawChooseTree(ti_ptr);
3550 if (!anyScrollbarGadgetActive() &&
3551 IN_VIS_FIELD(x, y) &&
3552 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3553 y >= 0 && y < num_page_entries)
3557 if (y != ti->cl_cursor)
3559 PlaySound(SND_MENU_ITEM_ACTIVATING);
3561 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3562 drawChooseTreeCursor(y, TRUE);
3563 drawChooseTreeInfo(ti->cl_first + y, ti);
3570 TreeInfo *node_first, *node_cursor;
3571 int entry_pos = ti->cl_first + y;
3573 PlaySound(SND_MENU_ITEM_SELECTING);
3575 node_first = getTreeInfoFirstGroupEntry(ti);
3576 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3578 if (node_cursor->node_group)
3582 node_cursor->cl_first = ti->cl_first;
3583 node_cursor->cl_cursor = ti->cl_cursor;
3584 *ti_ptr = node_cursor->node_group;
3585 DrawChooseTree(ti_ptr);
3587 else if (node_cursor->parent_link)
3591 *ti_ptr = node_cursor->node_parent;
3592 DrawChooseTree(ti_ptr);
3598 node_cursor->cl_first = ti->cl_first;
3599 node_cursor->cl_cursor = ti->cl_cursor;
3600 *ti_ptr = node_cursor;
3602 if (ti->type == TREE_TYPE_LEVEL_DIR)
3604 LoadLevelSetup_SeriesInfo();
3606 SaveLevelSetup_LastSeries();
3607 SaveLevelSetup_SeriesInfo();
3611 if (game_status == GAME_MODE_SETUP)
3613 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3614 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3616 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3617 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3618 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3619 execSetupGraphics();
3620 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3621 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3622 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3624 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3625 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3626 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3633 if (game_status == GAME_MODE_LEVELNR)
3634 level_nr = atoi(level_number_current->identifier);
3636 game_status = GAME_MODE_MAIN;
3645 void DrawChooseLevelSet()
3647 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3649 DrawChooseTree(&leveldir_current);
3655 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
3657 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
3660 void DrawChooseLevelNr()
3664 if (level_number != NULL)
3666 freeTreeInfo(level_number);
3668 level_number = NULL;
3671 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
3673 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
3674 char identifier[32], name[32];
3677 /* temporarily load level info to get level name */
3678 LoadLevelInfoOnly(i);
3680 ti->node_top = &level_number;
3681 ti->sort_priority = 10000 + value;
3682 ti->color = (level.no_valid_file ? FC_BLUE :
3683 LevelStats_getSolved(i) ? FC_GREEN :
3684 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
3686 sprintf(identifier, "%d", value);
3687 sprintf(name, "%03d: %s", value,
3688 (level.no_valid_file ? "(no file)" : level.name));
3690 setString(&ti->identifier, identifier);
3691 setString(&ti->name, name);
3692 setString(&ti->name_sorting, name);
3694 pushTreeInfo(&level_number, ti);
3697 /* sort level number values to start with lowest level number */
3698 sortTreeInfo(&level_number);
3700 /* set current level number to current level number */
3701 level_number_current =
3702 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
3704 /* if that also fails, set current level number to first available level */
3705 if (level_number_current == NULL)
3706 level_number_current = level_number;
3708 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3710 DrawChooseTree(&level_number_current);
3716 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
3718 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
3721 void DrawHallOfFame(int highlight_position)
3724 FadeSoundsAndMusic();
3726 /* (this is needed when called from GameEnd() after winning a game) */
3727 KeyboardAutoRepeatOn();
3730 /* (this is needed when called from GameEnd() after winning a game) */
3731 SetDrawDeactivationMask(REDRAW_NONE);
3732 SetDrawBackgroundMask(REDRAW_FIELD);
3734 CloseDoor(DOOR_CLOSE_2);
3736 if (highlight_position < 0)
3737 LoadScore(level_nr);
3739 FadeSetEnterScreen();
3741 FadeOut(REDRAW_FIELD);
3748 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
3750 FadeIn(REDRAW_FIELD);
3753 static void drawHallOfFameList(int first_entry, int highlight_position)
3757 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
3760 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
3761 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
3762 "HighScores of Level %d", level_nr);
3764 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
3766 int entry = first_entry + i;
3767 boolean active = (entry == highlight_position);
3768 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
3769 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
3770 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
3771 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
3772 int dx1 = 3 * getFontWidth(font_nr1);
3773 int dx2 = dx1 + getFontWidth(font_nr1);
3774 int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
3775 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
3776 int sy = mSY + 64 + i * 32;
3778 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
3779 DrawText(mSX + dx1, sy, ".", font_nr1);
3781 for (j = 0; j < num_dots; j++)
3782 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
3784 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
3785 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
3787 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
3790 redraw_mask |= REDRAW_FIELD;
3793 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
3795 static int first_entry = 0;
3796 static int highlight_position = 0;
3797 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3799 if (button == MB_MENU_INITIALIZE)
3802 highlight_position = mx;
3803 drawHallOfFameList(first_entry, highlight_position);
3808 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
3809 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
3813 if (first_entry > 0)
3815 first_entry -= step;
3816 if (first_entry < 0)
3819 drawHallOfFameList(first_entry, highlight_position);
3824 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
3826 first_entry += step;
3827 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
3828 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
3830 drawHallOfFameList(first_entry, highlight_position);
3833 else if (button == MB_MENU_LEAVE)
3835 PlaySound(SND_MENU_ITEM_SELECTING);
3837 FadeSound(SND_BACKGROUND_SCORES);
3839 game_status = GAME_MODE_MAIN;
3843 else if (button == MB_MENU_CHOICE)
3845 PlaySound(SND_MENU_ITEM_SELECTING);
3847 FadeSound(SND_BACKGROUND_SCORES);
3849 game_status = GAME_MODE_MAIN;
3851 DrawAndFadeInMainMenu(REDRAW_FIELD);
3854 if (game_status == GAME_MODE_SCORES)
3855 PlayMenuSoundIfLoop();
3859 /* ========================================================================= */
3860 /* setup screen functions */
3861 /* ========================================================================= */
3863 static struct TokenInfo *setup_info;
3864 static int num_setup_info; /* number of setup entries shown on screen */
3865 static int max_setup_info; /* total number of setup entries in list */
3867 static char *screen_mode_text;
3868 static char *window_size_text;
3869 static char *scaling_type_text;
3870 static char *scroll_delay_text;
3871 static char *game_speed_text;
3872 static char *graphics_set_name;
3873 static char *sounds_set_name;
3874 static char *music_set_name;
3875 static char *volume_simple_text;
3876 static char *volume_loops_text;
3877 static char *volume_music_text;
3878 static char *touch_controls_text;
3879 static char *move_distance_text;
3880 static char *drop_distance_text;
3882 static void execSetupMain()
3884 setup_mode = SETUP_MODE_MAIN;
3889 static void execSetupGame_setGameSpeeds()
3891 if (game_speeds == NULL)
3895 for (i = 0; game_speeds_list[i].value != -1; i++)
3897 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3898 char identifier[32], name[32];
3899 int value = game_speeds_list[i].value;
3900 char *text = game_speeds_list[i].text;
3902 ti->node_top = &game_speeds;
3903 ti->sort_priority = 10000 - value;
3905 sprintf(identifier, "%d", value);
3906 sprintf(name, "%s", text);
3908 setString(&ti->identifier, identifier);
3909 setString(&ti->name, name);
3910 setString(&ti->name_sorting, name);
3911 setString(&ti->infotext, "Game Speed");
3913 pushTreeInfo(&game_speeds, ti);
3916 /* sort game speed values to start with slowest game speed */
3917 sortTreeInfo(&game_speeds);
3919 /* set current game speed to configured game speed value */
3920 game_speed_current =
3921 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
3923 /* if that fails, set current game speed to reliable default value */
3924 if (game_speed_current == NULL)
3925 game_speed_current =
3926 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
3928 /* if that also fails, set current game speed to first available speed */
3929 if (game_speed_current == NULL)
3930 game_speed_current = game_speeds;
3933 setup.game_frame_delay = atoi(game_speed_current->identifier);
3935 /* needed for displaying game speed text instead of identifier */
3936 game_speed_text = game_speed_current->name;
3939 static void execSetupGame_setScrollDelays()
3941 if (scroll_delays == NULL)
3945 for (i = 0; scroll_delays_list[i].value != -1; i++)
3947 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3948 char identifier[32], name[32];
3949 int value = scroll_delays_list[i].value;
3950 char *text = scroll_delays_list[i].text;
3952 ti->node_top = &scroll_delays;
3953 ti->sort_priority = value;
3955 sprintf(identifier, "%d", value);
3956 sprintf(name, "%s", text);
3958 setString(&ti->identifier, identifier);
3959 setString(&ti->name, name);
3960 setString(&ti->name_sorting, name);
3961 setString(&ti->infotext, "Scaling Type");
3963 pushTreeInfo(&scroll_delays, ti);
3966 /* sort scaling type values to start with lowest scaling type value */
3967 sortTreeInfo(&scroll_delays);
3969 /* set current scaling type value to configured scaling type value */
3970 scroll_delay_current =
3971 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
3973 /* if that fails, set current scaling type to reliable default value */
3974 if (scroll_delay_current == NULL)
3975 scroll_delay_current =
3976 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
3978 /* if that also fails, set current scaling type to first available value */
3979 if (scroll_delay_current == NULL)
3980 scroll_delay_current = scroll_delays;
3983 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
3985 /* needed for displaying scaling type text instead of identifier */
3986 scroll_delay_text = scroll_delay_current->name;
3989 static void execSetupGame()
3991 execSetupGame_setGameSpeeds();
3992 execSetupGame_setScrollDelays();
3994 setup_mode = SETUP_MODE_GAME;
3999 static void execSetupChooseGameSpeed()
4001 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4006 static void execSetupChooseScrollDelay()
4008 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4013 static void execSetupEditor()
4015 setup_mode = SETUP_MODE_EDITOR;
4020 static void execSetupGraphics_setWindowSizes(boolean update_list)
4022 if (window_sizes != NULL && update_list)
4024 freeTreeInfo(window_sizes);
4026 window_sizes = NULL;
4029 if (window_sizes == NULL)
4031 boolean current_window_size_found = FALSE;
4034 for (i = 0; window_sizes_list[i].value != -1; i++)
4036 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4037 char identifier[32], name[32];
4038 int value = window_sizes_list[i].value;
4039 char *text = window_sizes_list[i].text;
4041 ti->node_top = &window_sizes;
4042 ti->sort_priority = value;
4044 sprintf(identifier, "%d", value);
4045 sprintf(name, "%s", text);
4047 setString(&ti->identifier, identifier);
4048 setString(&ti->name, name);
4049 setString(&ti->name_sorting, name);
4050 setString(&ti->infotext, "Window Scaling");
4052 pushTreeInfo(&window_sizes, ti);
4054 if (value == setup.window_scaling_percent)
4055 current_window_size_found = TRUE;
4058 if (!current_window_size_found)
4060 // add entry for non-preset window scaling value
4062 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4063 char identifier[32], name[32];
4064 int value = setup.window_scaling_percent;
4066 ti->node_top = &window_sizes;
4067 ti->sort_priority = value;
4069 sprintf(identifier, "%d", value);
4070 sprintf(name, "%d %% (Current)", value);
4072 setString(&ti->identifier, identifier);
4073 setString(&ti->name, name);
4074 setString(&ti->name_sorting, name);
4075 setString(&ti->infotext, "Window Scaling");
4077 pushTreeInfo(&window_sizes, ti);
4080 /* sort window size values to start with lowest window size value */
4081 sortTreeInfo(&window_sizes);
4083 /* set current window size value to configured window size value */
4084 window_size_current =
4085 getTreeInfoFromIdentifier(window_sizes,
4086 i_to_a(setup.window_scaling_percent));
4088 /* if that fails, set current window size to reliable default value */
4089 if (window_size_current == NULL)
4090 window_size_current =
4091 getTreeInfoFromIdentifier(window_sizes,
4092 i_to_a(STD_WINDOW_SCALING_PERCENT));
4094 /* if that also fails, set current window size to first available value */
4095 if (window_size_current == NULL)
4096 window_size_current = window_sizes;
4099 setup.window_scaling_percent = atoi(window_size_current->identifier);
4101 /* needed for displaying window size text instead of identifier */
4102 window_size_text = window_size_current->name;
4105 static void execSetupGraphics_setScalingTypes()
4107 if (scaling_types == NULL)
4111 for (i = 0; scaling_types_list[i].value != NULL; i++)
4113 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4114 char identifier[32], name[32];
4115 char *value = scaling_types_list[i].value;
4116 char *text = scaling_types_list[i].text;
4118 ti->node_top = &scaling_types;
4119 ti->sort_priority = i;
4121 sprintf(identifier, "%s", value);
4122 sprintf(name, "%s", text);
4124 setString(&ti->identifier, identifier);
4125 setString(&ti->name, name);
4126 setString(&ti->name_sorting, name);
4127 setString(&ti->infotext, "Anti-Aliasing");
4129 pushTreeInfo(&scaling_types, ti);
4132 /* sort scaling type values to start with lowest scaling type value */
4133 sortTreeInfo(&scaling_types);
4135 /* set current scaling type value to configured scaling type value */
4136 scaling_type_current =
4137 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4139 /* if that fails, set current scaling type to reliable default value */
4140 if (scaling_type_current == NULL)
4141 scaling_type_current =
4142 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4144 /* if that also fails, set current scaling type to first available value */
4145 if (scaling_type_current == NULL)
4146 scaling_type_current = scaling_types;
4149 setup.window_scaling_quality = scaling_type_current->identifier;
4151 /* needed for displaying scaling type text instead of identifier */
4152 scaling_type_text = scaling_type_current->name;
4155 static void execSetupGraphics_setScreenModes()
4157 // if (screen_modes == NULL && video.fullscreen_available)
4158 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4162 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4164 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4165 char identifier[32], name[32];
4166 int x = video.fullscreen_modes[i].width;
4167 int y = video.fullscreen_modes[i].height;
4170 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4172 ti->node_top = &screen_modes;
4173 ti->sort_priority = x * 10000 + y;
4175 sprintf(identifier, "%dx%d", x, y);
4176 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4178 setString(&ti->identifier, identifier);
4179 setString(&ti->name, name);
4180 setString(&ti->name_sorting, name);
4181 setString(&ti->infotext, "Fullscreen Mode");
4183 pushTreeInfo(&screen_modes, ti);
4186 /* sort fullscreen modes to start with lowest available screen resolution */
4187 sortTreeInfo(&screen_modes);
4189 /* set current screen mode for fullscreen mode to configured setup value */
4190 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4191 setup.fullscreen_mode);
4193 /* if that fails, set current screen mode to reliable default value */
4194 if (screen_mode_current == NULL)
4195 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4196 DEFAULT_FULLSCREEN_MODE);
4198 /* if that also fails, set current screen mode to first available mode */
4199 if (screen_mode_current == NULL)
4200 screen_mode_current = screen_modes;
4202 if (screen_mode_current == NULL)
4203 video.fullscreen_available = FALSE;
4206 // if (video.fullscreen_available)
4207 if (screen_mode_current != NULL)
4209 setup.fullscreen_mode = screen_mode_current->identifier;
4211 /* needed for displaying screen mode name instead of identifier */
4212 screen_mode_text = screen_mode_current->name;
4216 static void execSetupGraphics()
4218 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4220 // update "setup.window_scaling_percent" from list selection
4221 execSetupGraphics_setWindowSizes(FALSE);
4225 // update list selection from "setup.window_scaling_percent"
4226 execSetupGraphics_setWindowSizes(TRUE);
4229 execSetupGraphics_setScalingTypes();
4230 execSetupGraphics_setScreenModes();
4232 setup_mode = SETUP_MODE_GRAPHICS;
4236 #if defined(TARGET_SDL2)
4237 // window scaling may have changed at this point
4238 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4240 // window scaling quality may have changed at this point
4241 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4242 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4246 #if !defined(PLATFORM_ANDROID)
4247 #if defined(TARGET_SDL2)
4248 static void execSetupChooseWindowSize()
4250 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4255 static void execSetupChooseScalingType()
4257 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4262 static void execSetupChooseScreenMode()
4264 if (!video.fullscreen_available)
4267 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4274 static void execSetupChooseVolumeSimple()
4276 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4281 static void execSetupChooseVolumeLoops()
4283 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4288 static void execSetupChooseVolumeMusic()
4290 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4295 static void execSetupSound()
4297 if (volumes_simple == NULL)
4301 for (i = 0; volumes_list[i].value != -1; i++)
4303 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4304 char identifier[32], name[32];
4305 int value = volumes_list[i].value;
4306 char *text = volumes_list[i].text;
4308 ti->node_top = &volumes_simple;
4309 ti->sort_priority = value;
4311 sprintf(identifier, "%d", value);
4312 sprintf(name, "%s", text);
4314 setString(&ti->identifier, identifier);
4315 setString(&ti->name, name);
4316 setString(&ti->name_sorting, name);
4317 setString(&ti->infotext, "Sound Volume");
4319 pushTreeInfo(&volumes_simple, ti);
4322 /* sort volume values to start with lowest volume value */
4323 sortTreeInfo(&volumes_simple);
4325 /* set current volume value to configured volume value */
4326 volume_simple_current =
4327 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4329 /* if that fails, set current volume to reliable default value */
4330 if (volume_simple_current == NULL)
4331 volume_simple_current =
4332 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4334 /* if that also fails, set current volume to first available value */
4335 if (volume_simple_current == NULL)
4336 volume_simple_current = volumes_simple;
4339 if (volumes_loops == NULL)
4343 for (i = 0; volumes_list[i].value != -1; i++)
4345 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4346 char identifier[32], name[32];
4347 int value = volumes_list[i].value;
4348 char *text = volumes_list[i].text;
4350 ti->node_top = &volumes_loops;
4351 ti->sort_priority = value;
4353 sprintf(identifier, "%d", value);
4354 sprintf(name, "%s", text);
4356 setString(&ti->identifier, identifier);
4357 setString(&ti->name, name);
4358 setString(&ti->name_sorting, name);
4359 setString(&ti->infotext, "Loops Volume");
4361 pushTreeInfo(&volumes_loops, ti);
4364 /* sort volume values to start with lowest volume value */
4365 sortTreeInfo(&volumes_loops);
4367 /* set current volume value to configured volume value */
4368 volume_loops_current =
4369 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4371 /* if that fails, set current volume to reliable default value */
4372 if (volume_loops_current == NULL)
4373 volume_loops_current =
4374 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4376 /* if that also fails, set current volume to first available value */
4377 if (volume_loops_current == NULL)
4378 volume_loops_current = volumes_loops;
4381 if (volumes_music == NULL)
4385 for (i = 0; volumes_list[i].value != -1; i++)
4387 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4388 char identifier[32], name[32];
4389 int value = volumes_list[i].value;
4390 char *text = volumes_list[i].text;
4392 ti->node_top = &volumes_music;
4393 ti->sort_priority = value;
4395 sprintf(identifier, "%d", value);
4396 sprintf(name, "%s", text);
4398 setString(&ti->identifier, identifier);
4399 setString(&ti->name, name);
4400 setString(&ti->name_sorting, name);
4401 setString(&ti->infotext, "Music Volume");
4403 pushTreeInfo(&volumes_music, ti);
4406 /* sort volume values to start with lowest volume value */
4407 sortTreeInfo(&volumes_music);
4409 /* set current volume value to configured volume value */
4410 volume_music_current =
4411 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4413 /* if that fails, set current volume to reliable default value */
4414 if (volume_music_current == NULL)
4415 volume_music_current =
4416 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4418 /* if that also fails, set current volume to first available value */
4419 if (volume_music_current == NULL)
4420 volume_music_current = volumes_music;
4423 setup.volume_simple = atoi(volume_simple_current->identifier);
4424 setup.volume_loops = atoi(volume_loops_current->identifier);
4425 setup.volume_music = atoi(volume_music_current->identifier);
4427 /* needed for displaying volume text instead of identifier */
4428 volume_simple_text = volume_simple_current->name;
4429 volume_loops_text = volume_loops_current->name;
4430 volume_music_text = volume_music_current->name;
4432 setup_mode = SETUP_MODE_SOUND;
4437 static void execSetupChooseTouchControls()
4439 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4444 static void execSetupChooseMoveDistance()
4446 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4451 static void execSetupChooseDropDistance()
4453 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4458 static void execSetupTouch()
4460 if (touch_controls == NULL)
4464 for (i = 0; touch_controls_list[i].value != NULL; i++)
4466 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4467 char identifier[32], name[32];
4468 char *value = touch_controls_list[i].value;
4469 char *text = touch_controls_list[i].text;
4471 ti->node_top = &touch_controls;
4472 ti->sort_priority = i;
4474 sprintf(identifier, "%s", value);
4475 sprintf(name, "%s", text);
4477 setString(&ti->identifier, identifier);
4478 setString(&ti->name, name);
4479 setString(&ti->name_sorting, name);
4480 setString(&ti->infotext, "Control Type");
4482 pushTreeInfo(&touch_controls, ti);
4485 /* sort touch control values to start with lowest touch control value */
4486 sortTreeInfo(&touch_controls);
4488 /* set current touch control value to configured touch control value */
4489 touch_control_current =
4490 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4492 /* if that fails, set current touch control to reliable default value */
4493 if (touch_control_current == NULL)
4494 touch_control_current =
4495 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4497 /* if that also fails, set current touch control to first available value */
4498 if (touch_control_current == NULL)
4499 touch_control_current = touch_controls;
4502 if (move_distances == NULL)
4506 for (i = 0; distances_list[i].value != -1; i++)
4508 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4509 char identifier[32], name[32];
4510 int value = distances_list[i].value;
4511 char *text = distances_list[i].text;
4513 ti->node_top = &move_distances;
4514 ti->sort_priority = value;
4516 sprintf(identifier, "%d", value);
4517 sprintf(name, "%s", text);
4519 setString(&ti->identifier, identifier);
4520 setString(&ti->name, name);
4521 setString(&ti->name_sorting, name);
4522 setString(&ti->infotext, "Move Distance");
4524 pushTreeInfo(&move_distances, ti);
4527 /* sort distance values to start with lowest distance value */
4528 sortTreeInfo(&move_distances);
4530 /* set current distance value to configured distance value */
4531 move_distance_current =
4532 getTreeInfoFromIdentifier(move_distances,
4533 i_to_a(setup.touch.move_distance));
4535 /* if that fails, set current distance to reliable default value */
4536 if (move_distance_current == NULL)
4537 move_distance_current =
4538 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4540 /* if that also fails, set current distance to first available value */
4541 if (move_distance_current == NULL)
4542 move_distance_current = move_distances;
4545 if (drop_distances == NULL)
4549 for (i = 0; distances_list[i].value != -1; i++)
4551 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4552 char identifier[32], name[32];
4553 int value = distances_list[i].value;
4554 char *text = distances_list[i].text;
4556 ti->node_top = &drop_distances;
4557 ti->sort_priority = value;
4559 sprintf(identifier, "%d", value);
4560 sprintf(name, "%s", text);
4562 setString(&ti->identifier, identifier);
4563 setString(&ti->name, name);
4564 setString(&ti->name_sorting, name);
4565 setString(&ti->infotext, "Drop Distance");
4567 pushTreeInfo(&drop_distances, ti);
4570 /* sort distance values to start with lowest distance value */
4571 sortTreeInfo(&drop_distances);
4573 /* set current distance value to configured distance value */
4574 drop_distance_current =
4575 getTreeInfoFromIdentifier(drop_distances,
4576 i_to_a(setup.touch.drop_distance));
4578 /* if that fails, set current distance to reliable default value */
4579 if (drop_distance_current == NULL)
4580 drop_distance_current =
4581 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
4583 /* if that also fails, set current distance to first available value */
4584 if (drop_distance_current == NULL)
4585 drop_distance_current = drop_distances;
4588 setup.touch.control_type = touch_control_current->identifier;
4589 setup.touch.move_distance = atoi(move_distance_current->identifier);
4590 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
4592 /* needed for displaying volume text instead of identifier */
4593 touch_controls_text = touch_control_current->name;
4594 move_distance_text = move_distance_current->name;
4595 drop_distance_text = drop_distance_current->name;
4597 setup_mode = SETUP_MODE_TOUCH;
4602 static void execSetupArtwork()
4605 printf("::: '%s', '%s', '%s'\n",
4606 artwork.gfx_current->subdir,
4607 artwork.gfx_current->fullpath,
4608 artwork.gfx_current->basepath);
4611 setup.graphics_set = artwork.gfx_current->identifier;
4612 setup.sounds_set = artwork.snd_current->identifier;
4613 setup.music_set = artwork.mus_current->identifier;
4615 /* needed if last screen (setup choice) changed graphics, sounds or music */
4616 ReloadCustomArtwork(0);
4618 /* needed for displaying artwork name instead of artwork identifier */
4619 graphics_set_name = artwork.gfx_current->name;
4620 sounds_set_name = artwork.snd_current->name;
4621 music_set_name = artwork.mus_current->name;
4623 setup_mode = SETUP_MODE_ARTWORK;
4628 static void execSetupChooseGraphics()
4630 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4635 static void execSetupChooseSounds()
4637 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4642 static void execSetupChooseMusic()
4644 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4649 #if !defined(PLATFORM_ANDROID)
4650 static void execSetupInput()
4652 setup_mode = SETUP_MODE_INPUT;
4658 static void execSetupShortcuts()
4660 setup_mode = SETUP_MODE_SHORTCUTS;
4665 static void execSetupShortcuts1()
4667 setup_mode = SETUP_MODE_SHORTCUTS_1;
4672 static void execSetupShortcuts2()
4674 setup_mode = SETUP_MODE_SHORTCUTS_2;
4679 static void execSetupShortcuts3()
4681 setup_mode = SETUP_MODE_SHORTCUTS_3;
4686 static void execSetupShortcuts4()
4688 setup_mode = SETUP_MODE_SHORTCUTS_4;
4693 static void execSetupShortcuts5()
4695 setup_mode = SETUP_MODE_SHORTCUTS_5;
4700 static void execExitSetup()
4702 game_status = GAME_MODE_MAIN;
4704 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4707 static void execSaveAndExitSetup()
4713 static struct TokenInfo setup_info_main[] =
4715 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4716 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4717 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4718 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4719 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4720 #if !defined(PLATFORM_ANDROID)
4721 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4722 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4724 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4726 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
4727 { TYPE_EMPTY, NULL, "" },
4728 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4729 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4734 static struct TokenInfo setup_info_game[] =
4736 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4737 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4738 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4739 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4740 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4741 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4742 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4743 { TYPE_STRING, &game_speed_text, "" },
4745 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4746 { TYPE_STRING, &scroll_delay_text, "" },
4748 { TYPE_EMPTY, NULL, "" },
4749 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4754 static struct TokenInfo setup_info_editor[] =
4757 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4758 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4759 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4760 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4761 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4762 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4763 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4764 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4766 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4767 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4768 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4770 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4772 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4773 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4774 { TYPE_EMPTY, NULL, "" },
4776 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4777 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4778 { TYPE_EMPTY, NULL, "" },
4780 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4781 { TYPE_EMPTY, NULL, "" },
4782 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4787 static struct TokenInfo setup_info_graphics[] =
4789 #if !defined(PLATFORM_ANDROID)
4790 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4791 #if defined(TARGET_SDL2)
4792 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
4793 { TYPE_STRING, &window_size_text, "" },
4794 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
4795 { TYPE_STRING, &scaling_type_text, "" },
4797 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4798 { TYPE_STRING, &screen_mode_text, "" },
4802 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4803 { TYPE_STRING, &scroll_delay_text, "" },
4805 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4806 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4807 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4808 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4809 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4810 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4811 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
4812 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
4813 { TYPE_EMPTY, NULL, "" },
4814 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4819 static struct TokenInfo setup_info_sound[] =
4821 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4822 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4823 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4824 { TYPE_EMPTY, NULL, "" },
4825 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
4826 { TYPE_STRING, &volume_simple_text, "" },
4827 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
4828 { TYPE_STRING, &volume_loops_text, "" },
4829 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
4830 { TYPE_STRING, &volume_music_text, "" },
4831 { TYPE_EMPTY, NULL, "" },
4832 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4837 static struct TokenInfo setup_info_artwork[] =
4839 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4840 { TYPE_STRING, &graphics_set_name, "" },
4841 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4842 { TYPE_STRING, &sounds_set_name, "" },
4843 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4844 { TYPE_STRING, &music_set_name, "" },
4845 { TYPE_EMPTY, NULL, "" },
4846 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
4847 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
4848 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
4849 { TYPE_EMPTY, NULL, "" },
4850 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4855 static struct TokenInfo setup_info_input[] =
4857 { TYPE_SWITCH, NULL, "Player:" },
4858 { TYPE_SWITCH, NULL, "Device:" },
4859 { TYPE_ENTER_MENU, NULL, "" },
4860 { TYPE_EMPTY, NULL, "" },
4861 { TYPE_EMPTY, NULL, "" },
4862 { TYPE_EMPTY, NULL, "" },
4863 { TYPE_EMPTY, NULL, "" },
4864 { TYPE_EMPTY, NULL, "" },
4865 { TYPE_EMPTY, NULL, "" },
4866 { TYPE_EMPTY, NULL, "" },
4867 { TYPE_EMPTY, NULL, "" },
4868 { TYPE_EMPTY, NULL, "" },
4869 { TYPE_EMPTY, NULL, "" },
4870 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4875 static struct TokenInfo setup_info_touch[] =
4877 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
4878 { TYPE_STRING, &touch_controls_text, "" },
4879 { TYPE_EMPTY, NULL, "" },
4880 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
4881 { TYPE_STRING, &move_distance_text, "" },
4882 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
4883 { TYPE_STRING, &drop_distance_text, "" },
4884 { TYPE_EMPTY, NULL, "" },
4885 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4890 static struct TokenInfo setup_info_shortcuts[] =
4892 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
4893 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
4894 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
4895 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
4896 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
4897 { TYPE_EMPTY, NULL, "" },
4898 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4903 static struct TokenInfo setup_info_shortcuts_1[] =
4905 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4906 { TYPE_KEY, &setup.shortcut.save_game, "" },
4907 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4908 { TYPE_KEY, &setup.shortcut.load_game, "" },
4909 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4910 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4911 { TYPE_EMPTY, NULL, "" },
4912 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4913 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4914 { TYPE_EMPTY, NULL, "" },
4915 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4920 static struct TokenInfo setup_info_shortcuts_2[] =
4922 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4923 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4924 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4925 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4926 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4927 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4928 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4929 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4930 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4931 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4932 { TYPE_EMPTY, NULL, "" },
4933 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4938 static struct TokenInfo setup_info_shortcuts_3[] =
4940 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
4941 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
4942 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
4943 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
4944 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
4945 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
4946 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
4947 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
4948 { TYPE_KEYTEXT, NULL, "Record Tape:", },
4949 { TYPE_KEY, &setup.shortcut.tape_record, "" },
4950 { TYPE_KEYTEXT, NULL, "Play Tape:", },
4951 { TYPE_KEY, &setup.shortcut.tape_play, "" },
4952 { TYPE_EMPTY, NULL, "" },
4953 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4958 static struct TokenInfo setup_info_shortcuts_4[] =
4960 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
4961 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
4962 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
4963 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
4964 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
4965 { TYPE_KEY, &setup.shortcut.sound_music, "" },
4966 { TYPE_EMPTY, NULL, "" },
4967 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4972 static struct TokenInfo setup_info_shortcuts_5[] =
4974 { TYPE_KEYTEXT, NULL, "Snap Left:", },
4975 { TYPE_KEY, &setup.shortcut.snap_left, "" },
4976 { TYPE_KEYTEXT, NULL, "Snap Right:", },
4977 { TYPE_KEY, &setup.shortcut.snap_right, "" },
4978 { TYPE_KEYTEXT, NULL, "Snap Up:", },
4979 { TYPE_KEY, &setup.shortcut.snap_up, "" },
4980 { TYPE_KEYTEXT, NULL, "Snap Down:", },
4981 { TYPE_KEY, &setup.shortcut.snap_down, "" },
4982 { TYPE_EMPTY, NULL, "" },
4983 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4988 static Key getSetupKey()
4990 Key key = KSYM_UNDEFINED;
4991 boolean got_key_event = FALSE;
4993 while (!got_key_event)
4995 if (PendingEvent()) /* got event */
5003 case EVENT_KEYPRESS:
5005 key = GetEventKey((KeyEvent *)&event, TRUE);
5007 /* press 'Escape' or 'Enter' to keep the existing key binding */
5008 if (key == KSYM_Escape || key == KSYM_Return)
5009 key = KSYM_UNDEFINED; /* keep old value */
5011 got_key_event = TRUE;
5015 case EVENT_KEYRELEASE:
5016 key_joystick_mapping = 0;
5020 HandleOtherEvents(&event);
5028 /* don't eat all CPU time */
5035 static int getSetupTextFont(int type)
5037 if (type & (TYPE_SWITCH |
5049 static int getSetupValueFont(int type, void *value)
5051 if (type & TYPE_KEY)
5052 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5053 else if (type & TYPE_STRING)
5054 return FONT_VALUE_2;
5055 else if (type & TYPE_ECS_AGA)
5056 return FONT_VALUE_1;
5057 else if (type & TYPE_BOOLEAN_STYLE)
5058 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5059 else if (type & TYPE_YES_NO_AUTO)
5060 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5061 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5063 return FONT_VALUE_1;
5066 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5068 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5069 struct TokenInfo *si = &setup_info[si_pos];
5070 boolean font_draw_xoffset_modified = FALSE;
5071 int font_draw_xoffset_old = -1;
5072 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5073 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5074 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5075 int xpos = menu_screen_value_xpos;
5076 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5077 int startx = mSX + xpos * 32;
5078 int starty = mSY + ypos * 32;
5079 int font_nr, font_width;
5080 int type = si->type;
5081 void *value = si->value;
5082 char *value_string = getSetupValue(type, value);
5085 if (value_string == NULL)
5088 if (type & TYPE_KEY)
5090 xpos = MENU_SCREEN_START_XPOS;
5092 if (type & TYPE_QUERY)
5093 value_string = "<press key>";
5095 else if (type & TYPE_STRING)
5097 int max_value_len = (SCR_FIELDX - 2) * 2;
5099 xpos = MENU_SCREEN_START_XPOS;
5101 if (strlen(value_string) > max_value_len)
5102 value_string[max_value_len] = '\0';
5104 else if (type & TYPE_YES_NO_AUTO)
5106 xpos = menu_screen_value_xpos - 1;
5109 startx = mSX + xpos * 32;
5110 starty = mSY + ypos * 32;
5111 font_nr = getSetupValueFont(type, value);
5112 font_width = getFontWidth(font_nr);
5114 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5115 if (setup_mode != SETUP_MODE_INPUT)
5117 int max_menu_text_length_big = (menu_screen_value_xpos -
5118 MENU_SCREEN_START_XPOS);
5119 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5120 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5121 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5122 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5123 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5124 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5125 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5126 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5127 boolean correct_font_draw_xoffset = FALSE;
5129 if (xpos == MENU_SCREEN_START_XPOS &&
5130 startx + font1_xoffset < text_startx + text_font_xoffset)
5131 correct_font_draw_xoffset = TRUE;
5133 if (xpos == menu_screen_value_xpos &&
5134 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5135 correct_font_draw_xoffset = TRUE;
5137 /* check if setup value would overlap with setup text when printed */
5138 /* (this can happen for extreme/wrong values for font draw offset) */
5139 if (correct_font_draw_xoffset)
5141 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5142 font_draw_xoffset_modified = TRUE;
5144 if (type & TYPE_KEY)
5145 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5146 else if (!(type & TYPE_STRING))
5147 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5148 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5152 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5153 DrawText(startx + i * font_width, starty, " ", font_nr);
5155 DrawText(startx, starty, value_string, font_nr);
5157 if (font_draw_xoffset_modified)
5158 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5161 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5163 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5164 struct TokenInfo *si = &setup_info[si_pos];
5166 if (si->type & TYPE_BOOLEAN_STYLE)
5168 *(boolean *)si->value ^= TRUE;
5170 else if (si->type & TYPE_YES_NO_AUTO)
5174 (*(int *)si->value == AUTO ? TRUE :
5175 *(int *)si->value == TRUE ? FALSE : AUTO) :
5176 (*(int *)si->value == TRUE ? AUTO :
5177 *(int *)si->value == AUTO ? FALSE : TRUE));
5179 else if (si->type & TYPE_KEY)
5183 si->type |= TYPE_QUERY;
5184 drawSetupValue(screen_pos, setup_info_pos_raw);
5185 si->type &= ~TYPE_QUERY;
5187 key = getSetupKey();
5188 if (key != KSYM_UNDEFINED)
5189 *(Key *)si->value = key;
5192 drawSetupValue(screen_pos, setup_info_pos_raw);
5194 // fullscreen state may have changed at this point
5195 if (si->value == &setup.fullscreen)
5196 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5199 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5202 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5203 struct TokenInfo *si = &setup_info[si_pos];
5204 int xpos = MENU_SCREEN_START_XPOS;
5205 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5206 int font_nr = getSetupTextFont(si->type);
5208 if (setup_info == setup_info_input)
5209 font_nr = FONT_MENU_1;
5212 font_nr = FONT_ACTIVE(font_nr);
5214 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5216 if (si->type & ~TYPE_SKIP_ENTRY)
5217 drawCursor(screen_pos, active);
5220 static void drawSetupInfoList(struct TokenInfo *setup_info,
5221 int first_entry, int num_page_entries)
5225 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5226 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5228 if (num_page_entries > max_setup_info)
5229 num_page_entries = max_setup_info;
5231 if (first_entry + num_page_entries > max_setup_info)
5234 /* clear tree list area, but not title or scrollbar */
5235 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
5236 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
5237 NUM_MENU_ENTRIES_ON_SCREEN * 32);
5239 for (i = 0; i < num_page_entries; i++)
5241 int setup_info_pos = first_entry + i;
5242 struct TokenInfo *si = &setup_info[setup_info_pos];
5243 void *value_ptr = si->value;
5245 /* set some entries to "unchangeable" according to other variables */
5246 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5247 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5248 (value_ptr == &setup.sound_music && !audio.music_available) ||
5249 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5250 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5251 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5252 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5253 si->type |= TYPE_GHOSTED;
5255 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5256 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5257 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5258 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5259 else if (si->type & ~TYPE_SKIP_ENTRY)
5260 initCursor(i, IMG_MENU_BUTTON);
5262 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5264 if (si->type & TYPE_VALUE)
5265 drawSetupValue(i, setup_info_pos);
5269 static void DrawSetupScreen_Generic()
5271 boolean redraw_all = FALSE;
5272 char *title_string = NULL;
5277 FreeScreenGadgets();
5278 CreateScreenGadgets();
5280 CloseDoor(DOOR_CLOSE_2);
5282 if (redraw_mask & REDRAW_ALL)
5285 FadeOut(REDRAW_FIELD);
5289 if (setup_mode == SETUP_MODE_MAIN)
5291 setup_info = setup_info_main;
5292 title_string = "Setup";
5294 else if (setup_mode == SETUP_MODE_GAME)
5296 setup_info = setup_info_game;
5297 title_string = "Setup Game";
5299 else if (setup_mode == SETUP_MODE_EDITOR)
5301 setup_info = setup_info_editor;
5302 title_string = "Setup Editor";
5304 else if (setup_mode == SETUP_MODE_GRAPHICS)
5306 setup_info = setup_info_graphics;
5307 title_string = "Setup Graphics";
5309 else if (setup_mode == SETUP_MODE_SOUND)
5311 setup_info = setup_info_sound;
5312 title_string = "Setup Sound";
5314 else if (setup_mode == SETUP_MODE_ARTWORK)
5316 setup_info = setup_info_artwork;
5317 title_string = "Custom Artwork";
5319 else if (setup_mode == SETUP_MODE_TOUCH)
5321 setup_info = setup_info_touch;
5322 title_string = "Setup Touch Ctrls";
5324 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5326 setup_info = setup_info_shortcuts;
5327 title_string = "Setup Shortcuts";
5329 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5331 setup_info = setup_info_shortcuts_1;
5332 title_string = "Setup Shortcuts";
5334 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5336 setup_info = setup_info_shortcuts_2;
5337 title_string = "Setup Shortcuts";
5339 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
5341 setup_info = setup_info_shortcuts_3;
5342 title_string = "Setup Shortcuts";
5344 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
5346 setup_info = setup_info_shortcuts_4;
5347 title_string = "Setup Shortcuts";
5349 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
5351 setup_info = setup_info_shortcuts_5;
5352 title_string = "Setup Shortcuts";
5355 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5357 // determine maximal number of setup entries that can be displayed on screen
5359 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5362 // determine maximal number of setup entries available for this setup screen
5364 for (i = 0; setup_info[i].type != 0; i++)
5367 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5369 MapScreenGadgets(max_setup_info);
5372 redraw_mask = REDRAW_ALL;
5374 FadeIn(redraw_mask);
5379 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5381 static int choice_store[MAX_SETUP_MODES];
5382 static int first_entry_store[MAX_SETUP_MODES];
5383 int choice = choice_store[setup_mode]; /* starts with 0 */
5384 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
5386 int y = choice - first_entry;
5388 boolean position_set_by_scrollbar = (dx == 999);
5389 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
5390 int num_page_entries;
5392 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
5394 if (button == MB_MENU_INITIALIZE)
5396 /* advance to first valid menu entry */
5397 while (choice < num_setup_info &&
5398 setup_info[choice].type & TYPE_SKIP_ENTRY)
5401 if (position_set_by_scrollbar)
5402 first_entry = first_entry_store[setup_mode] = dy;
5404 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5405 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5407 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5409 if (choice < first_entry)
5411 choice = first_entry;
5413 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5416 else if (choice > first_entry + num_page_entries - 1)
5418 choice = first_entry + num_page_entries - 1;
5420 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5424 choice_store[setup_mode] = choice;
5426 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5430 else if (button == MB_MENU_LEAVE)
5434 PlaySound(SND_MENU_ITEM_SELECTING);
5436 for (i = 0; setup_info[i].type != 0; i++)
5438 if (setup_info[i].type & TYPE_LEAVE_MENU)
5440 void (*menu_callback_function)(void) = setup_info[i].value;
5444 menu_callback_function();
5446 break; /* absolutely needed because function changes 'setup_info'! */
5453 if (mx || my) /* mouse input */
5455 x = (mx - mSX) / 32;
5456 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5458 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
5460 /* move cursor instead of scrolling when already at start/end of list */
5461 if (dy == -1 * SCROLL_LINE && first_entry == 0)
5463 else if (dy == +1 * SCROLL_LINE &&
5464 first_entry + num_page_entries == max_setup_info)
5467 /* handle scrolling screen one line or page */
5469 y + dy > num_page_entries - 1)
5471 boolean redraw = FALSE;
5473 if (ABS(dy) == SCROLL_PAGE)
5474 step = num_page_entries - 1;
5476 if (dy < 0 && first_entry > 0)
5478 /* scroll page/line up */
5480 first_entry -= step;
5481 if (first_entry < 0)
5486 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
5488 /* scroll page/line down */
5490 first_entry += step;
5491 if (first_entry + num_page_entries > max_setup_info)
5492 first_entry = MAX(0, max_setup_info - num_page_entries);
5499 choice += first_entry - first_entry_store[setup_mode];
5501 if (choice < first_entry)
5503 choice = first_entry;
5505 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5508 else if (choice > first_entry + num_page_entries - 1)
5510 choice = first_entry + num_page_entries - 1;
5512 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5515 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5519 if (choice < first_entry ||
5520 choice > first_entry + num_page_entries - 1)
5521 first_entry += SIGN(dy);
5524 first_entry_store[setup_mode] = first_entry;
5525 choice_store[setup_mode] = choice;
5527 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5529 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5531 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5532 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5540 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5542 if (setup_info[choice].type & menu_navigation_type ||
5543 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
5544 setup_info[choice].type & TYPE_YES_NO_AUTO)
5545 button = MB_MENU_CHOICE;
5550 /* jump to next non-empty menu entry (up or down) */
5551 while (first_entry + y > 0 &&
5552 first_entry + y < max_setup_info - 1 &&
5553 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
5556 if (!IN_VIS_FIELD(x, y))
5558 choice += y - y_old;
5560 if (choice < first_entry)
5561 first_entry = choice;
5562 else if (choice > first_entry + num_page_entries - 1)
5563 first_entry = choice - num_page_entries + 1;
5565 if (first_entry >= 0 &&
5566 first_entry + num_page_entries <= max_setup_info)
5568 first_entry_store[setup_mode] = first_entry;
5570 if (choice < first_entry)
5571 choice = first_entry;
5572 else if (choice > first_entry + num_page_entries - 1)
5573 choice = first_entry + num_page_entries - 1;
5575 choice_store[setup_mode] = choice;
5577 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5579 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5581 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5582 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5589 if (!anyScrollbarGadgetActive() &&
5590 IN_VIS_FIELD(x, y) &&
5591 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
5592 y >= 0 && y < num_page_entries)
5596 if (first_entry + y != choice &&
5597 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
5599 PlaySound(SND_MENU_ITEM_ACTIVATING);
5601 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
5602 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
5604 choice = choice_store[setup_mode] = first_entry + y;
5607 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
5609 PlaySound(SND_MENU_ITEM_SELECTING);
5611 /* when selecting key headline, execute function for key value change */
5612 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
5613 setup_info[first_entry + y + 1].type & TYPE_KEY)
5616 /* when selecting string value, execute function for list selection */
5617 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
5618 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
5621 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
5623 void (*menu_callback_function)(void) =
5624 setup_info[first_entry + y].value;
5626 FadeSetFromType(setup_info[first_entry + y].type);
5628 menu_callback_function();
5632 if (setup_info[first_entry + y].type & TYPE_VALUE)
5633 changeSetupValue(y, first_entry + y, dx);
5639 void DrawSetupScreen_Input()
5643 FadeOut(REDRAW_FIELD);
5647 setup_info = setup_info_input;
5649 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5651 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5652 "Joysticks deactivated on this screen");
5654 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5656 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5657 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5658 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5659 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5660 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5661 initCursor(i, IMG_MENU_BUTTON);
5663 DrawCursorAndText_Setup(i, -1, FALSE);
5666 /* create gadgets for setup input menu screen */
5667 FreeScreenGadgets();
5668 CreateScreenGadgets();
5670 /* map gadgets for setup input menu screen */
5671 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5673 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5675 FadeIn(REDRAW_FIELD);
5680 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5682 if (device_name == NULL)
5685 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5688 if (strlen(device_name) > 1)
5690 char c1 = device_name[strlen(device_name) - 1];
5691 char c2 = device_name[strlen(device_name) - 2];
5693 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5694 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5697 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5698 strlen(device_name));
5701 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5704 static struct SetupKeyboardInfo custom_key;
5711 { &custom_key.left, "Joystick Left" },
5712 { &custom_key.right, "Joystick Right" },
5713 { &custom_key.up, "Joystick Up" },
5714 { &custom_key.down, "Joystick Down" },
5715 { &custom_key.snap, "Button 1" },
5716 { &custom_key.drop, "Button 2" }
5718 static char *joystick_name[MAX_PLAYERS] =
5725 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5729 custom_key = setup.input[player_nr].key;
5731 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5732 FONT_INPUT_1_ACTIVE);
5734 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5736 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5737 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5739 if (setup.input[player_nr].use_joystick)
5741 char *device_name = setup.input[player_nr].joy.device_name;
5742 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5743 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5745 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5746 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5750 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5751 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5754 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5756 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5757 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5758 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5759 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5761 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5762 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5763 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5764 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5765 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5766 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5768 for (i = 0; i < 6; i++)
5770 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5772 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5774 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5775 (setup.input[player_nr].use_joystick ?
5777 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5781 static int input_player_nr = 0;
5783 void HandleSetupScreen_Input_Player(int step, int direction)
5785 int old_player_nr = input_player_nr;
5788 new_player_nr = old_player_nr + step * direction;
5789 if (new_player_nr < 0)
5791 if (new_player_nr > MAX_PLAYERS - 1)
5792 new_player_nr = MAX_PLAYERS - 1;
5794 if (new_player_nr != old_player_nr)
5796 input_player_nr = new_player_nr;
5798 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5802 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5804 static int choice = 0;
5807 int pos_start = SETUPINPUT_SCREEN_POS_START;
5808 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5809 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5810 int pos_end = SETUPINPUT_SCREEN_POS_END;
5812 if (button == MB_MENU_INITIALIZE)
5814 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5816 DrawCursorAndText_Setup(choice, -1, TRUE);
5820 else if (button == MB_MENU_LEAVE)
5822 setup_mode = SETUP_MODE_MAIN;
5829 if (mx || my) /* mouse input */
5831 x = (mx - mSX) / 32;
5832 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5834 else if (dx || dy) /* keyboard input */
5836 if (dx && choice == 0)
5837 x = (dx < 0 ? 10 : 12);
5838 else if ((dx && choice == 1) ||
5839 (dx == +1 && choice == 2) ||
5840 (dx == -1 && choice == pos_end))
5841 button = MB_MENU_CHOICE;
5845 if (y >= pos_empty1 && y <= pos_empty2)
5846 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5849 if (y == 0 && dx != 0 && button)
5851 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5853 else if (IN_VIS_FIELD(x, y) &&
5854 y >= pos_start && y <= pos_end &&
5855 !(y >= pos_empty1 && y <= pos_empty2))
5861 DrawCursorAndText_Setup(choice, -1, FALSE);
5862 DrawCursorAndText_Setup(y, -1, TRUE);
5864 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5873 char *device_name = setup.input[input_player_nr].joy.device_name;
5875 if (!setup.input[input_player_nr].use_joystick)
5877 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5879 setJoystickDeviceToNr(device_name, new_device_nr);
5880 setup.input[input_player_nr].use_joystick = TRUE;
5884 int device_nr = getJoystickNrFromDeviceName(device_name);
5885 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5887 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5888 setup.input[input_player_nr].use_joystick = FALSE;
5890 setJoystickDeviceToNr(device_name, new_device_nr);
5893 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5897 if (setup.input[input_player_nr].use_joystick)
5900 CalibrateJoystick(input_player_nr);
5903 CustomizeKeyboard(input_player_nr);
5905 else if (y == pos_end)
5911 setup_mode = SETUP_MODE_MAIN;
5918 void CustomizeKeyboard(int player_nr)
5922 boolean finished = FALSE;
5923 static struct SetupKeyboardInfo custom_key;
5928 } customize_step[] =
5930 { &custom_key.left, "Move Left" },
5931 { &custom_key.right, "Move Right" },
5932 { &custom_key.up, "Move Up" },
5933 { &custom_key.down, "Move Down" },
5934 { &custom_key.snap, "Snap Field" },
5935 { &custom_key.drop, "Drop Element" }
5938 /* read existing key bindings from player setup */
5939 custom_key = setup.input[player_nr].key;
5942 FadeOut(REDRAW_FIELD);
5946 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5949 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5950 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5951 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5952 "Key:", FONT_INPUT_1_ACTIVE);
5953 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5954 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5956 FadeIn(REDRAW_FIELD);
5962 if (PendingEvent()) /* got event */
5970 case EVENT_KEYPRESS:
5972 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5974 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5976 if (key == KSYM_Escape)
5977 FadeSkipNextFadeIn();
5983 /* all keys configured -- wait for "Escape" or "Return" key */
5987 /* press 'Enter' to keep the existing key binding */
5988 if (key == KSYM_Return)
5989 key = *customize_step[step_nr].key;
5991 /* check if key already used */
5992 for (i = 0; i < step_nr; i++)
5993 if (*customize_step[i].key == key)
5998 /* got new key binding */
5999 *customize_step[step_nr].key = key;
6000 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6002 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6003 getKeyNameFromKey(key), FONT_VALUE_1);
6006 /* un-highlight last query */
6007 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6008 customize_step[step_nr - 1].text, FONT_MENU_1);
6009 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6010 "Key:", FONT_MENU_1);
6012 /* press 'Enter' to leave */
6015 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6016 "Press Enter", FONT_TITLE_1);
6020 /* query next key binding */
6021 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6022 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6023 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6024 "Key:", FONT_INPUT_1_ACTIVE);
6025 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6026 getKeyNameFromKey(*customize_step[step_nr].key),
6031 case EVENT_KEYRELEASE:
6032 key_joystick_mapping = 0;
6036 HandleOtherEvents(&event);
6044 /* don't eat all CPU time */
6048 /* write new key bindings back to player setup */
6049 setup.input[player_nr].key = custom_key;
6052 DrawSetupScreen_Input();
6055 static boolean CalibrateJoystickMain(int player_nr)
6057 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6058 int new_joystick_xright = JOYSTICK_XMIDDLE;
6059 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6060 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6061 int new_joystick_xmiddle, new_joystick_ymiddle;
6063 int joystick_fd = joystick.fd[player_nr];
6064 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6065 boolean check[3][3];
6066 int check_remaining = 3 * 3;
6071 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6074 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6078 FadeOut(REDRAW_FIELD);
6082 for (y = 0; y < 3; y++)
6084 for (x = 0; x < 3; x++)
6086 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6087 check[x][y] = FALSE;
6091 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6092 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6093 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6094 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6095 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6096 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6097 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6099 joy_value = Joystick(player_nr);
6100 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6101 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6103 /* eventually uncalibrated center position (joystick could be uncentered) */
6104 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6107 new_joystick_xmiddle = joy_x;
6108 new_joystick_ymiddle = joy_y;
6110 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6112 FadeIn(REDRAW_FIELD);
6114 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6119 if (PendingEvent()) /* got event */
6127 case EVENT_KEYPRESS:
6128 switch (GetEventKey((KeyEvent *)&event, TRUE))
6131 if (check_remaining == 0)
6136 FadeSkipNextFadeIn();
6145 case EVENT_KEYRELEASE:
6146 key_joystick_mapping = 0;
6150 HandleOtherEvents(&event);
6155 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6158 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
6159 new_joystick_xright = MAX(new_joystick_xright, joy_x);
6160 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
6161 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
6163 setup.input[player_nr].joy.xleft = new_joystick_xleft;
6164 setup.input[player_nr].joy.yupper = new_joystick_yupper;
6165 setup.input[player_nr].joy.xright = new_joystick_xright;
6166 setup.input[player_nr].joy.ylower = new_joystick_ylower;
6167 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
6168 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
6170 CheckJoystickData();
6172 joy_value = Joystick(player_nr);
6174 if (joy_value & JOY_BUTTON && check_remaining == 0)
6177 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6178 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6180 if (x != last_x || y != last_y)
6182 DrawFixedGraphic(xpos + last_x, ypos + last_y,
6183 IMG_MENU_CALIBRATE_YELLOW, 0);
6184 DrawFixedGraphic(xpos + x, ypos + y,
6185 IMG_MENU_CALIBRATE_RED, 0);
6190 if (check_remaining > 0 && !check[x+1][y+1])
6192 check[x+1][y+1] = TRUE;
6200 /* don't eat all CPU time */
6204 /* calibrated center position (joystick should now be centered) */
6205 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6208 new_joystick_xmiddle = joy_x;
6209 new_joystick_ymiddle = joy_y;
6213 /* wait until the last pressed button was released */
6214 while (Joystick(player_nr) & JOY_BUTTON)
6216 if (PendingEvent()) /* got event */
6221 HandleOtherEvents(&event);
6230 void CalibrateJoystick(int player_nr)
6232 if (!CalibrateJoystickMain(player_nr))
6234 char *device_name = setup.input[player_nr].joy.device_name;
6235 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6236 int xpos = mSX - SX;
6237 int ypos = mSY - SY;
6241 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6242 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
6245 Delay(2000); /* show error message for a short time */
6250 DrawSetupScreen_Input();
6253 void DrawSetupScreen()
6255 DeactivateJoystick();
6257 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6259 if (setup_mode == SETUP_MODE_INPUT)
6260 DrawSetupScreen_Input();
6261 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6262 DrawChooseTree(&game_speed_current);
6263 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6264 DrawChooseTree(&scroll_delay_current);
6265 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6266 DrawChooseTree(&screen_mode_current);
6267 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6268 DrawChooseTree(&window_size_current);
6269 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6270 DrawChooseTree(&scaling_type_current);
6271 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6272 DrawChooseTree(&artwork.gfx_current);
6273 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6274 DrawChooseTree(&artwork.snd_current);
6275 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6276 DrawChooseTree(&artwork.mus_current);
6277 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6278 DrawChooseTree(&volume_simple_current);
6279 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6280 DrawChooseTree(&volume_loops_current);
6281 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6282 DrawChooseTree(&volume_music_current);
6283 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6284 DrawChooseTree(&touch_control_current);
6285 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6286 DrawChooseTree(&move_distance_current);
6287 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6288 DrawChooseTree(&drop_distance_current);
6290 DrawSetupScreen_Generic();
6296 void RedrawSetupScreenAfterFullscreenToggle()
6298 if (setup_mode == SETUP_MODE_GRAPHICS ||
6299 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6301 // update list selection from "setup.window_scaling_percent"
6302 execSetupGraphics_setWindowSizes(TRUE);
6308 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
6310 if (setup_mode == SETUP_MODE_INPUT)
6311 HandleSetupScreen_Input(mx, my, dx, dy, button);
6312 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6313 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
6314 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6315 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
6316 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6317 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
6318 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6319 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
6320 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6321 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
6322 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6323 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
6324 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6325 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
6326 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6327 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
6328 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6329 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
6330 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6331 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
6332 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6333 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
6334 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6335 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
6336 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6337 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
6338 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6339 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
6341 HandleSetupScreen_Generic(mx, my, dx, dy, button);
6344 void HandleGameActions()
6346 if (game_status != GAME_MODE_PLAYING)
6349 GameActions(); /* main game loop */
6351 if (tape.auto_play && !tape.playing)
6352 AutoPlayTape(); /* continue automatically playing next tape */
6356 /* ---------- new screen button stuff -------------------------------------- */
6358 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6362 case SCREEN_CTRL_ID_PREV_LEVEL:
6363 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
6364 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
6367 case SCREEN_CTRL_ID_NEXT_LEVEL:
6368 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
6369 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
6372 case SCREEN_CTRL_ID_PREV_PLAYER:
6373 *x = mSX + TILEX * 10;
6374 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6377 case SCREEN_CTRL_ID_NEXT_PLAYER:
6378 *x = mSX + TILEX * 12;
6379 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6383 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6389 int gfx_unpressed, gfx_pressed;
6390 void (*get_gadget_position)(int *, int *, int);
6394 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6397 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6398 getScreenMenuButtonPos,
6399 SCREEN_CTRL_ID_PREV_LEVEL,
6404 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6405 getScreenMenuButtonPos,
6406 SCREEN_CTRL_ID_NEXT_LEVEL,
6411 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6412 getScreenMenuButtonPos,
6413 SCREEN_CTRL_ID_PREV_PLAYER,
6418 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6419 getScreenMenuButtonPos,
6420 SCREEN_CTRL_ID_NEXT_PLAYER,
6428 int gfx_unpressed, gfx_pressed;
6432 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6435 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6436 -1, -1, /* these values are not constant, but can change at runtime */
6437 SCREEN_CTRL_ID_SCROLL_UP,
6441 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6442 -1, -1, /* these values are not constant, but can change at runtime */
6443 SCREEN_CTRL_ID_SCROLL_DOWN,
6450 int gfx_unpressed, gfx_pressed;
6456 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6459 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6460 -1, -1, /* these values are not constant, but can change at runtime */
6461 -1, -1, /* these values are not constant, but can change at runtime */
6462 GD_TYPE_SCROLLBAR_VERTICAL,
6463 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6464 "scroll level series vertically"
6468 static void CreateScreenMenubuttons()
6470 struct GadgetInfo *gi;
6471 unsigned int event_mask;
6474 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6476 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6477 int gfx_unpressed, gfx_pressed;
6478 int x, y, width, height;
6479 int gd_x1, gd_x2, gd_y1, gd_y2;
6480 int id = menubutton_info[i].gadget_id;
6482 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6484 menubutton_info[i].get_gadget_position(&x, &y, id);
6486 width = SC_MENUBUTTON_XSIZE;
6487 height = SC_MENUBUTTON_YSIZE;
6489 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6490 gfx_pressed = menubutton_info[i].gfx_pressed;
6491 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6492 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6493 gd_x1 = graphic_info[gfx_unpressed].src_x;
6494 gd_y1 = graphic_info[gfx_unpressed].src_y;
6495 gd_x2 = graphic_info[gfx_pressed].src_x;
6496 gd_y2 = graphic_info[gfx_pressed].src_y;
6498 gi = CreateGadget(GDI_CUSTOM_ID, id,
6499 GDI_CUSTOM_TYPE_ID, i,
6500 GDI_INFO_TEXT, menubutton_info[i].infotext,
6505 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6506 GDI_STATE, GD_BUTTON_UNPRESSED,
6507 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6508 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6509 GDI_DIRECT_DRAW, FALSE,
6510 GDI_EVENT_MASK, event_mask,
6511 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6515 Error(ERR_EXIT, "cannot create gadget");
6517 screen_gadget[id] = gi;
6521 static void CreateScreenScrollbuttons()
6523 struct GadgetInfo *gi;
6524 unsigned int event_mask;
6527 /* these values are not constant, but can change at runtime */
6528 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
6529 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
6530 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
6531 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
6533 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6535 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6536 int gfx_unpressed, gfx_pressed;
6537 int x, y, width, height;
6538 int gd_x1, gd_x2, gd_y1, gd_y2;
6539 int id = scrollbutton_info[i].gadget_id;
6541 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6543 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6544 y = mSY + scrollbutton_info[i].y;
6545 width = SC_SCROLLBUTTON_XSIZE;
6546 height = SC_SCROLLBUTTON_YSIZE;
6548 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6549 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6550 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6552 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6553 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6554 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6555 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6556 gd_x1 = graphic_info[gfx_unpressed].src_x;
6557 gd_y1 = graphic_info[gfx_unpressed].src_y;
6558 gd_x2 = graphic_info[gfx_pressed].src_x;
6559 gd_y2 = graphic_info[gfx_pressed].src_y;
6561 gi = CreateGadget(GDI_CUSTOM_ID, id,
6562 GDI_CUSTOM_TYPE_ID, i,
6563 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6568 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6569 GDI_STATE, GD_BUTTON_UNPRESSED,
6570 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6571 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6572 GDI_DIRECT_DRAW, FALSE,
6573 GDI_EVENT_MASK, event_mask,
6574 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6578 Error(ERR_EXIT, "cannot create gadget");
6580 screen_gadget[id] = gi;
6584 static void CreateScreenScrollbars()
6588 /* these values are not constant, but can change at runtime */
6589 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
6590 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
6591 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
6592 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
6594 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6596 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6597 int gfx_unpressed, gfx_pressed;
6598 int x, y, width, height;
6599 int gd_x1, gd_x2, gd_y1, gd_y2;
6600 struct GadgetInfo *gi;
6601 int items_max, items_visible, item_position;
6602 unsigned int event_mask;
6603 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6604 int id = scrollbar_info[i].gadget_id;
6606 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6608 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6609 y = mSY + scrollbar_info[i].y;
6610 width = scrollbar_info[i].width;
6611 height = scrollbar_info[i].height;
6613 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6614 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6616 items_max = num_page_entries;
6617 items_visible = num_page_entries;
6620 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6621 gfx_pressed = scrollbar_info[i].gfx_pressed;
6622 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6623 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6624 gd_x1 = graphic_info[gfx_unpressed].src_x;
6625 gd_y1 = graphic_info[gfx_unpressed].src_y;
6626 gd_x2 = graphic_info[gfx_pressed].src_x;
6627 gd_y2 = graphic_info[gfx_pressed].src_y;
6629 gi = CreateGadget(GDI_CUSTOM_ID, id,
6630 GDI_CUSTOM_TYPE_ID, i,
6631 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6636 GDI_TYPE, scrollbar_info[i].type,
6637 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6638 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6639 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6640 GDI_WHEEL_AREA_X, SX,
6641 GDI_WHEEL_AREA_Y, SY,
6642 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6643 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6644 GDI_STATE, GD_BUTTON_UNPRESSED,
6645 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6646 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6647 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6648 GDI_DIRECT_DRAW, FALSE,
6649 GDI_EVENT_MASK, event_mask,
6650 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6654 Error(ERR_EXIT, "cannot create gadget");
6656 screen_gadget[id] = gi;
6660 void CreateScreenGadgets()
6662 int last_game_status = game_status; /* save current game status */
6664 CreateScreenMenubuttons();
6666 CreateScreenScrollbuttons();
6667 CreateScreenScrollbars();
6669 game_status = last_game_status; /* restore current game status */
6672 void FreeScreenGadgets()
6676 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6677 FreeGadget(screen_gadget[i]);
6680 void MapScreenMenuGadgets(int screen_mask)
6684 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6685 if (screen_mask & menubutton_info[i].screen_mask)
6686 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6689 void MapScreenGadgets(int num_entries)
6693 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6696 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6697 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6699 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6700 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6703 void MapScreenTreeGadgets(TreeInfo *ti)
6705 MapScreenGadgets(numTreeInfoInGroup(ti));
6708 static void HandleScreenGadgets(struct GadgetInfo *gi)
6710 int id = gi->custom_id;
6711 int button = gi->event.button;
6712 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6716 case SCREEN_CTRL_ID_PREV_LEVEL:
6717 HandleMainMenu_SelectLevel(step, -1);
6720 case SCREEN_CTRL_ID_NEXT_LEVEL:
6721 HandleMainMenu_SelectLevel(step, +1);
6724 case SCREEN_CTRL_ID_PREV_PLAYER:
6725 HandleSetupScreen_Input_Player(step, -1);
6728 case SCREEN_CTRL_ID_NEXT_PLAYER:
6729 HandleSetupScreen_Input_Player(step, +1);
6732 case SCREEN_CTRL_ID_SCROLL_UP:
6733 if (game_status == GAME_MODE_LEVELS)
6734 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6735 else if (game_status == GAME_MODE_LEVELNR)
6736 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6737 else if (game_status == GAME_MODE_SETUP)
6738 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6741 case SCREEN_CTRL_ID_SCROLL_DOWN:
6742 if (game_status == GAME_MODE_LEVELS)
6743 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6744 else if (game_status == GAME_MODE_LEVELNR)
6745 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6746 else if (game_status == GAME_MODE_SETUP)
6747 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6750 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6751 if (game_status == GAME_MODE_LEVELS)
6752 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6753 else if (game_status == GAME_MODE_LEVELNR)
6754 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6755 else if (game_status == GAME_MODE_SETUP)
6756 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);