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 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3165 setup.player_name[xpos] = key_char;
3166 setup.player_name[xpos + 1] = 0;
3170 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3174 setup.player_name[xpos] = 0;
3176 else if (key == KSYM_Return && xpos > 0)
3182 game_status = GAME_MODE_MAIN;
3184 else if (key == KSYM_Escape)
3186 strcpy(setup.player_name, last_player_name);
3190 game_status = GAME_MODE_MAIN;
3195 pos->width = (strlen(setup.player_name) + 1) * font_width;
3196 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3198 DrawText(startx, starty, setup.player_name, font_active_nr);
3199 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3203 pos->width = strlen(setup.player_name) * font_width;
3204 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3206 DrawText(startx, starty, setup.player_name, font_nr);
3211 /* ========================================================================= */
3212 /* tree menu functions */
3213 /* ========================================================================= */
3215 static void DrawChooseTree(TreeInfo **ti_ptr)
3219 FreeScreenGadgets();
3220 CreateScreenGadgets();
3222 CloseDoor(DOOR_CLOSE_2);
3224 FadeOut(REDRAW_FIELD);
3228 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3229 MapScreenTreeGadgets(*ti_ptr);
3231 FadeIn(REDRAW_FIELD);
3236 static void AdjustScrollbar(int id, int items_max, int items_visible,
3239 struct GadgetInfo *gi = screen_gadget[id];
3241 if (item_position > items_max - items_visible)
3242 item_position = items_max - items_visible;
3244 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3245 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3246 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3249 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3251 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3255 static void drawChooseTreeList(int first_entry, int num_page_entries,
3259 char *title_string = NULL;
3260 int yoffset_sets = MENU_TITLE1_YPOS;
3261 int yoffset_setup = 16;
3262 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3263 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3264 int last_game_status = game_status; /* save current game status */
3266 title_string = ti->infotext;
3268 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3270 /* clear tree list area, but not title or scrollbar */
3271 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3272 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3273 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3275 for (i = 0; i < num_page_entries; i++)
3277 TreeInfo *node, *node_first;
3278 int entry_pos = first_entry + i;
3279 int xpos = MENU_SCREEN_START_XPOS;
3280 int ypos = MENU_SCREEN_START_YPOS + i;
3281 int startx = mSX + xpos * 32;
3282 int starty = mSY + ypos * 32;
3283 int font_nr = FONT_TEXT_1;
3284 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3285 int startx_text = startx + font_xoffset;
3286 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3287 int text_size = startx_scrollbar - startx_text;
3288 int max_buffer_len = text_size / getFontWidth(font_nr);
3289 char buffer[max_buffer_len + 1];
3291 node_first = getTreeInfoFirstGroupEntry(ti);
3292 node = getTreeInfoFromPos(node_first, entry_pos);
3294 strncpy(buffer, node->name, max_buffer_len);
3295 buffer[max_buffer_len] = '\0';
3297 DrawText(startx, starty, buffer, font_nr + node->color);
3299 if (node->parent_link)
3300 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3301 else if (node->level_group)
3302 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3304 initCursor(i, IMG_MENU_BUTTON);
3307 game_status = last_game_status; /* restore current game status */
3309 redraw_mask |= REDRAW_FIELD;
3312 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3314 TreeInfo *node, *node_first;
3315 int x, last_redraw_mask = redraw_mask;
3316 int ypos = MENU_TITLE2_YPOS;
3317 int font_nr = FONT_TITLE_2;
3319 if (ti->type == TREE_TYPE_LEVEL_NR)
3320 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3322 if (ti->type != TREE_TYPE_LEVEL_DIR)
3325 node_first = getTreeInfoFirstGroupEntry(ti);
3326 node = getTreeInfoFromPos(node_first, entry_pos);
3328 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3330 if (node->parent_link)
3331 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3332 node->node_parent->name);
3333 else if (node->level_group)
3334 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3336 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3337 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3338 node->levels, (node->levels > 1 ? "levels" : "level"),
3341 /* let BackToFront() redraw only what is needed */
3342 redraw_mask = last_redraw_mask | REDRAW_TILES;
3343 for (x = 0; x < SCR_FIELDX; x++)
3344 MarkTileDirty(x, 1);
3347 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3350 TreeInfo *ti = *ti_ptr;
3352 int y = ti->cl_cursor;
3353 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3354 int num_entries = numTreeInfoInGroup(ti);
3355 int num_page_entries;
3356 int last_game_status = game_status; /* save current game status */
3357 boolean position_set_by_scrollbar = (dx == 999);
3359 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3360 num_page_entries = num_entries;
3362 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3364 game_status = last_game_status; /* restore current game status */
3366 if (button == MB_MENU_INITIALIZE)
3368 int num_entries = numTreeInfoInGroup(ti);
3369 int entry_pos = posTreeInfo(ti);
3371 if (ti->cl_first == -1)
3373 /* only on initialization */
3374 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3375 ti->cl_cursor = entry_pos - ti->cl_first;
3377 else if (ti->cl_cursor >= num_page_entries ||
3378 (num_entries > num_page_entries &&
3379 num_entries - ti->cl_first < num_page_entries))
3381 /* only after change of list size (by custom graphic configuration) */
3382 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3383 ti->cl_cursor = entry_pos - ti->cl_first;
3386 if (position_set_by_scrollbar)
3389 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3392 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3393 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3394 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3398 else if (button == MB_MENU_LEAVE)
3402 PlaySound(SND_MENU_ITEM_SELECTING);
3404 if (ti->node_parent)
3406 *ti_ptr = ti->node_parent;
3407 DrawChooseTree(ti_ptr);
3409 else if (game_status == GAME_MODE_SETUP)
3411 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3412 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3414 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3415 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3416 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3417 execSetupGraphics();
3418 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3419 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3420 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3422 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3423 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3424 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3431 if (game_status == GAME_MODE_LEVELNR)
3432 level_nr = atoi(level_number_current->identifier);
3434 game_status = GAME_MODE_MAIN;
3436 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3442 if (mx || my) /* mouse input */
3444 int last_game_status = game_status; /* save current game status */
3446 x = (mx - mSX) / 32;
3447 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3449 game_status = last_game_status; /* restore current game status */
3451 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3453 /* move cursor instead of scrolling when already at start/end of list */
3454 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3456 else if (dy == +1 * SCROLL_LINE &&
3457 ti->cl_first + num_page_entries == num_entries)
3460 /* handle scrolling screen one line or page */
3461 if (ti->cl_cursor + dy < 0 ||
3462 ti->cl_cursor + dy > num_page_entries - 1)
3464 boolean redraw = FALSE;
3466 if (ABS(dy) == SCROLL_PAGE)
3467 step = num_page_entries - 1;
3469 if (dy < 0 && ti->cl_first > 0)
3471 /* scroll page/line up */
3473 ti->cl_first -= step;
3474 if (ti->cl_first < 0)
3479 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3481 /* scroll page/line down */
3483 ti->cl_first += step;
3484 if (ti->cl_first + num_page_entries > num_entries)
3485 ti->cl_first = MAX(0, num_entries - num_page_entries);
3492 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3493 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3494 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3496 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3504 /* handle moving cursor one line */
3505 y = ti->cl_cursor + dy;
3510 TreeInfo *node_first, *node_cursor;
3511 int entry_pos = ti->cl_first + y;
3513 node_first = getTreeInfoFirstGroupEntry(ti);
3514 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3516 if (node_cursor->node_group)
3520 PlaySound(SND_MENU_ITEM_SELECTING);
3522 node_cursor->cl_first = ti->cl_first;
3523 node_cursor->cl_cursor = ti->cl_cursor;
3524 *ti_ptr = node_cursor->node_group;
3525 DrawChooseTree(ti_ptr);
3530 else if (dx == -1 && ti->node_parent)
3534 PlaySound(SND_MENU_ITEM_SELECTING);
3536 *ti_ptr = ti->node_parent;
3537 DrawChooseTree(ti_ptr);
3542 if (!anyScrollbarGadgetActive() &&
3543 IN_VIS_FIELD(x, y) &&
3544 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3545 y >= 0 && y < num_page_entries)
3549 if (y != ti->cl_cursor)
3551 PlaySound(SND_MENU_ITEM_ACTIVATING);
3553 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3554 drawChooseTreeCursor(y, TRUE);
3555 drawChooseTreeInfo(ti->cl_first + y, ti);
3562 TreeInfo *node_first, *node_cursor;
3563 int entry_pos = ti->cl_first + y;
3565 PlaySound(SND_MENU_ITEM_SELECTING);
3567 node_first = getTreeInfoFirstGroupEntry(ti);
3568 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3570 if (node_cursor->node_group)
3574 node_cursor->cl_first = ti->cl_first;
3575 node_cursor->cl_cursor = ti->cl_cursor;
3576 *ti_ptr = node_cursor->node_group;
3577 DrawChooseTree(ti_ptr);
3579 else if (node_cursor->parent_link)
3583 *ti_ptr = node_cursor->node_parent;
3584 DrawChooseTree(ti_ptr);
3590 node_cursor->cl_first = ti->cl_first;
3591 node_cursor->cl_cursor = ti->cl_cursor;
3592 *ti_ptr = node_cursor;
3594 if (ti->type == TREE_TYPE_LEVEL_DIR)
3596 LoadLevelSetup_SeriesInfo();
3598 SaveLevelSetup_LastSeries();
3599 SaveLevelSetup_SeriesInfo();
3603 if (game_status == GAME_MODE_SETUP)
3605 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3606 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3608 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3609 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3610 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3611 execSetupGraphics();
3612 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3613 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3614 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3616 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3617 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3618 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3625 if (game_status == GAME_MODE_LEVELNR)
3626 level_nr = atoi(level_number_current->identifier);
3628 game_status = GAME_MODE_MAIN;
3637 void DrawChooseLevelSet()
3639 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3641 DrawChooseTree(&leveldir_current);
3647 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
3649 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
3652 void DrawChooseLevelNr()
3656 if (level_number != NULL)
3658 freeTreeInfo(level_number);
3660 level_number = NULL;
3663 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
3665 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
3666 char identifier[32], name[32];
3669 /* temporarily load level info to get level name */
3670 LoadLevelInfoOnly(i);
3672 ti->node_top = &level_number;
3673 ti->sort_priority = 10000 + value;
3674 ti->color = (level.no_valid_file ? FC_BLUE :
3675 LevelStats_getSolved(i) ? FC_GREEN :
3676 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
3678 sprintf(identifier, "%d", value);
3679 sprintf(name, "%03d: %s", value,
3680 (level.no_valid_file ? "(no file)" : level.name));
3682 setString(&ti->identifier, identifier);
3683 setString(&ti->name, name);
3684 setString(&ti->name_sorting, name);
3686 pushTreeInfo(&level_number, ti);
3689 /* sort level number values to start with lowest level number */
3690 sortTreeInfo(&level_number);
3692 /* set current level number to current level number */
3693 level_number_current =
3694 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
3696 /* if that also fails, set current level number to first available level */
3697 if (level_number_current == NULL)
3698 level_number_current = level_number;
3700 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3702 DrawChooseTree(&level_number_current);
3708 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
3710 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
3713 void DrawHallOfFame(int highlight_position)
3716 FadeSoundsAndMusic();
3718 /* (this is needed when called from GameEnd() after winning a game) */
3719 KeyboardAutoRepeatOn();
3722 /* (this is needed when called from GameEnd() after winning a game) */
3723 SetDrawDeactivationMask(REDRAW_NONE);
3724 SetDrawBackgroundMask(REDRAW_FIELD);
3726 CloseDoor(DOOR_CLOSE_2);
3728 if (highlight_position < 0)
3729 LoadScore(level_nr);
3731 FadeSetEnterScreen();
3733 FadeOut(REDRAW_FIELD);
3740 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
3742 FadeIn(REDRAW_FIELD);
3745 static void drawHallOfFameList(int first_entry, int highlight_position)
3749 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
3752 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
3753 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
3754 "HighScores of Level %d", level_nr);
3756 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
3758 int entry = first_entry + i;
3759 boolean active = (entry == highlight_position);
3760 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
3761 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
3762 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
3763 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
3764 int dx1 = 3 * getFontWidth(font_nr1);
3765 int dx2 = dx1 + getFontWidth(font_nr1);
3766 int dx3 = SXSIZE - 5 * getFontWidth(font_nr4);
3767 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
3768 int sy = mSY + 64 + i * 32;
3770 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
3771 DrawText(mSX + dx1, sy, ".", font_nr1);
3773 for (j = 0; j < num_dots; j++)
3774 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
3776 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
3777 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
3779 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
3782 redraw_mask |= REDRAW_FIELD;
3785 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
3787 static int first_entry = 0;
3788 static int highlight_position = 0;
3789 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3791 if (button == MB_MENU_INITIALIZE)
3794 highlight_position = mx;
3795 drawHallOfFameList(first_entry, highlight_position);
3800 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
3801 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
3805 if (first_entry > 0)
3807 first_entry -= step;
3808 if (first_entry < 0)
3811 drawHallOfFameList(first_entry, highlight_position);
3816 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
3818 first_entry += step;
3819 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
3820 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
3822 drawHallOfFameList(first_entry, highlight_position);
3825 else if (button == MB_MENU_LEAVE)
3827 PlaySound(SND_MENU_ITEM_SELECTING);
3829 FadeSound(SND_BACKGROUND_SCORES);
3831 game_status = GAME_MODE_MAIN;
3835 else if (button == MB_MENU_CHOICE)
3837 PlaySound(SND_MENU_ITEM_SELECTING);
3839 FadeSound(SND_BACKGROUND_SCORES);
3841 game_status = GAME_MODE_MAIN;
3843 DrawAndFadeInMainMenu(REDRAW_FIELD);
3846 if (game_status == GAME_MODE_SCORES)
3847 PlayMenuSoundIfLoop();
3851 /* ========================================================================= */
3852 /* setup screen functions */
3853 /* ========================================================================= */
3855 static struct TokenInfo *setup_info;
3856 static int num_setup_info; /* number of setup entries shown on screen */
3857 static int max_setup_info; /* total number of setup entries in list */
3859 static char *screen_mode_text;
3860 static char *window_size_text;
3861 static char *scaling_type_text;
3862 static char *scroll_delay_text;
3863 static char *game_speed_text;
3864 static char *graphics_set_name;
3865 static char *sounds_set_name;
3866 static char *music_set_name;
3867 static char *volume_simple_text;
3868 static char *volume_loops_text;
3869 static char *volume_music_text;
3870 static char *touch_controls_text;
3871 static char *move_distance_text;
3872 static char *drop_distance_text;
3874 static void execSetupMain()
3876 setup_mode = SETUP_MODE_MAIN;
3881 static void execSetupGame_setGameSpeeds()
3883 if (game_speeds == NULL)
3887 for (i = 0; game_speeds_list[i].value != -1; i++)
3889 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3890 char identifier[32], name[32];
3891 int value = game_speeds_list[i].value;
3892 char *text = game_speeds_list[i].text;
3894 ti->node_top = &game_speeds;
3895 ti->sort_priority = 10000 - value;
3897 sprintf(identifier, "%d", value);
3898 sprintf(name, "%s", text);
3900 setString(&ti->identifier, identifier);
3901 setString(&ti->name, name);
3902 setString(&ti->name_sorting, name);
3903 setString(&ti->infotext, "Game Speed");
3905 pushTreeInfo(&game_speeds, ti);
3908 /* sort game speed values to start with slowest game speed */
3909 sortTreeInfo(&game_speeds);
3911 /* set current game speed to configured game speed value */
3912 game_speed_current =
3913 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
3915 /* if that fails, set current game speed to reliable default value */
3916 if (game_speed_current == NULL)
3917 game_speed_current =
3918 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
3920 /* if that also fails, set current game speed to first available speed */
3921 if (game_speed_current == NULL)
3922 game_speed_current = game_speeds;
3925 setup.game_frame_delay = atoi(game_speed_current->identifier);
3927 /* needed for displaying game speed text instead of identifier */
3928 game_speed_text = game_speed_current->name;
3931 static void execSetupGame_setScrollDelays()
3933 if (scroll_delays == NULL)
3937 for (i = 0; scroll_delays_list[i].value != -1; i++)
3939 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3940 char identifier[32], name[32];
3941 int value = scroll_delays_list[i].value;
3942 char *text = scroll_delays_list[i].text;
3944 ti->node_top = &scroll_delays;
3945 ti->sort_priority = value;
3947 sprintf(identifier, "%d", value);
3948 sprintf(name, "%s", text);
3950 setString(&ti->identifier, identifier);
3951 setString(&ti->name, name);
3952 setString(&ti->name_sorting, name);
3953 setString(&ti->infotext, "Scaling Type");
3955 pushTreeInfo(&scroll_delays, ti);
3958 /* sort scaling type values to start with lowest scaling type value */
3959 sortTreeInfo(&scroll_delays);
3961 /* set current scaling type value to configured scaling type value */
3962 scroll_delay_current =
3963 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
3965 /* if that fails, set current scaling type to reliable default value */
3966 if (scroll_delay_current == NULL)
3967 scroll_delay_current =
3968 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
3970 /* if that also fails, set current scaling type to first available value */
3971 if (scroll_delay_current == NULL)
3972 scroll_delay_current = scroll_delays;
3975 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
3977 /* needed for displaying scaling type text instead of identifier */
3978 scroll_delay_text = scroll_delay_current->name;
3981 static void execSetupGame()
3983 execSetupGame_setGameSpeeds();
3984 execSetupGame_setScrollDelays();
3986 setup_mode = SETUP_MODE_GAME;
3991 static void execSetupChooseGameSpeed()
3993 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
3998 static void execSetupChooseScrollDelay()
4000 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4005 static void execSetupEditor()
4007 setup_mode = SETUP_MODE_EDITOR;
4012 static void execSetupGraphics_setWindowSizes(boolean update_list)
4014 if (window_sizes != NULL && update_list)
4016 freeTreeInfo(window_sizes);
4018 window_sizes = NULL;
4021 if (window_sizes == NULL)
4023 boolean current_window_size_found = FALSE;
4026 for (i = 0; window_sizes_list[i].value != -1; i++)
4028 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4029 char identifier[32], name[32];
4030 int value = window_sizes_list[i].value;
4031 char *text = window_sizes_list[i].text;
4033 ti->node_top = &window_sizes;
4034 ti->sort_priority = value;
4036 sprintf(identifier, "%d", value);
4037 sprintf(name, "%s", text);
4039 setString(&ti->identifier, identifier);
4040 setString(&ti->name, name);
4041 setString(&ti->name_sorting, name);
4042 setString(&ti->infotext, "Window Scaling");
4044 pushTreeInfo(&window_sizes, ti);
4046 if (value == setup.window_scaling_percent)
4047 current_window_size_found = TRUE;
4050 if (!current_window_size_found)
4052 // add entry for non-preset window scaling value
4054 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4055 char identifier[32], name[32];
4056 int value = setup.window_scaling_percent;
4058 ti->node_top = &window_sizes;
4059 ti->sort_priority = value;
4061 sprintf(identifier, "%d", value);
4062 sprintf(name, "%d %% (Current)", value);
4064 setString(&ti->identifier, identifier);
4065 setString(&ti->name, name);
4066 setString(&ti->name_sorting, name);
4067 setString(&ti->infotext, "Window Scaling");
4069 pushTreeInfo(&window_sizes, ti);
4072 /* sort window size values to start with lowest window size value */
4073 sortTreeInfo(&window_sizes);
4075 /* set current window size value to configured window size value */
4076 window_size_current =
4077 getTreeInfoFromIdentifier(window_sizes,
4078 i_to_a(setup.window_scaling_percent));
4080 /* if that fails, set current window size to reliable default value */
4081 if (window_size_current == NULL)
4082 window_size_current =
4083 getTreeInfoFromIdentifier(window_sizes,
4084 i_to_a(STD_WINDOW_SCALING_PERCENT));
4086 /* if that also fails, set current window size to first available value */
4087 if (window_size_current == NULL)
4088 window_size_current = window_sizes;
4091 setup.window_scaling_percent = atoi(window_size_current->identifier);
4093 /* needed for displaying window size text instead of identifier */
4094 window_size_text = window_size_current->name;
4097 static void execSetupGraphics_setScalingTypes()
4099 if (scaling_types == NULL)
4103 for (i = 0; scaling_types_list[i].value != NULL; i++)
4105 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4106 char identifier[32], name[32];
4107 char *value = scaling_types_list[i].value;
4108 char *text = scaling_types_list[i].text;
4110 ti->node_top = &scaling_types;
4111 ti->sort_priority = i;
4113 sprintf(identifier, "%s", value);
4114 sprintf(name, "%s", text);
4116 setString(&ti->identifier, identifier);
4117 setString(&ti->name, name);
4118 setString(&ti->name_sorting, name);
4119 setString(&ti->infotext, "Anti-Aliasing");
4121 pushTreeInfo(&scaling_types, ti);
4124 /* sort scaling type values to start with lowest scaling type value */
4125 sortTreeInfo(&scaling_types);
4127 /* set current scaling type value to configured scaling type value */
4128 scaling_type_current =
4129 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4131 /* if that fails, set current scaling type to reliable default value */
4132 if (scaling_type_current == NULL)
4133 scaling_type_current =
4134 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4136 /* if that also fails, set current scaling type to first available value */
4137 if (scaling_type_current == NULL)
4138 scaling_type_current = scaling_types;
4141 setup.window_scaling_quality = scaling_type_current->identifier;
4143 /* needed for displaying scaling type text instead of identifier */
4144 scaling_type_text = scaling_type_current->name;
4147 static void execSetupGraphics_setScreenModes()
4149 // if (screen_modes == NULL && video.fullscreen_available)
4150 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4154 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4156 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4157 char identifier[32], name[32];
4158 int x = video.fullscreen_modes[i].width;
4159 int y = video.fullscreen_modes[i].height;
4162 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4164 ti->node_top = &screen_modes;
4165 ti->sort_priority = x * 10000 + y;
4167 sprintf(identifier, "%dx%d", x, y);
4168 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4170 setString(&ti->identifier, identifier);
4171 setString(&ti->name, name);
4172 setString(&ti->name_sorting, name);
4173 setString(&ti->infotext, "Fullscreen Mode");
4175 pushTreeInfo(&screen_modes, ti);
4178 /* sort fullscreen modes to start with lowest available screen resolution */
4179 sortTreeInfo(&screen_modes);
4181 /* set current screen mode for fullscreen mode to configured setup value */
4182 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4183 setup.fullscreen_mode);
4185 /* if that fails, set current screen mode to reliable default value */
4186 if (screen_mode_current == NULL)
4187 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4188 DEFAULT_FULLSCREEN_MODE);
4190 /* if that also fails, set current screen mode to first available mode */
4191 if (screen_mode_current == NULL)
4192 screen_mode_current = screen_modes;
4194 if (screen_mode_current == NULL)
4195 video.fullscreen_available = FALSE;
4198 // if (video.fullscreen_available)
4199 if (screen_mode_current != NULL)
4201 setup.fullscreen_mode = screen_mode_current->identifier;
4203 /* needed for displaying screen mode name instead of identifier */
4204 screen_mode_text = screen_mode_current->name;
4208 static void execSetupGraphics()
4210 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4212 // update "setup.window_scaling_percent" from list selection
4213 execSetupGraphics_setWindowSizes(FALSE);
4217 // update list selection from "setup.window_scaling_percent"
4218 execSetupGraphics_setWindowSizes(TRUE);
4221 execSetupGraphics_setScalingTypes();
4222 execSetupGraphics_setScreenModes();
4224 setup_mode = SETUP_MODE_GRAPHICS;
4228 #if defined(TARGET_SDL2)
4229 // window scaling may have changed at this point
4230 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4232 // window scaling quality may have changed at this point
4233 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4234 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4238 #if !defined(PLATFORM_ANDROID)
4239 #if defined(TARGET_SDL2)
4240 static void execSetupChooseWindowSize()
4242 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4247 static void execSetupChooseScalingType()
4249 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4254 static void execSetupChooseScreenMode()
4256 if (!video.fullscreen_available)
4259 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4266 static void execSetupChooseVolumeSimple()
4268 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4273 static void execSetupChooseVolumeLoops()
4275 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4280 static void execSetupChooseVolumeMusic()
4282 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4287 static void execSetupSound()
4289 if (volumes_simple == NULL)
4293 for (i = 0; volumes_list[i].value != -1; i++)
4295 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4296 char identifier[32], name[32];
4297 int value = volumes_list[i].value;
4298 char *text = volumes_list[i].text;
4300 ti->node_top = &volumes_simple;
4301 ti->sort_priority = value;
4303 sprintf(identifier, "%d", value);
4304 sprintf(name, "%s", text);
4306 setString(&ti->identifier, identifier);
4307 setString(&ti->name, name);
4308 setString(&ti->name_sorting, name);
4309 setString(&ti->infotext, "Sound Volume");
4311 pushTreeInfo(&volumes_simple, ti);
4314 /* sort volume values to start with lowest volume value */
4315 sortTreeInfo(&volumes_simple);
4317 /* set current volume value to configured volume value */
4318 volume_simple_current =
4319 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4321 /* if that fails, set current volume to reliable default value */
4322 if (volume_simple_current == NULL)
4323 volume_simple_current =
4324 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4326 /* if that also fails, set current volume to first available value */
4327 if (volume_simple_current == NULL)
4328 volume_simple_current = volumes_simple;
4331 if (volumes_loops == NULL)
4335 for (i = 0; volumes_list[i].value != -1; i++)
4337 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4338 char identifier[32], name[32];
4339 int value = volumes_list[i].value;
4340 char *text = volumes_list[i].text;
4342 ti->node_top = &volumes_loops;
4343 ti->sort_priority = value;
4345 sprintf(identifier, "%d", value);
4346 sprintf(name, "%s", text);
4348 setString(&ti->identifier, identifier);
4349 setString(&ti->name, name);
4350 setString(&ti->name_sorting, name);
4351 setString(&ti->infotext, "Loops Volume");
4353 pushTreeInfo(&volumes_loops, ti);
4356 /* sort volume values to start with lowest volume value */
4357 sortTreeInfo(&volumes_loops);
4359 /* set current volume value to configured volume value */
4360 volume_loops_current =
4361 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4363 /* if that fails, set current volume to reliable default value */
4364 if (volume_loops_current == NULL)
4365 volume_loops_current =
4366 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4368 /* if that also fails, set current volume to first available value */
4369 if (volume_loops_current == NULL)
4370 volume_loops_current = volumes_loops;
4373 if (volumes_music == NULL)
4377 for (i = 0; volumes_list[i].value != -1; i++)
4379 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4380 char identifier[32], name[32];
4381 int value = volumes_list[i].value;
4382 char *text = volumes_list[i].text;
4384 ti->node_top = &volumes_music;
4385 ti->sort_priority = value;
4387 sprintf(identifier, "%d", value);
4388 sprintf(name, "%s", text);
4390 setString(&ti->identifier, identifier);
4391 setString(&ti->name, name);
4392 setString(&ti->name_sorting, name);
4393 setString(&ti->infotext, "Music Volume");
4395 pushTreeInfo(&volumes_music, ti);
4398 /* sort volume values to start with lowest volume value */
4399 sortTreeInfo(&volumes_music);
4401 /* set current volume value to configured volume value */
4402 volume_music_current =
4403 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4405 /* if that fails, set current volume to reliable default value */
4406 if (volume_music_current == NULL)
4407 volume_music_current =
4408 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4410 /* if that also fails, set current volume to first available value */
4411 if (volume_music_current == NULL)
4412 volume_music_current = volumes_music;
4415 setup.volume_simple = atoi(volume_simple_current->identifier);
4416 setup.volume_loops = atoi(volume_loops_current->identifier);
4417 setup.volume_music = atoi(volume_music_current->identifier);
4419 /* needed for displaying volume text instead of identifier */
4420 volume_simple_text = volume_simple_current->name;
4421 volume_loops_text = volume_loops_current->name;
4422 volume_music_text = volume_music_current->name;
4424 setup_mode = SETUP_MODE_SOUND;
4429 static void execSetupChooseTouchControls()
4431 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4436 static void execSetupChooseMoveDistance()
4438 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4443 static void execSetupChooseDropDistance()
4445 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4450 static void execSetupTouch()
4452 if (touch_controls == NULL)
4456 for (i = 0; touch_controls_list[i].value != NULL; i++)
4458 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4459 char identifier[32], name[32];
4460 char *value = touch_controls_list[i].value;
4461 char *text = touch_controls_list[i].text;
4463 ti->node_top = &touch_controls;
4464 ti->sort_priority = i;
4466 sprintf(identifier, "%s", value);
4467 sprintf(name, "%s", text);
4469 setString(&ti->identifier, identifier);
4470 setString(&ti->name, name);
4471 setString(&ti->name_sorting, name);
4472 setString(&ti->infotext, "Control Type");
4474 pushTreeInfo(&touch_controls, ti);
4477 /* sort touch control values to start with lowest touch control value */
4478 sortTreeInfo(&touch_controls);
4480 /* set current touch control value to configured touch control value */
4481 touch_control_current =
4482 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4484 /* if that fails, set current touch control to reliable default value */
4485 if (touch_control_current == NULL)
4486 touch_control_current =
4487 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4489 /* if that also fails, set current touch control to first available value */
4490 if (touch_control_current == NULL)
4491 touch_control_current = touch_controls;
4494 if (move_distances == NULL)
4498 for (i = 0; distances_list[i].value != -1; i++)
4500 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4501 char identifier[32], name[32];
4502 int value = distances_list[i].value;
4503 char *text = distances_list[i].text;
4505 ti->node_top = &move_distances;
4506 ti->sort_priority = value;
4508 sprintf(identifier, "%d", value);
4509 sprintf(name, "%s", text);
4511 setString(&ti->identifier, identifier);
4512 setString(&ti->name, name);
4513 setString(&ti->name_sorting, name);
4514 setString(&ti->infotext, "Move Distance");
4516 pushTreeInfo(&move_distances, ti);
4519 /* sort distance values to start with lowest distance value */
4520 sortTreeInfo(&move_distances);
4522 /* set current distance value to configured distance value */
4523 move_distance_current =
4524 getTreeInfoFromIdentifier(move_distances,
4525 i_to_a(setup.touch.move_distance));
4527 /* if that fails, set current distance to reliable default value */
4528 if (move_distance_current == NULL)
4529 move_distance_current =
4530 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4532 /* if that also fails, set current distance to first available value */
4533 if (move_distance_current == NULL)
4534 move_distance_current = move_distances;
4537 if (drop_distances == NULL)
4541 for (i = 0; distances_list[i].value != -1; i++)
4543 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4544 char identifier[32], name[32];
4545 int value = distances_list[i].value;
4546 char *text = distances_list[i].text;
4548 ti->node_top = &drop_distances;
4549 ti->sort_priority = value;
4551 sprintf(identifier, "%d", value);
4552 sprintf(name, "%s", text);
4554 setString(&ti->identifier, identifier);
4555 setString(&ti->name, name);
4556 setString(&ti->name_sorting, name);
4557 setString(&ti->infotext, "Drop Distance");
4559 pushTreeInfo(&drop_distances, ti);
4562 /* sort distance values to start with lowest distance value */
4563 sortTreeInfo(&drop_distances);
4565 /* set current distance value to configured distance value */
4566 drop_distance_current =
4567 getTreeInfoFromIdentifier(drop_distances,
4568 i_to_a(setup.touch.drop_distance));
4570 /* if that fails, set current distance to reliable default value */
4571 if (drop_distance_current == NULL)
4572 drop_distance_current =
4573 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
4575 /* if that also fails, set current distance to first available value */
4576 if (drop_distance_current == NULL)
4577 drop_distance_current = drop_distances;
4580 setup.touch.control_type = touch_control_current->identifier;
4581 setup.touch.move_distance = atoi(move_distance_current->identifier);
4582 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
4584 /* needed for displaying volume text instead of identifier */
4585 touch_controls_text = touch_control_current->name;
4586 move_distance_text = move_distance_current->name;
4587 drop_distance_text = drop_distance_current->name;
4589 setup_mode = SETUP_MODE_TOUCH;
4594 static void execSetupArtwork()
4597 printf("::: '%s', '%s', '%s'\n",
4598 artwork.gfx_current->subdir,
4599 artwork.gfx_current->fullpath,
4600 artwork.gfx_current->basepath);
4603 setup.graphics_set = artwork.gfx_current->identifier;
4604 setup.sounds_set = artwork.snd_current->identifier;
4605 setup.music_set = artwork.mus_current->identifier;
4607 /* needed if last screen (setup choice) changed graphics, sounds or music */
4608 ReloadCustomArtwork(0);
4610 /* needed for displaying artwork name instead of artwork identifier */
4611 graphics_set_name = artwork.gfx_current->name;
4612 sounds_set_name = artwork.snd_current->name;
4613 music_set_name = artwork.mus_current->name;
4615 setup_mode = SETUP_MODE_ARTWORK;
4620 static void execSetupChooseGraphics()
4622 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4627 static void execSetupChooseSounds()
4629 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4634 static void execSetupChooseMusic()
4636 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4641 static void execSetupInput()
4643 setup_mode = SETUP_MODE_INPUT;
4648 static void execSetupShortcuts()
4650 setup_mode = SETUP_MODE_SHORTCUTS;
4655 static void execSetupShortcuts1()
4657 setup_mode = SETUP_MODE_SHORTCUTS_1;
4662 static void execSetupShortcuts2()
4664 setup_mode = SETUP_MODE_SHORTCUTS_2;
4669 static void execSetupShortcuts3()
4671 setup_mode = SETUP_MODE_SHORTCUTS_3;
4676 static void execSetupShortcuts4()
4678 setup_mode = SETUP_MODE_SHORTCUTS_4;
4683 static void execSetupShortcuts5()
4685 setup_mode = SETUP_MODE_SHORTCUTS_5;
4690 static void execExitSetup()
4692 game_status = GAME_MODE_MAIN;
4694 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4697 static void execSaveAndExitSetup()
4703 static struct TokenInfo setup_info_main[] =
4705 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4706 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4707 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4708 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4709 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4710 #if !defined(PLATFORM_ANDROID)
4711 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4712 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4714 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4716 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
4717 { TYPE_EMPTY, NULL, "" },
4718 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4719 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4724 static struct TokenInfo setup_info_game[] =
4726 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4727 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4728 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4729 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4730 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4731 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4732 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4733 { TYPE_STRING, &game_speed_text, "" },
4735 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4736 { TYPE_STRING, &scroll_delay_text, "" },
4738 { TYPE_EMPTY, NULL, "" },
4739 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4744 static struct TokenInfo setup_info_editor[] =
4747 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4748 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4749 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4750 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4751 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4752 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4753 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4754 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4756 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4757 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4758 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4760 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4762 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4763 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4764 { TYPE_EMPTY, NULL, "" },
4766 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4767 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4768 { TYPE_EMPTY, NULL, "" },
4770 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4771 { TYPE_EMPTY, NULL, "" },
4772 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4777 static struct TokenInfo setup_info_graphics[] =
4779 #if !defined(PLATFORM_ANDROID)
4780 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4781 #if defined(TARGET_SDL2)
4782 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
4783 { TYPE_STRING, &window_size_text, "" },
4784 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
4785 { TYPE_STRING, &scaling_type_text, "" },
4787 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4788 { TYPE_STRING, &screen_mode_text, "" },
4792 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4793 { TYPE_STRING, &scroll_delay_text, "" },
4795 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4796 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4797 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4798 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4799 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4800 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4801 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
4802 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
4803 { TYPE_EMPTY, NULL, "" },
4804 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4809 static struct TokenInfo setup_info_sound[] =
4811 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4812 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4813 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4814 { TYPE_EMPTY, NULL, "" },
4815 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
4816 { TYPE_STRING, &volume_simple_text, "" },
4817 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
4818 { TYPE_STRING, &volume_loops_text, "" },
4819 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
4820 { TYPE_STRING, &volume_music_text, "" },
4821 { TYPE_EMPTY, NULL, "" },
4822 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4827 static struct TokenInfo setup_info_artwork[] =
4829 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4830 { TYPE_STRING, &graphics_set_name, "" },
4831 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4832 { TYPE_STRING, &sounds_set_name, "" },
4833 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4834 { TYPE_STRING, &music_set_name, "" },
4835 { TYPE_EMPTY, NULL, "" },
4836 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
4837 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
4838 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
4839 { TYPE_EMPTY, NULL, "" },
4840 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4845 static struct TokenInfo setup_info_input[] =
4847 { TYPE_SWITCH, NULL, "Player:" },
4848 { TYPE_SWITCH, NULL, "Device:" },
4849 { TYPE_ENTER_MENU, NULL, "" },
4850 { TYPE_EMPTY, NULL, "" },
4851 { TYPE_EMPTY, NULL, "" },
4852 { TYPE_EMPTY, NULL, "" },
4853 { TYPE_EMPTY, NULL, "" },
4854 { TYPE_EMPTY, NULL, "" },
4855 { TYPE_EMPTY, NULL, "" },
4856 { TYPE_EMPTY, NULL, "" },
4857 { TYPE_EMPTY, NULL, "" },
4858 { TYPE_EMPTY, NULL, "" },
4859 { TYPE_EMPTY, NULL, "" },
4860 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4865 static struct TokenInfo setup_info_touch[] =
4867 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
4868 { TYPE_STRING, &touch_controls_text, "" },
4869 { TYPE_EMPTY, NULL, "" },
4870 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
4871 { TYPE_STRING, &move_distance_text, "" },
4872 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
4873 { TYPE_STRING, &drop_distance_text, "" },
4874 { TYPE_EMPTY, NULL, "" },
4875 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4880 static struct TokenInfo setup_info_shortcuts[] =
4882 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
4883 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
4884 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
4885 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
4886 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
4887 { TYPE_EMPTY, NULL, "" },
4888 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4893 static struct TokenInfo setup_info_shortcuts_1[] =
4895 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4896 { TYPE_KEY, &setup.shortcut.save_game, "" },
4897 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4898 { TYPE_KEY, &setup.shortcut.load_game, "" },
4899 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4900 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4901 { TYPE_EMPTY, NULL, "" },
4902 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4903 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4904 { TYPE_EMPTY, NULL, "" },
4905 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4910 static struct TokenInfo setup_info_shortcuts_2[] =
4912 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4913 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4914 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4915 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4916 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4917 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4918 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4919 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4920 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4921 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4922 { TYPE_EMPTY, NULL, "" },
4923 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4928 static struct TokenInfo setup_info_shortcuts_3[] =
4930 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
4931 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
4932 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
4933 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
4934 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
4935 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
4936 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
4937 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
4938 { TYPE_KEYTEXT, NULL, "Record Tape:", },
4939 { TYPE_KEY, &setup.shortcut.tape_record, "" },
4940 { TYPE_KEYTEXT, NULL, "Play Tape:", },
4941 { TYPE_KEY, &setup.shortcut.tape_play, "" },
4942 { TYPE_EMPTY, NULL, "" },
4943 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4948 static struct TokenInfo setup_info_shortcuts_4[] =
4950 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
4951 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
4952 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
4953 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
4954 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
4955 { TYPE_KEY, &setup.shortcut.sound_music, "" },
4956 { TYPE_EMPTY, NULL, "" },
4957 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4962 static struct TokenInfo setup_info_shortcuts_5[] =
4964 { TYPE_KEYTEXT, NULL, "Snap Left:", },
4965 { TYPE_KEY, &setup.shortcut.snap_left, "" },
4966 { TYPE_KEYTEXT, NULL, "Snap Right:", },
4967 { TYPE_KEY, &setup.shortcut.snap_right, "" },
4968 { TYPE_KEYTEXT, NULL, "Snap Up:", },
4969 { TYPE_KEY, &setup.shortcut.snap_up, "" },
4970 { TYPE_KEYTEXT, NULL, "Snap Down:", },
4971 { TYPE_KEY, &setup.shortcut.snap_down, "" },
4972 { TYPE_EMPTY, NULL, "" },
4973 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4978 static Key getSetupKey()
4980 Key key = KSYM_UNDEFINED;
4981 boolean got_key_event = FALSE;
4983 while (!got_key_event)
4985 if (PendingEvent()) /* got event */
4993 case EVENT_KEYPRESS:
4995 key = GetEventKey((KeyEvent *)&event, TRUE);
4997 /* press 'Escape' or 'Enter' to keep the existing key binding */
4998 if (key == KSYM_Escape || key == KSYM_Return)
4999 key = KSYM_UNDEFINED; /* keep old value */
5001 got_key_event = TRUE;
5005 case EVENT_KEYRELEASE:
5006 key_joystick_mapping = 0;
5010 HandleOtherEvents(&event);
5018 /* don't eat all CPU time */
5025 static int getSetupTextFont(int type)
5027 if (type & (TYPE_SWITCH |
5039 static int getSetupValueFont(int type, void *value)
5041 if (type & TYPE_KEY)
5042 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5043 else if (type & TYPE_STRING)
5044 return FONT_VALUE_2;
5045 else if (type & TYPE_ECS_AGA)
5046 return FONT_VALUE_1;
5047 else if (type & TYPE_BOOLEAN_STYLE)
5048 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5049 else if (type & TYPE_YES_NO_AUTO)
5050 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5051 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5053 return FONT_VALUE_1;
5056 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5058 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5059 struct TokenInfo *si = &setup_info[si_pos];
5060 boolean font_draw_xoffset_modified = FALSE;
5061 int font_draw_xoffset_old = -1;
5062 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5063 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5064 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5065 int xpos = menu_screen_value_xpos;
5066 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5067 int startx = mSX + xpos * 32;
5068 int starty = mSY + ypos * 32;
5069 int font_nr, font_width;
5070 int type = si->type;
5071 void *value = si->value;
5072 char *value_string = getSetupValue(type, value);
5075 if (value_string == NULL)
5078 if (type & TYPE_KEY)
5080 xpos = MENU_SCREEN_START_XPOS;
5082 if (type & TYPE_QUERY)
5083 value_string = "<press key>";
5085 else if (type & TYPE_STRING)
5087 int max_value_len = (SCR_FIELDX - 2) * 2;
5089 xpos = MENU_SCREEN_START_XPOS;
5091 if (strlen(value_string) > max_value_len)
5092 value_string[max_value_len] = '\0';
5094 else if (type & TYPE_YES_NO_AUTO)
5096 xpos = menu_screen_value_xpos - 1;
5099 startx = mSX + xpos * 32;
5100 starty = mSY + ypos * 32;
5101 font_nr = getSetupValueFont(type, value);
5102 font_width = getFontWidth(font_nr);
5104 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5105 if (setup_mode != SETUP_MODE_INPUT)
5107 int max_menu_text_length_big = (menu_screen_value_xpos -
5108 MENU_SCREEN_START_XPOS);
5109 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5110 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5111 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5112 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5113 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5114 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5115 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5116 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5117 boolean correct_font_draw_xoffset = FALSE;
5119 if (xpos == MENU_SCREEN_START_XPOS &&
5120 startx + font1_xoffset < text_startx + text_font_xoffset)
5121 correct_font_draw_xoffset = TRUE;
5123 if (xpos == menu_screen_value_xpos &&
5124 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5125 correct_font_draw_xoffset = TRUE;
5127 /* check if setup value would overlap with setup text when printed */
5128 /* (this can happen for extreme/wrong values for font draw offset) */
5129 if (correct_font_draw_xoffset)
5131 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5132 font_draw_xoffset_modified = TRUE;
5134 if (type & TYPE_KEY)
5135 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5136 else if (!(type & TYPE_STRING))
5137 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5138 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5142 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5143 DrawText(startx + i * font_width, starty, " ", font_nr);
5145 DrawText(startx, starty, value_string, font_nr);
5147 if (font_draw_xoffset_modified)
5148 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5151 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5153 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5154 struct TokenInfo *si = &setup_info[si_pos];
5156 if (si->type & TYPE_BOOLEAN_STYLE)
5158 *(boolean *)si->value ^= TRUE;
5160 else if (si->type & TYPE_YES_NO_AUTO)
5164 (*(int *)si->value == AUTO ? TRUE :
5165 *(int *)si->value == TRUE ? FALSE : AUTO) :
5166 (*(int *)si->value == TRUE ? AUTO :
5167 *(int *)si->value == AUTO ? FALSE : TRUE));
5169 else if (si->type & TYPE_KEY)
5173 si->type |= TYPE_QUERY;
5174 drawSetupValue(screen_pos, setup_info_pos_raw);
5175 si->type &= ~TYPE_QUERY;
5177 key = getSetupKey();
5178 if (key != KSYM_UNDEFINED)
5179 *(Key *)si->value = key;
5182 drawSetupValue(screen_pos, setup_info_pos_raw);
5184 // fullscreen state may have changed at this point
5185 if (si->value == &setup.fullscreen)
5186 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5189 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5192 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5193 struct TokenInfo *si = &setup_info[si_pos];
5194 int xpos = MENU_SCREEN_START_XPOS;
5195 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5196 int font_nr = getSetupTextFont(si->type);
5198 if (setup_info == setup_info_input)
5199 font_nr = FONT_MENU_1;
5202 font_nr = FONT_ACTIVE(font_nr);
5204 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5206 if (si->type & ~TYPE_SKIP_ENTRY)
5207 drawCursor(screen_pos, active);
5210 static void drawSetupInfoList(struct TokenInfo *setup_info,
5211 int first_entry, int num_page_entries)
5215 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5216 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5218 if (num_page_entries > max_setup_info)
5219 num_page_entries = max_setup_info;
5221 if (first_entry + num_page_entries > max_setup_info)
5224 /* clear tree list area, but not title or scrollbar */
5225 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
5226 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
5227 NUM_MENU_ENTRIES_ON_SCREEN * 32);
5229 for (i = 0; i < num_page_entries; i++)
5231 int setup_info_pos = first_entry + i;
5232 struct TokenInfo *si = &setup_info[setup_info_pos];
5233 void *value_ptr = si->value;
5235 /* set some entries to "unchangeable" according to other variables */
5236 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5237 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5238 (value_ptr == &setup.sound_music && !audio.music_available) ||
5239 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5240 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5241 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5242 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5243 si->type |= TYPE_GHOSTED;
5245 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5246 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5247 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5248 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5249 else if (si->type & ~TYPE_SKIP_ENTRY)
5250 initCursor(i, IMG_MENU_BUTTON);
5252 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5254 if (si->type & TYPE_VALUE)
5255 drawSetupValue(i, setup_info_pos);
5259 static void DrawSetupScreen_Generic()
5261 boolean redraw_all = FALSE;
5262 char *title_string = NULL;
5267 FreeScreenGadgets();
5268 CreateScreenGadgets();
5270 CloseDoor(DOOR_CLOSE_2);
5272 if (redraw_mask & REDRAW_ALL)
5275 FadeOut(REDRAW_FIELD);
5279 if (setup_mode == SETUP_MODE_MAIN)
5281 setup_info = setup_info_main;
5282 title_string = "Setup";
5284 else if (setup_mode == SETUP_MODE_GAME)
5286 setup_info = setup_info_game;
5287 title_string = "Setup Game";
5289 else if (setup_mode == SETUP_MODE_EDITOR)
5291 setup_info = setup_info_editor;
5292 title_string = "Setup Editor";
5294 else if (setup_mode == SETUP_MODE_GRAPHICS)
5296 setup_info = setup_info_graphics;
5297 title_string = "Setup Graphics";
5299 else if (setup_mode == SETUP_MODE_SOUND)
5301 setup_info = setup_info_sound;
5302 title_string = "Setup Sound";
5304 else if (setup_mode == SETUP_MODE_ARTWORK)
5306 setup_info = setup_info_artwork;
5307 title_string = "Custom Artwork";
5309 else if (setup_mode == SETUP_MODE_TOUCH)
5311 setup_info = setup_info_touch;
5312 title_string = "Setup Touch Ctrls";
5314 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5316 setup_info = setup_info_shortcuts;
5317 title_string = "Setup Shortcuts";
5319 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5321 setup_info = setup_info_shortcuts_1;
5322 title_string = "Setup Shortcuts";
5324 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5326 setup_info = setup_info_shortcuts_2;
5327 title_string = "Setup Shortcuts";
5329 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
5331 setup_info = setup_info_shortcuts_3;
5332 title_string = "Setup Shortcuts";
5334 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
5336 setup_info = setup_info_shortcuts_4;
5337 title_string = "Setup Shortcuts";
5339 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
5341 setup_info = setup_info_shortcuts_5;
5342 title_string = "Setup Shortcuts";
5345 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5348 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5352 for (i = 0; setup_info[i].type != 0; i++)
5355 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5357 MapScreenGadgets(max_setup_info);
5360 redraw_mask = REDRAW_ALL;
5362 FadeIn(redraw_mask);
5367 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5369 static int choice_store[MAX_SETUP_MODES];
5370 static int first_entry_store[MAX_SETUP_MODES];
5371 int choice = choice_store[setup_mode]; /* starts with 0 */
5372 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
5374 int y = choice - first_entry;
5376 boolean position_set_by_scrollbar = (dx == 999);
5377 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
5378 int num_page_entries;
5380 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
5382 if (button == MB_MENU_INITIALIZE)
5384 /* advance to first valid menu entry */
5385 while (choice < num_setup_info &&
5386 setup_info[choice].type & TYPE_SKIP_ENTRY)
5389 if (position_set_by_scrollbar)
5390 first_entry = first_entry_store[setup_mode] = dy;
5392 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5393 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5395 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5397 if (choice < first_entry)
5399 choice = first_entry;
5401 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5404 else if (choice > first_entry + num_page_entries - 1)
5406 choice = first_entry + num_page_entries - 1;
5408 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5412 choice_store[setup_mode] = choice;
5414 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5418 else if (button == MB_MENU_LEAVE)
5422 PlaySound(SND_MENU_ITEM_SELECTING);
5424 for (i = 0; setup_info[i].type != 0; i++)
5426 if (setup_info[i].type & TYPE_LEAVE_MENU)
5428 void (*menu_callback_function)(void) = setup_info[i].value;
5432 menu_callback_function();
5434 break; /* absolutely needed because function changes 'setup_info'! */
5441 if (mx || my) /* mouse input */
5443 x = (mx - mSX) / 32;
5444 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5446 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
5448 /* move cursor instead of scrolling when already at start/end of list */
5449 if (dy == -1 * SCROLL_LINE && first_entry == 0)
5451 else if (dy == +1 * SCROLL_LINE &&
5452 first_entry + num_page_entries == max_setup_info)
5455 /* handle scrolling screen one line or page */
5457 y + dy > num_page_entries - 1)
5459 boolean redraw = FALSE;
5461 if (ABS(dy) == SCROLL_PAGE)
5462 step = num_page_entries - 1;
5464 if (dy < 0 && first_entry > 0)
5466 /* scroll page/line up */
5468 first_entry -= step;
5469 if (first_entry < 0)
5474 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
5476 /* scroll page/line down */
5478 first_entry += step;
5479 if (first_entry + num_page_entries > max_setup_info)
5480 first_entry = MAX(0, max_setup_info - num_page_entries);
5487 choice += first_entry - first_entry_store[setup_mode];
5489 if (choice < first_entry)
5491 choice = first_entry;
5493 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5496 else if (choice > first_entry + num_page_entries - 1)
5498 choice = first_entry + num_page_entries - 1;
5500 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5503 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5507 if (choice < first_entry ||
5508 choice > first_entry + num_page_entries - 1)
5509 first_entry += SIGN(dy);
5512 first_entry_store[setup_mode] = first_entry;
5513 choice_store[setup_mode] = choice;
5515 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5517 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5519 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5520 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5528 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5530 if (setup_info[choice].type & menu_navigation_type ||
5531 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
5532 setup_info[choice].type & TYPE_YES_NO_AUTO)
5533 button = MB_MENU_CHOICE;
5538 /* jump to next non-empty menu entry (up or down) */
5539 while (first_entry + y > 0 &&
5540 first_entry + y < max_setup_info - 1 &&
5541 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
5544 if (!IN_VIS_FIELD(x, y))
5546 choice += y - y_old;
5548 if (choice < first_entry)
5549 first_entry = choice;
5550 else if (choice > first_entry + num_page_entries - 1)
5551 first_entry = choice - num_page_entries + 1;
5553 if (first_entry >= 0 &&
5554 first_entry + num_page_entries <= max_setup_info)
5556 first_entry_store[setup_mode] = first_entry;
5558 if (choice < first_entry)
5559 choice = first_entry;
5560 else if (choice > first_entry + num_page_entries - 1)
5561 choice = first_entry + num_page_entries - 1;
5563 choice_store[setup_mode] = choice;
5565 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5567 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5569 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5570 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5577 if (!anyScrollbarGadgetActive() &&
5578 IN_VIS_FIELD(x, y) &&
5579 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
5580 y >= 0 && y < num_page_entries)
5584 if (first_entry + y != choice &&
5585 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
5587 PlaySound(SND_MENU_ITEM_ACTIVATING);
5589 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
5590 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
5592 choice = choice_store[setup_mode] = first_entry + y;
5595 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
5597 PlaySound(SND_MENU_ITEM_SELECTING);
5599 /* when selecting key headline, execute function for key value change */
5600 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
5601 setup_info[first_entry + y + 1].type & TYPE_KEY)
5604 /* when selecting string value, execute function for list selection */
5605 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
5606 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
5609 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
5611 void (*menu_callback_function)(void) =
5612 setup_info[first_entry + y].value;
5614 FadeSetFromType(setup_info[first_entry + y].type);
5616 menu_callback_function();
5620 if (setup_info[first_entry + y].type & TYPE_VALUE)
5621 changeSetupValue(y, first_entry + y, dx);
5627 void DrawSetupScreen_Input()
5631 FadeOut(REDRAW_FIELD);
5635 setup_info = setup_info_input;
5637 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5639 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5640 "Joysticks deactivated on this screen");
5642 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5644 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5645 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5646 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5647 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5648 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5649 initCursor(i, IMG_MENU_BUTTON);
5651 DrawCursorAndText_Setup(i, -1, FALSE);
5654 /* create gadgets for setup input menu screen */
5655 FreeScreenGadgets();
5656 CreateScreenGadgets();
5658 /* map gadgets for setup input menu screen */
5659 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5661 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5663 FadeIn(REDRAW_FIELD);
5668 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5670 if (device_name == NULL)
5673 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5676 if (strlen(device_name) > 1)
5678 char c1 = device_name[strlen(device_name) - 1];
5679 char c2 = device_name[strlen(device_name) - 2];
5681 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5682 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5685 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5686 strlen(device_name));
5689 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5692 static struct SetupKeyboardInfo custom_key;
5699 { &custom_key.left, "Joystick Left" },
5700 { &custom_key.right, "Joystick Right" },
5701 { &custom_key.up, "Joystick Up" },
5702 { &custom_key.down, "Joystick Down" },
5703 { &custom_key.snap, "Button 1" },
5704 { &custom_key.drop, "Button 2" }
5706 static char *joystick_name[MAX_PLAYERS] =
5713 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5717 custom_key = setup.input[player_nr].key;
5719 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5720 FONT_INPUT_1_ACTIVE);
5722 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5724 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5725 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5727 if (setup.input[player_nr].use_joystick)
5729 char *device_name = setup.input[player_nr].joy.device_name;
5730 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5731 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5733 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5734 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5738 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5739 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5742 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5744 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5745 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5746 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5747 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5749 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5750 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5751 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5752 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5753 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5754 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5756 for (i = 0; i < 6; i++)
5758 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5760 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5762 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5763 (setup.input[player_nr].use_joystick ?
5765 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5769 static int input_player_nr = 0;
5771 void HandleSetupScreen_Input_Player(int step, int direction)
5773 int old_player_nr = input_player_nr;
5776 new_player_nr = old_player_nr + step * direction;
5777 if (new_player_nr < 0)
5779 if (new_player_nr > MAX_PLAYERS - 1)
5780 new_player_nr = MAX_PLAYERS - 1;
5782 if (new_player_nr != old_player_nr)
5784 input_player_nr = new_player_nr;
5786 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5790 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5792 static int choice = 0;
5795 int pos_start = SETUPINPUT_SCREEN_POS_START;
5796 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5797 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5798 int pos_end = SETUPINPUT_SCREEN_POS_END;
5800 if (button == MB_MENU_INITIALIZE)
5802 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5804 DrawCursorAndText_Setup(choice, -1, TRUE);
5808 else if (button == MB_MENU_LEAVE)
5810 setup_mode = SETUP_MODE_MAIN;
5817 if (mx || my) /* mouse input */
5819 x = (mx - mSX) / 32;
5820 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5822 else if (dx || dy) /* keyboard input */
5824 if (dx && choice == 0)
5825 x = (dx < 0 ? 10 : 12);
5826 else if ((dx && choice == 1) ||
5827 (dx == +1 && choice == 2) ||
5828 (dx == -1 && choice == pos_end))
5829 button = MB_MENU_CHOICE;
5833 if (y >= pos_empty1 && y <= pos_empty2)
5834 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5837 if (y == 0 && dx != 0 && button)
5839 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5841 else if (IN_VIS_FIELD(x, y) &&
5842 y >= pos_start && y <= pos_end &&
5843 !(y >= pos_empty1 && y <= pos_empty2))
5849 DrawCursorAndText_Setup(choice, -1, FALSE);
5850 DrawCursorAndText_Setup(y, -1, TRUE);
5852 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5861 char *device_name = setup.input[input_player_nr].joy.device_name;
5863 if (!setup.input[input_player_nr].use_joystick)
5865 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5867 setJoystickDeviceToNr(device_name, new_device_nr);
5868 setup.input[input_player_nr].use_joystick = TRUE;
5872 int device_nr = getJoystickNrFromDeviceName(device_name);
5873 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5875 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5876 setup.input[input_player_nr].use_joystick = FALSE;
5878 setJoystickDeviceToNr(device_name, new_device_nr);
5881 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5885 if (setup.input[input_player_nr].use_joystick)
5888 CalibrateJoystick(input_player_nr);
5891 CustomizeKeyboard(input_player_nr);
5893 else if (y == pos_end)
5899 setup_mode = SETUP_MODE_MAIN;
5906 void CustomizeKeyboard(int player_nr)
5910 boolean finished = FALSE;
5911 static struct SetupKeyboardInfo custom_key;
5916 } customize_step[] =
5918 { &custom_key.left, "Move Left" },
5919 { &custom_key.right, "Move Right" },
5920 { &custom_key.up, "Move Up" },
5921 { &custom_key.down, "Move Down" },
5922 { &custom_key.snap, "Snap Field" },
5923 { &custom_key.drop, "Drop Element" }
5926 /* read existing key bindings from player setup */
5927 custom_key = setup.input[player_nr].key;
5930 FadeOut(REDRAW_FIELD);
5934 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5937 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5938 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5939 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5940 "Key:", FONT_INPUT_1_ACTIVE);
5941 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5942 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5944 FadeIn(REDRAW_FIELD);
5950 if (PendingEvent()) /* got event */
5958 case EVENT_KEYPRESS:
5960 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5962 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5964 if (key == KSYM_Escape)
5965 FadeSkipNextFadeIn();
5971 /* all keys configured -- wait for "Escape" or "Return" key */
5975 /* press 'Enter' to keep the existing key binding */
5976 if (key == KSYM_Return)
5977 key = *customize_step[step_nr].key;
5979 /* check if key already used */
5980 for (i = 0; i < step_nr; i++)
5981 if (*customize_step[i].key == key)
5986 /* got new key binding */
5987 *customize_step[step_nr].key = key;
5988 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5990 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5991 getKeyNameFromKey(key), FONT_VALUE_1);
5994 /* un-highlight last query */
5995 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
5996 customize_step[step_nr - 1].text, FONT_MENU_1);
5997 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
5998 "Key:", FONT_MENU_1);
6000 /* press 'Enter' to leave */
6003 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6004 "Press Enter", FONT_TITLE_1);
6008 /* query next key binding */
6009 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6010 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6011 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6012 "Key:", FONT_INPUT_1_ACTIVE);
6013 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6014 getKeyNameFromKey(*customize_step[step_nr].key),
6019 case EVENT_KEYRELEASE:
6020 key_joystick_mapping = 0;
6024 HandleOtherEvents(&event);
6032 /* don't eat all CPU time */
6036 /* write new key bindings back to player setup */
6037 setup.input[player_nr].key = custom_key;
6040 DrawSetupScreen_Input();
6043 static boolean CalibrateJoystickMain(int player_nr)
6045 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6046 int new_joystick_xright = JOYSTICK_XMIDDLE;
6047 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6048 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6049 int new_joystick_xmiddle, new_joystick_ymiddle;
6051 int joystick_fd = joystick.fd[player_nr];
6052 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6053 boolean check[3][3];
6054 int check_remaining = 3 * 3;
6059 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6062 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6066 FadeOut(REDRAW_FIELD);
6070 for (y = 0; y < 3; y++)
6072 for (x = 0; x < 3; x++)
6074 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6075 check[x][y] = FALSE;
6079 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6080 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6081 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6082 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6083 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6084 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6085 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6087 joy_value = Joystick(player_nr);
6088 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6089 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6091 /* eventually uncalibrated center position (joystick could be uncentered) */
6092 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6095 new_joystick_xmiddle = joy_x;
6096 new_joystick_ymiddle = joy_y;
6098 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6100 FadeIn(REDRAW_FIELD);
6102 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6107 if (PendingEvent()) /* got event */
6115 case EVENT_KEYPRESS:
6116 switch (GetEventKey((KeyEvent *)&event, TRUE))
6119 if (check_remaining == 0)
6124 FadeSkipNextFadeIn();
6133 case EVENT_KEYRELEASE:
6134 key_joystick_mapping = 0;
6138 HandleOtherEvents(&event);
6143 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6146 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
6147 new_joystick_xright = MAX(new_joystick_xright, joy_x);
6148 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
6149 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
6151 setup.input[player_nr].joy.xleft = new_joystick_xleft;
6152 setup.input[player_nr].joy.yupper = new_joystick_yupper;
6153 setup.input[player_nr].joy.xright = new_joystick_xright;
6154 setup.input[player_nr].joy.ylower = new_joystick_ylower;
6155 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
6156 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
6158 CheckJoystickData();
6160 joy_value = Joystick(player_nr);
6162 if (joy_value & JOY_BUTTON && check_remaining == 0)
6165 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6166 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6168 if (x != last_x || y != last_y)
6170 DrawFixedGraphic(xpos + last_x, ypos + last_y,
6171 IMG_MENU_CALIBRATE_YELLOW, 0);
6172 DrawFixedGraphic(xpos + x, ypos + y,
6173 IMG_MENU_CALIBRATE_RED, 0);
6178 if (check_remaining > 0 && !check[x+1][y+1])
6180 check[x+1][y+1] = TRUE;
6188 /* don't eat all CPU time */
6192 /* calibrated center position (joystick should now be centered) */
6193 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6196 new_joystick_xmiddle = joy_x;
6197 new_joystick_ymiddle = joy_y;
6201 /* wait until the last pressed button was released */
6202 while (Joystick(player_nr) & JOY_BUTTON)
6204 if (PendingEvent()) /* got event */
6209 HandleOtherEvents(&event);
6218 void CalibrateJoystick(int player_nr)
6220 if (!CalibrateJoystickMain(player_nr))
6222 char *device_name = setup.input[player_nr].joy.device_name;
6223 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6224 int xpos = mSX - SX;
6225 int ypos = mSY - SY;
6229 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6230 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
6233 Delay(2000); /* show error message for a short time */
6238 DrawSetupScreen_Input();
6241 void DrawSetupScreen()
6243 DeactivateJoystick();
6245 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6247 if (setup_mode == SETUP_MODE_INPUT)
6248 DrawSetupScreen_Input();
6249 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6250 DrawChooseTree(&game_speed_current);
6251 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6252 DrawChooseTree(&scroll_delay_current);
6253 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6254 DrawChooseTree(&screen_mode_current);
6255 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6256 DrawChooseTree(&window_size_current);
6257 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6258 DrawChooseTree(&scaling_type_current);
6259 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6260 DrawChooseTree(&artwork.gfx_current);
6261 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6262 DrawChooseTree(&artwork.snd_current);
6263 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6264 DrawChooseTree(&artwork.mus_current);
6265 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6266 DrawChooseTree(&volume_simple_current);
6267 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6268 DrawChooseTree(&volume_loops_current);
6269 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6270 DrawChooseTree(&volume_music_current);
6271 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6272 DrawChooseTree(&touch_control_current);
6273 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6274 DrawChooseTree(&move_distance_current);
6275 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6276 DrawChooseTree(&drop_distance_current);
6278 DrawSetupScreen_Generic();
6284 void RedrawSetupScreenAfterFullscreenToggle()
6286 if (setup_mode == SETUP_MODE_GRAPHICS ||
6287 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6289 // update list selection from "setup.window_scaling_percent"
6290 execSetupGraphics_setWindowSizes(TRUE);
6296 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
6298 if (setup_mode == SETUP_MODE_INPUT)
6299 HandleSetupScreen_Input(mx, my, dx, dy, button);
6300 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6301 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
6302 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6303 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
6304 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6305 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
6306 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6307 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
6308 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6309 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
6310 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6311 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
6312 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6313 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
6314 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6315 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
6316 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6317 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
6318 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6319 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
6320 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6321 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
6322 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6323 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
6324 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6325 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
6326 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6327 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
6329 HandleSetupScreen_Generic(mx, my, dx, dy, button);
6332 void HandleGameActions()
6334 if (game_status != GAME_MODE_PLAYING)
6337 GameActions(); /* main game loop */
6339 if (tape.auto_play && !tape.playing)
6340 AutoPlayTape(); /* continue automatically playing next tape */
6344 /* ---------- new screen button stuff -------------------------------------- */
6346 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6350 case SCREEN_CTRL_ID_PREV_LEVEL:
6351 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
6352 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
6355 case SCREEN_CTRL_ID_NEXT_LEVEL:
6356 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
6357 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
6360 case SCREEN_CTRL_ID_PREV_PLAYER:
6361 *x = mSX + TILEX * 10;
6362 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6365 case SCREEN_CTRL_ID_NEXT_PLAYER:
6366 *x = mSX + TILEX * 12;
6367 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6371 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6377 int gfx_unpressed, gfx_pressed;
6378 void (*get_gadget_position)(int *, int *, int);
6382 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6385 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6386 getScreenMenuButtonPos,
6387 SCREEN_CTRL_ID_PREV_LEVEL,
6392 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6393 getScreenMenuButtonPos,
6394 SCREEN_CTRL_ID_NEXT_LEVEL,
6399 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6400 getScreenMenuButtonPos,
6401 SCREEN_CTRL_ID_PREV_PLAYER,
6406 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6407 getScreenMenuButtonPos,
6408 SCREEN_CTRL_ID_NEXT_PLAYER,
6416 int gfx_unpressed, gfx_pressed;
6420 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6423 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6424 -1, -1, /* these values are not constant, but can change at runtime */
6425 SCREEN_CTRL_ID_SCROLL_UP,
6429 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6430 -1, -1, /* these values are not constant, but can change at runtime */
6431 SCREEN_CTRL_ID_SCROLL_DOWN,
6438 int gfx_unpressed, gfx_pressed;
6444 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6447 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6448 -1, -1, /* these values are not constant, but can change at runtime */
6449 -1, -1, /* these values are not constant, but can change at runtime */
6450 GD_TYPE_SCROLLBAR_VERTICAL,
6451 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6452 "scroll level series vertically"
6456 static void CreateScreenMenubuttons()
6458 struct GadgetInfo *gi;
6459 unsigned int event_mask;
6462 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6464 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6465 int gfx_unpressed, gfx_pressed;
6466 int x, y, width, height;
6467 int gd_x1, gd_x2, gd_y1, gd_y2;
6468 int id = menubutton_info[i].gadget_id;
6470 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6472 menubutton_info[i].get_gadget_position(&x, &y, id);
6474 width = SC_MENUBUTTON_XSIZE;
6475 height = SC_MENUBUTTON_YSIZE;
6477 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6478 gfx_pressed = menubutton_info[i].gfx_pressed;
6479 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6480 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6481 gd_x1 = graphic_info[gfx_unpressed].src_x;
6482 gd_y1 = graphic_info[gfx_unpressed].src_y;
6483 gd_x2 = graphic_info[gfx_pressed].src_x;
6484 gd_y2 = graphic_info[gfx_pressed].src_y;
6486 gi = CreateGadget(GDI_CUSTOM_ID, id,
6487 GDI_CUSTOM_TYPE_ID, i,
6488 GDI_INFO_TEXT, menubutton_info[i].infotext,
6493 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6494 GDI_STATE, GD_BUTTON_UNPRESSED,
6495 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6496 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6497 GDI_DIRECT_DRAW, FALSE,
6498 GDI_EVENT_MASK, event_mask,
6499 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6503 Error(ERR_EXIT, "cannot create gadget");
6505 screen_gadget[id] = gi;
6509 static void CreateScreenScrollbuttons()
6511 struct GadgetInfo *gi;
6512 unsigned int event_mask;
6515 /* these values are not constant, but can change at runtime */
6516 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
6517 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
6518 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
6519 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
6521 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6523 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6524 int gfx_unpressed, gfx_pressed;
6525 int x, y, width, height;
6526 int gd_x1, gd_x2, gd_y1, gd_y2;
6527 int id = scrollbutton_info[i].gadget_id;
6529 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6531 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6532 y = mSY + scrollbutton_info[i].y;
6533 width = SC_SCROLLBUTTON_XSIZE;
6534 height = SC_SCROLLBUTTON_YSIZE;
6536 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6537 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6538 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6540 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6541 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6542 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6543 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6544 gd_x1 = graphic_info[gfx_unpressed].src_x;
6545 gd_y1 = graphic_info[gfx_unpressed].src_y;
6546 gd_x2 = graphic_info[gfx_pressed].src_x;
6547 gd_y2 = graphic_info[gfx_pressed].src_y;
6549 gi = CreateGadget(GDI_CUSTOM_ID, id,
6550 GDI_CUSTOM_TYPE_ID, i,
6551 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6556 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6557 GDI_STATE, GD_BUTTON_UNPRESSED,
6558 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6559 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6560 GDI_DIRECT_DRAW, FALSE,
6561 GDI_EVENT_MASK, event_mask,
6562 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6566 Error(ERR_EXIT, "cannot create gadget");
6568 screen_gadget[id] = gi;
6572 static void CreateScreenScrollbars()
6576 /* these values are not constant, but can change at runtime */
6577 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
6578 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
6579 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
6580 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
6582 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6584 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6585 int gfx_unpressed, gfx_pressed;
6586 int x, y, width, height;
6587 int gd_x1, gd_x2, gd_y1, gd_y2;
6588 struct GadgetInfo *gi;
6589 int items_max, items_visible, item_position;
6590 unsigned int event_mask;
6591 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6592 int id = scrollbar_info[i].gadget_id;
6594 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6596 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6597 y = mSY + scrollbar_info[i].y;
6598 width = scrollbar_info[i].width;
6599 height = scrollbar_info[i].height;
6601 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6602 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6604 items_max = num_page_entries;
6605 items_visible = num_page_entries;
6608 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6609 gfx_pressed = scrollbar_info[i].gfx_pressed;
6610 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6611 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6612 gd_x1 = graphic_info[gfx_unpressed].src_x;
6613 gd_y1 = graphic_info[gfx_unpressed].src_y;
6614 gd_x2 = graphic_info[gfx_pressed].src_x;
6615 gd_y2 = graphic_info[gfx_pressed].src_y;
6617 gi = CreateGadget(GDI_CUSTOM_ID, id,
6618 GDI_CUSTOM_TYPE_ID, i,
6619 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6624 GDI_TYPE, scrollbar_info[i].type,
6625 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6626 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6627 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6628 GDI_WHEEL_AREA_X, SX,
6629 GDI_WHEEL_AREA_Y, SY,
6630 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6631 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6632 GDI_STATE, GD_BUTTON_UNPRESSED,
6633 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6634 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6635 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6636 GDI_DIRECT_DRAW, FALSE,
6637 GDI_EVENT_MASK, event_mask,
6638 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6642 Error(ERR_EXIT, "cannot create gadget");
6644 screen_gadget[id] = gi;
6648 void CreateScreenGadgets()
6650 int last_game_status = game_status; /* save current game status */
6652 CreateScreenMenubuttons();
6654 CreateScreenScrollbuttons();
6655 CreateScreenScrollbars();
6657 game_status = last_game_status; /* restore current game status */
6660 void FreeScreenGadgets()
6664 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6665 FreeGadget(screen_gadget[i]);
6668 void MapScreenMenuGadgets(int screen_mask)
6672 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6673 if (screen_mask & menubutton_info[i].screen_mask)
6674 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6677 void MapScreenGadgets(int num_entries)
6681 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6684 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6685 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6687 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6688 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6691 void MapScreenTreeGadgets(TreeInfo *ti)
6693 MapScreenGadgets(numTreeInfoInGroup(ti));
6696 static void HandleScreenGadgets(struct GadgetInfo *gi)
6698 int id = gi->custom_id;
6699 int button = gi->event.button;
6700 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6704 case SCREEN_CTRL_ID_PREV_LEVEL:
6705 HandleMainMenu_SelectLevel(step, -1);
6708 case SCREEN_CTRL_ID_NEXT_LEVEL:
6709 HandleMainMenu_SelectLevel(step, +1);
6712 case SCREEN_CTRL_ID_PREV_PLAYER:
6713 HandleSetupScreen_Input_Player(step, -1);
6716 case SCREEN_CTRL_ID_NEXT_PLAYER:
6717 HandleSetupScreen_Input_Player(step, +1);
6720 case SCREEN_CTRL_ID_SCROLL_UP:
6721 if (game_status == GAME_MODE_LEVELS)
6722 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6723 else if (game_status == GAME_MODE_LEVELNR)
6724 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6725 else if (game_status == GAME_MODE_SETUP)
6726 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6729 case SCREEN_CTRL_ID_SCROLL_DOWN:
6730 if (game_status == GAME_MODE_LEVELS)
6731 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6732 else if (game_status == GAME_MODE_LEVELNR)
6733 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6734 else if (game_status == GAME_MODE_SETUP)
6735 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6738 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6739 if (game_status == GAME_MODE_LEVELS)
6740 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6741 else if (game_status == GAME_MODE_LEVELNR)
6742 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6743 else if (game_status == GAME_MODE_SETUP)
6744 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);