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"
27 #define DEBUG_JOYSTICKS 0
30 /* screens on the info screen */
31 #define INFO_MODE_MAIN 0
32 #define INFO_MODE_TITLE 1
33 #define INFO_MODE_ELEMENTS 2
34 #define INFO_MODE_MUSIC 3
35 #define INFO_MODE_CREDITS 4
36 #define INFO_MODE_PROGRAM 5
37 #define INFO_MODE_VERSION 6
38 #define INFO_MODE_LEVELSET 7
40 #define MAX_INFO_MODES 8
42 /* screens on the setup screen */
43 /* (must match GFX_SPECIAL_ARG_SETUP_* values as defined in src/main.h) */
44 /* (should also match corresponding entries in src/conf_gfx.c) */
45 #define SETUP_MODE_MAIN 0
46 #define SETUP_MODE_GAME 1
47 #define SETUP_MODE_EDITOR 2
48 #define SETUP_MODE_GRAPHICS 3
49 #define SETUP_MODE_SOUND 4
50 #define SETUP_MODE_ARTWORK 5
51 #define SETUP_MODE_INPUT 6
52 #define SETUP_MODE_TOUCH 7
53 #define SETUP_MODE_SHORTCUTS 8
54 #define SETUP_MODE_SHORTCUTS_1 9
55 #define SETUP_MODE_SHORTCUTS_2 10
56 #define SETUP_MODE_SHORTCUTS_3 11
57 #define SETUP_MODE_SHORTCUTS_4 12
58 #define SETUP_MODE_SHORTCUTS_5 13
60 /* sub-screens on the setup screen (generic) */
61 #define SETUP_MODE_CHOOSE_ARTWORK 14
62 #define SETUP_MODE_CHOOSE_OTHER 15
64 /* sub-screens on the setup screen (specific) */
65 #define SETUP_MODE_CHOOSE_GAME_SPEED 16
66 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17
67 #define SETUP_MODE_CHOOSE_SNAPSHOT_MODE 18
68 #define SETUP_MODE_CHOOSE_WINDOW_SIZE 19
69 #define SETUP_MODE_CHOOSE_SCALING_TYPE 20
70 #define SETUP_MODE_CHOOSE_RENDERING 21
71 #define SETUP_MODE_CHOOSE_GRAPHICS 22
72 #define SETUP_MODE_CHOOSE_SOUNDS 23
73 #define SETUP_MODE_CHOOSE_MUSIC 24
74 #define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 25
75 #define SETUP_MODE_CHOOSE_VOLUME_LOOPS 26
76 #define SETUP_MODE_CHOOSE_VOLUME_MUSIC 27
77 #define SETUP_MODE_CHOOSE_TOUCH_CONTROL 28
78 #define SETUP_MODE_CHOOSE_MOVE_DISTANCE 29
79 #define SETUP_MODE_CHOOSE_DROP_DISTANCE 30
81 #define MAX_SETUP_MODES 31
83 #define MAX_MENU_MODES MAX(MAX_INFO_MODES, MAX_SETUP_MODES)
85 /* for input setup functions */
86 #define SETUPINPUT_SCREEN_POS_START 0
87 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
88 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
89 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
91 #define MENU_SETUP_FONT_TITLE FONT_TEXT_1
92 #define MENU_SETUP_FONT_TEXT FONT_REQUEST
94 /* for various menu stuff */
95 #define MENU_SCREEN_START_XPOS 1
96 #define MENU_SCREEN_START_YPOS 2
97 #define MENU_SCREEN_VALUE_XPOS (SCR_FIELDX - 3)
98 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
99 #define MENU_TITLE1_YPOS 8
100 #define MENU_TITLE2_YPOS 46
101 #define MENU_INFO_FONT_TITLE FONT_TEXT_1
102 #define MENU_INFO_FONT_HEAD FONT_TEXT_2
103 #define MENU_INFO_FONT_TEXT FONT_TEXT_3
104 #define MENU_INFO_FONT_FOOT FONT_TEXT_4
105 #define MENU_INFO_SPACE_HEAD (menu.headline2_spacing_info[info_mode])
106 #define MENU_SCREEN_INFO_XSTART 16
107 #define MENU_SCREEN_INFO_YSTART1 100
108 #define MENU_SCREEN_INFO_YSTART2 (MENU_SCREEN_INFO_YSTART1 + \
109 getMenuTextStep(MENU_INFO_SPACE_HEAD, \
110 MENU_INFO_FONT_TITLE))
111 #define MENU_SCREEN_INFO_YSTEP (TILEY + 4)
112 #define MENU_SCREEN_INFO_YBOTTOM (SYSIZE - 20)
113 #define MENU_SCREEN_INFO_YSIZE (MENU_SCREEN_INFO_YBOTTOM - \
114 MENU_SCREEN_INFO_YSTART2 - \
116 #define MAX_INFO_ELEMENTS_ON_SCREEN 128
117 #define STD_INFO_ELEMENTS_ON_SCREEN (MENU_SCREEN_INFO_YSIZE / \
118 MENU_SCREEN_INFO_YSTEP)
119 #define NUM_INFO_ELEMENTS_FROM_CONF \
120 (menu.list_size_info[GFX_SPECIAL_ARG_INFO_ELEMENTS] > 0 ? \
121 menu.list_size_info[GFX_SPECIAL_ARG_INFO_ELEMENTS] : \
122 MAX_MENU_ENTRIES_ON_SCREEN)
123 #define NUM_INFO_ELEMENTS_ON_SCREEN MIN(MIN(STD_INFO_ELEMENTS_ON_SCREEN, \
124 MAX_INFO_ELEMENTS_ON_SCREEN), \
125 NUM_INFO_ELEMENTS_FROM_CONF)
126 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
127 #define MAX_MENU_TEXT_LENGTH_BIG 13
128 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
130 /* buttons and scrollbars identifiers */
131 #define SCREEN_CTRL_ID_PREV_LEVEL 0
132 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
133 #define SCREEN_CTRL_ID_PREV_PLAYER 2
134 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
135 #define SCREEN_CTRL_ID_SCROLL_UP 4
136 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
137 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
139 #define NUM_SCREEN_GADGETS 7
141 #define NUM_SCREEN_MENUBUTTONS 4
142 #define NUM_SCREEN_SCROLLBUTTONS 2
143 #define NUM_SCREEN_SCROLLBARS 1
145 #define SCREEN_MASK_MAIN (1 << 0)
146 #define SCREEN_MASK_INPUT (1 << 1)
148 /* graphic position and size values for buttons and scrollbars */
149 #define SC_MENUBUTTON_XSIZE TILEX
150 #define SC_MENUBUTTON_YSIZE TILEY
152 #define SC_SCROLLBUTTON_XSIZE TILEX
153 #define SC_SCROLLBUTTON_YSIZE TILEY
155 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
157 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
158 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
159 SC_SCROLLBUTTON_YSIZE)
161 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
162 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
164 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
165 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
166 SC_SCROLLBUTTON_YSIZE)
168 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
169 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
170 SC_SCROLL_VERTICAL_YSIZE)
172 #define SC_BORDER_SIZE 14
175 /* forward declarations of internal functions */
176 static void HandleScreenGadgets(struct GadgetInfo *);
177 static void HandleSetupScreen_Generic(int, int, int, int, int);
178 static void HandleSetupScreen_Input(int, int, int, int, int);
179 static void CustomizeKeyboard(int);
180 static void ConfigureJoystick(int);
181 static void execSetupGame(void);
182 static void execSetupGraphics(void);
183 static void execSetupSound(void);
184 static void execSetupTouch(void);
185 static void execSetupArtwork(void);
186 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
188 static void DrawChooseLevelSet(void);
189 static void DrawChooseLevelNr(void);
190 static void DrawInfoScreen(void);
191 static void DrawSetupScreen(void);
193 static void DrawInfoScreen_NotAvailable(char *, char *);
194 static void DrawInfoScreen_HelpAnim(int, int, boolean);
195 static void DrawInfoScreen_HelpText(int, int, int, int);
196 static void HandleInfoScreen_Main(int, int, int, int, int);
197 static void HandleInfoScreen_TitleScreen(int);
198 static void HandleInfoScreen_Elements(int);
199 static void HandleInfoScreen_Music(int);
200 static void HandleInfoScreen_Credits(int);
201 static void HandleInfoScreen_Program(int);
202 static void HandleInfoScreen_Version(int);
204 static void MapScreenMenuGadgets(int);
205 static void MapScreenGadgets(int);
206 static void MapScreenTreeGadgets(TreeInfo *);
208 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
210 static int info_mode = INFO_MODE_MAIN;
211 static int setup_mode = SETUP_MODE_MAIN;
213 static TreeInfo *window_sizes = NULL;
214 static TreeInfo *window_size_current = NULL;
216 static TreeInfo *scaling_types = NULL;
217 static TreeInfo *scaling_type_current = NULL;
219 static TreeInfo *rendering_modes = NULL;
220 static TreeInfo *rendering_mode_current = NULL;
222 static TreeInfo *scroll_delays = NULL;
223 static TreeInfo *scroll_delay_current = NULL;
225 static TreeInfo *snapshot_modes = NULL;
226 static TreeInfo *snapshot_mode_current = NULL;
228 static TreeInfo *game_speeds = NULL;
229 static TreeInfo *game_speed_current = NULL;
231 static TreeInfo *volumes_simple = NULL;
232 static TreeInfo *volume_simple_current = NULL;
234 static TreeInfo *volumes_loops = NULL;
235 static TreeInfo *volume_loops_current = NULL;
237 static TreeInfo *volumes_music = NULL;
238 static TreeInfo *volume_music_current = NULL;
240 static TreeInfo *touch_controls = NULL;
241 static TreeInfo *touch_control_current = NULL;
243 static TreeInfo *move_distances = NULL;
244 static TreeInfo *move_distance_current = NULL;
246 static TreeInfo *drop_distances = NULL;
247 static TreeInfo *drop_distance_current = NULL;
249 static TreeInfo *level_number = NULL;
250 static TreeInfo *level_number_current = NULL;
256 } window_sizes_list[] =
261 { 100, "100 % (Default)" },
278 } scaling_types_list[] =
280 { SCALING_QUALITY_NEAREST, "None" },
281 { SCALING_QUALITY_LINEAR, "Linear" },
282 { SCALING_QUALITY_BEST, "Anisotropic" },
291 } rendering_modes_list[] =
293 { STR_SPECIAL_RENDERING_OFF, "Off (May show artifacts, fast)" },
294 { STR_SPECIAL_RENDERING_BITMAP, "Bitmap/Texture mode (slower)" },
296 // this mode may work under certain conditions, but does not work on Windows
297 { STR_SPECIAL_RENDERING_TARGET, "Target Texture mode (slower)" },
299 { STR_SPECIAL_RENDERING_DOUBLE, "Double Texture mode (slower)" },
308 } game_speeds_list[] =
317 { 1000, "1/1s (Extremely Slow)" },
322 { 29, "1/35s (Original Supaplex)" },
324 { 20, "1/50s (Normal Speed)" },
325 { 14, "1/70s (Maximum Supaplex)" },
329 { 1, "1/1000s (Extremely Fast)" },
339 } scroll_delays_list[] =
341 { 0, "0 Tiles (No Scroll Delay)" },
344 { 3, "3 Tiles (Default)" },
349 { 8, "8 Tiles (Maximum Scroll Delay)"},
358 } snapshot_modes_list[] =
360 { STR_SNAPSHOT_MODE_OFF, "Off" },
361 { STR_SNAPSHOT_MODE_EVERY_STEP, "Every Step" },
362 { STR_SNAPSHOT_MODE_EVERY_MOVE, "Every Move" },
363 { STR_SNAPSHOT_MODE_EVERY_COLLECT, "Every Collect" },
396 } touch_controls_list[] =
398 { TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" },
399 { TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" },
400 { TOUCH_CONTROL_FOLLOW_FINGER, "Follow Finger" },
424 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
425 (s) <= GAME_MODE_SETUP ? (s) : \
426 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
427 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
429 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
430 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_TITLE && \
431 (i) <= INFO_MODE_LEVELSET ? (i) : \
434 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
435 (i) <= SETUP_MODE_SHORTCUTS_5 ? (i) : \
436 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
437 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
438 SETUP_MODE_CHOOSE_ARTWORK : \
439 SETUP_MODE_CHOOSE_OTHER)
441 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
442 menu.draw_xoffset[GAME_MODE_INFO] : \
443 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
444 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
445 menu.draw_yoffset[GAME_MODE_INFO] : \
446 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
447 #define EXTRA_SPACING_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
448 menu.extra_spacing[GAME_MODE_INFO] : \
449 menu.extra_spacing_info[DRAW_MODE_INFO(i)])
451 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
452 menu.draw_xoffset[GAME_MODE_SETUP] : \
453 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
454 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
455 menu.draw_yoffset[GAME_MODE_SETUP] : \
456 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
457 #define EXTRA_SPACING_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
458 menu.extra_spacing[GAME_MODE_SETUP] : \
459 menu.extra_spacing_setup[DRAW_MODE_SETUP(i)])
461 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
462 DRAW_XOFFSET_INFO(info_mode) : \
463 (s) == GAME_MODE_SETUP ? \
464 DRAW_XOFFSET_SETUP(setup_mode) : \
465 menu.draw_xoffset[DRAW_MODE(s)])
466 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
467 DRAW_YOFFSET_INFO(info_mode) : \
468 (s) == GAME_MODE_SETUP ? \
469 DRAW_YOFFSET_SETUP(setup_mode) : \
470 menu.draw_yoffset[DRAW_MODE(s)])
471 #define EXTRA_SPACING(s) ((s) == GAME_MODE_INFO ? \
472 EXTRA_SPACING_INFO(info_mode) : \
473 (s) == GAME_MODE_SETUP ? \
474 EXTRA_SPACING_SETUP(setup_mode) : \
475 menu.extra_spacing[DRAW_MODE(s)])
477 #define mSX (SX + DRAW_XOFFSET(game_status))
478 #define mSY (SY + DRAW_YOFFSET(game_status))
480 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
481 menu.list_size[game_status] : \
482 MAX_MENU_ENTRIES_ON_SCREEN)
484 #define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \
485 NUM_MENU_ENTRIES_ON_SCREEN)
488 /* title display and control definitions */
490 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
491 2 * MAX_NUM_TITLE_MESSAGES)
493 #define NO_DIRECT_LEVEL_SELECT (-1)
496 static int num_title_screens = 0;
498 struct TitleControlInfo
507 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
509 /* main menu display and control definitions */
511 #define MAIN_CONTROL_NAME 0
512 #define MAIN_CONTROL_LEVELS 1
513 #define MAIN_CONTROL_SCORES 2
514 #define MAIN_CONTROL_EDITOR 3
515 #define MAIN_CONTROL_INFO 4
516 #define MAIN_CONTROL_GAME 5
517 #define MAIN_CONTROL_SETUP 6
518 #define MAIN_CONTROL_QUIT 7
519 #define MAIN_CONTROL_PREV_LEVEL 8
520 #define MAIN_CONTROL_NEXT_LEVEL 9
521 #define MAIN_CONTROL_FIRST_LEVEL 10
522 #define MAIN_CONTROL_LAST_LEVEL 11
523 #define MAIN_CONTROL_LEVEL_NUMBER 12
524 #define MAIN_CONTROL_LEVEL_INFO_1 13
525 #define MAIN_CONTROL_LEVEL_INFO_2 14
526 #define MAIN_CONTROL_LEVEL_NAME 15
527 #define MAIN_CONTROL_LEVEL_AUTHOR 16
528 #define MAIN_CONTROL_LEVEL_YEAR 17
529 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
530 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
531 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
532 #define MAIN_CONTROL_TITLE_1 21
533 #define MAIN_CONTROL_TITLE_2 22
534 #define MAIN_CONTROL_TITLE_3 23
536 static char str_main_text_name[10];
537 static char str_main_text_first_level[10];
538 static char str_main_text_last_level[10];
539 static char str_main_text_level_number[10];
541 static char *main_text_name = str_main_text_name;
542 static char *main_text_first_level = str_main_text_first_level;
543 static char *main_text_last_level = str_main_text_last_level;
544 static char *main_text_level_number = str_main_text_level_number;
545 static char *main_text_levels = "Levelset";
546 static char *main_text_scores = "Hall Of Fame";
547 static char *main_text_editor = "Level Creator";
548 static char *main_text_info = "Info Screen";
549 static char *main_text_game = "Start Game";
550 static char *main_text_setup = "Setup";
551 static char *main_text_quit = "Quit";
552 static char *main_text_level_name = level.name;
553 static char *main_text_level_author = level.author;
554 static char *main_text_level_year = NULL;
555 static char *main_text_level_imported_from = NULL;
556 static char *main_text_level_imported_by = NULL;
557 static char *main_text_level_tested_by = NULL;
559 struct MainControlInfo
563 struct MenuPosInfo *pos_button;
566 struct TextPosInfo *pos_text;
569 struct TextPosInfo *pos_input;
573 static struct MainControlInfo main_controls[] =
577 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
578 &menu.main.text.name, &main_text_name,
579 &menu.main.input.name, &setup.player_name,
583 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
584 &menu.main.text.levels, &main_text_levels,
589 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
590 &menu.main.text.scores, &main_text_scores,
595 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
596 &menu.main.text.editor, &main_text_editor,
601 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
602 &menu.main.text.info, &main_text_info,
607 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
608 &menu.main.text.game, &main_text_game,
613 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
614 &menu.main.text.setup, &main_text_setup,
619 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
620 &menu.main.text.quit, &main_text_quit,
624 /* (these two buttons are real gadgets) */
626 MAIN_CONTROL_PREV_LEVEL,
627 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
632 MAIN_CONTROL_NEXT_LEVEL,
633 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
639 MAIN_CONTROL_FIRST_LEVEL,
641 &menu.main.text.first_level, &main_text_first_level,
645 MAIN_CONTROL_LAST_LEVEL,
647 &menu.main.text.last_level, &main_text_last_level,
651 MAIN_CONTROL_LEVEL_NUMBER,
653 &menu.main.text.level_number, &main_text_level_number,
657 MAIN_CONTROL_LEVEL_INFO_1,
659 &menu.main.text.level_info_1, NULL,
663 MAIN_CONTROL_LEVEL_INFO_2,
665 &menu.main.text.level_info_2, NULL,
669 MAIN_CONTROL_LEVEL_NAME,
671 &menu.main.text.level_name, &main_text_level_name,
675 MAIN_CONTROL_LEVEL_AUTHOR,
677 &menu.main.text.level_author, &main_text_level_author,
681 MAIN_CONTROL_LEVEL_YEAR,
683 &menu.main.text.level_year, &main_text_level_year,
687 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
689 &menu.main.text.level_imported_from, &main_text_level_imported_from,
693 MAIN_CONTROL_LEVEL_IMPORTED_BY,
695 &menu.main.text.level_imported_by, &main_text_level_imported_by,
699 MAIN_CONTROL_LEVEL_TESTED_BY,
701 &menu.main.text.level_tested_by, &main_text_level_tested_by,
705 MAIN_CONTROL_TITLE_1,
707 &menu.main.text.title_1, &setup.internal.program_title,
711 MAIN_CONTROL_TITLE_2,
713 &menu.main.text.title_2, &setup.internal.program_copyright,
717 MAIN_CONTROL_TITLE_3,
719 &menu.main.text.title_3, &setup.internal.program_company,
732 static int getTitleScreenGraphic(int nr, boolean initial)
734 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
737 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
739 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
743 static int getTitleScreenGameMode(boolean initial)
745 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
749 static int getTitleMessageGameMode(boolean initial)
751 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
754 static int getTitleAnimMode(struct TitleControlInfo *tci)
756 int base = (tci->initial ? GAME_MODE_TITLE_INITIAL_1 : GAME_MODE_TITLE_1);
758 return base + tci->local_nr;
762 static int getTitleScreenBackground(boolean initial)
764 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
769 static int getTitleMessageBackground(int nr, boolean initial)
771 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
775 static int getTitleBackground(int nr, boolean initial, boolean is_image)
777 int base = (is_image ?
778 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
779 IMG_BACKGROUND_TITLESCREEN_1) :
780 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
781 IMG_BACKGROUND_TITLEMESSAGE_1));
782 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
783 IMG_BACKGROUND_TITLE);
784 int graphic_local = base + nr;
786 if (graphic_info[graphic_local].bitmap != NULL)
787 return graphic_local;
789 if (graphic_info[graphic_global].bitmap != NULL)
790 return graphic_global;
792 return IMG_UNDEFINED;
795 static int getTitleSound(struct TitleControlInfo *tci)
797 boolean is_image = tci->is_image;
798 int initial = tci->initial;
799 int nr = tci->local_nr;
800 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
801 int base = (is_image ?
802 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
803 SND_BACKGROUND_TITLESCREEN_1) :
804 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
805 SND_BACKGROUND_TITLEMESSAGE_1));
806 int sound_global = menu.sound[mode];
807 int sound_local = base + nr;
810 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
811 nr, initial, is_image,
812 sound_global, getSoundListEntry(sound_global)->filename,
813 sound_local, getSoundListEntry(sound_local)->filename);
816 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
819 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
822 return SND_UNDEFINED;
825 static int getTitleMusic(struct TitleControlInfo *tci)
827 boolean is_image = tci->is_image;
828 int initial = tci->initial;
829 int nr = tci->local_nr;
830 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
831 int base = (is_image ?
832 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
833 MUS_BACKGROUND_TITLESCREEN_1) :
834 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
835 MUS_BACKGROUND_TITLEMESSAGE_1));
836 int music_global = menu.music[mode];
837 int music_local = base + nr;
840 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
841 nr, initial, is_image,
842 music_global, getMusicListEntry(music_global)->filename,
843 music_local, getMusicListEntry(music_local)->filename);
846 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
849 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
852 return MUS_UNDEFINED;
855 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
857 boolean is_image = tci->is_image;
858 boolean initial = tci->initial;
859 boolean first = tci->first;
860 int nr = tci->local_nr;
861 struct TitleMessageInfo tmi;
862 struct TitleFadingInfo ti;
864 tmi = (is_image ? (initial ? (first ?
865 titlescreen_initial_first[nr] :
866 titlescreen_initial[nr])
868 titlescreen_first[nr] :
870 : (initial ? (first ?
871 titlemessage_initial_first[nr] :
872 titlemessage_initial[nr])
874 titlemessage_first[nr] :
877 ti.fade_mode = tmi.fade_mode;
878 ti.fade_delay = tmi.fade_delay;
879 ti.post_delay = tmi.post_delay;
880 ti.auto_delay = tmi.auto_delay;
885 static int compareTitleControlInfo(const void *object1, const void *object2)
887 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
888 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
891 if (tci1->initial != tci2->initial)
892 compare_result = (tci1->initial ? -1 : +1);
893 else if (tci1->sort_priority != tci2->sort_priority)
894 compare_result = tci1->sort_priority - tci2->sort_priority;
895 else if (tci1->is_image != tci2->is_image)
896 compare_result = (tci1->is_image ? -1 : +1);
898 compare_result = tci1->local_nr - tci2->local_nr;
900 return compare_result;
903 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
905 int nr, int sort_priority)
907 title_controls[num_title_screens].is_image = is_image;
908 title_controls[num_title_screens].initial = initial;
909 title_controls[num_title_screens].local_nr = nr;
910 title_controls[num_title_screens].sort_priority = sort_priority;
912 title_controls[num_title_screens].first = FALSE; /* will be set later */
917 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
921 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
923 int graphic = getTitleScreenGraphic(i, initial);
924 Bitmap *bitmap = graphic_info[graphic].bitmap;
925 int sort_priority = graphic_info[graphic].sort_priority;
928 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
931 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
933 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
934 char *filename = getLevelSetTitleMessageFilename(i, initial);
935 int sort_priority = tmi->sort_priority;
937 if (filename != NULL)
938 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
942 static void InitializeTitleControls(boolean show_title_initial)
944 num_title_screens = 0;
946 /* 1st step: initialize title screens for game start (only when starting) */
947 if (show_title_initial)
948 InitializeTitleControls_CheckTitleInfo(TRUE);
950 /* 2nd step: initialize title screens for current level set */
951 InitializeTitleControls_CheckTitleInfo(FALSE);
953 /* sort title screens according to sort_priority and title number */
954 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
955 compareTitleControlInfo);
957 /* mark first title screen */
958 title_controls[0].first = TRUE;
961 static boolean visibleMenuPos(struct MenuPosInfo *pos)
963 return (pos != NULL && pos->x != -1 && pos->y != -1);
966 static boolean visibleTextPos(struct TextPosInfo *pos)
968 return (pos != NULL && pos->x != -1 && pos->y != -1);
971 static void InitializeMainControls()
973 boolean local_team_mode = (!options.network && setup.team_mode);
976 /* set main control text values to dynamically determined values */
977 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
979 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
980 menu.main.text.first_level.size));
981 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
982 menu.main.text.last_level.size));
983 strcpy(main_text_level_number, int2str(level_nr,
984 menu.main.text.level_number.size));
986 main_text_level_year = leveldir_current->year;
987 main_text_level_imported_from = leveldir_current->imported_from;
988 main_text_level_imported_by = leveldir_current->imported_by;
989 main_text_level_tested_by = leveldir_current->tested_by;
991 /* set main control screen positions to dynamically determined values */
992 for (i = 0; main_controls[i].nr != -1; i++)
994 struct MainControlInfo *mci = &main_controls[i];
996 struct MenuPosInfo *pos_button = mci->pos_button;
997 struct TextPosInfo *pos_text = mci->pos_text;
998 struct TextPosInfo *pos_input = mci->pos_input;
999 char *text = (mci->text ? *mci->text : NULL);
1000 char *input = (mci->input ? *mci->input : NULL);
1001 int button_graphic = mci->button_graphic;
1002 int font_text = (pos_text ? pos_text->font : -1);
1003 int font_input = (pos_input ? pos_input->font : -1);
1005 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
1006 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
1007 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
1008 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
1009 int text_chars = (text != NULL ? strlen(text) : 0);
1010 int input_chars = (input != NULL ? strlen(input) : 0);
1013 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
1015 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
1016 int text_width = font_text_width * text_chars;
1017 int text_height = font_text_height;
1018 int input_width = font_input_width * input_chars;
1019 int input_height = font_input_height;
1021 if (nr == MAIN_CONTROL_NAME)
1023 menu.main.input.name.width = input_width;
1024 menu.main.input.name.height = input_height;
1027 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
1029 pos_button->width = button_width;
1030 pos_button->height = button_height;
1033 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
1035 /* calculate size for non-clickable text -- needed for text alignment */
1036 boolean calculate_text_size = (pos_button == NULL && text != NULL);
1038 if (pos_text->width == -1 || calculate_text_size)
1039 pos_text->width = text_width;
1040 if (pos_text->height == -1 || calculate_text_size)
1041 pos_text->height = text_height;
1043 if (visibleMenuPos(pos_button))
1045 if (pos_text->x == -1)
1046 pos_text->x = pos_button->x + pos_button->width;
1047 if (pos_text->y == -1)
1049 pos_button->y + (pos_button->height - pos_text->height) / 2;
1053 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
1055 if (visibleTextPos(pos_text))
1057 if (pos_input->x == -1)
1058 pos_input->x = pos_text->x + pos_text->width;
1059 if (pos_input->y == -1)
1060 pos_input->y = pos_text->y;
1063 if (pos_input->width == -1)
1064 pos_input->width = input_width;
1065 if (pos_input->height == -1)
1066 pos_input->height = input_height;
1071 static void DrawPressedGraphicThruMask(int dst_x, int dst_y,
1072 int graphic, boolean pressed)
1074 struct GraphicInfo *g = &graphic_info[graphic];
1077 int xoffset = (pressed ? g->pressed_xoffset : 0);
1078 int yoffset = (pressed ? g->pressed_yoffset : 0);
1080 getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
1082 BlitBitmapMasked(src_bitmap, drawto, src_x + xoffset, src_y + yoffset,
1083 g->width, g->height, dst_x, dst_y);
1086 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1087 boolean active_input,
1088 boolean pressed_button)
1092 for (i = 0; main_controls[i].nr != -1; i++)
1094 struct MainControlInfo *mci = &main_controls[i];
1096 if (mci->nr == nr || nr == -1)
1098 struct MenuPosInfo *pos_button = mci->pos_button;
1099 struct TextPosInfo *pos_text = mci->pos_text;
1100 struct TextPosInfo *pos_input = mci->pos_input;
1101 char *text = (mci->text ? *mci->text : NULL);
1102 char *input = (mci->input ? *mci->input : NULL);
1103 int button_graphic = mci->button_graphic;
1104 int font_text = (pos_text ? pos_text->font : -1);
1105 int font_input = (pos_input ? pos_input->font : -1);
1109 button_graphic = BUTTON_ACTIVE(button_graphic);
1110 font_text = FONT_ACTIVE(font_text);
1115 font_input = FONT_ACTIVE(font_input);
1118 if (visibleMenuPos(pos_button))
1120 struct MenuPosInfo *pos = pos_button;
1121 int x = mSX + pos->x;
1122 int y = mSY + pos->y;
1124 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1125 DrawPressedGraphicThruMask(x, y, button_graphic, pressed_button);
1128 if (visibleTextPos(pos_text) && text != NULL)
1130 struct TextPosInfo *pos = pos_text;
1131 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1132 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1135 /* (check why/if this is needed) */
1136 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1138 DrawText(x, y, text, font_text);
1141 if (visibleTextPos(pos_input) && input != NULL)
1143 struct TextPosInfo *pos = pos_input;
1144 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1145 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1148 /* (check why/if this is needed) */
1149 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1151 DrawText(x, y, input, font_input);
1157 static void DrawCursorAndText_Main(int nr, boolean active_text,
1158 boolean pressed_button)
1160 DrawCursorAndText_Main_Ext(nr, active_text, FALSE, pressed_button);
1164 static void DrawCursorAndText_Main_Input(int nr, boolean active_text,
1165 boolean pressed_button)
1167 DrawCursorAndText_Main_Ext(nr, active_text, TRUE, pressed_button);
1171 static struct MainControlInfo *getMainControlInfo(int nr)
1175 for (i = 0; main_controls[i].nr != -1; i++)
1176 if (main_controls[i].nr == nr)
1177 return &main_controls[i];
1182 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1187 int rect_x = ALIGNED_TEXT_XPOS(rect);
1188 int rect_y = ALIGNED_TEXT_YPOS(rect);
1190 return (x >= rect_x && x < rect_x + rect->width &&
1191 y >= rect_y && y < rect_y + rect->height);
1194 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1199 int rect_x = ALIGNED_TEXT_XPOS(rect);
1200 int rect_y = ALIGNED_TEXT_YPOS(rect);
1203 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1204 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1205 (x >= rect_x && x < rect_x + rect->width &&
1206 y >= rect_y && y < rect_y + rect->height));
1209 return (x >= rect_x && x < rect_x + rect->width &&
1210 y >= rect_y && y < rect_y + rect->height);
1213 static boolean insidePreviewRect(struct PreviewInfo *preview, int x, int y)
1215 int rect_width = preview->xsize * preview->tile_size;
1216 int rect_height = preview->ysize * preview->tile_size;
1217 int rect_x = ALIGNED_XPOS(preview->x, rect_width, preview->align);
1218 int rect_y = ALIGNED_YPOS(preview->y, rect_height, preview->valign);
1220 return (x >= rect_x && x < rect_x + rect_width &&
1221 y >= rect_y && y < rect_y + rect_height);
1224 static void AdjustScrollbar(int id, int items_max, int items_visible,
1227 struct GadgetInfo *gi = screen_gadget[id];
1229 if (item_position > items_max - items_visible)
1230 item_position = items_max - items_visible;
1232 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
1233 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
1234 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
1237 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
1239 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
1243 static void clearMenuListArea()
1245 int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
1247 /* correct scrollbar position if placed outside menu (playfield) area */
1248 if (scrollbar_xpos > SX + SC_SCROLLBAR_XPOS)
1249 scrollbar_xpos = SX + SC_SCROLLBAR_XPOS;
1251 /* clear menu list area, but not title or scrollbar */
1252 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
1253 scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
1256 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1258 static int cursor_array[MAX_LEV_FIELDY];
1259 int x = mSX + TILEX * xpos;
1260 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1265 cursor_array[ypos] = graphic;
1267 graphic = cursor_array[ypos];
1271 graphic = BUTTON_ACTIVE(graphic);
1273 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1274 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1277 static void initCursor(int ypos, int graphic)
1279 drawCursorExt(0, ypos, FALSE, graphic);
1282 static void drawCursor(int ypos, boolean active)
1284 drawCursorExt(0, ypos, active, -1);
1287 static void drawCursorXY(int xpos, int ypos, int graphic)
1289 drawCursorExt(xpos, ypos, FALSE, graphic);
1292 static void drawChooseTreeCursor(int ypos, boolean active)
1294 drawCursorExt(0, ypos, active, -1);
1299 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, getProgramTitleString());
1300 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
1301 setup.internal.program_copyright);
1304 void DrawTitleScreenImage(int nr, boolean initial)
1306 int graphic = getTitleScreenGraphic(nr, initial);
1307 Bitmap *bitmap = graphic_info[graphic].bitmap;
1308 int width = graphic_info[graphic].width;
1309 int height = graphic_info[graphic].height;
1310 int src_x = graphic_info[graphic].src_x;
1311 int src_y = graphic_info[graphic].src_y;
1317 if (width > WIN_XSIZE)
1319 /* image width too large for window => center image horizontally */
1320 src_x = (width - WIN_XSIZE) / 2;
1324 if (height > WIN_YSIZE)
1326 /* image height too large for window => center image vertically */
1327 src_y = (height - WIN_YSIZE) / 2;
1331 /* always display title screens centered */
1332 dst_x = (WIN_XSIZE - width) / 2;
1333 dst_y = (WIN_YSIZE - height) / 2;
1335 SetDrawBackgroundMask(REDRAW_ALL);
1336 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1338 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1340 if (DrawingOnBackground(dst_x, dst_y))
1341 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1343 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1345 redraw_mask = REDRAW_ALL;
1348 void DrawTitleScreenMessage(int nr, boolean initial)
1350 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1351 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1353 if (filename == NULL)
1356 /* force TITLE font on title message screen */
1357 SetFontStatus(getTitleMessageGameMode(initial));
1359 /* if chars *and* width set to "-1", automatically determine width */
1360 if (tmi->chars == -1 && tmi->width == -1)
1361 tmi->width = viewport.window[game_status].width;
1363 /* if lines *and* height set to "-1", automatically determine height */
1364 if (tmi->lines == -1 && tmi->height == -1)
1365 tmi->height = viewport.window[game_status].height;
1367 /* if chars set to "-1", automatically determine by text and font width */
1368 if (tmi->chars == -1)
1369 tmi->chars = tmi->width / getFontWidth(tmi->font);
1371 tmi->width = tmi->chars * getFontWidth(tmi->font);
1373 /* if lines set to "-1", automatically determine by text and font height */
1374 if (tmi->lines == -1)
1375 tmi->lines = tmi->height / getFontHeight(tmi->font);
1377 tmi->height = tmi->lines * getFontHeight(tmi->font);
1379 /* if x set to "-1", automatically determine by width and alignment */
1381 tmi->x = -1 * ALIGNED_XPOS(0, tmi->width, tmi->align);
1383 /* if y set to "-1", automatically determine by height and alignment */
1385 tmi->y = -1 * ALIGNED_YPOS(0, tmi->height, tmi->valign);
1387 SetDrawBackgroundMask(REDRAW_ALL);
1388 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1390 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1392 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1393 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1394 tmi->autowrap, tmi->centered, tmi->parse_comments);
1399 void DrawTitleScreen()
1401 KeyboardAutoRepeatOff();
1403 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1406 boolean CheckTitleScreen(boolean levelset_has_changed)
1408 static boolean show_title_initial = TRUE;
1409 boolean show_titlescreen = FALSE;
1411 /* needed to be able to skip title screen, if no image or message defined */
1412 InitializeTitleControls(show_title_initial);
1414 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1415 show_titlescreen = TRUE;
1417 /* show initial title images and messages only once at program start */
1418 show_title_initial = FALSE;
1420 return (show_titlescreen && num_title_screens > 0);
1425 static LevelDirTree *leveldir_last_valid = NULL;
1426 boolean levelset_has_changed = FALSE;
1427 int fade_mask = REDRAW_FIELD;
1429 LimitScreenUpdates(FALSE);
1431 FadeSetLeaveScreen();
1433 /* do not fade out here -- function may continue and fade on editor screen */
1436 FadeMenuSoundsAndMusic();
1438 ExpireSoundLoops(FALSE);
1440 KeyboardAutoRepeatOn();
1442 audio.sound_deactivated = FALSE;
1446 /* needed if last screen was the playing screen, invoked from level editor */
1447 if (level_editor_test_game)
1449 CloseDoor(DOOR_CLOSE_ALL);
1451 SetGameStatus(GAME_MODE_EDITOR);
1458 /* needed if last screen was the setup screen and fullscreen state changed */
1459 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1460 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1462 /* leveldir_current may be invalid (level group, parent link) */
1463 if (!validLevelSeries(leveldir_current))
1464 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1466 if (leveldir_current != leveldir_last_valid)
1467 levelset_has_changed = TRUE;
1469 /* store valid level series information */
1470 leveldir_last_valid = leveldir_current;
1472 init_last = init; /* switch to new busy animation */
1474 /* needed if last screen (level choice) changed graphics, sounds or music */
1475 ReloadCustomArtwork(0);
1477 if (CheckTitleScreen(levelset_has_changed))
1479 SetGameStatus(GAME_MODE_TITLE);
1486 if (redraw_mask & REDRAW_ALL)
1487 fade_mask = REDRAW_ALL;
1489 if (CheckIfGlobalBorderHasChanged())
1490 fade_mask = REDRAW_ALL;
1494 /* needed if different viewport properties defined for menues */
1495 ChangeViewportPropertiesIfNeeded();
1497 SetDrawtoField(DRAW_TO_BACKBUFFER);
1499 /* level_nr may have been set to value over handicap with level editor */
1500 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1501 level_nr = leveldir_current->handicap_level;
1503 LoadLevel(level_nr);
1504 LoadScore(level_nr);
1506 SaveLevelSetup_SeriesInfo();
1508 // set this after "ChangeViewportPropertiesIfNeeded()" (which may reset it)
1509 SetDrawDeactivationMask(REDRAW_NONE);
1510 SetDrawBackgroundMask(REDRAW_FIELD);
1512 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1515 if (fade_mask == REDRAW_ALL)
1516 RedrawGlobalBorder();
1521 InitializeMainControls();
1523 DrawCursorAndText_Main(-1, FALSE, FALSE);
1524 DrawPreviewLevelInitial();
1526 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1529 if (TAPE_IS_EMPTY(tape))
1531 DrawCompleteVideoDisplay();
1533 PlayMenuSoundsAndMusic();
1535 /* create gadgets for main menu screen */
1536 FreeScreenGadgets();
1537 CreateScreenGadgets();
1539 /* map gadgets for main menu screen */
1541 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1543 /* copy actual game door content to door double buffer for OpenDoor() */
1544 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
1545 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1547 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1549 DrawMaskedBorder(fade_mask);
1554 /* update screen area with special editor door */
1555 redraw_mask |= REDRAW_ALL;
1558 SetMouseCursor(CURSOR_DEFAULT);
1560 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1563 static void gotoTopLevelDir()
1565 /* move upwards until inside (but not above) top level directory */
1566 while (leveldir_current->node_parent &&
1567 !strEqual(leveldir_current->node_parent->subdir, STRING_TOP_DIRECTORY))
1569 /* write a "path" into level tree for easy navigation to last level */
1570 if (leveldir_current->node_parent->node_group->cl_first == -1)
1572 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1573 int leveldir_pos = posTreeInfo(leveldir_current);
1574 int num_page_entries;
1575 int cl_first, cl_cursor;
1577 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1578 num_page_entries = num_leveldirs;
1580 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1582 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1583 cl_cursor = leveldir_pos - cl_first;
1585 leveldir_current->node_parent->node_group->cl_first = cl_first;
1586 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1589 leveldir_current = leveldir_current->node_parent;
1593 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1595 static unsigned int title_delay = 0;
1596 static int title_screen_nr = 0;
1597 static int last_sound = -1, last_music = -1;
1598 boolean return_to_main_menu = FALSE;
1599 struct TitleControlInfo *tci;
1602 if (button == MB_MENU_INITIALIZE)
1605 title_screen_nr = 0;
1606 tci = &title_controls[title_screen_nr];
1608 SetAnimStatus(getTitleAnimMode(tci));
1610 last_sound = SND_UNDEFINED;
1611 last_music = MUS_UNDEFINED;
1613 if (num_title_screens != 0)
1615 FadeSetEnterScreen();
1617 /* use individual title fading instead of global "enter screen" fading */
1618 fading = getTitleFading(tci);
1621 if (game_status_last_screen == GAME_MODE_INFO)
1623 if (num_title_screens == 0)
1625 /* switch game mode from title screen mode back to info screen mode */
1626 SetGameStatus(GAME_MODE_INFO);
1628 /* store that last screen was info screen, not main menu screen */
1629 game_status_last_screen = GAME_MODE_INFO;
1631 DrawInfoScreen_NotAvailable("Title screen information:",
1632 "No title screen for this level set.");
1636 FadeMenuSoundsAndMusic();
1639 FadeOut(REDRAW_ALL);
1641 /* title screens may have different window size */
1642 ChangeViewportPropertiesIfNeeded();
1644 /* only required to update logic for redrawing global border */
1648 DrawTitleScreenImage(tci->local_nr, tci->initial);
1650 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1652 sound = getTitleSound(tci);
1653 music = getTitleMusic(tci);
1655 if (sound != last_sound)
1656 PlayMenuSoundExt(sound);
1657 if (music != last_music)
1658 PlayMenuMusicExt(music);
1663 SetMouseCursor(CURSOR_NONE);
1667 DelayReached(&title_delay, 0); /* reset delay counter */
1672 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1673 button = MB_MENU_CHOICE;
1675 if (button == MB_MENU_LEAVE)
1677 return_to_main_menu = TRUE;
1679 else if (button == MB_MENU_CHOICE)
1681 if (game_status_last_screen == GAME_MODE_INFO && num_title_screens == 0)
1683 SetGameStatus(GAME_MODE_INFO);
1685 info_mode = INFO_MODE_MAIN;
1694 if (title_screen_nr < num_title_screens)
1696 tci = &title_controls[title_screen_nr];
1698 SetAnimStatus(getTitleAnimMode(tci));
1700 sound = getTitleSound(tci);
1701 music = getTitleMusic(tci);
1703 if (last_sound != SND_UNDEFINED && sound != last_sound)
1704 FadeSound(last_sound);
1705 if (last_music != MUS_UNDEFINED && music != last_music)
1708 fading = getTitleFading(tci);
1710 FadeOut(REDRAW_ALL);
1713 DrawTitleScreenImage(tci->local_nr, tci->initial);
1715 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1717 sound = getTitleSound(tci);
1718 music = getTitleMusic(tci);
1720 if (sound != last_sound)
1721 PlayMenuSoundExt(sound);
1722 if (music != last_music)
1723 PlayMenuMusicExt(music);
1730 DelayReached(&title_delay, 0); /* reset delay counter */
1734 FadeMenuSoundsAndMusic();
1736 return_to_main_menu = TRUE;
1740 if (return_to_main_menu)
1742 SetMouseCursor(CURSOR_DEFAULT);
1744 /* force full menu screen redraw after displaying title screens */
1745 redraw_mask = REDRAW_ALL;
1747 if (game_status_last_screen == GAME_MODE_INFO)
1749 SetGameStatus(GAME_MODE_INFO);
1751 info_mode = INFO_MODE_MAIN;
1755 else /* default: return to main menu */
1757 SetGameStatus(GAME_MODE_MAIN);
1764 void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
1766 int old_level_nr = level_nr;
1769 if (selected_level_nr != NO_DIRECT_LEVEL_SELECT)
1770 new_level_nr = selected_level_nr;
1772 new_level_nr = old_level_nr + step * direction;
1774 if (new_level_nr < leveldir_current->first_level)
1775 new_level_nr = leveldir_current->first_level;
1776 if (new_level_nr > leveldir_current->last_level)
1777 new_level_nr = leveldir_current->last_level;
1779 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1781 /* skipping levels is only allowed when trying to skip single level */
1782 if (setup.skip_levels && new_level_nr == old_level_nr + 1 &&
1783 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1785 leveldir_current->handicap_level++;
1786 SaveLevelSetup_SeriesInfo();
1789 new_level_nr = leveldir_current->handicap_level;
1792 if (new_level_nr != old_level_nr)
1794 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1796 PlaySound(SND_MENU_ITEM_SELECTING);
1798 level_nr = new_level_nr;
1800 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1801 int2str(level_nr, menu.main.text.level_number.size),
1802 mci->pos_text->font);
1804 LoadLevel(level_nr);
1805 DrawPreviewLevelInitial();
1809 DrawCompleteVideoDisplay();
1811 SaveLevelSetup_SeriesInfo();
1813 /* needed because DrawPreviewLevelInitial() takes some time */
1815 /* SyncDisplay(); */
1819 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1821 static int choice = MAIN_CONTROL_GAME;
1822 static boolean button_pressed_last = FALSE;
1823 boolean button_pressed = FALSE;
1827 if (button == MB_MENU_INITIALIZE)
1829 DrawCursorAndText_Main(choice, TRUE, FALSE);
1834 if (mx || my) /* mouse input */
1838 for (i = 0; main_controls[i].nr != -1; i++)
1840 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1841 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1842 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1844 pos = main_controls[i].nr;
1850 /* check if level preview was clicked */
1851 if (insidePreviewRect(&preview, mx - SX, my - SY))
1852 pos = MAIN_CONTROL_GAME;
1854 // handle pressed/unpressed state for active/inactive menu buttons
1855 // (if pos != -1, "i" contains index position corresponding to "pos")
1857 pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT &&
1858 insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY))
1859 button_pressed = TRUE;
1861 if (button_pressed != button_pressed_last)
1863 DrawCursorAndText_Main(choice, TRUE, button_pressed);
1866 PlaySound(SND_MENU_BUTTON_PRESSING);
1868 PlaySound(SND_MENU_BUTTON_RELEASING);
1871 else if (dx || dy) /* keyboard input */
1873 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1874 choice == MAIN_CONTROL_SETUP))
1875 button = MB_MENU_CHOICE;
1880 if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1882 HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
1884 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1886 HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT);
1888 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1890 CloseDoor(DOOR_CLOSE_2);
1892 SetGameStatus(GAME_MODE_LEVELNR);
1894 DrawChooseLevelNr();
1896 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1902 PlaySound(SND_MENU_ITEM_ACTIVATING);
1904 DrawCursorAndText_Main(choice, FALSE, FALSE);
1905 DrawCursorAndText_Main(pos, TRUE, button_pressed);
1911 if (choice != MAIN_CONTROL_INFO &&
1912 choice != MAIN_CONTROL_SETUP)
1913 HandleMainMenu_SelectLevel(1, dx, NO_DIRECT_LEVEL_SELECT);
1918 PlaySound(SND_MENU_ITEM_SELECTING);
1920 if (pos == MAIN_CONTROL_NAME)
1922 SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
1924 HandleTypeName(strlen(setup.player_name), 0);
1926 else if (pos == MAIN_CONTROL_LEVELS)
1930 CloseDoor(DOOR_CLOSE_2);
1932 SetGameStatus(GAME_MODE_LEVELS);
1934 SaveLevelSetup_LastSeries();
1935 SaveLevelSetup_SeriesInfo();
1937 if (setup.internal.choose_from_top_leveldir)
1940 DrawChooseLevelSet();
1943 else if (pos == MAIN_CONTROL_SCORES)
1945 CloseDoor(DOOR_CLOSE_2);
1947 SetGameStatus(GAME_MODE_SCORES);
1951 else if (pos == MAIN_CONTROL_EDITOR)
1953 if (leveldir_current->readonly &&
1954 !strEqual(setup.player_name, "Artsoft"))
1955 Request("This level is read only!", REQ_CONFIRM);
1957 CloseDoor(DOOR_CLOSE_2);
1959 SetGameStatus(GAME_MODE_EDITOR);
1961 FadeSetEnterScreen();
1965 else if (pos == MAIN_CONTROL_INFO)
1967 CloseDoor(DOOR_CLOSE_2);
1969 SetGameStatus(GAME_MODE_INFO);
1971 info_mode = INFO_MODE_MAIN;
1975 else if (pos == MAIN_CONTROL_GAME)
1977 StartGameActions(options.network, setup.autorecord, level.random_seed);
1979 else if (pos == MAIN_CONTROL_SETUP)
1981 CloseDoor(DOOR_CLOSE_2);
1983 SetGameStatus(GAME_MODE_SETUP);
1985 setup_mode = SETUP_MODE_MAIN;
1989 else if (pos == MAIN_CONTROL_QUIT)
1991 SaveLevelSetup_LastSeries();
1992 SaveLevelSetup_SeriesInfo();
1994 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1995 SetGameStatus(GAME_MODE_QUIT);
2000 button_pressed_last = button_pressed;
2004 /* ========================================================================= */
2005 /* info screen functions */
2006 /* ========================================================================= */
2008 static struct TokenInfo *info_info;
2009 static int num_info_info; /* number of info entries shown on screen */
2010 static int max_info_info; /* total number of info entries in list */
2012 static void execInfoTitleScreen()
2014 info_mode = INFO_MODE_TITLE;
2019 static void execInfoElements()
2021 info_mode = INFO_MODE_ELEMENTS;
2026 static void execInfoMusic()
2028 info_mode = INFO_MODE_MUSIC;
2033 static void execInfoCredits()
2035 info_mode = INFO_MODE_CREDITS;
2040 static void execInfoProgram()
2042 info_mode = INFO_MODE_PROGRAM;
2047 static void execInfoVersion()
2049 info_mode = INFO_MODE_VERSION;
2054 static void execInfoLevelSet()
2056 info_mode = INFO_MODE_LEVELSET;
2061 static void execExitInfo()
2063 SetGameStatus(GAME_MODE_MAIN);
2068 static struct TokenInfo info_info_main[] =
2070 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2071 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2072 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2073 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2074 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2075 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2076 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2077 { TYPE_EMPTY, NULL, "" },
2078 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2083 static int getMenuTextFont(int type)
2085 if (type & (TYPE_SWITCH |
2097 static struct TokenInfo *setup_info;
2098 static struct TokenInfo setup_info_input[];
2100 static struct TokenInfo *menu_info;
2102 static void DrawCursorAndText_Menu_Ext(struct TokenInfo *token_info,
2103 int screen_pos, int menu_info_pos_raw,
2106 int pos = (menu_info_pos_raw < 0 ? screen_pos : menu_info_pos_raw);
2107 struct TokenInfo *ti = &token_info[pos];
2108 int xpos = MENU_SCREEN_START_XPOS;
2109 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
2110 int font_nr = getMenuTextFont(ti->type);
2112 if (token_info == setup_info_input)
2113 font_nr = FONT_MENU_1;
2116 font_nr = FONT_ACTIVE(font_nr);
2118 DrawText(mSX + xpos * 32, mSY + ypos * 32, ti->text, font_nr);
2120 if (ti->type & ~TYPE_SKIP_ENTRY)
2121 drawCursor(screen_pos, active);
2124 static void DrawCursorAndText_Menu(int screen_pos, int menu_info_pos_raw,
2127 DrawCursorAndText_Menu_Ext(menu_info, screen_pos, menu_info_pos_raw, active);
2130 static void DrawCursorAndText_Setup(int screen_pos, int menu_info_pos_raw,
2133 DrawCursorAndText_Menu_Ext(setup_info, screen_pos, menu_info_pos_raw, active);
2136 static char *window_size_text;
2137 static char *scaling_type_text;
2139 static void drawSetupValue(int, int);
2141 static void drawMenuInfoList(int first_entry, int num_page_entries,
2142 int max_page_entries)
2146 if (first_entry + num_page_entries > max_page_entries)
2149 clearMenuListArea();
2151 for (i = 0; i < num_page_entries; i++)
2153 int menu_info_pos = first_entry + i;
2154 struct TokenInfo *si = &menu_info[menu_info_pos];
2155 void *value_ptr = si->value;
2157 /* set some entries to "unchangeable" according to other variables */
2158 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
2159 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
2160 (value_ptr == &setup.sound_music && !audio.music_available) ||
2161 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
2162 (value_ptr == &window_size_text && !video.window_scaling_available) ||
2163 (value_ptr == &scaling_type_text && !video.window_scaling_available))
2164 si->type |= TYPE_GHOSTED;
2166 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2167 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2168 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2169 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2170 else if (si->type & ~TYPE_SKIP_ENTRY)
2171 initCursor(i, IMG_MENU_BUTTON);
2173 DrawCursorAndText_Menu(i, menu_info_pos, FALSE);
2175 if (si->type & TYPE_VALUE &&
2176 menu_info == setup_info)
2177 drawSetupValue(i, menu_info_pos);
2181 static void DrawInfoScreen_Main()
2183 int fade_mask = REDRAW_FIELD;
2186 if (redraw_mask & REDRAW_ALL)
2187 fade_mask = REDRAW_ALL;
2189 if (CheckIfGlobalBorderHasChanged())
2190 fade_mask = REDRAW_ALL;
2193 FadeMenuSoundsAndMusic();
2195 FreeScreenGadgets();
2196 CreateScreenGadgets();
2198 /* (needed after displaying title screens which disable auto repeat) */
2199 KeyboardAutoRepeatOn();
2201 FadeSetLeaveScreen();
2205 /* needed if different viewport properties defined for info screen */
2206 ChangeViewportPropertiesIfNeeded();
2208 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
2212 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2214 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2216 info_info = info_info_main;
2218 // determine maximal number of info entries that can be displayed on screen
2220 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2223 // determine maximal number of info entries available for menu of info screen
2225 for (i = 0; info_info[i].type != 0; i++)
2228 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2230 MapScreenGadgets(max_info_info);
2232 PlayMenuSoundsAndMusic();
2234 DrawMaskedBorder(fade_mask);
2239 static void changeSetupValue(int, int, int);
2241 void HandleMenuScreen(int mx, int my, int dx, int dy, int button,
2242 int mode, int num_page_entries, int max_page_entries)
2244 static int num_page_entries_all_last[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
2245 static int choice_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
2246 static int first_entry_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
2247 int *num_page_entries_last = num_page_entries_all_last[game_status];
2248 int *choice_store = choice_stores[game_status];
2249 int *first_entry_store = first_entry_stores[game_status];
2250 int choice = choice_store[mode]; /* starts with 0 */
2251 int first_entry = first_entry_store[mode]; /* starts with 0 */
2253 int y = choice - first_entry;
2255 boolean position_set_by_scrollbar = (dx == 999);
2256 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
2259 if (button == MB_MENU_INITIALIZE)
2261 // check if number of menu page entries has changed (may happen by change
2262 // of custom artwork definition value for 'list_size' for this menu screen)
2263 // (in this case, the last menu position most probably has to be corrected)
2264 if (num_page_entries != num_page_entries_last[mode])
2266 choice_store[mode] = first_entry_store[mode] = 0;
2268 choice = first_entry = 0;
2271 num_page_entries_last[mode] = num_page_entries;
2274 /* advance to first valid menu entry */
2275 while (choice < num_page_entries &&
2276 menu_info[choice].type & TYPE_SKIP_ENTRY)
2279 if (position_set_by_scrollbar)
2280 first_entry = first_entry_store[mode] = dy;
2282 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_page_entries,
2283 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
2285 drawMenuInfoList(first_entry, num_page_entries, max_page_entries);
2287 if (choice < first_entry)
2289 choice = first_entry;
2291 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2294 else if (choice > first_entry + num_page_entries - 1)
2296 choice = first_entry + num_page_entries - 1;
2298 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2302 choice_store[mode] = choice;
2304 DrawCursorAndText_Menu(choice - first_entry, choice, TRUE);
2308 else if (button == MB_MENU_LEAVE)
2310 PlaySound(SND_MENU_ITEM_SELECTING);
2312 for (i = 0; i < max_page_entries; i++)
2314 if (menu_info[i].type & TYPE_LEAVE_MENU)
2316 void (*menu_callback_function)(void) = menu_info[i].value;
2320 menu_callback_function();
2322 break; /* absolutely needed because function changes 'menu_info'! */
2329 if (mx || my) /* mouse input */
2331 x = (mx - mSX) / 32;
2332 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2334 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
2336 /* move cursor instead of scrolling when already at start/end of list */
2337 if (dy == -1 * SCROLL_LINE && first_entry == 0)
2339 else if (dy == +1 * SCROLL_LINE &&
2340 first_entry + num_page_entries == max_page_entries)
2343 /* handle scrolling screen one line or page */
2345 y + dy > num_page_entries - 1)
2347 boolean redraw = FALSE;
2349 if (ABS(dy) == SCROLL_PAGE)
2350 step = num_page_entries - 1;
2352 if (dy < 0 && first_entry > 0)
2354 /* scroll page/line up */
2356 first_entry -= step;
2357 if (first_entry < 0)
2362 else if (dy > 0 && first_entry + num_page_entries < max_page_entries)
2364 /* scroll page/line down */
2366 first_entry += step;
2367 if (first_entry + num_page_entries > max_page_entries)
2368 first_entry = MAX(0, max_page_entries - num_page_entries);
2375 choice += first_entry - first_entry_store[mode];
2377 if (choice < first_entry)
2379 choice = first_entry;
2381 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2384 else if (choice > first_entry + num_page_entries - 1)
2386 choice = first_entry + num_page_entries - 1;
2388 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2391 else if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2395 if (choice < first_entry ||
2396 choice > first_entry + num_page_entries - 1)
2397 first_entry += SIGN(dy);
2400 first_entry_store[mode] = first_entry;
2401 choice_store[mode] = choice;
2403 drawMenuInfoList(first_entry, num_page_entries, max_page_entries);
2405 DrawCursorAndText_Menu(choice - first_entry, choice, TRUE);
2407 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_page_entries,
2408 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
2416 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2418 if (menu_info[choice].type & menu_navigation_type ||
2419 menu_info[choice].type & TYPE_BOOLEAN_STYLE ||
2420 menu_info[choice].type & TYPE_YES_NO_AUTO)
2421 button = MB_MENU_CHOICE;
2426 /* jump to next non-empty menu entry (up or down) */
2427 while (first_entry + y > 0 &&
2428 first_entry + y < max_page_entries - 1 &&
2429 menu_info[first_entry + y].type & TYPE_SKIP_ENTRY)
2432 if (!IN_VIS_MENU(x, y))
2434 choice += y - y_old;
2436 if (choice < first_entry)
2437 first_entry = choice;
2438 else if (choice > first_entry + num_page_entries - 1)
2439 first_entry = choice - num_page_entries + 1;
2441 if (first_entry >= 0 &&
2442 first_entry + num_page_entries <= max_page_entries)
2444 first_entry_store[mode] = first_entry;
2446 if (choice < first_entry)
2447 choice = first_entry;
2448 else if (choice > first_entry + num_page_entries - 1)
2449 choice = first_entry + num_page_entries - 1;
2451 choice_store[mode] = choice;
2453 drawMenuInfoList(first_entry, num_page_entries, max_page_entries);
2455 DrawCursorAndText_Menu(choice - first_entry, choice, TRUE);
2457 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_page_entries,
2458 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
2465 if (!anyScrollbarGadgetActive() &&
2466 IN_VIS_MENU(x, y) &&
2467 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
2468 y >= 0 && y < num_page_entries)
2472 if (first_entry + y != choice &&
2473 menu_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
2475 PlaySound(SND_MENU_ITEM_ACTIVATING);
2477 DrawCursorAndText_Menu(choice - first_entry, choice, FALSE);
2478 DrawCursorAndText_Menu(y, first_entry + y, TRUE);
2480 choice = choice_store[mode] = first_entry + y;
2484 PlaySound(SND_MENU_ITEM_SELECTING);
2486 for (i = 0; menu_info[i].type != 0; i++)
2488 if (menu_info[i].type & TYPE_LEAVE_MENU)
2490 void (*menu_callback_function)(void) = menu_info[i].value;
2494 menu_callback_function();
2496 /* absolutely needed because function changes 'menu_info'! */
2504 else if (!(menu_info[first_entry + y].type & TYPE_GHOSTED))
2506 PlaySound(SND_MENU_ITEM_SELECTING);
2508 /* when selecting key headline, execute function for key value change */
2509 if (menu_info[first_entry + y].type & TYPE_KEYTEXT &&
2510 menu_info[first_entry + y + 1].type & TYPE_KEY)
2513 /* when selecting string value, execute function for list selection */
2514 if (menu_info[first_entry + y].type & TYPE_STRING && y > 0 &&
2515 menu_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
2518 if (menu_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
2520 void (*menu_callback_function)(void) =
2521 menu_info[first_entry + y].value;
2523 FadeSetFromType(menu_info[first_entry + y].type);
2525 menu_callback_function();
2527 else if (menu_info[first_entry + y].type & TYPE_VALUE &&
2528 menu_info == setup_info)
2530 changeSetupValue(y, first_entry + y, dx);
2536 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2538 menu_info = info_info;
2540 HandleMenuScreen(mx, my, dx, dy, button,
2541 info_mode, num_info_info, max_info_info);
2544 static int getMenuFontSpacing(int spacing_height, int font_nr)
2546 int font_spacing = getFontHeight(font_nr) + EXTRA_SPACING(game_status);
2548 return (spacing_height < 0 ? ABS(spacing_height) * font_spacing :
2552 static int getMenuTextSpacing(int spacing_height, int font_nr)
2554 return (getMenuFontSpacing(spacing_height, font_nr) +
2555 EXTRA_SPACING(game_status));
2558 static int getMenuTextStep(int spacing_height, int font_nr)
2560 return getFontHeight(font_nr) + getMenuTextSpacing(spacing_height, font_nr);
2563 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2565 int font_title = MENU_INFO_FONT_TITLE;
2566 int font_error = FONT_TEXT_2;
2567 int font_foot = MENU_INFO_FONT_FOOT;
2568 int spacing_title = menu.headline1_spacing_info[info_mode];
2569 int ystep_title = getMenuTextStep(spacing_title, font_title);
2570 int ystart1 = mSY - SY + 100;
2571 int ystart2 = ystart1 + ystep_title;
2572 int ybottom = mSY - SY + SYSIZE - 20;
2574 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO);
2576 FadeOut(REDRAW_FIELD);
2581 DrawTextSCentered(ystart1, font_title, text_title);
2582 DrawTextSCentered(ystart2, font_error, text_error);
2584 DrawTextSCentered(ybottom, font_foot,
2585 "Press any key or button for info menu");
2587 FadeIn(REDRAW_FIELD);
2590 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2592 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2593 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2594 int font_title = MENU_INFO_FONT_TITLE;
2595 int font_foot = MENU_INFO_FONT_FOOT;
2596 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2597 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2598 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2599 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2600 int ystep = MENU_SCREEN_INFO_YSTEP;
2601 int element, action, direction;
2609 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2610 infoscreen_step[i] = infoscreen_frame[i] = 0;
2615 DrawTextSCentered(ystart1, font_title, "The Game Elements:");
2617 DrawTextSCentered(ybottom, font_foot,
2618 "Press any key or button for next page");
2624 while (helpanim_info[j].element != HELPANIM_LIST_END)
2626 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2631 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2640 j += infoscreen_step[i - start];
2642 element = helpanim_info[j].element;
2643 action = helpanim_info[j].action;
2644 direction = helpanim_info[j].direction;
2647 element = EL_UNKNOWN;
2649 if (action != -1 && direction != -1)
2650 graphic = el_act_dir2img(element, action, direction);
2651 else if (action != -1)
2652 graphic = el_act2img(element, action);
2653 else if (direction != -1)
2654 graphic = el_dir2img(element, direction);
2656 graphic = el2img(element);
2658 delay = helpanim_info[j++].delay;
2663 if (infoscreen_frame[i - start] == 0)
2666 infoscreen_frame[i - start] = delay - 1;
2670 sync_frame = delay - infoscreen_frame[i - start];
2671 infoscreen_frame[i - start]--;
2674 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2676 if (!infoscreen_frame[i - start])
2677 infoscreen_step[i - start] = 0;
2681 if (!infoscreen_frame[i - start])
2682 infoscreen_step[i - start]++;
2683 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2689 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2691 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2692 graphic, sync_frame, USE_MASKING);
2695 DrawInfoScreen_HelpText(element, action, direction, i - start);
2700 redraw_mask |= REDRAW_FIELD;
2705 static char *getHelpText(int element, int action, int direction)
2707 char token[MAX_LINE_LEN];
2709 strcpy(token, element_info[element].token_name);
2712 strcat(token, element_action_info[action].suffix);
2714 if (direction != -1)
2715 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2717 return getHashEntry(helptext_info, token);
2720 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2722 int font_nr = FONT_INFO_ELEMENTS;
2723 int font_width = getFontWidth(font_nr);
2724 int font_height = getFontHeight(font_nr);
2725 int yoffset = (TILEX - 2 * font_height) / 2;
2726 int xstart = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2727 int ystart = mSY + MENU_SCREEN_INFO_YSTART2 + yoffset;
2728 int ystep = TILEY + 4;
2729 int pad_x = xstart - SX;
2730 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2731 int max_lines_per_text = 2;
2734 if (action != -1 && direction != -1) /* element.action.direction */
2735 text = getHelpText(element, action, direction);
2737 if (text == NULL && action != -1) /* element.action */
2738 text = getHelpText(element, action, -1);
2740 if (text == NULL && direction != -1) /* element.direction */
2741 text = getHelpText(element, -1, direction);
2743 if (text == NULL) /* base element */
2744 text = getHelpText(element, -1, -1);
2746 if (text == NULL) /* not found */
2747 text = "No description available";
2749 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2750 ystart += getFontHeight(font_nr) / 2;
2752 DrawTextBuffer(xstart, ystart + ypos * ystep, text, font_nr,
2753 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2754 TRUE, FALSE, FALSE);
2757 void DrawInfoScreen_TitleScreen()
2759 SetGameStatus(GAME_MODE_TITLE);
2764 void HandleInfoScreen_TitleScreen(int button)
2766 HandleTitleScreen(0, 0, 0, 0, button);
2769 void DrawInfoScreen_Elements()
2771 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2773 FadeOut(REDRAW_FIELD);
2778 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2780 FadeIn(REDRAW_FIELD);
2783 void HandleInfoScreen_Elements(int button)
2785 static unsigned int info_delay = 0;
2786 static int num_anims;
2787 static int num_pages;
2789 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2792 if (button == MB_MENU_INITIALIZE)
2794 boolean new_element = TRUE;
2798 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2800 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2802 else if (new_element)
2805 new_element = FALSE;
2809 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2813 if (button == MB_MENU_LEAVE)
2815 PlaySound(SND_MENU_ITEM_SELECTING);
2817 info_mode = INFO_MODE_MAIN;
2822 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2824 if (button != MB_MENU_INITIALIZE)
2826 PlaySound(SND_MENU_ITEM_SELECTING);
2831 if (page >= num_pages)
2833 FadeMenuSoundsAndMusic();
2835 info_mode = INFO_MODE_MAIN;
2842 FadeSetNextScreen();
2844 if (button != MB_MENU_INITIALIZE)
2845 FadeOut(REDRAW_FIELD);
2847 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2849 if (button != MB_MENU_INITIALIZE)
2850 FadeIn(REDRAW_FIELD);
2854 if (DelayReached(&info_delay, GameFrameDelay))
2855 if (page < num_pages)
2856 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2858 PlayMenuSoundIfLoop();
2862 void DrawInfoScreen_Music()
2864 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2866 FadeOut(REDRAW_FIELD);
2873 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2875 FadeIn(REDRAW_FIELD);
2878 void HandleInfoScreen_Music(int button)
2880 static struct MusicFileInfo *list = NULL;
2881 int font_title = MENU_INFO_FONT_TITLE;
2882 int font_head = MENU_INFO_FONT_HEAD;
2883 int font_text = MENU_INFO_FONT_TEXT;
2884 int font_foot = MENU_INFO_FONT_FOOT;
2885 int spacing_title = menu.headline1_spacing_info[info_mode];
2886 int spacing_head = menu.headline2_spacing_info[info_mode];
2887 int ystep_title = getMenuTextStep(spacing_title, font_title);
2888 int ystep_head = getMenuTextStep(spacing_head, font_head);
2889 int ystart = mSY - SY + 100;
2890 int ybottom = mSY - SY + SYSIZE - 20;
2892 if (button == MB_MENU_INITIALIZE)
2894 list = music_file_info;
2898 FadeMenuSoundsAndMusic();
2903 DrawTextSCentered(ystart, font_title,
2904 "No music info for this level set.");
2906 DrawTextSCentered(ybottom, font_foot,
2907 "Press any key or button for info menu");
2913 if (button == MB_MENU_LEAVE)
2915 PlaySound(SND_MENU_ITEM_SELECTING);
2917 FadeMenuSoundsAndMusic();
2919 info_mode = INFO_MODE_MAIN;
2924 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2926 if (button != MB_MENU_INITIALIZE)
2928 PlaySound(SND_MENU_ITEM_SELECTING);
2936 FadeMenuSoundsAndMusic();
2938 info_mode = INFO_MODE_MAIN;
2944 FadeMenuSoundsAndMusic();
2946 if (list != music_file_info)
2947 FadeSetNextScreen();
2949 if (button != MB_MENU_INITIALIZE)
2950 FadeOut(REDRAW_FIELD);
2957 int sound = list->music;
2959 if (sound_info[sound].loop)
2960 PlaySoundLoop(sound);
2964 DrawTextSCentered(ystart, font_title, "The Game Background Sounds:");
2968 PlayMusic(list->music);
2970 DrawTextSCentered(ystart, font_title, "The Game Background Music:");
2973 ystart += ystep_title;
2975 if (!strEqual(list->title, UNKNOWN_NAME))
2977 if (!strEqual(list->title_header, UNKNOWN_NAME))
2979 DrawTextSCentered(ystart, font_head, list->title_header);
2980 ystart += ystep_head;
2983 DrawTextFCentered(ystart, font_text, "\"%s\"", list->title);
2984 ystart += ystep_head;
2987 if (!strEqual(list->artist, UNKNOWN_NAME))
2989 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2990 DrawTextSCentered(ystart, font_head, list->artist_header);
2992 DrawTextSCentered(ystart, font_head, "by");
2994 ystart += ystep_head;
2996 DrawTextFCentered(ystart, font_text, "%s", list->artist);
2997 ystart += ystep_head;
3000 if (!strEqual(list->album, UNKNOWN_NAME))
3002 if (!strEqual(list->album_header, UNKNOWN_NAME))
3003 DrawTextSCentered(ystart, font_head, list->album_header);
3005 DrawTextSCentered(ystart, font_head, "from the album");
3007 ystart += ystep_head;
3009 DrawTextFCentered(ystart, font_text, "\"%s\"", list->album);
3010 ystart += ystep_head;
3013 if (!strEqual(list->year, UNKNOWN_NAME))
3015 if (!strEqual(list->year_header, UNKNOWN_NAME))
3016 DrawTextSCentered(ystart, font_head, list->year_header);
3018 DrawTextSCentered(ystart, font_head, "from the year");
3020 ystart += ystep_head;
3022 DrawTextFCentered(ystart, font_text, "%s", list->year);
3023 ystart += ystep_head;
3026 DrawTextSCentered(ybottom, FONT_TEXT_4,
3027 "Press any key or button for next page");
3029 if (button != MB_MENU_INITIALIZE)
3030 FadeIn(REDRAW_FIELD);
3033 if (list != NULL && list->is_sound && sound_info[list->music].loop)
3034 PlaySoundLoop(list->music);
3037 static void DrawInfoScreen_CreditsScreen(int screen_nr)
3039 int font_title = MENU_INFO_FONT_TITLE;
3040 int font_head = MENU_INFO_FONT_HEAD;
3041 int font_text = MENU_INFO_FONT_TEXT;
3042 int font_foot = MENU_INFO_FONT_FOOT;
3043 int spacing_title = menu.headline1_spacing_info[info_mode];
3044 int spacing_head = menu.headline2_spacing_info[info_mode];
3045 int spacing_para = menu.paragraph_spacing_info[info_mode];
3046 int spacing_line = menu.line_spacing_info[info_mode];
3047 int ystep_title = getMenuTextStep(spacing_title, font_title);
3048 int ystep_head = getMenuTextStep(spacing_head, font_head);
3049 int ystep_para = getMenuTextStep(spacing_para, font_text);
3050 int ystep_line = getMenuTextStep(spacing_line, font_text);
3051 int ystart = mSY - SY + 100;
3052 int ybottom = mSY - SY + SYSIZE - 20;
3057 DrawTextSCentered(ystart, font_title, "Credits:");
3058 ystart += ystep_title;
3062 DrawTextSCentered(ystart, font_head,
3063 "Special thanks to");
3064 ystart += ystep_head;
3065 DrawTextSCentered(ystart, font_text,
3067 ystart += ystep_head;
3068 DrawTextSCentered(ystart, font_head,
3070 ystart += ystep_head;
3071 DrawTextSCentered(ystart, font_text,
3072 "\"Boulder Dash\"");
3073 ystart += ystep_head;
3074 DrawTextSCentered(ystart, font_head,
3076 ystart += ystep_head;
3077 DrawTextSCentered(ystart, font_text,
3079 ystart += ystep_head;
3080 DrawTextSCentered(ystart, font_head,
3082 ystart += ystep_head;
3083 DrawTextSCentered(ystart, font_text,
3084 "First Star Software");
3086 else if (screen_nr == 1)
3088 DrawTextSCentered(ystart, font_head,
3089 "Special thanks to");
3090 ystart += ystep_head;
3091 DrawTextSCentered(ystart, font_text,
3092 "Klaus Heinz & Volker Wertich");
3093 ystart += ystep_head;
3094 DrawTextSCentered(ystart, font_head,
3096 ystart += ystep_head;
3097 DrawTextSCentered(ystart, font_text,
3098 "\"Emerald Mine\"");
3099 ystart += ystep_head;
3100 DrawTextSCentered(ystart, font_head,
3102 ystart += ystep_head;
3103 DrawTextSCentered(ystart, font_text,
3105 ystart += ystep_head;
3106 DrawTextSCentered(ystart, font_head,
3108 ystart += ystep_head;
3109 DrawTextSCentered(ystart, font_text,
3112 else if (screen_nr == 2)
3114 DrawTextSCentered(ystart, font_head,
3115 "Special thanks to");
3116 ystart += ystep_head;
3117 DrawTextSCentered(ystart, font_text,
3118 "Michael Stopp & Philip Jespersen");
3119 ystart += ystep_head;
3120 DrawTextSCentered(ystart, font_head,
3122 ystart += ystep_head;
3123 DrawTextSCentered(ystart, font_text,
3125 ystart += ystep_head;
3126 DrawTextSCentered(ystart, font_head,
3128 ystart += ystep_head;
3129 DrawTextSCentered(ystart, font_text,
3131 ystart += ystep_head;
3132 DrawTextSCentered(ystart, font_head,
3134 ystart += ystep_head;
3135 DrawTextSCentered(ystart, font_text,
3136 "Digital Integration");
3138 else if (screen_nr == 3)
3140 DrawTextSCentered(ystart, font_head,
3141 "Special thanks to");
3142 ystart += ystep_head;
3143 DrawTextSCentered(ystart, font_text,
3144 "Hiroyuki Imabayashi");
3145 ystart += ystep_head;
3146 DrawTextSCentered(ystart, font_head,
3148 ystart += ystep_head;
3149 DrawTextSCentered(ystart, font_text,
3151 ystart += ystep_head;
3152 DrawTextSCentered(ystart, font_head,
3154 ystart += ystep_head;
3155 DrawTextSCentered(ystart, font_text,
3157 ystart += ystep_head;
3158 DrawTextSCentered(ystart, font_head,
3160 ystart += ystep_head;
3161 DrawTextSCentered(ystart, font_text,
3164 else if (screen_nr == 4)
3166 DrawTextSCentered(ystart, font_head,
3167 "Special thanks to");
3168 ystart += ystep_head;
3169 DrawTextSCentered(ystart, font_text,
3171 ystart += ystep_head;
3172 DrawTextSCentered(ystart, font_head,
3174 ystart += ystep_head;
3175 DrawTextSCentered(ystart, font_text,
3176 "J\xfcrgen Bonhagen");
3177 ystart += ystep_head;
3178 DrawTextSCentered(ystart, font_head,
3179 "for the continuous creation");
3180 ystart += ystep_line;
3181 DrawTextSCentered(ystart, font_head,
3182 "of outstanding level sets");
3184 else if (screen_nr == 5)
3186 DrawTextSCentered(ystart, font_head,
3188 ystart += ystep_head;
3189 DrawTextSCentered(ystart, font_text,
3191 ystart += ystep_head;
3192 DrawTextSCentered(ystart, font_head,
3193 "for ideas and inspiration by");
3194 ystart += ystep_head;
3195 DrawTextSCentered(ystart, font_text,
3197 ystart += ystep_para;
3199 DrawTextSCentered(ystart, font_head,
3201 ystart += ystep_head;
3202 DrawTextSCentered(ystart, font_text,
3204 ystart += ystep_head;
3205 DrawTextSCentered(ystart, font_head,
3206 "for ideas and inspiration by");
3207 ystart += ystep_head;
3208 DrawTextSCentered(ystart, font_text,
3211 else if (screen_nr == 6)
3213 DrawTextSCentered(ystart, font_head,
3215 ystart += ystep_head;
3216 DrawTextSCentered(ystart, font_text,
3218 ystart += ystep_head;
3219 DrawTextSCentered(ystart, font_head,
3220 "for the code base used for the");
3221 ystart += ystep_line;
3222 DrawTextSCentered(ystart, font_head,
3223 "native Emerald Mine engine");
3225 else if (screen_nr == 7)
3227 DrawTextSCentered(ystart, font_head,
3229 ystart += ystep_head;
3230 DrawTextSCentered(ystart, font_text,
3232 ystart += ystep_head;
3233 DrawTextSCentered(ystart, font_head,
3234 "for the initial DOS port");
3235 ystart += ystep_para;
3237 DrawTextSCentered(ystart, font_head,
3239 ystart += ystep_head;
3240 DrawTextSCentered(ystart, font_text,
3242 ystart += ystep_head;
3243 DrawTextSCentered(ystart, font_head,
3244 "for some additional toons");
3246 else if (screen_nr == 8)
3248 DrawTextSCentered(ystart, font_head,
3249 "And not to forget:");
3250 ystart += ystep_head;
3251 DrawTextSCentered(ystart, font_head,
3253 ystart += ystep_head;
3254 DrawTextSCentered(ystart, font_text,
3255 "All those who contributed");
3256 ystart += ystep_line;
3257 DrawTextSCentered(ystart, font_text,
3258 "levels to this game");
3259 ystart += ystep_line;
3260 DrawTextSCentered(ystart, font_text,
3264 DrawTextSCentered(ybottom, font_foot,
3265 "Press any key or button for next page");
3268 void DrawInfoScreen_Credits()
3270 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
3272 FadeMenuSoundsAndMusic();
3274 FadeOut(REDRAW_FIELD);
3276 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3278 FadeIn(REDRAW_FIELD);
3281 void HandleInfoScreen_Credits(int button)
3283 static int screen_nr = 0;
3284 int num_screens = 9;
3286 if (button == MB_MENU_INITIALIZE)
3290 // DrawInfoScreen_CreditsScreen(screen_nr);
3293 if (button == MB_MENU_LEAVE)
3295 PlaySound(SND_MENU_ITEM_SELECTING);
3297 info_mode = INFO_MODE_MAIN;
3302 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
3304 if (button != MB_MENU_INITIALIZE)
3306 PlaySound(SND_MENU_ITEM_SELECTING);
3311 if (screen_nr >= num_screens)
3313 FadeMenuSoundsAndMusic();
3315 info_mode = INFO_MODE_MAIN;
3322 FadeSetNextScreen();
3324 if (button != MB_MENU_INITIALIZE)
3325 FadeOut(REDRAW_FIELD);
3327 DrawInfoScreen_CreditsScreen(screen_nr);
3329 if (button != MB_MENU_INITIALIZE)
3330 FadeIn(REDRAW_FIELD);
3334 PlayMenuSoundIfLoop();
3338 void DrawInfoScreen_Program()
3340 int font_title = MENU_INFO_FONT_TITLE;
3341 int font_head = MENU_INFO_FONT_HEAD;
3342 int font_text = MENU_INFO_FONT_TEXT;
3343 int font_foot = MENU_INFO_FONT_FOOT;
3344 int spacing_title = menu.headline1_spacing_info[info_mode];
3345 int spacing_head = menu.headline2_spacing_info[info_mode];
3346 int spacing_para = menu.paragraph_spacing_info[info_mode];
3347 int spacing_line = menu.line_spacing_info[info_mode];
3348 int ystep_title = getMenuTextStep(spacing_title, font_title);
3349 int ystep_head = getMenuTextStep(spacing_head, font_head);
3350 int ystep_para = getMenuTextStep(spacing_para, font_text);
3351 int ystep_line = getMenuTextStep(spacing_line, font_text);
3352 int ystart = mSY - SY + 100;
3353 int ybottom = mSY - SY + SYSIZE - 20;
3355 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3357 FadeOut(REDRAW_FIELD);
3362 DrawTextSCentered(ystart, font_title, "Program Information:");
3363 ystart += ystep_title;
3365 DrawTextSCentered(ystart, font_head,
3366 "This game is Freeware!");
3367 ystart += ystep_head;
3368 DrawTextSCentered(ystart, font_head,
3369 "If you like it, send e-mail to:");
3370 ystart += ystep_head;
3371 DrawTextSCentered(ystart, font_text,
3372 setup.internal.program_email);
3373 ystart += ystep_para;
3375 DrawTextSCentered(ystart, font_head,
3376 "More information and levels:");
3377 ystart += ystep_head;
3378 DrawTextSCentered(ystart, font_text,
3379 setup.internal.program_website);
3380 ystart += ystep_para;
3382 DrawTextSCentered(ystart, font_head,
3383 "If you have created new levels,");
3384 ystart += ystep_line;
3385 DrawTextSCentered(ystart, font_head,
3386 "send them to me to include them!");
3387 ystart += ystep_head;
3388 DrawTextSCentered(ystart, font_head,
3391 DrawTextSCentered(ybottom, font_foot,
3392 "Press any key or button for info menu");
3394 FadeIn(REDRAW_FIELD);
3397 void HandleInfoScreen_Program(int button)
3399 if (button == MB_MENU_LEAVE)
3401 PlaySound(SND_MENU_ITEM_SELECTING);
3403 info_mode = INFO_MODE_MAIN;
3408 else if (button == MB_MENU_CHOICE)
3410 PlaySound(SND_MENU_ITEM_SELECTING);
3412 FadeMenuSoundsAndMusic();
3414 info_mode = INFO_MODE_MAIN;
3419 PlayMenuSoundIfLoop();
3423 void DrawInfoScreen_Version()
3425 int font_title = MENU_INFO_FONT_TITLE;
3426 int font_head = MENU_INFO_FONT_HEAD;
3427 int font_text = MENU_INFO_FONT_TEXT;
3428 int font_foot = MENU_INFO_FONT_FOOT;
3429 int spacing_title = menu.headline1_spacing_info[info_mode];
3430 int spacing_head = menu.headline2_spacing_info[info_mode];
3431 int spacing_para = menu.paragraph_spacing_info[info_mode];
3432 int spacing_line = menu.line_spacing_info[info_mode];
3433 int xstep = getFontWidth(font_text);
3434 int ystep_title = getMenuTextStep(spacing_title, font_title);
3435 int ystep_head = getMenuTextStep(spacing_head, font_head);
3436 int ystep_para = getMenuTextStep(spacing_para, font_text);
3437 int ystep_line = getMenuTextStep(spacing_line, font_text);
3438 int ystart = mSY - SY + 100;
3439 int ybottom = mSY - SY + SYSIZE - 20;
3440 int xstart1 = mSX - SX + 2 * xstep;
3441 int xstart2 = mSX - SX + 18 * xstep;
3442 int xstart3 = mSX - SX + 28 * xstep;
3443 SDL_version sdl_version_compiled;
3444 const SDL_version *sdl_version_linked;
3445 int driver_name_len = 10;
3446 #if defined(TARGET_SDL2)
3447 SDL_version sdl_version_linked_ext;
3448 const char *driver_name = NULL;
3450 char driver_name[driver_name_len];
3453 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3455 FadeOut(REDRAW_FIELD);
3460 DrawTextSCentered(ystart, font_title, "Version Information:");
3461 ystart += ystep_title;
3463 DrawTextF(xstart1, ystart, font_head, "Name");
3464 DrawTextF(xstart2, ystart, font_text, getProgramTitleString());
3465 ystart += ystep_line;
3467 if (!strEqual(getProgramVersionString(), getProgramRealVersionString()))
3469 DrawTextF(xstart1, ystart, font_head, "Version (fake)");
3470 DrawTextF(xstart2, ystart, font_text, getProgramVersionString());
3471 ystart += ystep_line;
3473 DrawTextF(xstart1, ystart, font_head, "Version (real)");
3474 DrawTextF(xstart2, ystart, font_text, getProgramRealVersionString());
3475 ystart += ystep_line;
3479 DrawTextF(xstart1, ystart, font_head, "Version");
3480 DrawTextF(xstart2, ystart, font_text, getProgramVersionString());
3481 ystart += ystep_line;
3484 DrawTextF(xstart1, ystart, font_head, "Platform");
3485 DrawTextF(xstart2, ystart, font_text, PLATFORM_STRING);
3486 ystart += ystep_line;
3488 DrawTextF(xstart1, ystart, font_head, "Target");
3489 DrawTextF(xstart2, ystart, font_text, TARGET_STRING);
3490 ystart += ystep_line;
3492 DrawTextF(xstart1, ystart, font_head, "Source date");
3493 DrawTextF(xstart2, ystart, font_text, getSourceDateString());
3494 ystart += ystep_para;
3496 DrawTextF(xstart1, ystart, font_head, "Library");
3497 DrawTextF(xstart2, ystart, font_head, "compiled");
3498 DrawTextF(xstart3, ystart, font_head, "linked");
3499 ystart += ystep_head;
3501 SDL_VERSION(&sdl_version_compiled);
3502 #if defined(TARGET_SDL2)
3503 SDL_GetVersion(&sdl_version_linked_ext);
3504 sdl_version_linked = &sdl_version_linked_ext;
3506 sdl_version_linked = SDL_Linked_Version();
3509 DrawTextF(xstart1, ystart, font_text, "SDL");
3510 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3511 sdl_version_compiled.major,
3512 sdl_version_compiled.minor,
3513 sdl_version_compiled.patch);
3514 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3515 sdl_version_linked->major,
3516 sdl_version_linked->minor,
3517 sdl_version_linked->patch);
3518 ystart += ystep_line;
3520 SDL_IMAGE_VERSION(&sdl_version_compiled);
3521 sdl_version_linked = IMG_Linked_Version();
3523 DrawTextF(xstart1, ystart, font_text, "SDL_image");
3524 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3525 sdl_version_compiled.major,
3526 sdl_version_compiled.minor,
3527 sdl_version_compiled.patch);
3528 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3529 sdl_version_linked->major,
3530 sdl_version_linked->minor,
3531 sdl_version_linked->patch);
3532 ystart += ystep_line;
3534 SDL_MIXER_VERSION(&sdl_version_compiled);
3535 sdl_version_linked = Mix_Linked_Version();
3537 DrawTextF(xstart1, ystart, font_text, "SDL_mixer");
3538 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3539 sdl_version_compiled.major,
3540 sdl_version_compiled.minor,
3541 sdl_version_compiled.patch);
3542 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3543 sdl_version_linked->major,
3544 sdl_version_linked->minor,
3545 sdl_version_linked->patch);
3546 ystart += ystep_line;
3548 SDL_NET_VERSION(&sdl_version_compiled);
3549 sdl_version_linked = SDLNet_Linked_Version();
3551 DrawTextF(xstart1, ystart, font_text, "SDL_net");
3552 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3553 sdl_version_compiled.major,
3554 sdl_version_compiled.minor,
3555 sdl_version_compiled.patch);
3556 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3557 sdl_version_linked->major,
3558 sdl_version_linked->minor,
3559 sdl_version_linked->patch);
3560 ystart += ystep_para;
3562 DrawTextF(xstart1, ystart, font_head, "Driver");
3563 DrawTextF(xstart2, ystart, font_head, "Requested");
3564 DrawTextF(xstart3, ystart, font_head, "Used");
3565 ystart += ystep_head;
3567 #if defined(TARGET_SDL2)
3568 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
3570 SDL_VideoDriverName(driver_name, driver_name_len);
3573 DrawTextF(xstart1, ystart, font_text, "SDL_VideoDriver");
3574 DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_videodriver);
3575 DrawTextF(xstart3, ystart, font_text, "%s", driver_name);
3576 ystart += ystep_line;
3578 #if defined(TARGET_SDL2)
3579 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
3581 SDL_AudioDriverName(driver_name, driver_name_len);
3584 DrawTextF(xstart1, ystart, font_text, "SDL_AudioDriver");
3585 DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_audiodriver);
3586 DrawTextF(xstart3, ystart, font_text, "%s", driver_name);
3588 DrawTextSCentered(ybottom, font_foot,
3589 "Press any key or button for info menu");
3591 FadeIn(REDRAW_FIELD);
3594 void HandleInfoScreen_Version(int button)
3596 if (button == MB_MENU_LEAVE)
3598 PlaySound(SND_MENU_ITEM_SELECTING);
3600 info_mode = INFO_MODE_MAIN;
3605 else if (button == MB_MENU_CHOICE)
3607 PlaySound(SND_MENU_ITEM_SELECTING);
3609 FadeMenuSoundsAndMusic();
3611 info_mode = INFO_MODE_MAIN;
3616 PlayMenuSoundIfLoop();
3620 void DrawInfoScreen_LevelSet()
3622 struct TitleMessageInfo *tmi = &readme;
3623 char *filename = getLevelSetInfoFilename();
3624 char *title = "Level Set Information:";
3625 int ystart = mSY - SY + 100;
3626 int ybottom = mSY - SY + SYSIZE - 20;
3628 if (filename == NULL)
3630 DrawInfoScreen_NotAvailable(title, "No information for this level set.");
3635 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3637 FadeOut(REDRAW_FIELD);
3642 DrawTextSCentered(ystart, FONT_TEXT_1, title);
3644 /* if x position set to "-1", automatically determine by playfield width */
3646 tmi->x = SXSIZE / 2;
3648 /* if y position set to "-1", use static default value */
3652 /* if width set to "-1", automatically determine by playfield width */
3653 if (tmi->width == -1)
3654 tmi->width = SXSIZE - 2 * TILEX;
3656 /* if height set to "-1", automatically determine by playfield height */
3657 if (tmi->height == -1)
3658 tmi->height = SYSIZE - 20 - tmi->y - 10;
3660 /* if chars set to "-1", automatically determine by text and font width */
3661 if (tmi->chars == -1)
3662 tmi->chars = tmi->width / getFontWidth(tmi->font);
3664 tmi->width = tmi->chars * getFontWidth(tmi->font);
3666 /* if lines set to "-1", automatically determine by text and font height */
3667 if (tmi->lines == -1)
3668 tmi->lines = tmi->height / getFontHeight(tmi->font);
3670 tmi->height = tmi->lines * getFontHeight(tmi->font);
3672 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3673 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3674 tmi->autowrap, tmi->centered, tmi->parse_comments);
3676 DrawTextSCentered(ybottom, FONT_TEXT_4,
3677 "Press any key or button for info menu");
3679 FadeIn(REDRAW_FIELD);
3682 void HandleInfoScreen_LevelSet(int button)
3684 if (button == MB_MENU_LEAVE)
3686 PlaySound(SND_MENU_ITEM_SELECTING);
3688 info_mode = INFO_MODE_MAIN;
3693 else if (button == MB_MENU_CHOICE)
3695 PlaySound(SND_MENU_ITEM_SELECTING);
3697 FadeMenuSoundsAndMusic();
3699 info_mode = INFO_MODE_MAIN;
3704 PlayMenuSoundIfLoop();
3708 static void DrawInfoScreen()
3710 if (info_mode == INFO_MODE_TITLE)
3711 DrawInfoScreen_TitleScreen();
3712 else if (info_mode == INFO_MODE_ELEMENTS)
3713 DrawInfoScreen_Elements();
3714 else if (info_mode == INFO_MODE_MUSIC)
3715 DrawInfoScreen_Music();
3716 else if (info_mode == INFO_MODE_CREDITS)
3717 DrawInfoScreen_Credits();
3718 else if (info_mode == INFO_MODE_PROGRAM)
3719 DrawInfoScreen_Program();
3720 else if (info_mode == INFO_MODE_VERSION)
3721 DrawInfoScreen_Version();
3722 else if (info_mode == INFO_MODE_LEVELSET)
3723 DrawInfoScreen_LevelSet();
3725 DrawInfoScreen_Main();
3727 if (info_mode != INFO_MODE_MAIN &&
3728 info_mode != INFO_MODE_TITLE &&
3729 info_mode != INFO_MODE_MUSIC)
3730 PlayMenuSoundsAndMusic();
3733 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3735 if (info_mode == INFO_MODE_TITLE)
3736 HandleInfoScreen_TitleScreen(button);
3737 else if (info_mode == INFO_MODE_ELEMENTS)
3738 HandleInfoScreen_Elements(button);
3739 else if (info_mode == INFO_MODE_MUSIC)
3740 HandleInfoScreen_Music(button);
3741 else if (info_mode == INFO_MODE_CREDITS)
3742 HandleInfoScreen_Credits(button);
3743 else if (info_mode == INFO_MODE_PROGRAM)
3744 HandleInfoScreen_Program(button);
3745 else if (info_mode == INFO_MODE_VERSION)
3746 HandleInfoScreen_Version(button);
3747 else if (info_mode == INFO_MODE_LEVELSET)
3748 HandleInfoScreen_LevelSet(button);
3750 HandleInfoScreen_Main(mx, my, dx, dy, button);
3754 /* ========================================================================= */
3755 /* type name functions */
3756 /* ========================================================================= */
3758 void HandleTypeName(int newxpos, Key key)
3760 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3761 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3762 struct TextPosInfo *pos = mci->pos_input;
3763 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3764 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3765 static int xpos = 0;
3766 int font_nr = pos->font;
3767 int font_active_nr = FONT_ACTIVE(font_nr);
3768 int font_width = getFontWidth(font_active_nr);
3769 char key_char = getValidConfigValueChar(getCharFromKey(key));
3770 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3771 boolean is_active = TRUE;
3773 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3777 strcpy(last_player_name, setup.player_name);
3781 StartTextInput(startx, starty, pos->width, pos->height);
3783 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3785 setup.player_name[xpos] = key_char;
3786 setup.player_name[xpos + 1] = 0;
3790 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3794 setup.player_name[xpos] = 0;
3796 else if (key == KSYM_Return && xpos > 0)
3802 SetGameStatus(GAME_MODE_MAIN);
3804 else if (key == KSYM_Escape)
3806 strcpy(setup.player_name, last_player_name);
3810 SetGameStatus(GAME_MODE_MAIN);
3815 pos->width = (strlen(setup.player_name) + 1) * font_width;
3816 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3818 DrawText(startx, starty, setup.player_name, font_active_nr);
3819 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3823 pos->width = strlen(setup.player_name) * font_width;
3824 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3826 DrawText(startx, starty, setup.player_name, font_nr);
3833 /* ========================================================================= */
3834 /* tree menu functions */
3835 /* ========================================================================= */
3837 static void DrawChooseTree(TreeInfo **ti_ptr)
3839 int fade_mask = REDRAW_FIELD;
3841 if (CheckIfGlobalBorderHasChanged())
3842 fade_mask = REDRAW_ALL;
3844 if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY))
3846 SetGameStatus(GAME_MODE_MAIN);
3855 FreeScreenGadgets();
3856 CreateScreenGadgets();
3860 /* needed if different viewport properties defined for choosing level (set) */
3861 ChangeViewportPropertiesIfNeeded();
3863 if (game_status == GAME_MODE_LEVELNR)
3864 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3865 else if (game_status == GAME_MODE_LEVELS)
3866 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3870 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
3872 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3873 MapScreenTreeGadgets(*ti_ptr);
3875 DrawMaskedBorder(fade_mask);
3880 static void drawChooseTreeList(int first_entry, int num_page_entries,
3884 char *title_string = NULL;
3885 int yoffset_sets = MENU_TITLE1_YPOS;
3886 int yoffset_setup = 16;
3887 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3888 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3890 title_string = ti->infotext;
3892 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3894 clearMenuListArea();
3896 for (i = 0; i < num_page_entries; i++)
3898 TreeInfo *node, *node_first;
3899 int entry_pos = first_entry + i;
3900 int xpos = MENU_SCREEN_START_XPOS;
3901 int ypos = MENU_SCREEN_START_YPOS + i;
3902 int startx = mSX + xpos * 32;
3903 int starty = mSY + ypos * 32;
3904 int font_nr = FONT_TEXT_1;
3905 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3906 int startx_text = startx + font_xoffset;
3907 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3908 int text_size = startx_scrollbar - startx_text;
3909 int max_buffer_len = text_size / getFontWidth(font_nr);
3910 char buffer[max_buffer_len + 1];
3912 node_first = getTreeInfoFirstGroupEntry(ti);
3913 node = getTreeInfoFromPos(node_first, entry_pos);
3915 strncpy(buffer, node->name, max_buffer_len);
3916 buffer[max_buffer_len] = '\0';
3918 DrawText(startx, starty, buffer, font_nr + node->color);
3920 if (node->parent_link)
3921 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3922 else if (node->level_group)
3923 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3925 initCursor(i, IMG_MENU_BUTTON);
3928 redraw_mask |= REDRAW_FIELD;
3931 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3933 TreeInfo *node, *node_first;
3934 int x, last_redraw_mask = redraw_mask;
3935 int ypos = MENU_TITLE2_YPOS;
3936 int font_nr = FONT_TITLE_2;
3938 if (ti->type == TREE_TYPE_LEVEL_NR)
3939 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3941 if (ti->type != TREE_TYPE_LEVEL_DIR)
3944 node_first = getTreeInfoFirstGroupEntry(ti);
3945 node = getTreeInfoFromPos(node_first, entry_pos);
3947 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3949 if (node->parent_link)
3950 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3951 node->node_parent->name);
3952 else if (node->level_group)
3953 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3955 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3956 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3957 node->levels, (node->levels > 1 ? "levels" : "level"),
3960 /* let BackToFront() redraw only what is needed */
3961 redraw_mask = last_redraw_mask;
3962 for (x = 0; x < SCR_FIELDX; x++)
3963 MarkTileDirty(x, 1);
3966 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3969 TreeInfo *ti = *ti_ptr;
3971 int y = ti->cl_cursor;
3972 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3973 int num_entries = numTreeInfoInGroup(ti);
3974 int num_page_entries;
3975 boolean position_set_by_scrollbar = (dx == 999);
3977 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3978 num_page_entries = num_entries;
3980 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3982 if (button == MB_MENU_INITIALIZE)
3984 int num_entries = numTreeInfoInGroup(ti);
3985 int entry_pos = posTreeInfo(ti);
3987 if (ti->cl_first == -1)
3989 /* only on initialization */
3990 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3991 ti->cl_cursor = entry_pos - ti->cl_first;
3993 else if (ti->cl_cursor >= num_page_entries ||
3994 (num_entries > num_page_entries &&
3995 num_entries - ti->cl_first < num_page_entries))
3997 /* only after change of list size (by custom graphic configuration) */
3998 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3999 ti->cl_cursor = entry_pos - ti->cl_first;
4002 if (position_set_by_scrollbar)
4005 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
4008 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
4009 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
4010 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4014 else if (button == MB_MENU_LEAVE)
4018 PlaySound(SND_MENU_ITEM_SELECTING);
4020 if (ti->node_parent)
4022 *ti_ptr = ti->node_parent;
4023 DrawChooseTree(ti_ptr);
4025 else if (game_status == GAME_MODE_SETUP)
4027 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4028 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
4029 setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
4031 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4032 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
4033 setup_mode == SETUP_MODE_CHOOSE_RENDERING)
4034 execSetupGraphics();
4035 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4036 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4037 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4039 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4040 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4041 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4048 if (game_status == GAME_MODE_LEVELNR)
4050 int new_level_nr = atoi(level_number_current->identifier);
4052 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
4055 SetGameStatus(GAME_MODE_MAIN);
4063 if (mx || my) /* mouse input */
4065 x = (mx - mSX) / 32;
4066 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
4068 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
4070 /* move cursor instead of scrolling when already at start/end of list */
4071 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
4073 else if (dy == +1 * SCROLL_LINE &&
4074 ti->cl_first + num_page_entries == num_entries)
4077 /* handle scrolling screen one line or page */
4078 if (ti->cl_cursor + dy < 0 ||
4079 ti->cl_cursor + dy > num_page_entries - 1)
4081 boolean redraw = FALSE;
4083 if (ABS(dy) == SCROLL_PAGE)
4084 step = num_page_entries - 1;
4086 if (dy < 0 && ti->cl_first > 0)
4088 /* scroll page/line up */
4090 ti->cl_first -= step;
4091 if (ti->cl_first < 0)
4096 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
4098 /* scroll page/line down */
4100 ti->cl_first += step;
4101 if (ti->cl_first + num_page_entries > num_entries)
4102 ti->cl_first = MAX(0, num_entries - num_page_entries);
4109 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
4110 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
4111 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4113 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
4120 /* handle moving cursor one line */
4121 y = ti->cl_cursor + dy;
4126 TreeInfo *node_first, *node_cursor;
4127 int entry_pos = ti->cl_first + y;
4129 node_first = getTreeInfoFirstGroupEntry(ti);
4130 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4132 if (node_cursor->node_group)
4136 PlaySound(SND_MENU_ITEM_SELECTING);
4138 node_cursor->cl_first = ti->cl_first;
4139 node_cursor->cl_cursor = ti->cl_cursor;
4140 *ti_ptr = node_cursor->node_group;
4141 DrawChooseTree(ti_ptr);
4146 else if (dx == -1 && ti->node_parent)
4150 PlaySound(SND_MENU_ITEM_SELECTING);
4152 *ti_ptr = ti->node_parent;
4153 DrawChooseTree(ti_ptr);
4158 if (!anyScrollbarGadgetActive() &&
4159 IN_VIS_MENU(x, y) &&
4160 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
4161 y >= 0 && y < num_page_entries)
4165 if (y != ti->cl_cursor)
4167 PlaySound(SND_MENU_ITEM_ACTIVATING);
4169 drawChooseTreeCursor(ti->cl_cursor, FALSE);
4170 drawChooseTreeCursor(y, TRUE);
4171 drawChooseTreeInfo(ti->cl_first + y, ti);
4177 if (game_status == GAME_MODE_SETUP)
4179 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4180 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
4181 setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
4183 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4184 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
4185 setup_mode == SETUP_MODE_CHOOSE_RENDERING)
4186 execSetupGraphics();
4187 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4188 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4189 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4191 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4192 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4193 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4202 TreeInfo *node_first, *node_cursor;
4203 int entry_pos = ti->cl_first + y;
4205 PlaySound(SND_MENU_ITEM_SELECTING);
4207 node_first = getTreeInfoFirstGroupEntry(ti);
4208 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4210 if (node_cursor->node_group)
4214 node_cursor->cl_first = ti->cl_first;
4215 node_cursor->cl_cursor = ti->cl_cursor;
4216 *ti_ptr = node_cursor->node_group;
4217 DrawChooseTree(ti_ptr);
4219 else if (node_cursor->parent_link)
4223 *ti_ptr = node_cursor->node_parent;
4224 DrawChooseTree(ti_ptr);
4230 node_cursor->cl_first = ti->cl_first;
4231 node_cursor->cl_cursor = ti->cl_cursor;
4232 *ti_ptr = node_cursor;
4234 if (ti->type == TREE_TYPE_LEVEL_DIR)
4236 LoadLevelSetup_SeriesInfo();
4238 SaveLevelSetup_LastSeries();
4239 SaveLevelSetup_SeriesInfo();
4243 if (game_status == GAME_MODE_SETUP)
4245 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4246 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
4247 setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
4249 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4250 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
4251 setup_mode == SETUP_MODE_CHOOSE_RENDERING)
4252 execSetupGraphics();
4253 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4254 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4255 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4257 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4258 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4259 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4266 if (game_status == GAME_MODE_LEVELNR)
4268 int new_level_nr = atoi(level_number_current->identifier);
4270 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
4273 SetGameStatus(GAME_MODE_MAIN);
4282 void DrawChooseLevelSet()
4284 FadeMenuSoundsAndMusic();
4286 DrawChooseTree(&leveldir_current);
4288 PlayMenuSoundsAndMusic();
4291 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
4293 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4296 void DrawChooseLevelNr()
4300 FadeMenuSoundsAndMusic();
4302 if (level_number != NULL)
4304 freeTreeInfo(level_number);
4306 level_number = NULL;
4309 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
4311 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
4312 char identifier[32], name[32];
4315 /* temporarily load level info to get level name */
4316 LoadLevelInfoOnly(i);
4318 ti->node_top = &level_number;
4319 ti->sort_priority = 10000 + value;
4320 ti->color = (level.no_level_file ? FC_BLUE :
4321 LevelStats_getSolved(i) ? FC_GREEN :
4322 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
4324 snprintf(identifier, sizeof(identifier), "%d", value);
4325 snprintf(name, sizeof(name), "%03d: %s", value,
4326 (level.no_level_file ? "(no file)" : level.name));
4328 setString(&ti->identifier, identifier);
4329 setString(&ti->name, name);
4330 setString(&ti->name_sorting, name);
4332 pushTreeInfo(&level_number, ti);
4335 /* sort level number values to start with lowest level number */
4336 sortTreeInfo(&level_number);
4338 /* set current level number to current level number */
4339 level_number_current =
4340 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
4342 /* if that also fails, set current level number to first available level */
4343 if (level_number_current == NULL)
4344 level_number_current = level_number;
4346 DrawChooseTree(&level_number_current);
4348 PlayMenuSoundsAndMusic();
4351 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
4353 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
4356 void DrawHallOfFame(int highlight_position)
4358 int fade_mask = REDRAW_FIELD;
4360 if (CheckIfGlobalBorderHasChanged())
4361 fade_mask = REDRAW_ALL;
4364 FadeMenuSoundsAndMusic();
4366 /* (this is needed when called from GameEnd() after winning a game) */
4367 KeyboardAutoRepeatOn();
4369 /* (this is needed when called from GameEnd() after winning a game) */
4370 SetDrawDeactivationMask(REDRAW_NONE);
4371 SetDrawBackgroundMask(REDRAW_FIELD);
4373 if (highlight_position < 0)
4374 LoadScore(level_nr);
4376 SetAnimStatus(GAME_MODE_PSEUDO_SCORESNEW);
4378 FadeSetEnterScreen();
4382 /* needed if different viewport properties defined for scores */
4383 ChangeViewportPropertiesIfNeeded();
4385 PlayMenuSoundsAndMusic();
4387 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
4389 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4391 DrawMaskedBorder(fade_mask);
4396 static void drawHallOfFameList(int first_entry, int highlight_position)
4400 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4403 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4404 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4405 "HighScores of Level %d", level_nr);
4407 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4409 int entry = first_entry + i;
4410 boolean active = (entry == highlight_position);
4411 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4412 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4413 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4414 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4415 int dxoff = getFontDrawOffsetX(font_nr1);
4416 int dx1 = 3 * getFontWidth(font_nr1);
4417 int dx2 = dx1 + getFontWidth(font_nr1);
4418 int dx3 = SXSIZE - 2 * (mSX - SX + dxoff) - 5 * getFontWidth(font_nr4);
4419 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
4420 int sy = mSY + 64 + i * 32;
4422 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4423 DrawText(mSX + dx1, sy, ".", font_nr1);
4425 for (j = 0; j < num_dots; j++)
4426 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
4428 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4429 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4431 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4434 redraw_mask |= REDRAW_FIELD;
4437 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4439 static int first_entry = 0;
4440 static int highlight_position = 0;
4441 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4443 if (button == MB_MENU_INITIALIZE)
4446 highlight_position = mx;
4447 drawHallOfFameList(first_entry, highlight_position);
4452 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4453 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4457 if (first_entry > 0)
4459 first_entry -= step;
4460 if (first_entry < 0)
4463 drawHallOfFameList(first_entry, highlight_position);
4468 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4470 first_entry += step;
4471 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4472 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4474 drawHallOfFameList(first_entry, highlight_position);
4477 else if (button == MB_MENU_LEAVE)
4479 PlaySound(SND_MENU_ITEM_SELECTING);
4481 FadeSound(SND_BACKGROUND_SCORES);
4483 SetGameStatus(GAME_MODE_MAIN);
4487 else if (button == MB_MENU_CHOICE)
4489 PlaySound(SND_MENU_ITEM_SELECTING);
4491 FadeSound(SND_BACKGROUND_SCORES);
4493 SetGameStatus(GAME_MODE_MAIN);
4498 if (game_status == GAME_MODE_SCORES)
4499 PlayMenuSoundIfLoop();
4503 /* ========================================================================= */
4504 /* setup screen functions */
4505 /* ========================================================================= */
4507 static struct TokenInfo *setup_info;
4508 static int num_setup_info; /* number of setup entries shown on screen */
4509 static int max_setup_info; /* total number of setup entries in list */
4511 static char *window_size_text;
4512 static char *scaling_type_text;
4513 static char *rendering_mode_text;
4514 static char *scroll_delay_text;
4515 static char *snapshot_mode_text;
4516 static char *game_speed_text;
4517 static char *graphics_set_name;
4518 static char *sounds_set_name;
4519 static char *music_set_name;
4520 static char *volume_simple_text;
4521 static char *volume_loops_text;
4522 static char *volume_music_text;
4523 static char *touch_controls_text;
4524 static char *move_distance_text;
4525 static char *drop_distance_text;
4527 static void execSetupMain()
4529 setup_mode = SETUP_MODE_MAIN;
4534 static void execSetupGame_setGameSpeeds()
4536 if (game_speeds == NULL)
4540 for (i = 0; game_speeds_list[i].value != -1; i++)
4542 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4543 char identifier[32], name[32];
4544 int value = game_speeds_list[i].value;
4545 char *text = game_speeds_list[i].text;
4547 ti->node_top = &game_speeds;
4548 ti->sort_priority = 10000 - value;
4550 sprintf(identifier, "%d", value);
4551 sprintf(name, "%s", text);
4553 setString(&ti->identifier, identifier);
4554 setString(&ti->name, name);
4555 setString(&ti->name_sorting, name);
4556 setString(&ti->infotext, "Game Speed");
4558 pushTreeInfo(&game_speeds, ti);
4561 /* sort game speed values to start with slowest game speed */
4562 sortTreeInfo(&game_speeds);
4564 /* set current game speed to configured game speed value */
4565 game_speed_current =
4566 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4568 /* if that fails, set current game speed to reliable default value */
4569 if (game_speed_current == NULL)
4570 game_speed_current =
4571 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4573 /* if that also fails, set current game speed to first available speed */
4574 if (game_speed_current == NULL)
4575 game_speed_current = game_speeds;
4578 setup.game_frame_delay = atoi(game_speed_current->identifier);
4580 /* needed for displaying game speed text instead of identifier */
4581 game_speed_text = game_speed_current->name;
4584 static void execSetupGame_setScrollDelays()
4586 if (scroll_delays == NULL)
4590 for (i = 0; scroll_delays_list[i].value != -1; i++)
4592 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4593 char identifier[32], name[32];
4594 int value = scroll_delays_list[i].value;
4595 char *text = scroll_delays_list[i].text;
4597 ti->node_top = &scroll_delays;
4598 ti->sort_priority = value;
4600 sprintf(identifier, "%d", value);
4601 sprintf(name, "%s", text);
4603 setString(&ti->identifier, identifier);
4604 setString(&ti->name, name);
4605 setString(&ti->name_sorting, name);
4606 setString(&ti->infotext, "Scroll Delay");
4608 pushTreeInfo(&scroll_delays, ti);
4611 /* sort scroll delay values to start with lowest scroll delay value */
4612 sortTreeInfo(&scroll_delays);
4614 /* set current scroll delay value to configured scroll delay value */
4615 scroll_delay_current =
4616 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4618 /* if that fails, set current scroll delay to reliable default value */
4619 if (scroll_delay_current == NULL)
4620 scroll_delay_current =
4621 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4623 /* if that also fails, set current scroll delay to first available value */
4624 if (scroll_delay_current == NULL)
4625 scroll_delay_current = scroll_delays;
4628 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4630 /* needed for displaying scroll delay text instead of identifier */
4631 scroll_delay_text = scroll_delay_current->name;
4634 static void execSetupGame_setSnapshotModes()
4636 if (snapshot_modes == NULL)
4640 for (i = 0; snapshot_modes_list[i].value != NULL; i++)
4642 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4643 char identifier[32], name[32];
4644 char *value = snapshot_modes_list[i].value;
4645 char *text = snapshot_modes_list[i].text;
4647 ti->node_top = &snapshot_modes;
4648 ti->sort_priority = i;
4650 sprintf(identifier, "%s", value);
4651 sprintf(name, "%s", text);
4653 setString(&ti->identifier, identifier);
4654 setString(&ti->name, name);
4655 setString(&ti->name_sorting, name);
4656 setString(&ti->infotext, "Snapshot Mode");
4658 pushTreeInfo(&snapshot_modes, ti);
4661 /* sort snapshot mode values to start with lowest snapshot mode value */
4662 sortTreeInfo(&snapshot_modes);
4664 /* set current snapshot mode value to configured snapshot mode value */
4665 snapshot_mode_current =
4666 getTreeInfoFromIdentifier(snapshot_modes, setup.engine_snapshot_mode);
4668 /* if that fails, set current snapshot mode to reliable default value */
4669 if (snapshot_mode_current == NULL)
4670 snapshot_mode_current =
4671 getTreeInfoFromIdentifier(snapshot_modes, STR_SNAPSHOT_MODE_DEFAULT);
4673 /* if that also fails, set current snapshot mode to first available value */
4674 if (snapshot_mode_current == NULL)
4675 snapshot_mode_current = snapshot_modes;
4678 setup.engine_snapshot_mode = snapshot_mode_current->identifier;
4680 /* needed for displaying snapshot mode text instead of identifier */
4681 snapshot_mode_text = snapshot_mode_current->name;
4684 static void execSetupGame()
4686 execSetupGame_setGameSpeeds();
4687 execSetupGame_setScrollDelays();
4688 execSetupGame_setSnapshotModes();
4690 setup_mode = SETUP_MODE_GAME;
4695 static void execSetupChooseGameSpeed()
4697 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4702 static void execSetupChooseScrollDelay()
4704 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4709 static void execSetupChooseSnapshotMode()
4711 setup_mode = SETUP_MODE_CHOOSE_SNAPSHOT_MODE;
4716 static void execSetupEditor()
4718 setup_mode = SETUP_MODE_EDITOR;
4723 static void execSetupGraphics_setWindowSizes(boolean update_list)
4725 if (window_sizes != NULL && update_list)
4727 freeTreeInfo(window_sizes);
4729 window_sizes = NULL;
4732 if (window_sizes == NULL)
4734 boolean current_window_size_found = FALSE;
4737 for (i = 0; window_sizes_list[i].value != -1; i++)
4739 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4740 char identifier[32], name[32];
4741 int value = window_sizes_list[i].value;
4742 char *text = window_sizes_list[i].text;
4744 ti->node_top = &window_sizes;
4745 ti->sort_priority = value;
4747 sprintf(identifier, "%d", value);
4748 sprintf(name, "%s", text);
4750 setString(&ti->identifier, identifier);
4751 setString(&ti->name, name);
4752 setString(&ti->name_sorting, name);
4753 setString(&ti->infotext, "Window Scaling");
4755 pushTreeInfo(&window_sizes, ti);
4757 if (value == setup.window_scaling_percent)
4758 current_window_size_found = TRUE;
4761 if (!current_window_size_found)
4763 // add entry for non-preset window scaling value
4765 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4766 char identifier[32], name[32];
4767 int value = setup.window_scaling_percent;
4769 ti->node_top = &window_sizes;
4770 ti->sort_priority = value;
4772 sprintf(identifier, "%d", value);
4773 sprintf(name, "%d %% (Current)", value);
4775 setString(&ti->identifier, identifier);
4776 setString(&ti->name, name);
4777 setString(&ti->name_sorting, name);
4778 setString(&ti->infotext, "Window Scaling");
4780 pushTreeInfo(&window_sizes, ti);
4783 /* sort window size values to start with lowest window size value */
4784 sortTreeInfo(&window_sizes);
4786 /* set current window size value to configured window size value */
4787 window_size_current =
4788 getTreeInfoFromIdentifier(window_sizes,
4789 i_to_a(setup.window_scaling_percent));
4791 /* if that fails, set current window size to reliable default value */
4792 if (window_size_current == NULL)
4793 window_size_current =
4794 getTreeInfoFromIdentifier(window_sizes,
4795 i_to_a(STD_WINDOW_SCALING_PERCENT));
4797 /* if that also fails, set current window size to first available value */
4798 if (window_size_current == NULL)
4799 window_size_current = window_sizes;
4802 setup.window_scaling_percent = atoi(window_size_current->identifier);
4804 /* needed for displaying window size text instead of identifier */
4805 window_size_text = window_size_current->name;
4808 static void execSetupGraphics_setScalingTypes()
4810 if (scaling_types == NULL)
4814 for (i = 0; scaling_types_list[i].value != NULL; i++)
4816 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4817 char identifier[32], name[32];
4818 char *value = scaling_types_list[i].value;
4819 char *text = scaling_types_list[i].text;
4821 ti->node_top = &scaling_types;
4822 ti->sort_priority = i;
4824 sprintf(identifier, "%s", value);
4825 sprintf(name, "%s", text);
4827 setString(&ti->identifier, identifier);
4828 setString(&ti->name, name);
4829 setString(&ti->name_sorting, name);
4830 setString(&ti->infotext, "Anti-Aliasing");
4832 pushTreeInfo(&scaling_types, ti);
4835 /* sort scaling type values to start with lowest scaling type value */
4836 sortTreeInfo(&scaling_types);
4838 /* set current scaling type value to configured scaling type value */
4839 scaling_type_current =
4840 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4842 /* if that fails, set current scaling type to reliable default value */
4843 if (scaling_type_current == NULL)
4844 scaling_type_current =
4845 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4847 /* if that also fails, set current scaling type to first available value */
4848 if (scaling_type_current == NULL)
4849 scaling_type_current = scaling_types;
4852 setup.window_scaling_quality = scaling_type_current->identifier;
4854 /* needed for displaying scaling type text instead of identifier */
4855 scaling_type_text = scaling_type_current->name;
4858 static void execSetupGraphics_setRenderingModes()
4860 if (rendering_modes == NULL)
4864 for (i = 0; rendering_modes_list[i].value != NULL; i++)
4866 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4867 char identifier[32], name[32];
4868 char *value = rendering_modes_list[i].value;
4869 char *text = rendering_modes_list[i].text;
4871 ti->node_top = &rendering_modes;
4872 ti->sort_priority = i;
4874 sprintf(identifier, "%s", value);
4875 sprintf(name, "%s", text);
4877 setString(&ti->identifier, identifier);
4878 setString(&ti->name, name);
4879 setString(&ti->name_sorting, name);
4880 setString(&ti->infotext, "Special Rendering");
4882 pushTreeInfo(&rendering_modes, ti);
4885 /* sort rendering mode values to start with lowest rendering mode value */
4886 sortTreeInfo(&rendering_modes);
4888 /* set current rendering mode value to configured rendering mode value */
4889 rendering_mode_current =
4890 getTreeInfoFromIdentifier(rendering_modes, setup.screen_rendering_mode);
4892 /* if that fails, set current rendering mode to reliable default value */
4893 if (rendering_mode_current == NULL)
4894 rendering_mode_current =
4895 getTreeInfoFromIdentifier(rendering_modes,
4896 STR_SPECIAL_RENDERING_DEFAULT);
4898 /* if that also fails, set current rendering mode to first available one */
4899 if (rendering_mode_current == NULL)
4900 rendering_mode_current = rendering_modes;
4903 setup.screen_rendering_mode = rendering_mode_current->identifier;
4905 /* needed for displaying rendering mode text instead of identifier */
4906 rendering_mode_text = rendering_mode_current->name;
4909 static void execSetupGraphics()
4911 // update "setup.window_scaling_percent" from list selection
4912 // (in this case, window scaling was changed on setup screen)
4913 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4914 execSetupGraphics_setWindowSizes(FALSE);
4916 // update list selection from "setup.window_scaling_percent"
4917 // (window scaling may have changed by resizing the window)
4918 execSetupGraphics_setWindowSizes(TRUE);
4920 execSetupGraphics_setScalingTypes();
4921 execSetupGraphics_setRenderingModes();
4923 setup_mode = SETUP_MODE_GRAPHICS;
4927 #if defined(TARGET_SDL2)
4928 // window scaling may have changed at this point
4929 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4931 // window scaling quality may have changed at this point
4932 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4933 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4935 // screen rendering mode may have changed at this point
4936 SDLSetScreenRenderingMode(setup.screen_rendering_mode);
4940 #if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
4941 static void execSetupChooseWindowSize()
4943 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4948 static void execSetupChooseScalingType()
4950 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4955 static void execSetupChooseRenderingMode()
4957 setup_mode = SETUP_MODE_CHOOSE_RENDERING;
4963 static void execSetupChooseVolumeSimple()
4965 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4970 static void execSetupChooseVolumeLoops()
4972 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4977 static void execSetupChooseVolumeMusic()
4979 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4984 static void execSetupSound()
4986 if (volumes_simple == NULL)
4988 boolean current_volume_simple_found = FALSE;
4991 for (i = 0; volumes_list[i].value != -1; i++)
4993 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4994 char identifier[32], name[32];
4995 int value = volumes_list[i].value;
4996 char *text = volumes_list[i].text;
4998 ti->node_top = &volumes_simple;
4999 ti->sort_priority = value;
5001 sprintf(identifier, "%d", value);
5002 sprintf(name, "%s", text);
5004 setString(&ti->identifier, identifier);
5005 setString(&ti->name, name);
5006 setString(&ti->name_sorting, name);
5007 setString(&ti->infotext, "Sound Volume");
5009 pushTreeInfo(&volumes_simple, ti);
5011 if (value == setup.volume_simple)
5012 current_volume_simple_found = TRUE;
5015 if (!current_volume_simple_found)
5017 // add entry for non-preset volume value
5019 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5020 char identifier[32], name[32];
5021 int value = setup.volume_simple;
5023 ti->node_top = &volumes_simple;
5024 ti->sort_priority = value;
5026 sprintf(identifier, "%d", value);
5027 sprintf(name, "%d %% (Current)", value);
5029 setString(&ti->identifier, identifier);
5030 setString(&ti->name, name);
5031 setString(&ti->name_sorting, name);
5032 setString(&ti->infotext, "Sound Volume");
5034 pushTreeInfo(&volumes_simple, ti);
5037 /* sort volume values to start with lowest volume value */
5038 sortTreeInfo(&volumes_simple);
5040 /* set current volume value to configured volume value */
5041 volume_simple_current =
5042 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
5044 /* if that fails, set current volume to reliable default value */
5045 if (volume_simple_current == NULL)
5046 volume_simple_current =
5047 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
5049 /* if that also fails, set current volume to first available value */
5050 if (volume_simple_current == NULL)
5051 volume_simple_current = volumes_simple;
5054 if (volumes_loops == NULL)
5056 boolean current_volume_loops_found = FALSE;
5059 for (i = 0; volumes_list[i].value != -1; i++)
5061 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5062 char identifier[32], name[32];
5063 int value = volumes_list[i].value;
5064 char *text = volumes_list[i].text;
5066 ti->node_top = &volumes_loops;
5067 ti->sort_priority = value;
5069 sprintf(identifier, "%d", value);
5070 sprintf(name, "%s", text);
5072 setString(&ti->identifier, identifier);
5073 setString(&ti->name, name);
5074 setString(&ti->name_sorting, name);
5075 setString(&ti->infotext, "Loops Volume");
5077 pushTreeInfo(&volumes_loops, ti);
5079 if (value == setup.volume_loops)
5080 current_volume_loops_found = TRUE;
5083 if (!current_volume_loops_found)
5085 // add entry for non-preset volume value
5087 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5088 char identifier[32], name[32];
5089 int value = setup.volume_loops;
5091 ti->node_top = &volumes_loops;
5092 ti->sort_priority = value;
5094 sprintf(identifier, "%d", value);
5095 sprintf(name, "%d %% (Current)", value);
5097 setString(&ti->identifier, identifier);
5098 setString(&ti->name, name);
5099 setString(&ti->name_sorting, name);
5100 setString(&ti->infotext, "Loops Volume");
5102 pushTreeInfo(&volumes_loops, ti);
5105 /* sort volume values to start with lowest volume value */
5106 sortTreeInfo(&volumes_loops);
5108 /* set current volume value to configured volume value */
5109 volume_loops_current =
5110 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
5112 /* if that fails, set current volume to reliable default value */
5113 if (volume_loops_current == NULL)
5114 volume_loops_current =
5115 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
5117 /* if that also fails, set current volume to first available value */
5118 if (volume_loops_current == NULL)
5119 volume_loops_current = volumes_loops;
5122 if (volumes_music == NULL)
5124 boolean current_volume_music_found = FALSE;
5127 for (i = 0; volumes_list[i].value != -1; i++)
5129 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5130 char identifier[32], name[32];
5131 int value = volumes_list[i].value;
5132 char *text = volumes_list[i].text;
5134 ti->node_top = &volumes_music;
5135 ti->sort_priority = value;
5137 sprintf(identifier, "%d", value);
5138 sprintf(name, "%s", text);
5140 setString(&ti->identifier, identifier);
5141 setString(&ti->name, name);
5142 setString(&ti->name_sorting, name);
5143 setString(&ti->infotext, "Music Volume");
5145 pushTreeInfo(&volumes_music, ti);
5147 if (value == setup.volume_music)
5148 current_volume_music_found = TRUE;
5151 if (!current_volume_music_found)
5153 // add entry for non-preset volume value
5155 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5156 char identifier[32], name[32];
5157 int value = setup.volume_music;
5159 ti->node_top = &volumes_music;
5160 ti->sort_priority = value;
5162 sprintf(identifier, "%d", value);
5163 sprintf(name, "%d %% (Current)", value);
5165 setString(&ti->identifier, identifier);
5166 setString(&ti->name, name);
5167 setString(&ti->name_sorting, name);
5168 setString(&ti->infotext, "Music Volume");
5170 pushTreeInfo(&volumes_music, ti);
5173 /* sort volume values to start with lowest volume value */
5174 sortTreeInfo(&volumes_music);
5176 /* set current volume value to configured volume value */
5177 volume_music_current =
5178 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
5180 /* if that fails, set current volume to reliable default value */
5181 if (volume_music_current == NULL)
5182 volume_music_current =
5183 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
5185 /* if that also fails, set current volume to first available value */
5186 if (volume_music_current == NULL)
5187 volume_music_current = volumes_music;
5190 setup.volume_simple = atoi(volume_simple_current->identifier);
5191 setup.volume_loops = atoi(volume_loops_current->identifier);
5192 setup.volume_music = atoi(volume_music_current->identifier);
5194 /* needed for displaying volume text instead of identifier */
5195 volume_simple_text = volume_simple_current->name;
5196 volume_loops_text = volume_loops_current->name;
5197 volume_music_text = volume_music_current->name;
5199 setup_mode = SETUP_MODE_SOUND;
5204 static void execSetupChooseTouchControls()
5206 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
5211 static void execSetupChooseMoveDistance()
5213 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
5218 static void execSetupChooseDropDistance()
5220 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
5225 static void execSetupTouch()
5227 if (touch_controls == NULL)
5231 for (i = 0; touch_controls_list[i].value != NULL; i++)
5233 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5234 char identifier[32], name[32];
5235 char *value = touch_controls_list[i].value;
5236 char *text = touch_controls_list[i].text;
5238 ti->node_top = &touch_controls;
5239 ti->sort_priority = i;
5241 sprintf(identifier, "%s", value);
5242 sprintf(name, "%s", text);
5244 setString(&ti->identifier, identifier);
5245 setString(&ti->name, name);
5246 setString(&ti->name_sorting, name);
5247 setString(&ti->infotext, "Control Type");
5249 pushTreeInfo(&touch_controls, ti);
5252 /* sort touch control values to start with lowest touch control value */
5253 sortTreeInfo(&touch_controls);
5255 /* set current touch control value to configured touch control value */
5256 touch_control_current =
5257 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
5259 /* if that fails, set current touch control to reliable default value */
5260 if (touch_control_current == NULL)
5261 touch_control_current =
5262 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
5264 /* if that also fails, set current touch control to first available value */
5265 if (touch_control_current == NULL)
5266 touch_control_current = touch_controls;
5269 if (move_distances == NULL)
5273 for (i = 0; distances_list[i].value != -1; i++)
5275 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5276 char identifier[32], name[32];
5277 int value = distances_list[i].value;
5278 char *text = distances_list[i].text;
5280 ti->node_top = &move_distances;
5281 ti->sort_priority = value;
5283 sprintf(identifier, "%d", value);
5284 sprintf(name, "%s", text);
5286 setString(&ti->identifier, identifier);
5287 setString(&ti->name, name);
5288 setString(&ti->name_sorting, name);
5289 setString(&ti->infotext, "Move Distance");
5291 pushTreeInfo(&move_distances, ti);
5294 /* sort distance values to start with lowest distance value */
5295 sortTreeInfo(&move_distances);
5297 /* set current distance value to configured distance value */
5298 move_distance_current =
5299 getTreeInfoFromIdentifier(move_distances,
5300 i_to_a(setup.touch.move_distance));
5302 /* if that fails, set current distance to reliable default value */
5303 if (move_distance_current == NULL)
5304 move_distance_current =
5305 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
5307 /* if that also fails, set current distance to first available value */
5308 if (move_distance_current == NULL)
5309 move_distance_current = move_distances;
5312 if (drop_distances == NULL)
5316 for (i = 0; distances_list[i].value != -1; i++)
5318 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5319 char identifier[32], name[32];
5320 int value = distances_list[i].value;
5321 char *text = distances_list[i].text;
5323 ti->node_top = &drop_distances;
5324 ti->sort_priority = value;
5326 sprintf(identifier, "%d", value);
5327 sprintf(name, "%s", text);
5329 setString(&ti->identifier, identifier);
5330 setString(&ti->name, name);
5331 setString(&ti->name_sorting, name);
5332 setString(&ti->infotext, "Drop Distance");
5334 pushTreeInfo(&drop_distances, ti);
5337 /* sort distance values to start with lowest distance value */
5338 sortTreeInfo(&drop_distances);
5340 /* set current distance value to configured distance value */
5341 drop_distance_current =
5342 getTreeInfoFromIdentifier(drop_distances,
5343 i_to_a(setup.touch.drop_distance));
5345 /* if that fails, set current distance to reliable default value */
5346 if (drop_distance_current == NULL)
5347 drop_distance_current =
5348 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
5350 /* if that also fails, set current distance to first available value */
5351 if (drop_distance_current == NULL)
5352 drop_distance_current = drop_distances;
5355 setup.touch.control_type = touch_control_current->identifier;
5356 setup.touch.move_distance = atoi(move_distance_current->identifier);
5357 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
5359 /* needed for displaying volume text instead of identifier */
5360 touch_controls_text = touch_control_current->name;
5361 move_distance_text = move_distance_current->name;
5362 drop_distance_text = drop_distance_current->name;
5364 setup_mode = SETUP_MODE_TOUCH;
5369 static void execSetupArtwork()
5372 printf("::: '%s', '%s', '%s'\n",
5373 artwork.gfx_current->subdir,
5374 artwork.gfx_current->fullpath,
5375 artwork.gfx_current->basepath);
5378 setup.graphics_set = artwork.gfx_current->identifier;
5379 setup.sounds_set = artwork.snd_current->identifier;
5380 setup.music_set = artwork.mus_current->identifier;
5382 /* needed if last screen (setup choice) changed graphics, sounds or music */
5383 ReloadCustomArtwork(0);
5385 /* needed for displaying artwork name instead of artwork identifier */
5386 graphics_set_name = artwork.gfx_current->name;
5387 sounds_set_name = artwork.snd_current->name;
5388 music_set_name = artwork.mus_current->name;
5390 setup_mode = SETUP_MODE_ARTWORK;
5395 static void execSetupChooseGraphics()
5397 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
5402 static void execSetupChooseSounds()
5404 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
5409 static void execSetupChooseMusic()
5411 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
5416 static void execSetupInput()
5418 setup_mode = SETUP_MODE_INPUT;
5423 static void execSetupShortcuts()
5425 setup_mode = SETUP_MODE_SHORTCUTS;
5430 static void execSetupShortcuts1()
5432 setup_mode = SETUP_MODE_SHORTCUTS_1;
5437 static void execSetupShortcuts2()
5439 setup_mode = SETUP_MODE_SHORTCUTS_2;
5444 static void execSetupShortcuts3()
5446 setup_mode = SETUP_MODE_SHORTCUTS_3;
5451 static void execSetupShortcuts4()
5453 setup_mode = SETUP_MODE_SHORTCUTS_4;
5458 static void execSetupShortcuts5()
5460 setup_mode = SETUP_MODE_SHORTCUTS_5;
5465 static void execExitSetup()
5467 SetGameStatus(GAME_MODE_MAIN);
5472 static void execSaveAndExitSetup()
5478 static struct TokenInfo setup_info_main[] =
5480 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
5481 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
5482 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
5483 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
5484 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
5485 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
5486 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
5487 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
5488 { TYPE_EMPTY, NULL, "" },
5489 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
5490 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
5495 static struct TokenInfo setup_info_game[] =
5497 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
5498 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
5499 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
5500 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
5501 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
5502 { TYPE_SWITCH, &setup.increment_levels,"Increment Solved Levels:" },
5503 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
5504 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
5505 { TYPE_STRING, &game_speed_text, "" },
5507 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
5508 { TYPE_STRING, &scroll_delay_text, "" },
5510 { TYPE_ENTER_LIST, execSetupChooseSnapshotMode,"Game Engine Snapshot Mode:" },
5511 { TYPE_STRING, &snapshot_mode_text, "" },
5512 { TYPE_SWITCH, &setup.show_snapshot_buttons,"Show Snapshot Buttons:" },
5513 { TYPE_EMPTY, NULL, "" },
5514 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5519 static struct TokenInfo setup_info_editor[] =
5522 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
5523 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
5524 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
5525 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
5526 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
5527 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
5528 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
5529 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
5530 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
5531 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
5533 { TYPE_SWITCH, &setup.editor.el_classic, "Classic Elements:" },
5534 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
5536 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
5538 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
5539 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
5540 { TYPE_EMPTY, NULL, "" },
5542 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
5543 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
5544 { TYPE_EMPTY, NULL, "" },
5546 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
5547 { TYPE_EMPTY, NULL, "" },
5548 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5553 static struct TokenInfo setup_info_graphics[] =
5555 #if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
5556 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
5557 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
5558 { TYPE_STRING, &window_size_text, "" },
5559 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
5560 { TYPE_STRING, &scaling_type_text, "" },
5561 { TYPE_ENTER_LIST, execSetupChooseRenderingMode, "Special Rendering:" },
5562 { TYPE_STRING, &rendering_mode_text, "" },
5565 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
5566 { TYPE_STRING, &scroll_delay_text, "" },
5568 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
5569 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
5570 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
5571 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
5572 { TYPE_SWITCH, &setup.toons, "Show Menu Animations:" },
5573 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
5574 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
5575 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
5576 { TYPE_EMPTY, NULL, "" },
5577 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5582 static struct TokenInfo setup_info_sound[] =
5584 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
5585 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
5586 { TYPE_SWITCH, &setup.sound_music, "Music:" },
5587 { TYPE_EMPTY, NULL, "" },
5588 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
5589 { TYPE_STRING, &volume_simple_text, "" },
5590 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
5591 { TYPE_STRING, &volume_loops_text, "" },
5592 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
5593 { TYPE_STRING, &volume_music_text, "" },
5594 { TYPE_EMPTY, NULL, "" },
5595 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5600 static struct TokenInfo setup_info_artwork[] =
5602 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
5603 { TYPE_STRING, &graphics_set_name, "" },
5604 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
5605 { TYPE_STRING, &sounds_set_name, "" },
5606 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
5607 { TYPE_STRING, &music_set_name, "" },
5608 { TYPE_EMPTY, NULL, "" },
5609 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
5610 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
5611 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
5612 { TYPE_EMPTY, NULL, "" },
5613 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5618 static struct TokenInfo setup_info_input[] =
5620 { TYPE_SWITCH, NULL, "Player:" },
5621 { TYPE_SWITCH, NULL, "Device:" },
5622 { TYPE_SWITCH, NULL, "" },
5623 { TYPE_EMPTY, NULL, "" },
5624 { TYPE_EMPTY, NULL, "" },
5625 { TYPE_EMPTY, NULL, "" },
5626 { TYPE_EMPTY, NULL, "" },
5627 { TYPE_EMPTY, NULL, "" },
5628 { TYPE_EMPTY, NULL, "" },
5629 { TYPE_EMPTY, NULL, "" },
5630 { TYPE_EMPTY, NULL, "" },
5631 { TYPE_EMPTY, NULL, "" },
5632 { TYPE_EMPTY, NULL, "" },
5633 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5638 static struct TokenInfo setup_info_touch[] =
5640 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
5641 { TYPE_STRING, &touch_controls_text, "" },
5642 { TYPE_EMPTY, NULL, "" },
5643 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5648 static struct TokenInfo setup_info_touch_wipe_gestures[] =
5650 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
5651 { TYPE_STRING, &touch_controls_text, "" },
5652 { TYPE_EMPTY, NULL, "" },
5653 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
5654 { TYPE_STRING, &move_distance_text, "" },
5655 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
5656 { TYPE_STRING, &drop_distance_text, "" },
5657 { TYPE_EMPTY, NULL, "" },
5658 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5663 static struct TokenInfo setup_info_shortcuts[] =
5665 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
5666 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
5667 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
5668 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
5669 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
5670 { TYPE_EMPTY, NULL, "" },
5671 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5676 static struct TokenInfo setup_info_shortcuts_1[] =
5678 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
5679 { TYPE_KEY, &setup.shortcut.save_game, "" },
5680 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
5681 { TYPE_KEY, &setup.shortcut.load_game, "" },
5682 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
5683 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
5684 { TYPE_EMPTY, NULL, "" },
5685 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
5686 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
5687 { TYPE_EMPTY, NULL, "" },
5688 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5693 static struct TokenInfo setup_info_shortcuts_2[] =
5695 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
5696 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
5697 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
5698 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
5699 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
5700 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
5701 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
5702 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
5703 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
5704 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
5705 { TYPE_EMPTY, NULL, "" },
5706 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5711 static struct TokenInfo setup_info_shortcuts_3[] =
5713 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
5714 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
5715 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
5716 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
5717 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
5718 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
5719 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
5720 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
5721 { TYPE_KEYTEXT, NULL, "Record Tape:", },
5722 { TYPE_KEY, &setup.shortcut.tape_record, "" },
5723 { TYPE_KEYTEXT, NULL, "Play Tape:", },
5724 { TYPE_KEY, &setup.shortcut.tape_play, "" },
5725 { TYPE_EMPTY, NULL, "" },
5726 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5731 static struct TokenInfo setup_info_shortcuts_4[] =
5733 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
5734 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
5735 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
5736 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
5737 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
5738 { TYPE_KEY, &setup.shortcut.sound_music, "" },
5739 { TYPE_EMPTY, NULL, "" },
5740 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5745 static struct TokenInfo setup_info_shortcuts_5[] =
5747 { TYPE_KEYTEXT, NULL, "Snap Left:", },
5748 { TYPE_KEY, &setup.shortcut.snap_left, "" },
5749 { TYPE_KEYTEXT, NULL, "Snap Right:", },
5750 { TYPE_KEY, &setup.shortcut.snap_right, "" },
5751 { TYPE_KEYTEXT, NULL, "Snap Up:", },
5752 { TYPE_KEY, &setup.shortcut.snap_up, "" },
5753 { TYPE_KEYTEXT, NULL, "Snap Down:", },
5754 { TYPE_KEY, &setup.shortcut.snap_down, "" },
5755 { TYPE_EMPTY, NULL, "" },
5756 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5761 static Key getSetupKey()
5763 Key key = KSYM_UNDEFINED;
5764 boolean got_key_event = FALSE;
5766 while (!got_key_event)
5770 if (NextValidEvent(&event))
5774 case EVENT_KEYPRESS:
5776 key = GetEventKey((KeyEvent *)&event, TRUE);
5778 /* press 'Escape' or 'Enter' to keep the existing key binding */
5779 if (key == KSYM_Escape || key == KSYM_Return)
5780 key = KSYM_UNDEFINED; /* keep old value */
5782 got_key_event = TRUE;
5786 case EVENT_KEYRELEASE:
5787 key_joystick_mapping = 0;
5791 HandleOtherEvents(&event);
5802 static int getSetupValueFont(int type, void *value)
5804 if (type & TYPE_GHOSTED)
5805 return FONT_OPTION_OFF;
5806 else if (type & TYPE_KEY)
5807 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5808 else if (type & TYPE_STRING)
5809 return FONT_VALUE_2;
5810 else if (type & TYPE_ECS_AGA)
5811 return FONT_VALUE_1;
5812 else if (type & TYPE_BOOLEAN_STYLE)
5813 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5814 else if (type & TYPE_YES_NO_AUTO)
5815 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5816 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5818 return FONT_VALUE_1;
5821 static int getSetupValueFontNarrow(int type, int font_nr)
5823 return (font_nr == FONT_VALUE_1 ? FONT_VALUE_NARROW :
5824 font_nr == FONT_OPTION_ON ? FONT_OPTION_ON_NARROW :
5825 font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW :
5829 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5831 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5832 struct TokenInfo *si = &setup_info[si_pos];
5833 boolean font_draw_xoffset_modified = FALSE;
5834 boolean scrollbar_needed = (num_setup_info < max_setup_info);
5835 int font_draw_xoffset_old = -1;
5836 int xoffset = (scrollbar_needed ? -1 : 0);
5837 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5838 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5839 int xpos = menu_screen_value_xpos;
5840 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5841 int startx = mSX + xpos * 32;
5842 int starty = mSY + ypos * 32;
5843 int font_nr, font_nr_default, font_width_default;
5844 int type = si->type;
5845 void *value = si->value;
5846 char *value_string = getSetupValue(type, value);
5849 if (value_string == NULL)
5852 if (type & TYPE_KEY)
5854 xpos = MENU_SCREEN_START_XPOS;
5856 if (type & TYPE_QUERY)
5857 value_string = "<press key>";
5859 else if (type & TYPE_STRING)
5861 int max_value_len = (SCR_FIELDX - 2) * 2;
5863 xpos = MENU_SCREEN_START_XPOS;
5865 if (strlen(value_string) > max_value_len)
5866 value_string[max_value_len] = '\0';
5868 else if (type & TYPE_YES_NO_AUTO)
5870 xpos = menu_screen_value_xpos - 1;
5873 startx = mSX + xpos * 32;
5874 starty = mSY + ypos * 32;
5875 font_nr_default = getSetupValueFont(type, value);
5876 font_width_default = getFontWidth(font_nr_default);
5878 font_nr = font_nr_default;
5880 // special check if right-side setup values moved left due to scrollbar
5881 if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS)
5883 int max_menu_text_length = 26; // maximum text length for classic menu
5884 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5885 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5886 int text_font_nr = getMenuTextFont(FONT_MENU_2);
5887 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5888 int text_width = max_menu_text_length * getFontWidth(text_font_nr);
5890 if (startx + font_xoffset < text_startx + text_width + text_font_xoffset)
5893 startx = mSX + xpos * 32;
5895 font_nr = getSetupValueFontNarrow(type, font_nr);
5899 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5900 if (setup_mode != SETUP_MODE_INPUT)
5902 int max_menu_text_length_big = (menu_screen_value_xpos -
5903 MENU_SCREEN_START_XPOS);
5904 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5905 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5906 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5907 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5908 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5909 int text_font_nr = getMenuTextFont(FONT_MENU_2);
5910 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5911 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5912 boolean correct_font_draw_xoffset = FALSE;
5914 if (xpos == MENU_SCREEN_START_XPOS &&
5915 startx + font1_xoffset < text_startx + text_font_xoffset)
5916 correct_font_draw_xoffset = TRUE;
5918 if (xpos == menu_screen_value_xpos &&
5919 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5920 correct_font_draw_xoffset = TRUE;
5922 /* check if setup value would overlap with setup text when printed */
5923 /* (this can happen for extreme/wrong values for font draw offset) */
5924 if (correct_font_draw_xoffset)
5926 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5927 font_draw_xoffset_modified = TRUE;
5929 if (type & TYPE_KEY)
5930 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5931 else if (!(type & TYPE_STRING))
5932 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5933 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5937 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5938 DrawText(startx + i * font_width_default, starty, " ", font_nr_default);
5940 DrawText(startx, starty, value_string, font_nr);
5942 if (font_draw_xoffset_modified)
5943 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5946 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5948 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5949 struct TokenInfo *si = &setup_info[si_pos];
5951 if (si->type & TYPE_BOOLEAN_STYLE)
5953 *(boolean *)si->value ^= TRUE;
5955 else if (si->type & TYPE_YES_NO_AUTO)
5959 (*(int *)si->value == AUTO ? TRUE :
5960 *(int *)si->value == TRUE ? FALSE : AUTO) :
5961 (*(int *)si->value == TRUE ? AUTO :
5962 *(int *)si->value == AUTO ? FALSE : TRUE));
5964 else if (si->type & TYPE_KEY)
5968 si->type |= TYPE_QUERY;
5969 drawSetupValue(screen_pos, setup_info_pos_raw);
5970 si->type &= ~TYPE_QUERY;
5972 key = getSetupKey();
5973 if (key != KSYM_UNDEFINED)
5974 *(Key *)si->value = key;
5977 drawSetupValue(screen_pos, setup_info_pos_raw);
5979 // fullscreen state may have changed at this point
5980 if (si->value == &setup.fullscreen)
5981 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5984 static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig)
5986 static struct TokenInfo *setup_info_hide = NULL;
5991 /* determine maximum list size of target list */
5992 while (setup_info_orig[list_size++].type != 0);
5994 /* free, allocate and clear memory for target list */
5995 checked_free(setup_info_hide);
5996 setup_info_hide = checked_calloc(list_size * sizeof(struct TokenInfo));
5998 /* copy setup info list without setup entries marked as hidden */
5999 for (i = 0; setup_info_orig[i].type != 0; i++)
6000 if (!hideSetupEntry(setup_info_orig[i].value))
6001 setup_info_hide[list_pos++] = setup_info_orig[i];
6003 return setup_info_hide;
6006 static void DrawSetupScreen_Generic()
6008 int fade_mask = REDRAW_FIELD;
6009 boolean redraw_all = FALSE;
6010 char *title_string = NULL;
6013 if (CheckIfGlobalBorderHasChanged())
6014 fade_mask = REDRAW_ALL;
6017 FadeMenuSoundsAndMusic();
6019 FreeScreenGadgets();
6020 CreateScreenGadgets();
6022 if (redraw_mask & REDRAW_ALL)
6027 /* needed if different viewport properties defined for setup screen */
6028 ChangeViewportPropertiesIfNeeded();
6030 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6034 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
6036 if (setup_mode == SETUP_MODE_MAIN)
6038 setup_info = setup_info_main;
6039 title_string = "Setup";
6041 else if (setup_mode == SETUP_MODE_GAME)
6043 setup_info = setup_info_game;
6044 title_string = "Setup Game";
6046 else if (setup_mode == SETUP_MODE_EDITOR)
6048 setup_info = setup_info_editor;
6049 title_string = "Setup Editor";
6051 else if (setup_mode == SETUP_MODE_GRAPHICS)
6053 setup_info = setup_info_graphics;
6054 title_string = "Setup Graphics";
6056 else if (setup_mode == SETUP_MODE_SOUND)
6058 setup_info = setup_info_sound;
6059 title_string = "Setup Sound";
6061 else if (setup_mode == SETUP_MODE_ARTWORK)
6063 setup_info = setup_info_artwork;
6064 title_string = "Custom Artwork";
6066 else if (setup_mode == SETUP_MODE_TOUCH)
6068 setup_info = setup_info_touch;
6069 title_string = "Setup Touch Ctrls";
6071 if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
6072 setup_info = setup_info_touch_wipe_gestures;
6074 else if (setup_mode == SETUP_MODE_SHORTCUTS)
6076 setup_info = setup_info_shortcuts;
6077 title_string = "Setup Shortcuts";
6079 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
6081 setup_info = setup_info_shortcuts_1;
6082 title_string = "Setup Shortcuts";
6084 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
6086 setup_info = setup_info_shortcuts_2;
6087 title_string = "Setup Shortcuts";
6089 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
6091 setup_info = setup_info_shortcuts_3;
6092 title_string = "Setup Shortcuts";
6094 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
6096 setup_info = setup_info_shortcuts_4;
6097 title_string = "Setup Shortcuts";
6099 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
6101 setup_info = setup_info_shortcuts_5;
6102 title_string = "Setup Shortcuts";
6105 /* use modified setup info without setup entries marked as hidden */
6106 setup_info = getSetupInfoFinal(setup_info);
6108 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
6110 // determine maximal number of setup entries that can be displayed on screen
6112 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
6115 // determine maximal number of setup entries available for this setup screen
6117 for (i = 0; setup_info[i].type != 0; i++)
6120 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
6122 MapScreenGadgets(max_setup_info);
6125 redraw_mask = fade_mask = REDRAW_ALL;
6127 DrawMaskedBorder(fade_mask);
6132 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
6134 menu_info = setup_info;
6136 HandleMenuScreen(mx, my, dx, dy, button,
6137 setup_mode, num_setup_info, max_setup_info);
6140 void DrawSetupScreen_Input()
6144 FadeOut(REDRAW_FIELD);
6148 setup_info = setup_info_input;
6150 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
6152 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
6154 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
6155 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
6156 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
6157 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
6158 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
6159 initCursor(i, IMG_MENU_BUTTON);
6161 DrawCursorAndText_Setup(i, -1, FALSE);
6164 /* create gadgets for setup input menu screen */
6165 FreeScreenGadgets();
6166 CreateScreenGadgets();
6168 /* map gadgets for setup input menu screen */
6169 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
6171 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
6173 FadeIn(REDRAW_FIELD);
6176 static void setJoystickDeviceToNr(char *device_name, int device_nr)
6178 if (device_name == NULL)
6181 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
6184 if (strlen(device_name) > 1)
6186 char c1 = device_name[strlen(device_name) - 1];
6187 char c2 = device_name[strlen(device_name) - 2];
6189 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
6190 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
6193 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
6194 strlen(device_name));
6197 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
6200 static struct SetupKeyboardInfo custom_key;
6207 { &custom_key.left, "Axis/Pad Left" },
6208 { &custom_key.right, "Axis/Pad Right" },
6209 { &custom_key.up, "Axis/Pad Up" },
6210 { &custom_key.down, "Axis/Pad Down" },
6211 { &custom_key.snap, "Button 1/A/X" },
6212 { &custom_key.drop, "Button 2/B/Y" }
6214 static char *joystick_name[MAX_PLAYERS] =
6221 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
6223 custom_key = setup.input[player_nr].key;
6225 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
6226 FONT_INPUT_1_ACTIVE);
6228 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
6230 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
6231 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
6233 if (setup.input[player_nr].use_joystick)
6235 char *device_name = setup.input[player_nr].joy.device_name;
6236 int joystick_nr = getJoystickNrFromDeviceName(device_name);
6237 boolean joystick_active = CheckJoystickOpened(joystick_nr);
6238 char *text = joystick_name[joystick_nr];
6239 int font_nr = (joystick_active ? FONT_VALUE_1 : FONT_VALUE_OLD);
6241 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
6242 DrawText(mSX + 32, mSY + 4 * 32, "Configure", text_font_nr);
6246 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
6247 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
6250 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
6252 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
6253 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
6254 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
6255 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
6257 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
6258 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
6259 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
6260 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
6261 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
6262 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
6264 for (i = 0; i < 6; i++)
6266 int ypos = 6 + i + (i > 3 ? i-3 : 0);
6268 DrawText(mSX + 3 * 32, mSY + ypos * 32,
6270 DrawText(mSX + 3 * 32, mSY + ypos * 32,
6271 (setup.input[player_nr].use_joystick ?
6273 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
6277 static int input_player_nr = 0;
6279 void HandleSetupScreen_Input_Player(int step, int direction)
6281 int old_player_nr = input_player_nr;
6284 new_player_nr = old_player_nr + step * direction;
6285 if (new_player_nr < 0)
6287 if (new_player_nr > MAX_PLAYERS - 1)
6288 new_player_nr = MAX_PLAYERS - 1;
6290 if (new_player_nr != old_player_nr)
6292 input_player_nr = new_player_nr;
6294 drawPlayerSetupInputInfo(input_player_nr, FALSE);
6298 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
6300 static int choice = 0;
6303 int pos_start = SETUPINPUT_SCREEN_POS_START;
6304 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
6305 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
6306 int pos_end = SETUPINPUT_SCREEN_POS_END;
6308 if (button == MB_MENU_INITIALIZE)
6310 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
6312 DrawCursorAndText_Setup(choice, -1, TRUE);
6316 else if (button == MB_MENU_LEAVE)
6318 setup_mode = SETUP_MODE_MAIN;
6325 if (mx || my) /* mouse input */
6327 x = (mx - mSX) / 32;
6328 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
6330 else if (dx || dy) /* keyboard input */
6332 if (dx && choice == 0)
6333 x = (dx < 0 ? 10 : 12);
6334 else if ((dx && choice == 1) ||
6335 (dx == -1 && choice == pos_end))
6336 button = MB_MENU_CHOICE;
6340 if (y >= pos_empty1 && y <= pos_empty2)
6341 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
6344 if (y == 0 && dx != 0 && button)
6346 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
6348 else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
6349 y >= pos_start && y <= pos_end &&
6350 !(y >= pos_empty1 && y <= pos_empty2))
6356 DrawCursorAndText_Setup(choice, -1, FALSE);
6357 DrawCursorAndText_Setup(y, -1, TRUE);
6359 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
6368 char *device_name = setup.input[input_player_nr].joy.device_name;
6370 if (!setup.input[input_player_nr].use_joystick)
6372 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
6374 setJoystickDeviceToNr(device_name, new_device_nr);
6375 setup.input[input_player_nr].use_joystick = TRUE;
6379 int device_nr = getJoystickNrFromDeviceName(device_name);
6380 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
6382 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
6383 setup.input[input_player_nr].use_joystick = FALSE;
6385 setJoystickDeviceToNr(device_name, new_device_nr);
6388 drawPlayerSetupInputInfo(input_player_nr, FALSE);
6392 if (setup.input[input_player_nr].use_joystick)
6393 ConfigureJoystick(input_player_nr);
6395 CustomizeKeyboard(input_player_nr);
6397 else if (y == pos_end)
6403 setup_mode = SETUP_MODE_MAIN;
6410 void CustomizeKeyboard(int player_nr)
6414 boolean finished = FALSE;
6415 static struct SetupKeyboardInfo custom_key;
6420 } customize_step[] =
6422 { &custom_key.left, "Move Left" },
6423 { &custom_key.right, "Move Right" },
6424 { &custom_key.up, "Move Up" },
6425 { &custom_key.down, "Move Down" },
6426 { &custom_key.snap, "Snap Field" },
6427 { &custom_key.drop, "Drop Element" }
6430 /* read existing key bindings from player setup */
6431 custom_key = setup.input[player_nr].key;
6434 FadeOut(REDRAW_FIELD);
6438 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
6441 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6442 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6443 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6444 "Key:", FONT_INPUT_1_ACTIVE);
6445 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6446 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
6448 FadeIn(REDRAW_FIELD);
6454 if (NextValidEvent(&event))
6458 case EVENT_KEYPRESS:
6460 Key key = GetEventKey((KeyEvent *)&event, FALSE);
6462 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
6464 if (key == KSYM_Escape)
6465 FadeSkipNextFadeIn();
6471 /* all keys configured -- wait for "Escape" or "Return" key */
6475 /* press 'Enter' to keep the existing key binding */
6476 if (key == KSYM_Return)
6477 key = *customize_step[step_nr].key;
6479 /* check if key already used */
6480 for (i = 0; i < step_nr; i++)
6481 if (*customize_step[i].key == key)
6486 /* got new key binding */
6487 *customize_step[step_nr].key = key;
6488 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6490 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6491 getKeyNameFromKey(key), FONT_VALUE_1);
6494 /* un-highlight last query */
6495 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6496 customize_step[step_nr - 1].text, FONT_MENU_1);
6497 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6498 "Key:", FONT_MENU_1);
6500 /* press 'Enter' to leave */
6503 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6504 "Press Enter", FONT_TITLE_1);
6508 /* query next key binding */
6509 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6510 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6511 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6512 "Key:", FONT_INPUT_1_ACTIVE);
6513 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6514 getKeyNameFromKey(*customize_step[step_nr].key),
6519 case EVENT_KEYRELEASE:
6520 key_joystick_mapping = 0;
6524 HandleOtherEvents(&event);
6532 /* write new key bindings back to player setup */
6533 setup.input[player_nr].key = custom_key;
6535 DrawSetupScreen_Input();
6538 /* game controller mapping generator by Gabriel Jacobo <gabomdq@gmail.com> */
6540 #define MARKER_BUTTON 1
6541 #define MARKER_AXIS_X 2
6542 #define MARKER_AXIS_Y 3
6544 static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
6546 #if defined(TARGET_SDL2)
6547 static boolean bitmaps_initialized = FALSE;
6548 boolean screen_initialized = FALSE;
6549 static Bitmap *controller, *button, *axis_x, *axis_y;
6551 boolean success = TRUE;
6552 boolean done = FALSE, next = FALSE;
6554 int alpha = 200, alpha_step = -1;
6555 int alpha_ticks = 0;
6556 char mapping[4096], temp[4096];
6557 int font_name = MENU_SETUP_FONT_TITLE;
6558 int font_info = MENU_SETUP_FONT_TEXT;
6559 int spacing_name = menu.line_spacing_setup[SETUP_MODE_INPUT];
6560 int spacing_line = menu.line_spacing_setup[SETUP_MODE_INPUT];
6561 int spacing_para = menu.paragraph_spacing_setup[SETUP_MODE_INPUT];
6562 int ystep_name = getMenuTextStep(spacing_name, font_name);
6563 int ystep_line = getMenuTextStep(spacing_line, font_info);
6564 int ystep_para = getMenuTextStep(spacing_para, font_info);
6572 int axis, button, hat, hat_value;
6575 *step, *prev_step, steps[] =
6577 { 356, 155, MARKER_BUTTON, "a", },
6578 { 396, 122, MARKER_BUTTON, "b", },
6579 { 320, 125, MARKER_BUTTON, "x", },
6580 { 358, 95, MARKER_BUTTON, "y", },
6581 { 162, 125, MARKER_BUTTON, "back", },
6582 { 216, 125, MARKER_BUTTON, "guide", },
6583 { 271, 125, MARKER_BUTTON, "start", },
6584 { 110, 200, MARKER_BUTTON, "dpleft", },
6585 { 146, 228, MARKER_BUTTON, "dpdown", },
6586 { 178, 200, MARKER_BUTTON, "dpright", },
6587 { 146, 172, MARKER_BUTTON, "dpup", },
6588 { 50, 40, MARKER_BUTTON, "leftshoulder", },
6589 { 88, -10, MARKER_AXIS_Y, "lefttrigger", },
6590 { 382, 40, MARKER_BUTTON, "rightshoulder", },
6591 { 346, -10, MARKER_AXIS_Y, "righttrigger", },
6592 { 73, 141, MARKER_BUTTON, "leftstick", },
6593 { 282, 210, MARKER_BUTTON, "rightstick", },
6594 { 73, 141, MARKER_AXIS_X, "leftx", },
6595 { 73, 141, MARKER_AXIS_Y, "lefty", },
6596 { 282, 210, MARKER_AXIS_X, "rightx", },
6597 { 282, 210, MARKER_AXIS_Y, "righty", },
6600 unsigned int event_frame_delay = 0;
6601 unsigned int event_frame_delay_value = GAME_FRAME_DELAY;
6603 ResetDelayCounter(&event_frame_delay);
6605 if (!bitmaps_initialized)
6607 controller = LoadCustomImage("joystick/controller.png");
6608 button = LoadCustomImage("joystick/button.png");
6609 axis_x = LoadCustomImage("joystick/axis_x.png");
6610 axis_y = LoadCustomImage("joystick/axis_y.png");
6612 bitmaps_initialized = TRUE;
6615 name = getFormattedJoystickName(SDL_JoystickName(joystick));
6618 /* print info about the joystick we are watching */
6619 Error(ERR_DEBUG, "watching joystick %d: (%s)\n",
6620 SDL_JoystickInstanceID(joystick), name);
6621 Error(ERR_DEBUG, "joystick has %d axes, %d hats, %d balls, and %d buttons\n",
6622 SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
6623 SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
6626 /* initialize mapping with GUID and name */
6627 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), temp, sizeof(temp));
6629 snprintf(mapping, sizeof(mapping), "%s,%s,platform:%s,",
6630 temp, name, SDL_GetPlatform());
6632 /* loop through all steps (buttons and axes), getting joystick events */
6633 for (i = 0; i < SDL_arraysize(steps) && !done;)
6635 Bitmap *marker = button; /* initialize with reliable default value */
6638 strcpy(step->mapping, mapping);
6642 step->hat_value = -1;
6644 marker = (step->marker == MARKER_BUTTON ? button :
6645 step->marker == MARKER_AXIS_X ? axis_x :
6646 step->marker == MARKER_AXIS_Y ? axis_y : marker);
6650 while (!done && !next)
6652 alpha += alpha_step * (int)(SDL_GetTicks() - alpha_ticks) / 5;
6653 alpha_ticks = SDL_GetTicks();
6660 else if (alpha < 128)
6666 int controller_x = SX + (SXSIZE - controller->width) / 2;
6667 int controller_y = SY + ystep_line;
6669 int marker_x = controller_x + step->x;
6670 int marker_y = controller_y + step->y;
6672 int ystart1 = mSY - 2 * SY + controller_y + controller->height;
6673 int ystart2 = ystart1 + ystep_name + ystep_line;
6677 DrawTextSCentered(ystart1, font_name, name);
6679 DrawTextSCentered(ystart2, font_info,
6680 "Press buttons and move axes on");
6681 ystart2 += ystep_line;
6682 DrawTextSCentered(ystart2, font_info,
6683 "your controller when indicated.");
6684 ystart2 += ystep_line;
6685 DrawTextSCentered(ystart2, font_info,
6686 "(Your controller may look different.)");
6687 ystart2 += ystep_para;
6689 #if defined(PLATFORM_ANDROID)
6690 DrawTextSCentered(ystart2, font_info,
6691 "To correct a mistake,");
6692 ystart2 += ystep_line;
6693 DrawTextSCentered(ystart2, font_info,
6694 "press the 'back' button.");
6695 ystart2 += ystep_line;
6696 DrawTextSCentered(ystart2, font_info,
6697 "To skip a button or axis,");
6698 ystart2 += ystep_line;
6699 DrawTextSCentered(ystart2, font_info,
6700 "press the 'menu' button.");
6702 DrawTextSCentered(ystart2, font_info,
6703 "To correct a mistake,");
6704 ystart2 += ystep_line;
6705 DrawTextSCentered(ystart2, font_info,
6706 "press the 'backspace' key.");
6707 ystart2 += ystep_line;
6708 DrawTextSCentered(ystart2, font_info,
6709 "To skip a button or axis,");
6710 ystart2 += ystep_line;
6711 DrawTextSCentered(ystart2, font_info,
6712 "press the 'return' key.");
6713 ystart2 += ystep_line;
6714 DrawTextSCentered(ystart2, font_info,
6715 "To exit, press the 'escape' key.");
6718 BlitBitmapMasked(controller, drawto, 0, 0,
6719 controller->width, controller->height,
6720 controller_x, controller_y);
6722 SDL_SetSurfaceAlphaMod(marker->surface_masked, alpha);
6724 BlitBitmapMasked(marker, drawto, 0, 0,
6725 marker->width, marker->height,
6726 marker_x, marker_y);
6728 if (!screen_initialized)
6729 FadeIn(REDRAW_FIELD);
6733 screen_initialized = TRUE;
6735 while (NextValidEvent(&event))
6739 case SDL_JOYAXISMOTION:
6740 if (event.jaxis.value > 20000 ||
6741 event.jaxis.value < -20000)
6743 for (j = 0; j < i; j++)
6744 if (steps[j].axis == event.jaxis.axis)
6749 if (step->marker != MARKER_AXIS_X &&
6750 step->marker != MARKER_AXIS_Y)
6753 step->axis = event.jaxis.axis;
6754 strcat(mapping, step->field);
6755 snprintf(temp, sizeof(temp), ":a%u,", event.jaxis.axis);
6756 strcat(mapping, temp);
6764 case SDL_JOYHATMOTION:
6765 /* ignore centering; we're probably just coming back
6766 to the center from the previous item we set */
6767 if (event.jhat.value == SDL_HAT_CENTERED)
6770 for (j = 0; j < i; j++)
6771 if (steps[j].hat == event.jhat.hat &&
6772 steps[j].hat_value == event.jhat.value)
6777 step->hat = event.jhat.hat;
6778 step->hat_value = event.jhat.value;
6779 strcat(mapping, step->field);
6780 snprintf(temp, sizeof(temp), ":h%u.%u,",
6781 event.jhat.hat, event.jhat.value );
6782 strcat(mapping, temp);
6789 case SDL_JOYBALLMOTION:
6792 case SDL_JOYBUTTONUP:
6793 for (j = 0; j < i; j++)
6794 if (steps[j].button == event.jbutton.button)
6799 step->button = event.jbutton.button;
6800 strcat(mapping, step->field);
6801 snprintf(temp, sizeof(temp), ":b%u,", event.jbutton.button);
6802 strcat(mapping, temp);
6809 case SDL_FINGERDOWN:
6810 case SDL_MOUSEBUTTONDOWN:
6811 /* skip this step */
6818 if (event.key.keysym.sym == KSYM_BackSpace ||
6819 event.key.keysym.sym == KSYM_Back)
6828 /* undo this step */
6829 prev_step = &steps[i - 1];
6830 strcpy(mapping, prev_step->mapping);
6837 if (event.key.keysym.sym == KSYM_space ||
6838 event.key.keysym.sym == KSYM_Return ||
6839 event.key.keysym.sym == KSYM_Menu)
6841 /* skip this step */
6848 if (event.key.keysym.sym == KSYM_Escape)
6858 program.exit_function(0);
6865 // do not handle events for longer than standard frame delay period
6866 if (DelayReached(&event_frame_delay, event_frame_delay_value))
6875 Error(ERR_DEBUG, "New game controller mapping:\n\n%s\n\n", mapping);
6878 // activate mapping for this game
6879 SDL_GameControllerAddMapping(mapping);
6881 // save mapping to personal mappings
6882 SaveSetup_AddGameControllerMapping(mapping);
6885 /* wait until the last pending event was removed from event queue */
6886 while (NextValidEvent(&event));
6894 static int ConfigureJoystickMain(int player_nr)
6896 char *device_name = setup.input[player_nr].joy.device_name;
6897 int joystick_nr = getJoystickNrFromDeviceName(device_name);
6898 boolean joystick_active = CheckJoystickOpened(joystick_nr);
6899 int success = FALSE;
6902 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6903 return JOYSTICK_NOT_AVAILABLE;
6905 if (!joystick_active || !setup.input[player_nr].use_joystick)
6906 return JOYSTICK_NOT_AVAILABLE;
6909 FadeOut(REDRAW_FIELD);
6911 // close all joystick devices (potentially opened as game controllers)
6912 for (i = 0; i < SDL_NumJoysticks(); i++)
6913 SDLCloseJoystick(i);
6915 // open joystick device as plain joystick to configure as game controller
6916 SDL_Joystick *joystick = SDL_JoystickOpen(joystick_nr);
6918 // as the joystick was successfully opened before, this should not happen
6919 if (joystick == NULL)
6922 // create new game controller mapping (buttons and axes) for joystick device
6923 success = ConfigureJoystickMapButtonsAndAxes(joystick);
6925 // close joystick (and maybe re-open as configured game controller later)
6926 SDL_JoystickClose(joystick);
6928 // re-open all joystick devices (potentially as game controllers)
6929 for (i = 0; i < SDL_NumJoysticks(); i++)
6932 // clear all joystick input actions for all joystick devices
6933 SDLClearJoystickState();
6935 return (success ? JOYSTICK_CONFIGURED : JOYSTICK_NOT_CONFIGURED);
6938 void ConfigureJoystick(int player_nr)
6940 boolean state = ConfigureJoystickMain(player_nr);
6942 if (state != JOYSTICK_NOT_CONFIGURED)
6944 boolean success = (state == JOYSTICK_CONFIGURED);
6945 char *message = (success ? " IS CONFIGURED! " : " NOT AVAILABLE! ");
6946 char *device_name = setup.input[player_nr].joy.device_name;
6947 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6948 int xpos = mSX - SX;
6949 int ypos = mSY - SY;
6950 unsigned int wait_frame_delay = 0;
6951 unsigned int wait_frame_delay_value = 2000;
6953 ResetDelayCounter(&wait_frame_delay);
6957 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6958 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, message);
6960 while (!DelayReached(&wait_frame_delay, wait_frame_delay_value))
6966 DrawSetupScreen_Input();
6969 void DrawSetupScreen()
6971 if (setup_mode == SETUP_MODE_INPUT)
6972 DrawSetupScreen_Input();
6973 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6974 DrawChooseTree(&game_speed_current);
6975 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6976 DrawChooseTree(&scroll_delay_current);
6977 else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
6978 DrawChooseTree(&snapshot_mode_current);
6979 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6980 DrawChooseTree(&window_size_current);
6981 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6982 DrawChooseTree(&scaling_type_current);
6983 else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING)
6984 DrawChooseTree(&rendering_mode_current);
6985 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6986 DrawChooseTree(&artwork.gfx_current);
6987 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6988 DrawChooseTree(&artwork.snd_current);
6989 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6990 DrawChooseTree(&artwork.mus_current);
6991 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6992 DrawChooseTree(&volume_simple_current);
6993 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6994 DrawChooseTree(&volume_loops_current);
6995 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6996 DrawChooseTree(&volume_music_current);
6997 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6998 DrawChooseTree(&touch_control_current);
6999 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
7000 DrawChooseTree(&move_distance_current);
7001 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
7002 DrawChooseTree(&drop_distance_current);
7004 DrawSetupScreen_Generic();
7006 PlayMenuSoundsAndMusic();
7009 void RedrawSetupScreenAfterFullscreenToggle()
7011 if (setup_mode == SETUP_MODE_GRAPHICS ||
7012 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7014 // update list selection from "setup.window_scaling_percent"
7015 execSetupGraphics_setWindowSizes(TRUE);
7021 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
7023 if (setup_mode == SETUP_MODE_INPUT)
7024 HandleSetupScreen_Input(mx, my, dx, dy, button);
7025 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
7026 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
7027 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
7028 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
7029 else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
7030 HandleChooseTree(mx, my, dx, dy, button, &snapshot_mode_current);
7031 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7032 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
7033 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
7034 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
7035 else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING)
7036 HandleChooseTree(mx, my, dx, dy, button, &rendering_mode_current);
7037 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
7038 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
7039 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
7040 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
7041 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
7042 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
7043 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
7044 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
7045 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
7046 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
7047 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
7048 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
7049 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
7050 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
7051 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
7052 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
7053 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
7054 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
7056 HandleSetupScreen_Generic(mx, my, dx, dy, button);
7059 void HandleGameActions()
7061 if (game_status != GAME_MODE_PLAYING)
7064 GameActions(); /* main game loop */
7066 if (tape.auto_play && !tape.playing)
7067 AutoPlayTape(); /* continue automatically playing next tape */
7071 /* ---------- new screen button stuff -------------------------------------- */
7073 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
7077 case SCREEN_CTRL_ID_PREV_LEVEL:
7078 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
7079 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
7082 case SCREEN_CTRL_ID_NEXT_LEVEL:
7083 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
7084 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
7087 case SCREEN_CTRL_ID_PREV_PLAYER:
7088 *x = mSX + TILEX * 10;
7089 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
7092 case SCREEN_CTRL_ID_NEXT_PLAYER:
7093 *x = mSX + TILEX * 12;
7094 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
7098 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
7104 int gfx_unpressed, gfx_pressed;
7105 void (*get_gadget_position)(int *, int *, int);
7109 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
7112 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
7113 getScreenMenuButtonPos,
7114 SCREEN_CTRL_ID_PREV_LEVEL,
7119 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
7120 getScreenMenuButtonPos,
7121 SCREEN_CTRL_ID_NEXT_LEVEL,
7126 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
7127 getScreenMenuButtonPos,
7128 SCREEN_CTRL_ID_PREV_PLAYER,
7133 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
7134 getScreenMenuButtonPos,
7135 SCREEN_CTRL_ID_NEXT_PLAYER,
7143 int gfx_unpressed, gfx_pressed;
7147 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
7150 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
7151 -1, -1, /* these values are not constant, but can change at runtime */
7152 SCREEN_CTRL_ID_SCROLL_UP,
7156 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
7157 -1, -1, /* these values are not constant, but can change at runtime */
7158 SCREEN_CTRL_ID_SCROLL_DOWN,
7165 int gfx_unpressed, gfx_pressed;
7171 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
7174 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
7175 -1, -1, /* these values are not constant, but can change at runtime */
7176 -1, -1, /* these values are not constant, but can change at runtime */
7177 GD_TYPE_SCROLLBAR_VERTICAL,
7178 SCREEN_CTRL_ID_SCROLL_VERTICAL,
7179 "scroll level series vertically"
7183 static void CreateScreenMenubuttons()
7185 struct GadgetInfo *gi;
7186 unsigned int event_mask;
7189 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
7191 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7192 int gfx_unpressed, gfx_pressed;
7193 int x, y, width, height;
7194 int gd_x1, gd_x2, gd_y1, gd_y2;
7195 int id = menubutton_info[i].gadget_id;
7197 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7199 menubutton_info[i].get_gadget_position(&x, &y, id);
7201 width = SC_MENUBUTTON_XSIZE;
7202 height = SC_MENUBUTTON_YSIZE;
7204 gfx_unpressed = menubutton_info[i].gfx_unpressed;
7205 gfx_pressed = menubutton_info[i].gfx_pressed;
7206 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7207 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7208 gd_x1 = graphic_info[gfx_unpressed].src_x;
7209 gd_y1 = graphic_info[gfx_unpressed].src_y;
7210 gd_x2 = graphic_info[gfx_pressed].src_x;
7211 gd_y2 = graphic_info[gfx_pressed].src_y;
7213 gi = CreateGadget(GDI_CUSTOM_ID, id,
7214 GDI_CUSTOM_TYPE_ID, i,
7215 GDI_INFO_TEXT, menubutton_info[i].infotext,
7220 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7221 GDI_STATE, GD_BUTTON_UNPRESSED,
7222 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7223 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7224 GDI_DIRECT_DRAW, FALSE,
7225 GDI_EVENT_MASK, event_mask,
7226 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7230 Error(ERR_EXIT, "cannot create gadget");
7232 screen_gadget[id] = gi;
7236 static void CreateScreenScrollbuttons()
7238 struct GadgetInfo *gi;
7239 unsigned int event_mask;
7242 /* these values are not constant, but can change at runtime */
7243 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
7244 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
7245 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
7246 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
7248 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7250 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7251 int gfx_unpressed, gfx_pressed;
7252 int x, y, width, height;
7253 int gd_x1, gd_x2, gd_y1, gd_y2;
7254 int id = scrollbutton_info[i].gadget_id;
7256 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7258 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
7259 y = mSY + scrollbutton_info[i].y;
7260 width = SC_SCROLLBUTTON_XSIZE;
7261 height = SC_SCROLLBUTTON_YSIZE;
7263 /* correct scrollbar position if placed outside menu (playfield) area */
7264 if (x > SX + SC_SCROLL_UP_XPOS)
7265 x = SX + SC_SCROLL_UP_XPOS;
7267 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
7268 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
7269 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
7271 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
7272 gfx_pressed = scrollbutton_info[i].gfx_pressed;
7273 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7274 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7275 gd_x1 = graphic_info[gfx_unpressed].src_x;
7276 gd_y1 = graphic_info[gfx_unpressed].src_y;
7277 gd_x2 = graphic_info[gfx_pressed].src_x;
7278 gd_y2 = graphic_info[gfx_pressed].src_y;
7280 gi = CreateGadget(GDI_CUSTOM_ID, id,
7281 GDI_CUSTOM_TYPE_ID, i,
7282 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7287 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7288 GDI_STATE, GD_BUTTON_UNPRESSED,
7289 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7290 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7291 GDI_DIRECT_DRAW, FALSE,
7292 GDI_EVENT_MASK, event_mask,
7293 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7297 Error(ERR_EXIT, "cannot create gadget");
7299 screen_gadget[id] = gi;
7303 static void CreateScreenScrollbars()
7307 /* these values are not constant, but can change at runtime */
7308 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
7309 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
7310 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
7311 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
7313 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7315 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7316 int gfx_unpressed, gfx_pressed;
7317 int x, y, width, height;
7318 int gd_x1, gd_x2, gd_y1, gd_y2;
7319 struct GadgetInfo *gi;
7320 int items_max, items_visible, item_position;
7321 unsigned int event_mask;
7322 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
7323 int id = scrollbar_info[i].gadget_id;
7325 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7327 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
7328 y = mSY + scrollbar_info[i].y;
7329 width = scrollbar_info[i].width;
7330 height = scrollbar_info[i].height;
7332 /* correct scrollbar position if placed outside menu (playfield) area */
7333 if (x > SX + SC_SCROLL_VERTICAL_XPOS)
7334 x = SX + SC_SCROLL_VERTICAL_XPOS;
7336 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
7337 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
7339 items_max = num_page_entries;
7340 items_visible = num_page_entries;
7343 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
7344 gfx_pressed = scrollbar_info[i].gfx_pressed;
7345 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7346 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7347 gd_x1 = graphic_info[gfx_unpressed].src_x;
7348 gd_y1 = graphic_info[gfx_unpressed].src_y;
7349 gd_x2 = graphic_info[gfx_pressed].src_x;
7350 gd_y2 = graphic_info[gfx_pressed].src_y;
7352 gi = CreateGadget(GDI_CUSTOM_ID, id,
7353 GDI_CUSTOM_TYPE_ID, i,
7354 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7359 GDI_TYPE, scrollbar_info[i].type,
7360 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7361 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7362 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7363 GDI_WHEEL_AREA_X, SX,
7364 GDI_WHEEL_AREA_Y, SY,
7365 GDI_WHEEL_AREA_WIDTH, SXSIZE,
7366 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
7367 GDI_STATE, GD_BUTTON_UNPRESSED,
7368 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7369 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7370 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
7371 GDI_DIRECT_DRAW, FALSE,
7372 GDI_EVENT_MASK, event_mask,
7373 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7377 Error(ERR_EXIT, "cannot create gadget");
7379 screen_gadget[id] = gi;
7383 void CreateScreenGadgets()
7385 CreateScreenMenubuttons();
7387 CreateScreenScrollbuttons();
7388 CreateScreenScrollbars();
7391 void FreeScreenGadgets()
7395 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
7396 FreeGadget(screen_gadget[i]);
7399 void MapScreenMenuGadgets(int screen_mask)
7403 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
7404 if (screen_mask & menubutton_info[i].screen_mask)
7405 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
7408 void MapScreenGadgets(int num_entries)
7412 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
7415 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7416 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
7418 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7419 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
7422 void MapScreenTreeGadgets(TreeInfo *ti)
7424 MapScreenGadgets(numTreeInfoInGroup(ti));
7427 static void HandleScreenGadgets(struct GadgetInfo *gi)
7429 int id = gi->custom_id;
7430 int button = gi->event.button;
7431 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
7435 case SCREEN_CTRL_ID_PREV_LEVEL:
7436 HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT);
7439 case SCREEN_CTRL_ID_NEXT_LEVEL:
7440 HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT);
7443 case SCREEN_CTRL_ID_PREV_PLAYER:
7444 HandleSetupScreen_Input_Player(step, -1);
7447 case SCREEN_CTRL_ID_NEXT_PLAYER:
7448 HandleSetupScreen_Input_Player(step, +1);
7451 case SCREEN_CTRL_ID_SCROLL_UP:
7452 if (game_status == GAME_MODE_LEVELS)
7453 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7454 else if (game_status == GAME_MODE_LEVELNR)
7455 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7456 else if (game_status == GAME_MODE_SETUP)
7457 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7458 else if (game_status == GAME_MODE_INFO)
7459 HandleInfoScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7462 case SCREEN_CTRL_ID_SCROLL_DOWN:
7463 if (game_status == GAME_MODE_LEVELS)
7464 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7465 else if (game_status == GAME_MODE_LEVELNR)
7466 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7467 else if (game_status == GAME_MODE_SETUP)
7468 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7469 else if (game_status == GAME_MODE_INFO)
7470 HandleInfoScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7473 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
7474 if (game_status == GAME_MODE_LEVELS)
7475 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
7476 else if (game_status == GAME_MODE_LEVELNR)
7477 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
7478 else if (game_status == GAME_MODE_SETUP)
7479 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
7480 else if (game_status == GAME_MODE_INFO)
7481 HandleInfoScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);