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)])
448 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
449 menu.draw_xoffset[GAME_MODE_SETUP] : \
450 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
451 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
452 menu.draw_yoffset[GAME_MODE_SETUP] : \
453 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
455 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
456 DRAW_XOFFSET_INFO(info_mode) : \
457 (s) == GAME_MODE_SETUP ? \
458 DRAW_XOFFSET_SETUP(setup_mode) : \
459 menu.draw_xoffset[DRAW_MODE(s)])
460 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
461 DRAW_YOFFSET_INFO(info_mode) : \
462 (s) == GAME_MODE_SETUP ? \
463 DRAW_YOFFSET_SETUP(setup_mode) : \
464 menu.draw_yoffset[DRAW_MODE(s)])
466 #define mSX (SX + DRAW_XOFFSET(game_status))
467 #define mSY (SY + DRAW_YOFFSET(game_status))
469 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
470 menu.list_size[game_status] : \
471 MAX_MENU_ENTRIES_ON_SCREEN)
473 #define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \
474 NUM_MENU_ENTRIES_ON_SCREEN)
477 /* title display and control definitions */
479 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
480 2 * MAX_NUM_TITLE_MESSAGES)
482 #define NO_DIRECT_LEVEL_SELECT (-1)
485 static int num_title_screens = 0;
487 struct TitleControlInfo
496 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
498 /* main menu display and control definitions */
500 #define MAIN_CONTROL_NAME 0
501 #define MAIN_CONTROL_LEVELS 1
502 #define MAIN_CONTROL_SCORES 2
503 #define MAIN_CONTROL_EDITOR 3
504 #define MAIN_CONTROL_INFO 4
505 #define MAIN_CONTROL_GAME 5
506 #define MAIN_CONTROL_SETUP 6
507 #define MAIN_CONTROL_QUIT 7
508 #define MAIN_CONTROL_PREV_LEVEL 8
509 #define MAIN_CONTROL_NEXT_LEVEL 9
510 #define MAIN_CONTROL_FIRST_LEVEL 10
511 #define MAIN_CONTROL_LAST_LEVEL 11
512 #define MAIN_CONTROL_LEVEL_NUMBER 12
513 #define MAIN_CONTROL_LEVEL_INFO_1 13
514 #define MAIN_CONTROL_LEVEL_INFO_2 14
515 #define MAIN_CONTROL_LEVEL_NAME 15
516 #define MAIN_CONTROL_LEVEL_AUTHOR 16
517 #define MAIN_CONTROL_LEVEL_YEAR 17
518 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
519 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
520 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
521 #define MAIN_CONTROL_TITLE_1 21
522 #define MAIN_CONTROL_TITLE_2 22
523 #define MAIN_CONTROL_TITLE_3 23
525 static char str_main_text_name[10];
526 static char str_main_text_first_level[10];
527 static char str_main_text_last_level[10];
528 static char str_main_text_level_number[10];
530 static char *main_text_name = str_main_text_name;
531 static char *main_text_first_level = str_main_text_first_level;
532 static char *main_text_last_level = str_main_text_last_level;
533 static char *main_text_level_number = str_main_text_level_number;
534 static char *main_text_levels = "Levelset";
535 static char *main_text_scores = "Hall Of Fame";
536 static char *main_text_editor = "Level Creator";
537 static char *main_text_info = "Info Screen";
538 static char *main_text_game = "Start Game";
539 static char *main_text_setup = "Setup";
540 static char *main_text_quit = "Quit";
541 static char *main_text_level_name = level.name;
542 static char *main_text_level_author = level.author;
543 static char *main_text_level_year = NULL;
544 static char *main_text_level_imported_from = NULL;
545 static char *main_text_level_imported_by = NULL;
546 static char *main_text_level_tested_by = NULL;
548 struct MainControlInfo
552 struct MenuPosInfo *pos_button;
555 struct TextPosInfo *pos_text;
558 struct TextPosInfo *pos_input;
562 static struct MainControlInfo main_controls[] =
566 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
567 &menu.main.text.name, &main_text_name,
568 &menu.main.input.name, &setup.player_name,
572 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
573 &menu.main.text.levels, &main_text_levels,
578 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
579 &menu.main.text.scores, &main_text_scores,
584 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
585 &menu.main.text.editor, &main_text_editor,
590 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
591 &menu.main.text.info, &main_text_info,
596 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
597 &menu.main.text.game, &main_text_game,
602 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
603 &menu.main.text.setup, &main_text_setup,
608 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
609 &menu.main.text.quit, &main_text_quit,
613 /* (these two buttons are real gadgets) */
615 MAIN_CONTROL_PREV_LEVEL,
616 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
621 MAIN_CONTROL_NEXT_LEVEL,
622 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
628 MAIN_CONTROL_FIRST_LEVEL,
630 &menu.main.text.first_level, &main_text_first_level,
634 MAIN_CONTROL_LAST_LEVEL,
636 &menu.main.text.last_level, &main_text_last_level,
640 MAIN_CONTROL_LEVEL_NUMBER,
642 &menu.main.text.level_number, &main_text_level_number,
646 MAIN_CONTROL_LEVEL_INFO_1,
648 &menu.main.text.level_info_1, NULL,
652 MAIN_CONTROL_LEVEL_INFO_2,
654 &menu.main.text.level_info_2, NULL,
658 MAIN_CONTROL_LEVEL_NAME,
660 &menu.main.text.level_name, &main_text_level_name,
664 MAIN_CONTROL_LEVEL_AUTHOR,
666 &menu.main.text.level_author, &main_text_level_author,
670 MAIN_CONTROL_LEVEL_YEAR,
672 &menu.main.text.level_year, &main_text_level_year,
676 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
678 &menu.main.text.level_imported_from, &main_text_level_imported_from,
682 MAIN_CONTROL_LEVEL_IMPORTED_BY,
684 &menu.main.text.level_imported_by, &main_text_level_imported_by,
688 MAIN_CONTROL_LEVEL_TESTED_BY,
690 &menu.main.text.level_tested_by, &main_text_level_tested_by,
694 MAIN_CONTROL_TITLE_1,
696 &menu.main.text.title_1, &setup.internal.program_title,
700 MAIN_CONTROL_TITLE_2,
702 &menu.main.text.title_2, &setup.internal.program_copyright,
706 MAIN_CONTROL_TITLE_3,
708 &menu.main.text.title_3, &setup.internal.program_company,
721 static int getTitleScreenGraphic(int nr, boolean initial)
723 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
726 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
728 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
732 static int getTitleScreenGameMode(boolean initial)
734 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
738 static int getTitleMessageGameMode(boolean initial)
740 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
743 static int getTitleAnimMode(struct TitleControlInfo *tci)
745 int base = (tci->initial ? GAME_MODE_TITLE_INITIAL_1 : GAME_MODE_TITLE_1);
747 return base + tci->local_nr;
751 static int getTitleScreenBackground(boolean initial)
753 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
758 static int getTitleMessageBackground(int nr, boolean initial)
760 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
764 static int getTitleBackground(int nr, boolean initial, boolean is_image)
766 int base = (is_image ?
767 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
768 IMG_BACKGROUND_TITLESCREEN_1) :
769 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
770 IMG_BACKGROUND_TITLEMESSAGE_1));
771 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
772 IMG_BACKGROUND_TITLE);
773 int graphic_local = base + nr;
775 if (graphic_info[graphic_local].bitmap != NULL)
776 return graphic_local;
778 if (graphic_info[graphic_global].bitmap != NULL)
779 return graphic_global;
781 return IMG_UNDEFINED;
784 static int getTitleSound(struct TitleControlInfo *tci)
786 boolean is_image = tci->is_image;
787 int initial = tci->initial;
788 int nr = tci->local_nr;
789 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
790 int base = (is_image ?
791 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
792 SND_BACKGROUND_TITLESCREEN_1) :
793 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
794 SND_BACKGROUND_TITLEMESSAGE_1));
795 int sound_global = menu.sound[mode];
796 int sound_local = base + nr;
799 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
800 nr, initial, is_image,
801 sound_global, getSoundListEntry(sound_global)->filename,
802 sound_local, getSoundListEntry(sound_local)->filename);
805 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
808 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
811 return SND_UNDEFINED;
814 static int getTitleMusic(struct TitleControlInfo *tci)
816 boolean is_image = tci->is_image;
817 int initial = tci->initial;
818 int nr = tci->local_nr;
819 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
820 int base = (is_image ?
821 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
822 MUS_BACKGROUND_TITLESCREEN_1) :
823 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
824 MUS_BACKGROUND_TITLEMESSAGE_1));
825 int music_global = menu.music[mode];
826 int music_local = base + nr;
829 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
830 nr, initial, is_image,
831 music_global, getMusicListEntry(music_global)->filename,
832 music_local, getMusicListEntry(music_local)->filename);
835 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
838 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
841 return MUS_UNDEFINED;
844 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
846 boolean is_image = tci->is_image;
847 boolean initial = tci->initial;
848 boolean first = tci->first;
849 int nr = tci->local_nr;
850 struct TitleMessageInfo tmi;
851 struct TitleFadingInfo ti;
853 tmi = (is_image ? (initial ? (first ?
854 titlescreen_initial_first[nr] :
855 titlescreen_initial[nr])
857 titlescreen_first[nr] :
859 : (initial ? (first ?
860 titlemessage_initial_first[nr] :
861 titlemessage_initial[nr])
863 titlemessage_first[nr] :
866 ti.fade_mode = tmi.fade_mode;
867 ti.fade_delay = tmi.fade_delay;
868 ti.post_delay = tmi.post_delay;
869 ti.auto_delay = tmi.auto_delay;
874 static int compareTitleControlInfo(const void *object1, const void *object2)
876 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
877 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
880 if (tci1->initial != tci2->initial)
881 compare_result = (tci1->initial ? -1 : +1);
882 else if (tci1->sort_priority != tci2->sort_priority)
883 compare_result = tci1->sort_priority - tci2->sort_priority;
884 else if (tci1->is_image != tci2->is_image)
885 compare_result = (tci1->is_image ? -1 : +1);
887 compare_result = tci1->local_nr - tci2->local_nr;
889 return compare_result;
892 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
894 int nr, int sort_priority)
896 title_controls[num_title_screens].is_image = is_image;
897 title_controls[num_title_screens].initial = initial;
898 title_controls[num_title_screens].local_nr = nr;
899 title_controls[num_title_screens].sort_priority = sort_priority;
901 title_controls[num_title_screens].first = FALSE; /* will be set later */
906 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
910 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
912 int graphic = getTitleScreenGraphic(i, initial);
913 Bitmap *bitmap = graphic_info[graphic].bitmap;
914 int sort_priority = graphic_info[graphic].sort_priority;
917 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
920 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
922 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
923 char *filename = getLevelSetTitleMessageFilename(i, initial);
924 int sort_priority = tmi->sort_priority;
926 if (filename != NULL)
927 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
931 static void InitializeTitleControls(boolean show_title_initial)
933 num_title_screens = 0;
935 /* 1st step: initialize title screens for game start (only when starting) */
936 if (show_title_initial)
937 InitializeTitleControls_CheckTitleInfo(TRUE);
939 /* 2nd step: initialize title screens for current level set */
940 InitializeTitleControls_CheckTitleInfo(FALSE);
942 /* sort title screens according to sort_priority and title number */
943 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
944 compareTitleControlInfo);
946 /* mark first title screen */
947 title_controls[0].first = TRUE;
950 static boolean visibleMenuPos(struct MenuPosInfo *pos)
952 return (pos != NULL && pos->x != -1 && pos->y != -1);
955 static boolean visibleTextPos(struct TextPosInfo *pos)
957 return (pos != NULL && pos->x != -1 && pos->y != -1);
960 static void InitializeMainControls()
962 boolean local_team_mode = (!options.network && setup.team_mode);
965 /* set main control text values to dynamically determined values */
966 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
968 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
969 menu.main.text.first_level.size));
970 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
971 menu.main.text.last_level.size));
972 strcpy(main_text_level_number, int2str(level_nr,
973 menu.main.text.level_number.size));
975 main_text_level_year = leveldir_current->year;
976 main_text_level_imported_from = leveldir_current->imported_from;
977 main_text_level_imported_by = leveldir_current->imported_by;
978 main_text_level_tested_by = leveldir_current->tested_by;
980 /* set main control screen positions to dynamically determined values */
981 for (i = 0; main_controls[i].nr != -1; i++)
983 struct MainControlInfo *mci = &main_controls[i];
985 struct MenuPosInfo *pos_button = mci->pos_button;
986 struct TextPosInfo *pos_text = mci->pos_text;
987 struct TextPosInfo *pos_input = mci->pos_input;
988 char *text = (mci->text ? *mci->text : NULL);
989 char *input = (mci->input ? *mci->input : NULL);
990 int button_graphic = mci->button_graphic;
991 int font_text = (pos_text ? pos_text->font : -1);
992 int font_input = (pos_input ? pos_input->font : -1);
994 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
995 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
996 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
997 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
998 int text_chars = (text != NULL ? strlen(text) : 0);
999 int input_chars = (input != NULL ? strlen(input) : 0);
1002 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
1004 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
1005 int text_width = font_text_width * text_chars;
1006 int text_height = font_text_height;
1007 int input_width = font_input_width * input_chars;
1008 int input_height = font_input_height;
1010 if (nr == MAIN_CONTROL_NAME)
1012 menu.main.input.name.width = input_width;
1013 menu.main.input.name.height = input_height;
1016 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
1018 pos_button->width = button_width;
1019 pos_button->height = button_height;
1022 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
1024 /* calculate size for non-clickable text -- needed for text alignment */
1025 boolean calculate_text_size = (pos_button == NULL && text != NULL);
1027 if (pos_text->width == -1 || calculate_text_size)
1028 pos_text->width = text_width;
1029 if (pos_text->height == -1 || calculate_text_size)
1030 pos_text->height = text_height;
1032 if (visibleMenuPos(pos_button))
1034 if (pos_text->x == -1)
1035 pos_text->x = pos_button->x + pos_button->width;
1036 if (pos_text->y == -1)
1038 pos_button->y + (pos_button->height - pos_text->height) / 2;
1042 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
1044 if (visibleTextPos(pos_text))
1046 if (pos_input->x == -1)
1047 pos_input->x = pos_text->x + pos_text->width;
1048 if (pos_input->y == -1)
1049 pos_input->y = pos_text->y;
1052 if (pos_input->width == -1)
1053 pos_input->width = input_width;
1054 if (pos_input->height == -1)
1055 pos_input->height = input_height;
1060 static void DrawPressedGraphicThruMask(int dst_x, int dst_y,
1061 int graphic, boolean pressed)
1063 struct GraphicInfo *g = &graphic_info[graphic];
1066 int xoffset = (pressed ? g->pressed_xoffset : 0);
1067 int yoffset = (pressed ? g->pressed_yoffset : 0);
1069 getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
1071 BlitBitmapMasked(src_bitmap, drawto, src_x + xoffset, src_y + yoffset,
1072 g->width, g->height, dst_x, dst_y);
1075 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1076 boolean active_input,
1077 boolean pressed_button)
1081 for (i = 0; main_controls[i].nr != -1; i++)
1083 struct MainControlInfo *mci = &main_controls[i];
1085 if (mci->nr == nr || nr == -1)
1087 struct MenuPosInfo *pos_button = mci->pos_button;
1088 struct TextPosInfo *pos_text = mci->pos_text;
1089 struct TextPosInfo *pos_input = mci->pos_input;
1090 char *text = (mci->text ? *mci->text : NULL);
1091 char *input = (mci->input ? *mci->input : NULL);
1092 int button_graphic = mci->button_graphic;
1093 int font_text = (pos_text ? pos_text->font : -1);
1094 int font_input = (pos_input ? pos_input->font : -1);
1098 button_graphic = BUTTON_ACTIVE(button_graphic);
1099 font_text = FONT_ACTIVE(font_text);
1104 font_input = FONT_ACTIVE(font_input);
1107 if (visibleMenuPos(pos_button))
1109 struct MenuPosInfo *pos = pos_button;
1110 int x = mSX + pos->x;
1111 int y = mSY + pos->y;
1113 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1114 DrawPressedGraphicThruMask(x, y, button_graphic, pressed_button);
1117 if (visibleTextPos(pos_text) && text != NULL)
1119 struct TextPosInfo *pos = pos_text;
1120 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1121 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1124 /* (check why/if this is needed) */
1125 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1127 DrawText(x, y, text, font_text);
1130 if (visibleTextPos(pos_input) && input != NULL)
1132 struct TextPosInfo *pos = pos_input;
1133 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1134 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1137 /* (check why/if this is needed) */
1138 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1140 DrawText(x, y, input, font_input);
1146 static void DrawCursorAndText_Main(int nr, boolean active_text,
1147 boolean pressed_button)
1149 DrawCursorAndText_Main_Ext(nr, active_text, FALSE, pressed_button);
1153 static void DrawCursorAndText_Main_Input(int nr, boolean active_text,
1154 boolean pressed_button)
1156 DrawCursorAndText_Main_Ext(nr, active_text, TRUE, pressed_button);
1160 static struct MainControlInfo *getMainControlInfo(int nr)
1164 for (i = 0; main_controls[i].nr != -1; i++)
1165 if (main_controls[i].nr == nr)
1166 return &main_controls[i];
1171 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1176 int rect_x = ALIGNED_TEXT_XPOS(rect);
1177 int rect_y = ALIGNED_TEXT_YPOS(rect);
1179 return (x >= rect_x && x < rect_x + rect->width &&
1180 y >= rect_y && y < rect_y + rect->height);
1183 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1188 int rect_x = ALIGNED_TEXT_XPOS(rect);
1189 int rect_y = ALIGNED_TEXT_YPOS(rect);
1192 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1193 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1194 (x >= rect_x && x < rect_x + rect->width &&
1195 y >= rect_y && y < rect_y + rect->height));
1198 return (x >= rect_x && x < rect_x + rect->width &&
1199 y >= rect_y && y < rect_y + rect->height);
1202 static boolean insidePreviewRect(struct PreviewInfo *preview, int x, int y)
1204 int rect_width = preview->xsize * preview->tile_size;
1205 int rect_height = preview->ysize * preview->tile_size;
1206 int rect_x = ALIGNED_XPOS(preview->x, rect_width, preview->align);
1207 int rect_y = ALIGNED_YPOS(preview->y, rect_height, preview->valign);
1209 return (x >= rect_x && x < rect_x + rect_width &&
1210 y >= rect_y && y < rect_y + rect_height);
1213 static void AdjustScrollbar(int id, int items_max, int items_visible,
1216 struct GadgetInfo *gi = screen_gadget[id];
1218 if (item_position > items_max - items_visible)
1219 item_position = items_max - items_visible;
1221 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
1222 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
1223 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
1226 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
1228 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
1232 static void clearMenuListArea()
1234 int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
1236 /* correct scrollbar position if placed outside menu (playfield) area */
1237 if (scrollbar_xpos > SX + SC_SCROLLBAR_XPOS)
1238 scrollbar_xpos = SX + SC_SCROLLBAR_XPOS;
1240 /* clear menu list area, but not title or scrollbar */
1241 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
1242 scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
1245 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1247 static int cursor_array[MAX_LEV_FIELDY];
1248 int x = mSX + TILEX * xpos;
1249 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1254 cursor_array[ypos] = graphic;
1256 graphic = cursor_array[ypos];
1260 graphic = BUTTON_ACTIVE(graphic);
1262 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1263 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1266 static void initCursor(int ypos, int graphic)
1268 drawCursorExt(0, ypos, FALSE, graphic);
1271 static void drawCursor(int ypos, boolean active)
1273 drawCursorExt(0, ypos, active, -1);
1276 static void drawCursorXY(int xpos, int ypos, int graphic)
1278 drawCursorExt(xpos, ypos, FALSE, graphic);
1281 static void drawChooseTreeCursor(int ypos, boolean active)
1283 drawCursorExt(0, ypos, active, -1);
1288 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, getProgramTitleString());
1289 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
1290 setup.internal.program_copyright);
1293 void DrawTitleScreenImage(int nr, boolean initial)
1295 int graphic = getTitleScreenGraphic(nr, initial);
1296 Bitmap *bitmap = graphic_info[graphic].bitmap;
1297 int width = graphic_info[graphic].width;
1298 int height = graphic_info[graphic].height;
1299 int src_x = graphic_info[graphic].src_x;
1300 int src_y = graphic_info[graphic].src_y;
1306 if (width > WIN_XSIZE)
1308 /* image width too large for window => center image horizontally */
1309 src_x = (width - WIN_XSIZE) / 2;
1313 if (height > WIN_YSIZE)
1315 /* image height too large for window => center image vertically */
1316 src_y = (height - WIN_YSIZE) / 2;
1320 /* always display title screens centered */
1321 dst_x = (WIN_XSIZE - width) / 2;
1322 dst_y = (WIN_YSIZE - height) / 2;
1324 SetDrawBackgroundMask(REDRAW_ALL);
1325 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1327 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1329 if (DrawingOnBackground(dst_x, dst_y))
1330 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1332 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1334 redraw_mask = REDRAW_ALL;
1337 void DrawTitleScreenMessage(int nr, boolean initial)
1339 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1340 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1342 if (filename == NULL)
1345 /* force TITLE font on title message screen */
1346 SetFontStatus(getTitleMessageGameMode(initial));
1348 /* if chars *and* width set to "-1", automatically determine width */
1349 if (tmi->chars == -1 && tmi->width == -1)
1350 tmi->width = viewport.window[game_status].width;
1352 /* if lines *and* height set to "-1", automatically determine height */
1353 if (tmi->lines == -1 && tmi->height == -1)
1354 tmi->height = viewport.window[game_status].height;
1356 /* if chars set to "-1", automatically determine by text and font width */
1357 if (tmi->chars == -1)
1358 tmi->chars = tmi->width / getFontWidth(tmi->font);
1360 tmi->width = tmi->chars * getFontWidth(tmi->font);
1362 /* if lines set to "-1", automatically determine by text and font height */
1363 if (tmi->lines == -1)
1364 tmi->lines = tmi->height / getFontHeight(tmi->font);
1366 tmi->height = tmi->lines * getFontHeight(tmi->font);
1368 /* if x set to "-1", automatically determine by width and alignment */
1370 tmi->x = -1 * ALIGNED_XPOS(0, tmi->width, tmi->align);
1372 /* if y set to "-1", automatically determine by height and alignment */
1374 tmi->y = -1 * ALIGNED_YPOS(0, tmi->height, tmi->valign);
1376 SetDrawBackgroundMask(REDRAW_ALL);
1377 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1379 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1381 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1382 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1383 tmi->autowrap, tmi->centered, tmi->parse_comments);
1388 void DrawTitleScreen()
1390 KeyboardAutoRepeatOff();
1392 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1395 boolean CheckTitleScreen(boolean levelset_has_changed)
1397 static boolean show_title_initial = TRUE;
1398 boolean show_titlescreen = FALSE;
1400 /* needed to be able to skip title screen, if no image or message defined */
1401 InitializeTitleControls(show_title_initial);
1403 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1404 show_titlescreen = TRUE;
1406 /* show initial title images and messages only once at program start */
1407 show_title_initial = FALSE;
1409 return (show_titlescreen && num_title_screens > 0);
1414 static LevelDirTree *leveldir_last_valid = NULL;
1415 boolean levelset_has_changed = FALSE;
1416 int fade_mask = REDRAW_FIELD;
1418 LimitScreenUpdates(FALSE);
1420 FadeSetLeaveScreen();
1422 /* do not fade out here -- function may continue and fade on editor screen */
1425 FadeMenuSoundsAndMusic();
1427 ExpireSoundLoops(FALSE);
1429 KeyboardAutoRepeatOn();
1431 audio.sound_deactivated = FALSE;
1435 /* needed if last screen was the playing screen, invoked from level editor */
1436 if (level_editor_test_game)
1438 CloseDoor(DOOR_CLOSE_ALL);
1440 SetGameStatus(GAME_MODE_EDITOR);
1447 /* needed if last screen was the setup screen and fullscreen state changed */
1448 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1449 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1451 /* leveldir_current may be invalid (level group, parent link) */
1452 if (!validLevelSeries(leveldir_current))
1453 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1455 if (leveldir_current != leveldir_last_valid)
1456 levelset_has_changed = TRUE;
1458 /* store valid level series information */
1459 leveldir_last_valid = leveldir_current;
1461 init_last = init; /* switch to new busy animation */
1463 /* needed if last screen (level choice) changed graphics, sounds or music */
1464 ReloadCustomArtwork(0);
1466 if (CheckTitleScreen(levelset_has_changed))
1468 SetGameStatus(GAME_MODE_TITLE);
1475 if (redraw_mask & REDRAW_ALL)
1476 fade_mask = REDRAW_ALL;
1478 if (CheckIfGlobalBorderHasChanged())
1479 fade_mask = REDRAW_ALL;
1483 /* needed if different viewport properties defined for menues */
1484 ChangeViewportPropertiesIfNeeded();
1486 SetDrawtoField(DRAW_TO_BACKBUFFER);
1488 /* level_nr may have been set to value over handicap with level editor */
1489 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1490 level_nr = leveldir_current->handicap_level;
1492 LoadLevel(level_nr);
1493 LoadScore(level_nr);
1495 SaveLevelSetup_SeriesInfo();
1497 // set this after "ChangeViewportPropertiesIfNeeded()" (which may reset it)
1498 SetDrawDeactivationMask(REDRAW_NONE);
1499 SetDrawBackgroundMask(REDRAW_FIELD);
1501 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1504 if (fade_mask == REDRAW_ALL)
1505 RedrawGlobalBorder();
1510 InitializeMainControls();
1512 DrawCursorAndText_Main(-1, FALSE, FALSE);
1513 DrawPreviewLevelInitial();
1515 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1518 if (TAPE_IS_EMPTY(tape))
1520 DrawCompleteVideoDisplay();
1522 PlayMenuSoundsAndMusic();
1524 /* create gadgets for main menu screen */
1525 FreeScreenGadgets();
1526 CreateScreenGadgets();
1528 /* map gadgets for main menu screen */
1530 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1532 /* copy actual game door content to door double buffer for OpenDoor() */
1533 BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0);
1534 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1536 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1538 DrawMaskedBorder(fade_mask);
1543 /* update screen area with special editor door */
1544 redraw_mask |= REDRAW_ALL;
1547 SetMouseCursor(CURSOR_DEFAULT);
1549 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1552 static void gotoTopLevelDir()
1554 /* move upwards until inside (but not above) top level directory */
1555 while (leveldir_current->node_parent &&
1556 !strEqual(leveldir_current->node_parent->subdir, STRING_TOP_DIRECTORY))
1558 /* write a "path" into level tree for easy navigation to last level */
1559 if (leveldir_current->node_parent->node_group->cl_first == -1)
1561 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1562 int leveldir_pos = posTreeInfo(leveldir_current);
1563 int num_page_entries;
1564 int cl_first, cl_cursor;
1566 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1567 num_page_entries = num_leveldirs;
1569 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1571 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1572 cl_cursor = leveldir_pos - cl_first;
1574 leveldir_current->node_parent->node_group->cl_first = cl_first;
1575 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1578 leveldir_current = leveldir_current->node_parent;
1582 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1584 static unsigned int title_delay = 0;
1585 static int title_screen_nr = 0;
1586 static int last_sound = -1, last_music = -1;
1587 boolean return_to_main_menu = FALSE;
1588 struct TitleControlInfo *tci;
1591 if (button == MB_MENU_INITIALIZE)
1594 title_screen_nr = 0;
1595 tci = &title_controls[title_screen_nr];
1597 SetAnimStatus(getTitleAnimMode(tci));
1599 last_sound = SND_UNDEFINED;
1600 last_music = MUS_UNDEFINED;
1602 if (num_title_screens != 0)
1604 FadeSetEnterScreen();
1606 /* use individual title fading instead of global "enter screen" fading */
1607 fading = getTitleFading(tci);
1610 if (game_status_last_screen == GAME_MODE_INFO)
1612 if (num_title_screens == 0)
1614 /* switch game mode from title screen mode back to info screen mode */
1615 SetGameStatus(GAME_MODE_INFO);
1617 /* store that last screen was info screen, not main menu screen */
1618 game_status_last_screen = GAME_MODE_INFO;
1620 DrawInfoScreen_NotAvailable("Title screen information:",
1621 "No title screen for this level set.");
1625 FadeMenuSoundsAndMusic();
1628 FadeOut(REDRAW_ALL);
1630 /* title screens may have different window size */
1631 ChangeViewportPropertiesIfNeeded();
1633 /* only required to update logic for redrawing global border */
1637 DrawTitleScreenImage(tci->local_nr, tci->initial);
1639 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1641 sound = getTitleSound(tci);
1642 music = getTitleMusic(tci);
1644 if (sound != last_sound)
1645 PlayMenuSoundExt(sound);
1646 if (music != last_music)
1647 PlayMenuMusicExt(music);
1652 SetMouseCursor(CURSOR_NONE);
1656 DelayReached(&title_delay, 0); /* reset delay counter */
1661 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1662 button = MB_MENU_CHOICE;
1664 if (button == MB_MENU_LEAVE)
1666 return_to_main_menu = TRUE;
1668 else if (button == MB_MENU_CHOICE)
1670 if (game_status_last_screen == GAME_MODE_INFO && num_title_screens == 0)
1672 SetGameStatus(GAME_MODE_INFO);
1674 info_mode = INFO_MODE_MAIN;
1683 if (title_screen_nr < num_title_screens)
1685 tci = &title_controls[title_screen_nr];
1687 SetAnimStatus(getTitleAnimMode(tci));
1689 sound = getTitleSound(tci);
1690 music = getTitleMusic(tci);
1692 if (last_sound != SND_UNDEFINED && sound != last_sound)
1693 FadeSound(last_sound);
1694 if (last_music != MUS_UNDEFINED && music != last_music)
1697 fading = getTitleFading(tci);
1699 FadeOut(REDRAW_ALL);
1702 DrawTitleScreenImage(tci->local_nr, tci->initial);
1704 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1706 sound = getTitleSound(tci);
1707 music = getTitleMusic(tci);
1709 if (sound != last_sound)
1710 PlayMenuSoundExt(sound);
1711 if (music != last_music)
1712 PlayMenuMusicExt(music);
1719 DelayReached(&title_delay, 0); /* reset delay counter */
1723 FadeMenuSoundsAndMusic();
1725 return_to_main_menu = TRUE;
1729 if (return_to_main_menu)
1731 SetMouseCursor(CURSOR_DEFAULT);
1733 /* force full menu screen redraw after displaying title screens */
1734 redraw_mask = REDRAW_ALL;
1736 if (game_status_last_screen == GAME_MODE_INFO)
1738 SetGameStatus(GAME_MODE_INFO);
1740 info_mode = INFO_MODE_MAIN;
1744 else /* default: return to main menu */
1746 SetGameStatus(GAME_MODE_MAIN);
1753 void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
1755 int old_level_nr = level_nr;
1758 if (selected_level_nr != NO_DIRECT_LEVEL_SELECT)
1759 new_level_nr = selected_level_nr;
1761 new_level_nr = old_level_nr + step * direction;
1763 if (new_level_nr < leveldir_current->first_level)
1764 new_level_nr = leveldir_current->first_level;
1765 if (new_level_nr > leveldir_current->last_level)
1766 new_level_nr = leveldir_current->last_level;
1768 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1770 /* skipping levels is only allowed when trying to skip single level */
1771 if (setup.skip_levels && new_level_nr == old_level_nr + 1 &&
1772 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1774 leveldir_current->handicap_level++;
1775 SaveLevelSetup_SeriesInfo();
1778 new_level_nr = leveldir_current->handicap_level;
1781 if (new_level_nr != old_level_nr)
1783 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1785 PlaySound(SND_MENU_ITEM_SELECTING);
1787 level_nr = new_level_nr;
1789 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1790 int2str(level_nr, menu.main.text.level_number.size),
1791 mci->pos_text->font);
1793 LoadLevel(level_nr);
1794 DrawPreviewLevelInitial();
1798 DrawCompleteVideoDisplay();
1800 SaveLevelSetup_SeriesInfo();
1802 /* needed because DrawPreviewLevelInitial() takes some time */
1804 /* SyncDisplay(); */
1808 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1810 static int choice = MAIN_CONTROL_GAME;
1811 static boolean button_pressed_last = FALSE;
1812 boolean button_pressed = FALSE;
1816 if (button == MB_MENU_INITIALIZE)
1818 DrawCursorAndText_Main(choice, TRUE, FALSE);
1823 if (mx || my) /* mouse input */
1827 for (i = 0; main_controls[i].nr != -1; i++)
1829 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1830 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1831 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1833 pos = main_controls[i].nr;
1839 /* check if level preview was clicked */
1840 if (insidePreviewRect(&preview, mx - SX, my - SY))
1841 pos = MAIN_CONTROL_GAME;
1843 // handle pressed/unpressed state for active/inactive menu buttons
1844 // (if pos != -1, "i" contains index position corresponding to "pos")
1846 pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT &&
1847 insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY))
1848 button_pressed = TRUE;
1850 if (button_pressed != button_pressed_last)
1852 DrawCursorAndText_Main(choice, TRUE, button_pressed);
1855 PlaySound(SND_MENU_BUTTON_PRESSING);
1857 PlaySound(SND_MENU_BUTTON_RELEASING);
1860 else if (dx || dy) /* keyboard input */
1862 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1863 choice == MAIN_CONTROL_SETUP))
1864 button = MB_MENU_CHOICE;
1869 if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1871 HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
1873 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1875 HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT);
1877 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1879 CloseDoor(DOOR_CLOSE_2);
1881 SetGameStatus(GAME_MODE_LEVELNR);
1883 DrawChooseLevelNr();
1885 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1891 PlaySound(SND_MENU_ITEM_ACTIVATING);
1893 DrawCursorAndText_Main(choice, FALSE, FALSE);
1894 DrawCursorAndText_Main(pos, TRUE, button_pressed);
1900 if (choice != MAIN_CONTROL_INFO &&
1901 choice != MAIN_CONTROL_SETUP)
1902 HandleMainMenu_SelectLevel(1, dx, NO_DIRECT_LEVEL_SELECT);
1907 PlaySound(SND_MENU_ITEM_SELECTING);
1909 if (pos == MAIN_CONTROL_NAME)
1911 SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
1913 HandleTypeName(strlen(setup.player_name), 0);
1915 else if (pos == MAIN_CONTROL_LEVELS)
1919 CloseDoor(DOOR_CLOSE_2);
1921 SetGameStatus(GAME_MODE_LEVELS);
1923 SaveLevelSetup_LastSeries();
1924 SaveLevelSetup_SeriesInfo();
1926 if (setup.internal.choose_from_top_leveldir)
1929 DrawChooseLevelSet();
1932 else if (pos == MAIN_CONTROL_SCORES)
1934 CloseDoor(DOOR_CLOSE_2);
1936 SetGameStatus(GAME_MODE_SCORES);
1940 else if (pos == MAIN_CONTROL_EDITOR)
1942 if (leveldir_current->readonly &&
1943 !strEqual(setup.player_name, "Artsoft"))
1944 Request("This level is read only!", REQ_CONFIRM);
1946 CloseDoor(DOOR_CLOSE_2);
1948 SetGameStatus(GAME_MODE_EDITOR);
1950 FadeSetEnterScreen();
1954 else if (pos == MAIN_CONTROL_INFO)
1956 CloseDoor(DOOR_CLOSE_2);
1958 SetGameStatus(GAME_MODE_INFO);
1960 info_mode = INFO_MODE_MAIN;
1964 else if (pos == MAIN_CONTROL_GAME)
1966 StartGameActions(options.network, setup.autorecord, level.random_seed);
1968 else if (pos == MAIN_CONTROL_SETUP)
1970 CloseDoor(DOOR_CLOSE_2);
1972 SetGameStatus(GAME_MODE_SETUP);
1974 setup_mode = SETUP_MODE_MAIN;
1978 else if (pos == MAIN_CONTROL_QUIT)
1980 SaveLevelSetup_LastSeries();
1981 SaveLevelSetup_SeriesInfo();
1983 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1984 SetGameStatus(GAME_MODE_QUIT);
1989 button_pressed_last = button_pressed;
1993 /* ========================================================================= */
1994 /* info screen functions */
1995 /* ========================================================================= */
1997 static struct TokenInfo *info_info;
1998 static int num_info_info; /* number of info entries shown on screen */
1999 static int max_info_info; /* total number of info entries in list */
2001 static void execInfoTitleScreen()
2003 info_mode = INFO_MODE_TITLE;
2008 static void execInfoElements()
2010 info_mode = INFO_MODE_ELEMENTS;
2015 static void execInfoMusic()
2017 info_mode = INFO_MODE_MUSIC;
2022 static void execInfoCredits()
2024 info_mode = INFO_MODE_CREDITS;
2029 static void execInfoProgram()
2031 info_mode = INFO_MODE_PROGRAM;
2036 static void execInfoVersion()
2038 info_mode = INFO_MODE_VERSION;
2043 static void execInfoLevelSet()
2045 info_mode = INFO_MODE_LEVELSET;
2050 static void execExitInfo()
2052 SetGameStatus(GAME_MODE_MAIN);
2057 static struct TokenInfo info_info_main[] =
2059 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2060 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2061 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2062 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2063 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2064 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2065 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2066 { TYPE_EMPTY, NULL, "" },
2067 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2072 static int getMenuTextFont(int type)
2074 if (type & (TYPE_SWITCH |
2086 static struct TokenInfo *setup_info;
2087 static struct TokenInfo setup_info_input[];
2089 static struct TokenInfo *menu_info;
2091 static void DrawCursorAndText_Menu_Ext(struct TokenInfo *token_info,
2092 int screen_pos, int menu_info_pos_raw,
2095 int pos = (menu_info_pos_raw < 0 ? screen_pos : menu_info_pos_raw);
2096 struct TokenInfo *ti = &token_info[pos];
2097 int xpos = MENU_SCREEN_START_XPOS;
2098 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
2099 int font_nr = getMenuTextFont(ti->type);
2101 if (token_info == setup_info_input)
2102 font_nr = FONT_MENU_1;
2105 font_nr = FONT_ACTIVE(font_nr);
2107 DrawText(mSX + xpos * 32, mSY + ypos * 32, ti->text, font_nr);
2109 if (ti->type & ~TYPE_SKIP_ENTRY)
2110 drawCursor(screen_pos, active);
2113 static void DrawCursorAndText_Menu(int screen_pos, int menu_info_pos_raw,
2116 DrawCursorAndText_Menu_Ext(menu_info, screen_pos, menu_info_pos_raw, active);
2119 static void DrawCursorAndText_Setup(int screen_pos, int menu_info_pos_raw,
2122 DrawCursorAndText_Menu_Ext(setup_info, screen_pos, menu_info_pos_raw, active);
2125 static char *window_size_text;
2126 static char *scaling_type_text;
2128 static void drawSetupValue(int, int);
2130 static void drawMenuInfoList(int first_entry, int num_page_entries,
2131 int max_page_entries)
2135 if (first_entry + num_page_entries > max_page_entries)
2138 clearMenuListArea();
2140 for (i = 0; i < num_page_entries; i++)
2142 int menu_info_pos = first_entry + i;
2143 struct TokenInfo *si = &menu_info[menu_info_pos];
2144 void *value_ptr = si->value;
2146 /* set some entries to "unchangeable" according to other variables */
2147 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
2148 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
2149 (value_ptr == &setup.sound_music && !audio.music_available) ||
2150 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
2151 (value_ptr == &window_size_text && !video.window_scaling_available) ||
2152 (value_ptr == &scaling_type_text && !video.window_scaling_available))
2153 si->type |= TYPE_GHOSTED;
2155 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2156 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2157 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2158 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2159 else if (si->type & ~TYPE_SKIP_ENTRY)
2160 initCursor(i, IMG_MENU_BUTTON);
2162 DrawCursorAndText_Menu(i, menu_info_pos, FALSE);
2164 if (si->type & TYPE_VALUE &&
2165 menu_info == setup_info)
2166 drawSetupValue(i, menu_info_pos);
2170 static void DrawInfoScreen_Main()
2172 int fade_mask = REDRAW_FIELD;
2175 if (redraw_mask & REDRAW_ALL)
2176 fade_mask = REDRAW_ALL;
2178 if (CheckIfGlobalBorderHasChanged())
2179 fade_mask = REDRAW_ALL;
2182 FadeMenuSoundsAndMusic();
2184 FreeScreenGadgets();
2185 CreateScreenGadgets();
2187 /* (needed after displaying title screens which disable auto repeat) */
2188 KeyboardAutoRepeatOn();
2190 FadeSetLeaveScreen();
2194 /* needed if different viewport properties defined for info screen */
2195 ChangeViewportPropertiesIfNeeded();
2197 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
2201 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2203 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2205 info_info = info_info_main;
2207 // determine maximal number of info entries that can be displayed on screen
2209 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2212 // determine maximal number of info entries available for menu of info screen
2214 for (i = 0; info_info[i].type != 0; i++)
2217 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2219 MapScreenGadgets(max_info_info);
2221 PlayMenuSoundsAndMusic();
2223 DrawMaskedBorder(fade_mask);
2228 static void changeSetupValue(int, int, int);
2230 void HandleMenuScreen(int mx, int my, int dx, int dy, int button,
2231 int mode, int num_page_entries, int max_page_entries)
2233 static int num_page_entries_all_last[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
2234 static int choice_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
2235 static int first_entry_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
2236 int *num_page_entries_last = num_page_entries_all_last[game_status];
2237 int *choice_store = choice_stores[game_status];
2238 int *first_entry_store = first_entry_stores[game_status];
2239 int choice = choice_store[mode]; /* starts with 0 */
2240 int first_entry = first_entry_store[mode]; /* starts with 0 */
2242 int y = choice - first_entry;
2244 boolean position_set_by_scrollbar = (dx == 999);
2245 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
2248 if (button == MB_MENU_INITIALIZE)
2250 // check if number of menu page entries has changed (may happen by change
2251 // of custom artwork definition value for 'list_size' for this menu screen)
2252 // (in this case, the last menu position most probably has to be corrected)
2253 if (num_page_entries != num_page_entries_last[mode])
2255 choice_store[mode] = first_entry_store[mode] = 0;
2257 choice = first_entry = 0;
2260 num_page_entries_last[mode] = num_page_entries;
2263 /* advance to first valid menu entry */
2264 while (choice < num_page_entries &&
2265 menu_info[choice].type & TYPE_SKIP_ENTRY)
2268 if (position_set_by_scrollbar)
2269 first_entry = first_entry_store[mode] = dy;
2271 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_page_entries,
2272 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
2274 drawMenuInfoList(first_entry, num_page_entries, max_page_entries);
2276 if (choice < first_entry)
2278 choice = first_entry;
2280 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2283 else if (choice > first_entry + num_page_entries - 1)
2285 choice = first_entry + num_page_entries - 1;
2287 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2291 choice_store[mode] = choice;
2293 DrawCursorAndText_Menu(choice - first_entry, choice, TRUE);
2297 else if (button == MB_MENU_LEAVE)
2299 PlaySound(SND_MENU_ITEM_SELECTING);
2301 for (i = 0; i < max_page_entries; i++)
2303 if (menu_info[i].type & TYPE_LEAVE_MENU)
2305 void (*menu_callback_function)(void) = menu_info[i].value;
2309 menu_callback_function();
2311 break; /* absolutely needed because function changes 'menu_info'! */
2318 if (mx || my) /* mouse input */
2320 x = (mx - mSX) / 32;
2321 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2323 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
2325 /* move cursor instead of scrolling when already at start/end of list */
2326 if (dy == -1 * SCROLL_LINE && first_entry == 0)
2328 else if (dy == +1 * SCROLL_LINE &&
2329 first_entry + num_page_entries == max_page_entries)
2332 /* handle scrolling screen one line or page */
2334 y + dy > num_page_entries - 1)
2336 boolean redraw = FALSE;
2338 if (ABS(dy) == SCROLL_PAGE)
2339 step = num_page_entries - 1;
2341 if (dy < 0 && first_entry > 0)
2343 /* scroll page/line up */
2345 first_entry -= step;
2346 if (first_entry < 0)
2351 else if (dy > 0 && first_entry + num_page_entries < max_page_entries)
2353 /* scroll page/line down */
2355 first_entry += step;
2356 if (first_entry + num_page_entries > max_page_entries)
2357 first_entry = MAX(0, max_page_entries - num_page_entries);
2364 choice += first_entry - first_entry_store[mode];
2366 if (choice < first_entry)
2368 choice = first_entry;
2370 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2373 else if (choice > first_entry + num_page_entries - 1)
2375 choice = first_entry + num_page_entries - 1;
2377 if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2380 else if (menu_info[choice].type & TYPE_SKIP_ENTRY)
2384 if (choice < first_entry ||
2385 choice > first_entry + num_page_entries - 1)
2386 first_entry += SIGN(dy);
2389 first_entry_store[mode] = first_entry;
2390 choice_store[mode] = choice;
2392 drawMenuInfoList(first_entry, num_page_entries, max_page_entries);
2394 DrawCursorAndText_Menu(choice - first_entry, choice, TRUE);
2396 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_page_entries,
2397 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
2405 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2407 if (menu_info[choice].type & menu_navigation_type ||
2408 menu_info[choice].type & TYPE_BOOLEAN_STYLE ||
2409 menu_info[choice].type & TYPE_YES_NO_AUTO)
2410 button = MB_MENU_CHOICE;
2415 /* jump to next non-empty menu entry (up or down) */
2416 while (first_entry + y > 0 &&
2417 first_entry + y < max_page_entries - 1 &&
2418 menu_info[first_entry + y].type & TYPE_SKIP_ENTRY)
2421 if (!IN_VIS_MENU(x, y))
2423 choice += y - y_old;
2425 if (choice < first_entry)
2426 first_entry = choice;
2427 else if (choice > first_entry + num_page_entries - 1)
2428 first_entry = choice - num_page_entries + 1;
2430 if (first_entry >= 0 &&
2431 first_entry + num_page_entries <= max_page_entries)
2433 first_entry_store[mode] = first_entry;
2435 if (choice < first_entry)
2436 choice = first_entry;
2437 else if (choice > first_entry + num_page_entries - 1)
2438 choice = first_entry + num_page_entries - 1;
2440 choice_store[mode] = choice;
2442 drawMenuInfoList(first_entry, num_page_entries, max_page_entries);
2444 DrawCursorAndText_Menu(choice - first_entry, choice, TRUE);
2446 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_page_entries,
2447 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
2454 if (!anyScrollbarGadgetActive() &&
2455 IN_VIS_MENU(x, y) &&
2456 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
2457 y >= 0 && y < num_page_entries)
2461 if (first_entry + y != choice &&
2462 menu_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
2464 PlaySound(SND_MENU_ITEM_ACTIVATING);
2466 DrawCursorAndText_Menu(choice - first_entry, choice, FALSE);
2467 DrawCursorAndText_Menu(y, first_entry + y, TRUE);
2469 choice = choice_store[mode] = first_entry + y;
2473 PlaySound(SND_MENU_ITEM_SELECTING);
2475 for (i = 0; menu_info[i].type != 0; i++)
2477 if (menu_info[i].type & TYPE_LEAVE_MENU)
2479 void (*menu_callback_function)(void) = menu_info[i].value;
2483 menu_callback_function();
2485 /* absolutely needed because function changes 'menu_info'! */
2493 else if (!(menu_info[first_entry + y].type & TYPE_GHOSTED))
2495 PlaySound(SND_MENU_ITEM_SELECTING);
2497 /* when selecting key headline, execute function for key value change */
2498 if (menu_info[first_entry + y].type & TYPE_KEYTEXT &&
2499 menu_info[first_entry + y + 1].type & TYPE_KEY)
2502 /* when selecting string value, execute function for list selection */
2503 if (menu_info[first_entry + y].type & TYPE_STRING && y > 0 &&
2504 menu_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
2507 if (menu_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
2509 void (*menu_callback_function)(void) =
2510 menu_info[first_entry + y].value;
2512 FadeSetFromType(menu_info[first_entry + y].type);
2514 menu_callback_function();
2516 else if (menu_info[first_entry + y].type & TYPE_VALUE &&
2517 menu_info == setup_info)
2519 changeSetupValue(y, first_entry + y, dx);
2525 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2527 menu_info = info_info;
2529 HandleMenuScreen(mx, my, dx, dy, button,
2530 info_mode, num_info_info, max_info_info);
2533 static int getMenuFontSpacing(int spacing_height, int font_nr)
2535 int font_spacing = getFontHeight(font_nr) + menu.extra_spacing;
2537 return (spacing_height < 0 ? ABS(spacing_height) * font_spacing :
2541 static int getMenuTextSpacing(int spacing_height, int font_nr)
2543 return getMenuFontSpacing(spacing_height, font_nr) + menu.extra_spacing;
2546 static int getMenuTextStep(int spacing_height, int font_nr)
2548 return getFontHeight(font_nr) + getMenuTextSpacing(spacing_height, font_nr);
2551 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2553 int font_title = MENU_INFO_FONT_TITLE;
2554 int font_error = FONT_TEXT_2;
2555 int font_foot = MENU_INFO_FONT_FOOT;
2556 int spacing_title = menu.headline1_spacing_info[info_mode];
2557 int ystep_title = getMenuTextStep(spacing_title, font_title);
2558 int ystart1 = mSY - SY + 100;
2559 int ystart2 = ystart1 + ystep_title;
2560 int ybottom = mSY - SY + SYSIZE - 20;
2562 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO);
2564 FadeOut(REDRAW_FIELD);
2569 DrawTextSCentered(ystart1, font_title, text_title);
2570 DrawTextSCentered(ystart2, font_error, text_error);
2572 DrawTextSCentered(ybottom, font_foot,
2573 "Press any key or button for info menu");
2575 FadeIn(REDRAW_FIELD);
2578 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2580 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2581 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2582 int font_title = MENU_INFO_FONT_TITLE;
2583 int font_foot = MENU_INFO_FONT_FOOT;
2584 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2585 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2586 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2587 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2588 int ystep = MENU_SCREEN_INFO_YSTEP;
2589 int element, action, direction;
2597 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2598 infoscreen_step[i] = infoscreen_frame[i] = 0;
2603 DrawTextSCentered(ystart1, font_title, "The Game Elements:");
2605 DrawTextSCentered(ybottom, font_foot,
2606 "Press any key or button for next page");
2612 while (helpanim_info[j].element != HELPANIM_LIST_END)
2614 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2619 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2628 j += infoscreen_step[i - start];
2630 element = helpanim_info[j].element;
2631 action = helpanim_info[j].action;
2632 direction = helpanim_info[j].direction;
2635 element = EL_UNKNOWN;
2637 if (action != -1 && direction != -1)
2638 graphic = el_act_dir2img(element, action, direction);
2639 else if (action != -1)
2640 graphic = el_act2img(element, action);
2641 else if (direction != -1)
2642 graphic = el_dir2img(element, direction);
2644 graphic = el2img(element);
2646 delay = helpanim_info[j++].delay;
2651 if (infoscreen_frame[i - start] == 0)
2654 infoscreen_frame[i - start] = delay - 1;
2658 sync_frame = delay - infoscreen_frame[i - start];
2659 infoscreen_frame[i - start]--;
2662 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2664 if (!infoscreen_frame[i - start])
2665 infoscreen_step[i - start] = 0;
2669 if (!infoscreen_frame[i - start])
2670 infoscreen_step[i - start]++;
2671 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2677 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2679 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2680 graphic, sync_frame, USE_MASKING);
2683 DrawInfoScreen_HelpText(element, action, direction, i - start);
2688 redraw_mask |= REDRAW_FIELD;
2693 static char *getHelpText(int element, int action, int direction)
2695 char token[MAX_LINE_LEN];
2697 strcpy(token, element_info[element].token_name);
2700 strcat(token, element_action_info[action].suffix);
2702 if (direction != -1)
2703 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2705 return getHashEntry(helptext_info, token);
2708 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2710 int font_nr = FONT_INFO_ELEMENTS;
2711 int font_width = getFontWidth(font_nr);
2712 int font_height = getFontHeight(font_nr);
2713 int yoffset = (TILEX - 2 * font_height) / 2;
2714 int xstart = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2715 int ystart = mSY + MENU_SCREEN_INFO_YSTART2 + yoffset;
2716 int ystep = TILEY + 4;
2717 int pad_x = xstart - SX;
2718 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2719 int max_lines_per_text = 2;
2722 if (action != -1 && direction != -1) /* element.action.direction */
2723 text = getHelpText(element, action, direction);
2725 if (text == NULL && action != -1) /* element.action */
2726 text = getHelpText(element, action, -1);
2728 if (text == NULL && direction != -1) /* element.direction */
2729 text = getHelpText(element, -1, direction);
2731 if (text == NULL) /* base element */
2732 text = getHelpText(element, -1, -1);
2734 if (text == NULL) /* not found */
2735 text = "No description available";
2737 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2738 ystart += getFontHeight(font_nr) / 2;
2740 DrawTextBuffer(xstart, ystart + ypos * ystep, text, font_nr,
2741 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2742 TRUE, FALSE, FALSE);
2745 void DrawInfoScreen_TitleScreen()
2747 SetGameStatus(GAME_MODE_TITLE);
2752 void HandleInfoScreen_TitleScreen(int button)
2754 HandleTitleScreen(0, 0, 0, 0, button);
2757 void DrawInfoScreen_Elements()
2759 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2761 FadeOut(REDRAW_FIELD);
2766 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2768 FadeIn(REDRAW_FIELD);
2771 void HandleInfoScreen_Elements(int button)
2773 static unsigned int info_delay = 0;
2774 static int num_anims;
2775 static int num_pages;
2777 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2780 if (button == MB_MENU_INITIALIZE)
2782 boolean new_element = TRUE;
2786 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2788 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2790 else if (new_element)
2793 new_element = FALSE;
2797 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2801 if (button == MB_MENU_LEAVE)
2803 PlaySound(SND_MENU_ITEM_SELECTING);
2805 info_mode = INFO_MODE_MAIN;
2810 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2812 if (button != MB_MENU_INITIALIZE)
2814 PlaySound(SND_MENU_ITEM_SELECTING);
2819 if (page >= num_pages)
2821 FadeMenuSoundsAndMusic();
2823 info_mode = INFO_MODE_MAIN;
2830 FadeSetNextScreen();
2832 if (button != MB_MENU_INITIALIZE)
2833 FadeOut(REDRAW_FIELD);
2835 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2837 if (button != MB_MENU_INITIALIZE)
2838 FadeIn(REDRAW_FIELD);
2842 if (DelayReached(&info_delay, GameFrameDelay))
2843 if (page < num_pages)
2844 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2846 PlayMenuSoundIfLoop();
2850 void DrawInfoScreen_Music()
2852 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2854 FadeOut(REDRAW_FIELD);
2861 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2863 FadeIn(REDRAW_FIELD);
2866 void HandleInfoScreen_Music(int button)
2868 static struct MusicFileInfo *list = NULL;
2869 int font_title = MENU_INFO_FONT_TITLE;
2870 int font_head = MENU_INFO_FONT_HEAD;
2871 int font_text = MENU_INFO_FONT_TEXT;
2872 int font_foot = MENU_INFO_FONT_FOOT;
2873 int spacing_title = menu.headline1_spacing_info[info_mode];
2874 int spacing_head = menu.headline2_spacing_info[info_mode];
2875 int ystep_title = getMenuTextStep(spacing_title, font_title);
2876 int ystep_head = getMenuTextStep(spacing_head, font_head);
2877 int ystart = mSY - SY + 100;
2878 int ybottom = mSY - SY + SYSIZE - 20;
2880 if (button == MB_MENU_INITIALIZE)
2882 list = music_file_info;
2886 FadeMenuSoundsAndMusic();
2891 DrawTextSCentered(ystart, font_title,
2892 "No music info for this level set.");
2894 DrawTextSCentered(ybottom, font_foot,
2895 "Press any key or button for info menu");
2901 if (button == MB_MENU_LEAVE)
2903 PlaySound(SND_MENU_ITEM_SELECTING);
2905 FadeMenuSoundsAndMusic();
2907 info_mode = INFO_MODE_MAIN;
2912 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2914 if (button != MB_MENU_INITIALIZE)
2916 PlaySound(SND_MENU_ITEM_SELECTING);
2924 FadeMenuSoundsAndMusic();
2926 info_mode = INFO_MODE_MAIN;
2932 FadeMenuSoundsAndMusic();
2934 if (list != music_file_info)
2935 FadeSetNextScreen();
2937 if (button != MB_MENU_INITIALIZE)
2938 FadeOut(REDRAW_FIELD);
2945 int sound = list->music;
2947 if (sound_info[sound].loop)
2948 PlaySoundLoop(sound);
2952 DrawTextSCentered(ystart, font_title, "The Game Background Sounds:");
2956 PlayMusic(list->music);
2958 DrawTextSCentered(ystart, font_title, "The Game Background Music:");
2961 ystart += ystep_title;
2963 if (!strEqual(list->title, UNKNOWN_NAME))
2965 if (!strEqual(list->title_header, UNKNOWN_NAME))
2967 DrawTextSCentered(ystart, font_head, list->title_header);
2968 ystart += ystep_head;
2971 DrawTextFCentered(ystart, font_text, "\"%s\"", list->title);
2972 ystart += ystep_head;
2975 if (!strEqual(list->artist, UNKNOWN_NAME))
2977 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2978 DrawTextSCentered(ystart, font_head, list->artist_header);
2980 DrawTextSCentered(ystart, font_head, "by");
2982 ystart += ystep_head;
2984 DrawTextFCentered(ystart, font_text, "%s", list->artist);
2985 ystart += ystep_head;
2988 if (!strEqual(list->album, UNKNOWN_NAME))
2990 if (!strEqual(list->album_header, UNKNOWN_NAME))
2991 DrawTextSCentered(ystart, font_head, list->album_header);
2993 DrawTextSCentered(ystart, font_head, "from the album");
2995 ystart += ystep_head;
2997 DrawTextFCentered(ystart, font_text, "\"%s\"", list->album);
2998 ystart += ystep_head;
3001 if (!strEqual(list->year, UNKNOWN_NAME))
3003 if (!strEqual(list->year_header, UNKNOWN_NAME))
3004 DrawTextSCentered(ystart, font_head, list->year_header);
3006 DrawTextSCentered(ystart, font_head, "from the year");
3008 ystart += ystep_head;
3010 DrawTextFCentered(ystart, font_text, "%s", list->year);
3011 ystart += ystep_head;
3014 DrawTextSCentered(ybottom, FONT_TEXT_4,
3015 "Press any key or button for next page");
3017 if (button != MB_MENU_INITIALIZE)
3018 FadeIn(REDRAW_FIELD);
3021 if (list != NULL && list->is_sound && sound_info[list->music].loop)
3022 PlaySoundLoop(list->music);
3025 static void DrawInfoScreen_CreditsScreen(int screen_nr)
3027 int font_title = MENU_INFO_FONT_TITLE;
3028 int font_head = MENU_INFO_FONT_HEAD;
3029 int font_text = MENU_INFO_FONT_TEXT;
3030 int font_foot = MENU_INFO_FONT_FOOT;
3031 int spacing_title = menu.headline1_spacing_info[info_mode];
3032 int spacing_head = menu.headline2_spacing_info[info_mode];
3033 int spacing_para = menu.paragraph_spacing_info[info_mode];
3034 int spacing_line = menu.line_spacing_info[info_mode];
3035 int ystep_title = getMenuTextStep(spacing_title, font_title);
3036 int ystep_head = getMenuTextStep(spacing_head, font_head);
3037 int ystep_para = getMenuTextStep(spacing_para, font_text);
3038 int ystep_line = getMenuTextStep(spacing_line, font_text);
3039 int ystart = mSY - SY + 100;
3040 int ybottom = mSY - SY + SYSIZE - 20;
3045 DrawTextSCentered(ystart, font_title, "Credits:");
3046 ystart += ystep_title;
3050 DrawTextSCentered(ystart, font_head,
3051 "Special thanks to");
3052 ystart += ystep_head;
3053 DrawTextSCentered(ystart, font_text,
3055 ystart += ystep_head;
3056 DrawTextSCentered(ystart, font_head,
3058 ystart += ystep_head;
3059 DrawTextSCentered(ystart, font_text,
3060 "\"Boulder Dash\"");
3061 ystart += ystep_head;
3062 DrawTextSCentered(ystart, font_head,
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 "First Star Software");
3074 else if (screen_nr == 1)
3076 DrawTextSCentered(ystart, font_head,
3077 "Special thanks to");
3078 ystart += ystep_head;
3079 DrawTextSCentered(ystart, font_text,
3080 "Klaus Heinz & Volker Wertich");
3081 ystart += ystep_head;
3082 DrawTextSCentered(ystart, font_head,
3084 ystart += ystep_head;
3085 DrawTextSCentered(ystart, font_text,
3086 "\"Emerald Mine\"");
3087 ystart += ystep_head;
3088 DrawTextSCentered(ystart, font_head,
3090 ystart += ystep_head;
3091 DrawTextSCentered(ystart, font_text,
3093 ystart += ystep_head;
3094 DrawTextSCentered(ystart, font_head,
3096 ystart += ystep_head;
3097 DrawTextSCentered(ystart, font_text,
3100 else if (screen_nr == 2)
3102 DrawTextSCentered(ystart, font_head,
3103 "Special thanks to");
3104 ystart += ystep_head;
3105 DrawTextSCentered(ystart, font_text,
3106 "Michael Stopp & Philip Jespersen");
3107 ystart += ystep_head;
3108 DrawTextSCentered(ystart, font_head,
3110 ystart += ystep_head;
3111 DrawTextSCentered(ystart, font_text,
3113 ystart += ystep_head;
3114 DrawTextSCentered(ystart, font_head,
3116 ystart += ystep_head;
3117 DrawTextSCentered(ystart, font_text,
3119 ystart += ystep_head;
3120 DrawTextSCentered(ystart, font_head,
3122 ystart += ystep_head;
3123 DrawTextSCentered(ystart, font_text,
3124 "Digital Integration");
3126 else if (screen_nr == 3)
3128 DrawTextSCentered(ystart, font_head,
3129 "Special thanks to");
3130 ystart += ystep_head;
3131 DrawTextSCentered(ystart, font_text,
3132 "Hiroyuki Imabayashi");
3133 ystart += ystep_head;
3134 DrawTextSCentered(ystart, font_head,
3136 ystart += ystep_head;
3137 DrawTextSCentered(ystart, font_text,
3139 ystart += ystep_head;
3140 DrawTextSCentered(ystart, font_head,
3142 ystart += ystep_head;
3143 DrawTextSCentered(ystart, font_text,
3145 ystart += ystep_head;
3146 DrawTextSCentered(ystart, font_head,
3148 ystart += ystep_head;
3149 DrawTextSCentered(ystart, font_text,
3152 else if (screen_nr == 4)
3154 DrawTextSCentered(ystart, font_head,
3155 "Special thanks to");
3156 ystart += ystep_head;
3157 DrawTextSCentered(ystart, font_text,
3159 ystart += ystep_head;
3160 DrawTextSCentered(ystart, font_head,
3162 ystart += ystep_head;
3163 DrawTextSCentered(ystart, font_text,
3164 "J\xfcrgen Bonhagen");
3165 ystart += ystep_head;
3166 DrawTextSCentered(ystart, font_head,
3167 "for the continuous creation");
3168 ystart += ystep_line;
3169 DrawTextSCentered(ystart, font_head,
3170 "of outstanding level sets");
3172 else if (screen_nr == 5)
3174 DrawTextSCentered(ystart, font_head,
3176 ystart += ystep_head;
3177 DrawTextSCentered(ystart, font_text,
3179 ystart += ystep_head;
3180 DrawTextSCentered(ystart, font_head,
3181 "for ideas and inspiration by");
3182 ystart += ystep_head;
3183 DrawTextSCentered(ystart, font_text,
3185 ystart += ystep_para;
3187 DrawTextSCentered(ystart, font_head,
3189 ystart += ystep_head;
3190 DrawTextSCentered(ystart, font_text,
3192 ystart += ystep_head;
3193 DrawTextSCentered(ystart, font_head,
3194 "for ideas and inspiration by");
3195 ystart += ystep_head;
3196 DrawTextSCentered(ystart, font_text,
3199 else if (screen_nr == 6)
3201 DrawTextSCentered(ystart, font_head,
3203 ystart += ystep_head;
3204 DrawTextSCentered(ystart, font_text,
3206 ystart += ystep_head;
3207 DrawTextSCentered(ystart, font_head,
3208 "for the code base used for the");
3209 ystart += ystep_line;
3210 DrawTextSCentered(ystart, font_head,
3211 "native Emerald Mine engine");
3213 else if (screen_nr == 7)
3215 DrawTextSCentered(ystart, font_head,
3217 ystart += ystep_head;
3218 DrawTextSCentered(ystart, font_text,
3220 ystart += ystep_head;
3221 DrawTextSCentered(ystart, font_head,
3222 "for the initial DOS port");
3223 ystart += ystep_para;
3225 DrawTextSCentered(ystart, font_head,
3227 ystart += ystep_head;
3228 DrawTextSCentered(ystart, font_text,
3230 ystart += ystep_head;
3231 DrawTextSCentered(ystart, font_head,
3232 "for some additional toons");
3234 else if (screen_nr == 8)
3236 DrawTextSCentered(ystart, font_head,
3237 "And not to forget:");
3238 ystart += ystep_head;
3239 DrawTextSCentered(ystart, font_head,
3241 ystart += ystep_head;
3242 DrawTextSCentered(ystart, font_text,
3243 "All those who contributed");
3244 ystart += ystep_line;
3245 DrawTextSCentered(ystart, font_text,
3246 "levels to this game");
3247 ystart += ystep_line;
3248 DrawTextSCentered(ystart, font_text,
3252 DrawTextSCentered(ybottom, font_foot,
3253 "Press any key or button for next page");
3256 void DrawInfoScreen_Credits()
3258 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
3260 FadeMenuSoundsAndMusic();
3262 FadeOut(REDRAW_FIELD);
3264 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
3266 FadeIn(REDRAW_FIELD);
3269 void HandleInfoScreen_Credits(int button)
3271 static int screen_nr = 0;
3272 int num_screens = 9;
3274 if (button == MB_MENU_INITIALIZE)
3278 // DrawInfoScreen_CreditsScreen(screen_nr);
3281 if (button == MB_MENU_LEAVE)
3283 PlaySound(SND_MENU_ITEM_SELECTING);
3285 info_mode = INFO_MODE_MAIN;
3290 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
3292 if (button != MB_MENU_INITIALIZE)
3294 PlaySound(SND_MENU_ITEM_SELECTING);
3299 if (screen_nr >= num_screens)
3301 FadeMenuSoundsAndMusic();
3303 info_mode = INFO_MODE_MAIN;
3310 FadeSetNextScreen();
3312 if (button != MB_MENU_INITIALIZE)
3313 FadeOut(REDRAW_FIELD);
3315 DrawInfoScreen_CreditsScreen(screen_nr);
3317 if (button != MB_MENU_INITIALIZE)
3318 FadeIn(REDRAW_FIELD);
3322 PlayMenuSoundIfLoop();
3326 void DrawInfoScreen_Program()
3328 int font_title = MENU_INFO_FONT_TITLE;
3329 int font_head = MENU_INFO_FONT_HEAD;
3330 int font_text = MENU_INFO_FONT_TEXT;
3331 int font_foot = MENU_INFO_FONT_FOOT;
3332 int spacing_title = menu.headline1_spacing_info[info_mode];
3333 int spacing_head = menu.headline2_spacing_info[info_mode];
3334 int spacing_para = menu.paragraph_spacing_info[info_mode];
3335 int spacing_line = menu.line_spacing_info[info_mode];
3336 int ystep_title = getMenuTextStep(spacing_title, font_title);
3337 int ystep_head = getMenuTextStep(spacing_head, font_head);
3338 int ystep_para = getMenuTextStep(spacing_para, font_text);
3339 int ystep_line = getMenuTextStep(spacing_line, font_text);
3340 int ystart = mSY - SY + 100;
3341 int ybottom = mSY - SY + SYSIZE - 20;
3343 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3345 FadeOut(REDRAW_FIELD);
3350 DrawTextSCentered(ystart, font_title, "Program Information:");
3351 ystart += ystep_title;
3353 DrawTextSCentered(ystart, font_head,
3354 "This game is Freeware!");
3355 ystart += ystep_head;
3356 DrawTextSCentered(ystart, font_head,
3357 "If you like it, send e-mail to:");
3358 ystart += ystep_head;
3359 DrawTextSCentered(ystart, font_text,
3360 setup.internal.program_email);
3361 ystart += ystep_para;
3363 DrawTextSCentered(ystart, font_head,
3364 "More information and levels:");
3365 ystart += ystep_head;
3366 DrawTextSCentered(ystart, font_text,
3367 setup.internal.program_website);
3368 ystart += ystep_para;
3370 DrawTextSCentered(ystart, font_head,
3371 "If you have created new levels,");
3372 ystart += ystep_line;
3373 DrawTextSCentered(ystart, font_head,
3374 "send them to me to include them!");
3375 ystart += ystep_head;
3376 DrawTextSCentered(ystart, font_head,
3379 DrawTextSCentered(ybottom, font_foot,
3380 "Press any key or button for info menu");
3382 FadeIn(REDRAW_FIELD);
3385 void HandleInfoScreen_Program(int button)
3387 if (button == MB_MENU_LEAVE)
3389 PlaySound(SND_MENU_ITEM_SELECTING);
3391 info_mode = INFO_MODE_MAIN;
3396 else if (button == MB_MENU_CHOICE)
3398 PlaySound(SND_MENU_ITEM_SELECTING);
3400 FadeMenuSoundsAndMusic();
3402 info_mode = INFO_MODE_MAIN;
3407 PlayMenuSoundIfLoop();
3411 void DrawInfoScreen_Version()
3413 int font_title = MENU_INFO_FONT_TITLE;
3414 int font_head = MENU_INFO_FONT_HEAD;
3415 int font_text = MENU_INFO_FONT_TEXT;
3416 int font_foot = MENU_INFO_FONT_FOOT;
3417 int spacing_title = menu.headline1_spacing_info[info_mode];
3418 int spacing_head = menu.headline2_spacing_info[info_mode];
3419 int spacing_para = menu.paragraph_spacing_info[info_mode];
3420 int spacing_line = menu.line_spacing_info[info_mode];
3421 int xstep = getFontWidth(font_text);
3422 int ystep_title = getMenuTextStep(spacing_title, font_title);
3423 int ystep_head = getMenuTextStep(spacing_head, font_head);
3424 int ystep_para = getMenuTextStep(spacing_para, font_text);
3425 int ystep_line = getMenuTextStep(spacing_line, font_text);
3426 int ystart = mSY - SY + 100;
3427 int ybottom = mSY - SY + SYSIZE - 20;
3428 int xstart1 = mSX - SX + 2 * xstep;
3429 int xstart2 = mSX - SX + 18 * xstep;
3430 int xstart3 = mSX - SX + 28 * xstep;
3431 SDL_version sdl_version_compiled;
3432 const SDL_version *sdl_version_linked;
3433 int driver_name_len = 10;
3434 #if defined(TARGET_SDL2)
3435 SDL_version sdl_version_linked_ext;
3436 const char *driver_name = NULL;
3438 char driver_name[driver_name_len];
3441 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3443 FadeOut(REDRAW_FIELD);
3448 DrawTextSCentered(ystart, font_title, "Version Information:");
3449 ystart += ystep_title;
3451 DrawTextF(xstart1, ystart, font_head, "Name");
3452 DrawTextF(xstart2, ystart, font_text, getProgramTitleString());
3453 ystart += ystep_line;
3455 if (!strEqual(getProgramVersionString(), getProgramRealVersionString()))
3457 DrawTextF(xstart1, ystart, font_head, "Version (fake)");
3458 DrawTextF(xstart2, ystart, font_text, getProgramVersionString());
3459 ystart += ystep_line;
3461 DrawTextF(xstart1, ystart, font_head, "Version (real)");
3462 DrawTextF(xstart2, ystart, font_text, getProgramRealVersionString());
3463 ystart += ystep_line;
3467 DrawTextF(xstart1, ystart, font_head, "Version");
3468 DrawTextF(xstart2, ystart, font_text, getProgramVersionString());
3469 ystart += ystep_line;
3472 DrawTextF(xstart1, ystart, font_head, "Platform");
3473 DrawTextF(xstart2, ystart, font_text, PLATFORM_STRING);
3474 ystart += ystep_line;
3476 DrawTextF(xstart1, ystart, font_head, "Target");
3477 DrawTextF(xstart2, ystart, font_text, TARGET_STRING);
3478 ystart += ystep_line;
3480 DrawTextF(xstart1, ystart, font_head, "Source date");
3481 DrawTextF(xstart2, ystart, font_text, getSourceDateString());
3482 ystart += ystep_para;
3484 DrawTextF(xstart1, ystart, font_head, "Library");
3485 DrawTextF(xstart2, ystart, font_head, "compiled");
3486 DrawTextF(xstart3, ystart, font_head, "linked");
3487 ystart += ystep_head;
3489 SDL_VERSION(&sdl_version_compiled);
3490 #if defined(TARGET_SDL2)
3491 SDL_GetVersion(&sdl_version_linked_ext);
3492 sdl_version_linked = &sdl_version_linked_ext;
3494 sdl_version_linked = SDL_Linked_Version();
3497 DrawTextF(xstart1, ystart, font_text, "SDL");
3498 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3499 sdl_version_compiled.major,
3500 sdl_version_compiled.minor,
3501 sdl_version_compiled.patch);
3502 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3503 sdl_version_linked->major,
3504 sdl_version_linked->minor,
3505 sdl_version_linked->patch);
3506 ystart += ystep_line;
3508 SDL_IMAGE_VERSION(&sdl_version_compiled);
3509 sdl_version_linked = IMG_Linked_Version();
3511 DrawTextF(xstart1, ystart, font_text, "SDL_image");
3512 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3513 sdl_version_compiled.major,
3514 sdl_version_compiled.minor,
3515 sdl_version_compiled.patch);
3516 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3517 sdl_version_linked->major,
3518 sdl_version_linked->minor,
3519 sdl_version_linked->patch);
3520 ystart += ystep_line;
3522 SDL_MIXER_VERSION(&sdl_version_compiled);
3523 sdl_version_linked = Mix_Linked_Version();
3525 DrawTextF(xstart1, ystart, font_text, "SDL_mixer");
3526 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3527 sdl_version_compiled.major,
3528 sdl_version_compiled.minor,
3529 sdl_version_compiled.patch);
3530 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3531 sdl_version_linked->major,
3532 sdl_version_linked->minor,
3533 sdl_version_linked->patch);
3534 ystart += ystep_line;
3536 SDL_NET_VERSION(&sdl_version_compiled);
3537 sdl_version_linked = SDLNet_Linked_Version();
3539 DrawTextF(xstart1, ystart, font_text, "SDL_net");
3540 DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
3541 sdl_version_compiled.major,
3542 sdl_version_compiled.minor,
3543 sdl_version_compiled.patch);
3544 DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
3545 sdl_version_linked->major,
3546 sdl_version_linked->minor,
3547 sdl_version_linked->patch);
3548 ystart += ystep_para;
3550 DrawTextF(xstart1, ystart, font_head, "Driver");
3551 DrawTextF(xstart2, ystart, font_head, "Requested");
3552 DrawTextF(xstart3, ystart, font_head, "Used");
3553 ystart += ystep_head;
3555 #if defined(TARGET_SDL2)
3556 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
3558 SDL_VideoDriverName(driver_name, driver_name_len);
3561 DrawTextF(xstart1, ystart, font_text, "SDL_VideoDriver");
3562 DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_videodriver);
3563 DrawTextF(xstart3, ystart, font_text, "%s", driver_name);
3564 ystart += ystep_line;
3566 #if defined(TARGET_SDL2)
3567 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
3569 SDL_AudioDriverName(driver_name, driver_name_len);
3572 DrawTextF(xstart1, ystart, font_text, "SDL_AudioDriver");
3573 DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_audiodriver);
3574 DrawTextF(xstart3, ystart, font_text, "%s", driver_name);
3576 DrawTextSCentered(ybottom, font_foot,
3577 "Press any key or button for info menu");
3579 FadeIn(REDRAW_FIELD);
3582 void HandleInfoScreen_Version(int button)
3584 if (button == MB_MENU_LEAVE)
3586 PlaySound(SND_MENU_ITEM_SELECTING);
3588 info_mode = INFO_MODE_MAIN;
3593 else if (button == MB_MENU_CHOICE)
3595 PlaySound(SND_MENU_ITEM_SELECTING);
3597 FadeMenuSoundsAndMusic();
3599 info_mode = INFO_MODE_MAIN;
3604 PlayMenuSoundIfLoop();
3608 void DrawInfoScreen_LevelSet()
3610 struct TitleMessageInfo *tmi = &readme;
3611 char *filename = getLevelSetInfoFilename();
3612 char *title = "Level Set Information:";
3613 int ystart = mSY - SY + 100;
3614 int ybottom = mSY - SY + SYSIZE - 20;
3616 if (filename == NULL)
3618 DrawInfoScreen_NotAvailable(title, "No information for this level set.");
3623 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3625 FadeOut(REDRAW_FIELD);
3630 DrawTextSCentered(ystart, FONT_TEXT_1, title);
3632 /* if x position set to "-1", automatically determine by playfield width */
3634 tmi->x = SXSIZE / 2;
3636 /* if y position set to "-1", use static default value */
3640 /* if width set to "-1", automatically determine by playfield width */
3641 if (tmi->width == -1)
3642 tmi->width = SXSIZE - 2 * TILEX;
3644 /* if height set to "-1", automatically determine by playfield height */
3645 if (tmi->height == -1)
3646 tmi->height = SYSIZE - 20 - tmi->y - 10;
3648 /* if chars set to "-1", automatically determine by text and font width */
3649 if (tmi->chars == -1)
3650 tmi->chars = tmi->width / getFontWidth(tmi->font);
3652 tmi->width = tmi->chars * getFontWidth(tmi->font);
3654 /* if lines set to "-1", automatically determine by text and font height */
3655 if (tmi->lines == -1)
3656 tmi->lines = tmi->height / getFontHeight(tmi->font);
3658 tmi->height = tmi->lines * getFontHeight(tmi->font);
3660 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3661 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3662 tmi->autowrap, tmi->centered, tmi->parse_comments);
3664 DrawTextSCentered(ybottom, FONT_TEXT_4,
3665 "Press any key or button for info menu");
3667 FadeIn(REDRAW_FIELD);
3670 void HandleInfoScreen_LevelSet(int button)
3672 if (button == MB_MENU_LEAVE)
3674 PlaySound(SND_MENU_ITEM_SELECTING);
3676 info_mode = INFO_MODE_MAIN;
3681 else if (button == MB_MENU_CHOICE)
3683 PlaySound(SND_MENU_ITEM_SELECTING);
3685 FadeMenuSoundsAndMusic();
3687 info_mode = INFO_MODE_MAIN;
3692 PlayMenuSoundIfLoop();
3696 static void DrawInfoScreen()
3698 if (info_mode == INFO_MODE_TITLE)
3699 DrawInfoScreen_TitleScreen();
3700 else if (info_mode == INFO_MODE_ELEMENTS)
3701 DrawInfoScreen_Elements();
3702 else if (info_mode == INFO_MODE_MUSIC)
3703 DrawInfoScreen_Music();
3704 else if (info_mode == INFO_MODE_CREDITS)
3705 DrawInfoScreen_Credits();
3706 else if (info_mode == INFO_MODE_PROGRAM)
3707 DrawInfoScreen_Program();
3708 else if (info_mode == INFO_MODE_VERSION)
3709 DrawInfoScreen_Version();
3710 else if (info_mode == INFO_MODE_LEVELSET)
3711 DrawInfoScreen_LevelSet();
3713 DrawInfoScreen_Main();
3715 if (info_mode != INFO_MODE_MAIN &&
3716 info_mode != INFO_MODE_TITLE &&
3717 info_mode != INFO_MODE_MUSIC)
3718 PlayMenuSoundsAndMusic();
3721 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3723 if (info_mode == INFO_MODE_TITLE)
3724 HandleInfoScreen_TitleScreen(button);
3725 else if (info_mode == INFO_MODE_ELEMENTS)
3726 HandleInfoScreen_Elements(button);
3727 else if (info_mode == INFO_MODE_MUSIC)
3728 HandleInfoScreen_Music(button);
3729 else if (info_mode == INFO_MODE_CREDITS)
3730 HandleInfoScreen_Credits(button);
3731 else if (info_mode == INFO_MODE_PROGRAM)
3732 HandleInfoScreen_Program(button);
3733 else if (info_mode == INFO_MODE_VERSION)
3734 HandleInfoScreen_Version(button);
3735 else if (info_mode == INFO_MODE_LEVELSET)
3736 HandleInfoScreen_LevelSet(button);
3738 HandleInfoScreen_Main(mx, my, dx, dy, button);
3742 /* ========================================================================= */
3743 /* type name functions */
3744 /* ========================================================================= */
3746 void HandleTypeName(int newxpos, Key key)
3748 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3749 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3750 struct TextPosInfo *pos = mci->pos_input;
3751 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3752 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3753 static int xpos = 0;
3754 int font_nr = pos->font;
3755 int font_active_nr = FONT_ACTIVE(font_nr);
3756 int font_width = getFontWidth(font_active_nr);
3757 char key_char = getValidConfigValueChar(getCharFromKey(key));
3758 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3759 boolean is_active = TRUE;
3761 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3765 strcpy(last_player_name, setup.player_name);
3769 StartTextInput(startx, starty, pos->width, pos->height);
3771 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3773 setup.player_name[xpos] = key_char;
3774 setup.player_name[xpos + 1] = 0;
3778 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3782 setup.player_name[xpos] = 0;
3784 else if (key == KSYM_Return && xpos > 0)
3790 SetGameStatus(GAME_MODE_MAIN);
3792 else if (key == KSYM_Escape)
3794 strcpy(setup.player_name, last_player_name);
3798 SetGameStatus(GAME_MODE_MAIN);
3803 pos->width = (strlen(setup.player_name) + 1) * font_width;
3804 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3806 DrawText(startx, starty, setup.player_name, font_active_nr);
3807 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3811 pos->width = strlen(setup.player_name) * font_width;
3812 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3814 DrawText(startx, starty, setup.player_name, font_nr);
3821 /* ========================================================================= */
3822 /* tree menu functions */
3823 /* ========================================================================= */
3825 static void DrawChooseTree(TreeInfo **ti_ptr)
3827 int fade_mask = REDRAW_FIELD;
3829 if (CheckIfGlobalBorderHasChanged())
3830 fade_mask = REDRAW_ALL;
3832 if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY))
3834 SetGameStatus(GAME_MODE_MAIN);
3843 FreeScreenGadgets();
3844 CreateScreenGadgets();
3848 /* needed if different viewport properties defined for choosing level (set) */
3849 ChangeViewportPropertiesIfNeeded();
3851 if (game_status == GAME_MODE_LEVELNR)
3852 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3853 else if (game_status == GAME_MODE_LEVELS)
3854 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3858 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
3860 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3861 MapScreenTreeGadgets(*ti_ptr);
3863 DrawMaskedBorder(fade_mask);
3868 static void drawChooseTreeList(int first_entry, int num_page_entries,
3872 char *title_string = NULL;
3873 int yoffset_sets = MENU_TITLE1_YPOS;
3874 int yoffset_setup = 16;
3875 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3876 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3878 title_string = ti->infotext;
3880 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3882 clearMenuListArea();
3884 for (i = 0; i < num_page_entries; i++)
3886 TreeInfo *node, *node_first;
3887 int entry_pos = first_entry + i;
3888 int xpos = MENU_SCREEN_START_XPOS;
3889 int ypos = MENU_SCREEN_START_YPOS + i;
3890 int startx = mSX + xpos * 32;
3891 int starty = mSY + ypos * 32;
3892 int font_nr = FONT_TEXT_1;
3893 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3894 int startx_text = startx + font_xoffset;
3895 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3896 int text_size = startx_scrollbar - startx_text;
3897 int max_buffer_len = text_size / getFontWidth(font_nr);
3898 char buffer[max_buffer_len + 1];
3900 node_first = getTreeInfoFirstGroupEntry(ti);
3901 node = getTreeInfoFromPos(node_first, entry_pos);
3903 strncpy(buffer, node->name, max_buffer_len);
3904 buffer[max_buffer_len] = '\0';
3906 DrawText(startx, starty, buffer, font_nr + node->color);
3908 if (node->parent_link)
3909 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3910 else if (node->level_group)
3911 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3913 initCursor(i, IMG_MENU_BUTTON);
3916 redraw_mask |= REDRAW_FIELD;
3919 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3921 TreeInfo *node, *node_first;
3922 int x, last_redraw_mask = redraw_mask;
3923 int ypos = MENU_TITLE2_YPOS;
3924 int font_nr = FONT_TITLE_2;
3926 if (ti->type == TREE_TYPE_LEVEL_NR)
3927 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3929 if (ti->type != TREE_TYPE_LEVEL_DIR)
3932 node_first = getTreeInfoFirstGroupEntry(ti);
3933 node = getTreeInfoFromPos(node_first, entry_pos);
3935 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3937 if (node->parent_link)
3938 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3939 node->node_parent->name);
3940 else if (node->level_group)
3941 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3943 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3944 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3945 node->levels, (node->levels > 1 ? "levels" : "level"),
3948 /* let BackToFront() redraw only what is needed */
3949 redraw_mask = last_redraw_mask;
3950 for (x = 0; x < SCR_FIELDX; x++)
3951 MarkTileDirty(x, 1);
3954 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3957 TreeInfo *ti = *ti_ptr;
3959 int y = ti->cl_cursor;
3960 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3961 int num_entries = numTreeInfoInGroup(ti);
3962 int num_page_entries;
3963 boolean position_set_by_scrollbar = (dx == 999);
3965 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3966 num_page_entries = num_entries;
3968 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3970 if (button == MB_MENU_INITIALIZE)
3972 int num_entries = numTreeInfoInGroup(ti);
3973 int entry_pos = posTreeInfo(ti);
3975 if (ti->cl_first == -1)
3977 /* only on initialization */
3978 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3979 ti->cl_cursor = entry_pos - ti->cl_first;
3981 else if (ti->cl_cursor >= num_page_entries ||
3982 (num_entries > num_page_entries &&
3983 num_entries - ti->cl_first < num_page_entries))
3985 /* only after change of list size (by custom graphic configuration) */
3986 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3987 ti->cl_cursor = entry_pos - ti->cl_first;
3990 if (position_set_by_scrollbar)
3993 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3996 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3997 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3998 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4002 else if (button == MB_MENU_LEAVE)
4006 PlaySound(SND_MENU_ITEM_SELECTING);
4008 if (ti->node_parent)
4010 *ti_ptr = ti->node_parent;
4011 DrawChooseTree(ti_ptr);
4013 else if (game_status == GAME_MODE_SETUP)
4015 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4016 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
4017 setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
4019 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4020 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
4021 setup_mode == SETUP_MODE_CHOOSE_RENDERING)
4022 execSetupGraphics();
4023 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4024 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4025 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4027 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4028 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4029 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4036 if (game_status == GAME_MODE_LEVELNR)
4038 int new_level_nr = atoi(level_number_current->identifier);
4040 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
4043 SetGameStatus(GAME_MODE_MAIN);
4051 if (mx || my) /* mouse input */
4053 x = (mx - mSX) / 32;
4054 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
4056 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
4058 /* move cursor instead of scrolling when already at start/end of list */
4059 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
4061 else if (dy == +1 * SCROLL_LINE &&
4062 ti->cl_first + num_page_entries == num_entries)
4065 /* handle scrolling screen one line or page */
4066 if (ti->cl_cursor + dy < 0 ||
4067 ti->cl_cursor + dy > num_page_entries - 1)
4069 boolean redraw = FALSE;
4071 if (ABS(dy) == SCROLL_PAGE)
4072 step = num_page_entries - 1;
4074 if (dy < 0 && ti->cl_first > 0)
4076 /* scroll page/line up */
4078 ti->cl_first -= step;
4079 if (ti->cl_first < 0)
4084 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
4086 /* scroll page/line down */
4088 ti->cl_first += step;
4089 if (ti->cl_first + num_page_entries > num_entries)
4090 ti->cl_first = MAX(0, num_entries - num_page_entries);
4097 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
4098 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
4099 drawChooseTreeCursor(ti->cl_cursor, TRUE);
4101 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
4108 /* handle moving cursor one line */
4109 y = ti->cl_cursor + dy;
4114 TreeInfo *node_first, *node_cursor;
4115 int entry_pos = ti->cl_first + y;
4117 node_first = getTreeInfoFirstGroupEntry(ti);
4118 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4120 if (node_cursor->node_group)
4124 PlaySound(SND_MENU_ITEM_SELECTING);
4126 node_cursor->cl_first = ti->cl_first;
4127 node_cursor->cl_cursor = ti->cl_cursor;
4128 *ti_ptr = node_cursor->node_group;
4129 DrawChooseTree(ti_ptr);
4134 else if (dx == -1 && ti->node_parent)
4138 PlaySound(SND_MENU_ITEM_SELECTING);
4140 *ti_ptr = ti->node_parent;
4141 DrawChooseTree(ti_ptr);
4146 if (!anyScrollbarGadgetActive() &&
4147 IN_VIS_MENU(x, y) &&
4148 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
4149 y >= 0 && y < num_page_entries)
4153 if (y != ti->cl_cursor)
4155 PlaySound(SND_MENU_ITEM_ACTIVATING);
4157 drawChooseTreeCursor(ti->cl_cursor, FALSE);
4158 drawChooseTreeCursor(y, TRUE);
4159 drawChooseTreeInfo(ti->cl_first + y, ti);
4165 if (game_status == GAME_MODE_SETUP)
4167 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4168 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
4169 setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
4171 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4172 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
4173 setup_mode == SETUP_MODE_CHOOSE_RENDERING)
4174 execSetupGraphics();
4175 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4176 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4177 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4179 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4180 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4181 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4190 TreeInfo *node_first, *node_cursor;
4191 int entry_pos = ti->cl_first + y;
4193 PlaySound(SND_MENU_ITEM_SELECTING);
4195 node_first = getTreeInfoFirstGroupEntry(ti);
4196 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
4198 if (node_cursor->node_group)
4202 node_cursor->cl_first = ti->cl_first;
4203 node_cursor->cl_cursor = ti->cl_cursor;
4204 *ti_ptr = node_cursor->node_group;
4205 DrawChooseTree(ti_ptr);
4207 else if (node_cursor->parent_link)
4211 *ti_ptr = node_cursor->node_parent;
4212 DrawChooseTree(ti_ptr);
4218 node_cursor->cl_first = ti->cl_first;
4219 node_cursor->cl_cursor = ti->cl_cursor;
4220 *ti_ptr = node_cursor;
4222 if (ti->type == TREE_TYPE_LEVEL_DIR)
4224 LoadLevelSetup_SeriesInfo();
4226 SaveLevelSetup_LastSeries();
4227 SaveLevelSetup_SeriesInfo();
4231 if (game_status == GAME_MODE_SETUP)
4233 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4234 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
4235 setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
4237 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4238 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
4239 setup_mode == SETUP_MODE_CHOOSE_RENDERING)
4240 execSetupGraphics();
4241 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4242 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4243 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4245 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4246 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4247 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4254 if (game_status == GAME_MODE_LEVELNR)
4256 int new_level_nr = atoi(level_number_current->identifier);
4258 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
4261 SetGameStatus(GAME_MODE_MAIN);
4270 void DrawChooseLevelSet()
4272 FadeMenuSoundsAndMusic();
4274 DrawChooseTree(&leveldir_current);
4276 PlayMenuSoundsAndMusic();
4279 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
4281 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4284 void DrawChooseLevelNr()
4288 FadeMenuSoundsAndMusic();
4290 if (level_number != NULL)
4292 freeTreeInfo(level_number);
4294 level_number = NULL;
4297 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
4299 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
4300 char identifier[32], name[32];
4303 /* temporarily load level info to get level name */
4304 LoadLevelInfoOnly(i);
4306 ti->node_top = &level_number;
4307 ti->sort_priority = 10000 + value;
4308 ti->color = (level.no_level_file ? FC_BLUE :
4309 LevelStats_getSolved(i) ? FC_GREEN :
4310 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
4312 snprintf(identifier, sizeof(identifier), "%d", value);
4313 snprintf(name, sizeof(name), "%03d: %s", value,
4314 (level.no_level_file ? "(no file)" : level.name));
4316 setString(&ti->identifier, identifier);
4317 setString(&ti->name, name);
4318 setString(&ti->name_sorting, name);
4320 pushTreeInfo(&level_number, ti);
4323 /* sort level number values to start with lowest level number */
4324 sortTreeInfo(&level_number);
4326 /* set current level number to current level number */
4327 level_number_current =
4328 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
4330 /* if that also fails, set current level number to first available level */
4331 if (level_number_current == NULL)
4332 level_number_current = level_number;
4334 DrawChooseTree(&level_number_current);
4336 PlayMenuSoundsAndMusic();
4339 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
4341 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
4344 void DrawHallOfFame(int highlight_position)
4346 int fade_mask = REDRAW_FIELD;
4348 if (CheckIfGlobalBorderHasChanged())
4349 fade_mask = REDRAW_ALL;
4352 FadeMenuSoundsAndMusic();
4354 /* (this is needed when called from GameEnd() after winning a game) */
4355 KeyboardAutoRepeatOn();
4357 /* (this is needed when called from GameEnd() after winning a game) */
4358 SetDrawDeactivationMask(REDRAW_NONE);
4359 SetDrawBackgroundMask(REDRAW_FIELD);
4361 if (highlight_position < 0)
4362 LoadScore(level_nr);
4364 SetAnimStatus(GAME_MODE_PSEUDO_SCORESNEW);
4366 FadeSetEnterScreen();
4370 /* needed if different viewport properties defined for scores */
4371 ChangeViewportPropertiesIfNeeded();
4373 PlayMenuSoundsAndMusic();
4375 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
4377 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4379 DrawMaskedBorder(fade_mask);
4384 static void drawHallOfFameList(int first_entry, int highlight_position)
4388 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4391 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4392 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4393 "HighScores of Level %d", level_nr);
4395 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4397 int entry = first_entry + i;
4398 boolean active = (entry == highlight_position);
4399 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4400 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4401 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4402 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4403 int dxoff = getFontDrawOffsetX(font_nr1);
4404 int dx1 = 3 * getFontWidth(font_nr1);
4405 int dx2 = dx1 + getFontWidth(font_nr1);
4406 int dx3 = SXSIZE - 2 * (mSX - SX + dxoff) - 5 * getFontWidth(font_nr4);
4407 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
4408 int sy = mSY + 64 + i * 32;
4410 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4411 DrawText(mSX + dx1, sy, ".", font_nr1);
4413 for (j = 0; j < num_dots; j++)
4414 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
4416 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4417 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4419 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4422 redraw_mask |= REDRAW_FIELD;
4425 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4427 static int first_entry = 0;
4428 static int highlight_position = 0;
4429 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4431 if (button == MB_MENU_INITIALIZE)
4434 highlight_position = mx;
4435 drawHallOfFameList(first_entry, highlight_position);
4440 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4441 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4445 if (first_entry > 0)
4447 first_entry -= step;
4448 if (first_entry < 0)
4451 drawHallOfFameList(first_entry, highlight_position);
4456 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4458 first_entry += step;
4459 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4460 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4462 drawHallOfFameList(first_entry, highlight_position);
4465 else if (button == MB_MENU_LEAVE)
4467 PlaySound(SND_MENU_ITEM_SELECTING);
4469 FadeSound(SND_BACKGROUND_SCORES);
4471 SetGameStatus(GAME_MODE_MAIN);
4475 else if (button == MB_MENU_CHOICE)
4477 PlaySound(SND_MENU_ITEM_SELECTING);
4479 FadeSound(SND_BACKGROUND_SCORES);
4481 SetGameStatus(GAME_MODE_MAIN);
4486 if (game_status == GAME_MODE_SCORES)
4487 PlayMenuSoundIfLoop();
4491 /* ========================================================================= */
4492 /* setup screen functions */
4493 /* ========================================================================= */
4495 static struct TokenInfo *setup_info;
4496 static int num_setup_info; /* number of setup entries shown on screen */
4497 static int max_setup_info; /* total number of setup entries in list */
4499 static char *window_size_text;
4500 static char *scaling_type_text;
4501 static char *rendering_mode_text;
4502 static char *scroll_delay_text;
4503 static char *snapshot_mode_text;
4504 static char *game_speed_text;
4505 static char *graphics_set_name;
4506 static char *sounds_set_name;
4507 static char *music_set_name;
4508 static char *volume_simple_text;
4509 static char *volume_loops_text;
4510 static char *volume_music_text;
4511 static char *touch_controls_text;
4512 static char *move_distance_text;
4513 static char *drop_distance_text;
4515 static void execSetupMain()
4517 setup_mode = SETUP_MODE_MAIN;
4522 static void execSetupGame_setGameSpeeds()
4524 if (game_speeds == NULL)
4528 for (i = 0; game_speeds_list[i].value != -1; i++)
4530 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4531 char identifier[32], name[32];
4532 int value = game_speeds_list[i].value;
4533 char *text = game_speeds_list[i].text;
4535 ti->node_top = &game_speeds;
4536 ti->sort_priority = 10000 - value;
4538 sprintf(identifier, "%d", value);
4539 sprintf(name, "%s", text);
4541 setString(&ti->identifier, identifier);
4542 setString(&ti->name, name);
4543 setString(&ti->name_sorting, name);
4544 setString(&ti->infotext, "Game Speed");
4546 pushTreeInfo(&game_speeds, ti);
4549 /* sort game speed values to start with slowest game speed */
4550 sortTreeInfo(&game_speeds);
4552 /* set current game speed to configured game speed value */
4553 game_speed_current =
4554 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4556 /* if that fails, set current game speed to reliable default value */
4557 if (game_speed_current == NULL)
4558 game_speed_current =
4559 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4561 /* if that also fails, set current game speed to first available speed */
4562 if (game_speed_current == NULL)
4563 game_speed_current = game_speeds;
4566 setup.game_frame_delay = atoi(game_speed_current->identifier);
4568 /* needed for displaying game speed text instead of identifier */
4569 game_speed_text = game_speed_current->name;
4572 static void execSetupGame_setScrollDelays()
4574 if (scroll_delays == NULL)
4578 for (i = 0; scroll_delays_list[i].value != -1; i++)
4580 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4581 char identifier[32], name[32];
4582 int value = scroll_delays_list[i].value;
4583 char *text = scroll_delays_list[i].text;
4585 ti->node_top = &scroll_delays;
4586 ti->sort_priority = value;
4588 sprintf(identifier, "%d", value);
4589 sprintf(name, "%s", text);
4591 setString(&ti->identifier, identifier);
4592 setString(&ti->name, name);
4593 setString(&ti->name_sorting, name);
4594 setString(&ti->infotext, "Scroll Delay");
4596 pushTreeInfo(&scroll_delays, ti);
4599 /* sort scroll delay values to start with lowest scroll delay value */
4600 sortTreeInfo(&scroll_delays);
4602 /* set current scroll delay value to configured scroll delay value */
4603 scroll_delay_current =
4604 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4606 /* if that fails, set current scroll delay to reliable default value */
4607 if (scroll_delay_current == NULL)
4608 scroll_delay_current =
4609 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4611 /* if that also fails, set current scroll delay to first available value */
4612 if (scroll_delay_current == NULL)
4613 scroll_delay_current = scroll_delays;
4616 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4618 /* needed for displaying scroll delay text instead of identifier */
4619 scroll_delay_text = scroll_delay_current->name;
4622 static void execSetupGame_setSnapshotModes()
4624 if (snapshot_modes == NULL)
4628 for (i = 0; snapshot_modes_list[i].value != NULL; i++)
4630 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4631 char identifier[32], name[32];
4632 char *value = snapshot_modes_list[i].value;
4633 char *text = snapshot_modes_list[i].text;
4635 ti->node_top = &snapshot_modes;
4636 ti->sort_priority = i;
4638 sprintf(identifier, "%s", value);
4639 sprintf(name, "%s", text);
4641 setString(&ti->identifier, identifier);
4642 setString(&ti->name, name);
4643 setString(&ti->name_sorting, name);
4644 setString(&ti->infotext, "Snapshot Mode");
4646 pushTreeInfo(&snapshot_modes, ti);
4649 /* sort snapshot mode values to start with lowest snapshot mode value */
4650 sortTreeInfo(&snapshot_modes);
4652 /* set current snapshot mode value to configured snapshot mode value */
4653 snapshot_mode_current =
4654 getTreeInfoFromIdentifier(snapshot_modes, setup.engine_snapshot_mode);
4656 /* if that fails, set current snapshot mode to reliable default value */
4657 if (snapshot_mode_current == NULL)
4658 snapshot_mode_current =
4659 getTreeInfoFromIdentifier(snapshot_modes, STR_SNAPSHOT_MODE_DEFAULT);
4661 /* if that also fails, set current snapshot mode to first available value */
4662 if (snapshot_mode_current == NULL)
4663 snapshot_mode_current = snapshot_modes;
4666 setup.engine_snapshot_mode = snapshot_mode_current->identifier;
4668 /* needed for displaying snapshot mode text instead of identifier */
4669 snapshot_mode_text = snapshot_mode_current->name;
4672 static void execSetupGame()
4674 execSetupGame_setGameSpeeds();
4675 execSetupGame_setScrollDelays();
4676 execSetupGame_setSnapshotModes();
4678 setup_mode = SETUP_MODE_GAME;
4683 static void execSetupChooseGameSpeed()
4685 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4690 static void execSetupChooseScrollDelay()
4692 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4697 static void execSetupChooseSnapshotMode()
4699 setup_mode = SETUP_MODE_CHOOSE_SNAPSHOT_MODE;
4704 static void execSetupEditor()
4706 setup_mode = SETUP_MODE_EDITOR;
4711 static void execSetupGraphics_setWindowSizes(boolean update_list)
4713 if (window_sizes != NULL && update_list)
4715 freeTreeInfo(window_sizes);
4717 window_sizes = NULL;
4720 if (window_sizes == NULL)
4722 boolean current_window_size_found = FALSE;
4725 for (i = 0; window_sizes_list[i].value != -1; i++)
4727 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4728 char identifier[32], name[32];
4729 int value = window_sizes_list[i].value;
4730 char *text = window_sizes_list[i].text;
4732 ti->node_top = &window_sizes;
4733 ti->sort_priority = value;
4735 sprintf(identifier, "%d", value);
4736 sprintf(name, "%s", text);
4738 setString(&ti->identifier, identifier);
4739 setString(&ti->name, name);
4740 setString(&ti->name_sorting, name);
4741 setString(&ti->infotext, "Window Scaling");
4743 pushTreeInfo(&window_sizes, ti);
4745 if (value == setup.window_scaling_percent)
4746 current_window_size_found = TRUE;
4749 if (!current_window_size_found)
4751 // add entry for non-preset window scaling value
4753 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4754 char identifier[32], name[32];
4755 int value = setup.window_scaling_percent;
4757 ti->node_top = &window_sizes;
4758 ti->sort_priority = value;
4760 sprintf(identifier, "%d", value);
4761 sprintf(name, "%d %% (Current)", value);
4763 setString(&ti->identifier, identifier);
4764 setString(&ti->name, name);
4765 setString(&ti->name_sorting, name);
4766 setString(&ti->infotext, "Window Scaling");
4768 pushTreeInfo(&window_sizes, ti);
4771 /* sort window size values to start with lowest window size value */
4772 sortTreeInfo(&window_sizes);
4774 /* set current window size value to configured window size value */
4775 window_size_current =
4776 getTreeInfoFromIdentifier(window_sizes,
4777 i_to_a(setup.window_scaling_percent));
4779 /* if that fails, set current window size to reliable default value */
4780 if (window_size_current == NULL)
4781 window_size_current =
4782 getTreeInfoFromIdentifier(window_sizes,
4783 i_to_a(STD_WINDOW_SCALING_PERCENT));
4785 /* if that also fails, set current window size to first available value */
4786 if (window_size_current == NULL)
4787 window_size_current = window_sizes;
4790 setup.window_scaling_percent = atoi(window_size_current->identifier);
4792 /* needed for displaying window size text instead of identifier */
4793 window_size_text = window_size_current->name;
4796 static void execSetupGraphics_setScalingTypes()
4798 if (scaling_types == NULL)
4802 for (i = 0; scaling_types_list[i].value != NULL; i++)
4804 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4805 char identifier[32], name[32];
4806 char *value = scaling_types_list[i].value;
4807 char *text = scaling_types_list[i].text;
4809 ti->node_top = &scaling_types;
4810 ti->sort_priority = i;
4812 sprintf(identifier, "%s", value);
4813 sprintf(name, "%s", text);
4815 setString(&ti->identifier, identifier);
4816 setString(&ti->name, name);
4817 setString(&ti->name_sorting, name);
4818 setString(&ti->infotext, "Anti-Aliasing");
4820 pushTreeInfo(&scaling_types, ti);
4823 /* sort scaling type values to start with lowest scaling type value */
4824 sortTreeInfo(&scaling_types);
4826 /* set current scaling type value to configured scaling type value */
4827 scaling_type_current =
4828 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4830 /* if that fails, set current scaling type to reliable default value */
4831 if (scaling_type_current == NULL)
4832 scaling_type_current =
4833 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4835 /* if that also fails, set current scaling type to first available value */
4836 if (scaling_type_current == NULL)
4837 scaling_type_current = scaling_types;
4840 setup.window_scaling_quality = scaling_type_current->identifier;
4842 /* needed for displaying scaling type text instead of identifier */
4843 scaling_type_text = scaling_type_current->name;
4846 static void execSetupGraphics_setRenderingModes()
4848 if (rendering_modes == NULL)
4852 for (i = 0; rendering_modes_list[i].value != NULL; i++)
4854 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4855 char identifier[32], name[32];
4856 char *value = rendering_modes_list[i].value;
4857 char *text = rendering_modes_list[i].text;
4859 ti->node_top = &rendering_modes;
4860 ti->sort_priority = i;
4862 sprintf(identifier, "%s", value);
4863 sprintf(name, "%s", text);
4865 setString(&ti->identifier, identifier);
4866 setString(&ti->name, name);
4867 setString(&ti->name_sorting, name);
4868 setString(&ti->infotext, "Special Rendering");
4870 pushTreeInfo(&rendering_modes, ti);
4873 /* sort rendering mode values to start with lowest rendering mode value */
4874 sortTreeInfo(&rendering_modes);
4876 /* set current rendering mode value to configured rendering mode value */
4877 rendering_mode_current =
4878 getTreeInfoFromIdentifier(rendering_modes, setup.screen_rendering_mode);
4880 /* if that fails, set current rendering mode to reliable default value */
4881 if (rendering_mode_current == NULL)
4882 rendering_mode_current =
4883 getTreeInfoFromIdentifier(rendering_modes,
4884 STR_SPECIAL_RENDERING_DEFAULT);
4886 /* if that also fails, set current rendering mode to first available one */
4887 if (rendering_mode_current == NULL)
4888 rendering_mode_current = rendering_modes;
4891 setup.screen_rendering_mode = rendering_mode_current->identifier;
4893 /* needed for displaying rendering mode text instead of identifier */
4894 rendering_mode_text = rendering_mode_current->name;
4897 static void execSetupGraphics()
4899 // update "setup.window_scaling_percent" from list selection
4900 // (in this case, window scaling was changed on setup screen)
4901 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4902 execSetupGraphics_setWindowSizes(FALSE);
4904 // update list selection from "setup.window_scaling_percent"
4905 // (window scaling may have changed by resizing the window)
4906 execSetupGraphics_setWindowSizes(TRUE);
4908 execSetupGraphics_setScalingTypes();
4909 execSetupGraphics_setRenderingModes();
4911 setup_mode = SETUP_MODE_GRAPHICS;
4915 #if defined(TARGET_SDL2)
4916 // window scaling may have changed at this point
4917 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4919 // window scaling quality may have changed at this point
4920 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4921 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4923 // screen rendering mode may have changed at this point
4924 SDLSetScreenRenderingMode(setup.screen_rendering_mode);
4928 #if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
4929 static void execSetupChooseWindowSize()
4931 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4936 static void execSetupChooseScalingType()
4938 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4943 static void execSetupChooseRenderingMode()
4945 setup_mode = SETUP_MODE_CHOOSE_RENDERING;
4951 static void execSetupChooseVolumeSimple()
4953 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4958 static void execSetupChooseVolumeLoops()
4960 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4965 static void execSetupChooseVolumeMusic()
4967 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4972 static void execSetupSound()
4974 if (volumes_simple == NULL)
4976 boolean current_volume_simple_found = FALSE;
4979 for (i = 0; volumes_list[i].value != -1; i++)
4981 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4982 char identifier[32], name[32];
4983 int value = volumes_list[i].value;
4984 char *text = volumes_list[i].text;
4986 ti->node_top = &volumes_simple;
4987 ti->sort_priority = value;
4989 sprintf(identifier, "%d", value);
4990 sprintf(name, "%s", text);
4992 setString(&ti->identifier, identifier);
4993 setString(&ti->name, name);
4994 setString(&ti->name_sorting, name);
4995 setString(&ti->infotext, "Sound Volume");
4997 pushTreeInfo(&volumes_simple, ti);
4999 if (value == setup.volume_simple)
5000 current_volume_simple_found = TRUE;
5003 if (!current_volume_simple_found)
5005 // add entry for non-preset volume value
5007 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5008 char identifier[32], name[32];
5009 int value = setup.volume_simple;
5011 ti->node_top = &volumes_simple;
5012 ti->sort_priority = value;
5014 sprintf(identifier, "%d", value);
5015 sprintf(name, "%d %% (Current)", value);
5017 setString(&ti->identifier, identifier);
5018 setString(&ti->name, name);
5019 setString(&ti->name_sorting, name);
5020 setString(&ti->infotext, "Sound Volume");
5022 pushTreeInfo(&volumes_simple, ti);
5025 /* sort volume values to start with lowest volume value */
5026 sortTreeInfo(&volumes_simple);
5028 /* set current volume value to configured volume value */
5029 volume_simple_current =
5030 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
5032 /* if that fails, set current volume to reliable default value */
5033 if (volume_simple_current == NULL)
5034 volume_simple_current =
5035 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
5037 /* if that also fails, set current volume to first available value */
5038 if (volume_simple_current == NULL)
5039 volume_simple_current = volumes_simple;
5042 if (volumes_loops == NULL)
5044 boolean current_volume_loops_found = FALSE;
5047 for (i = 0; volumes_list[i].value != -1; i++)
5049 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5050 char identifier[32], name[32];
5051 int value = volumes_list[i].value;
5052 char *text = volumes_list[i].text;
5054 ti->node_top = &volumes_loops;
5055 ti->sort_priority = value;
5057 sprintf(identifier, "%d", value);
5058 sprintf(name, "%s", text);
5060 setString(&ti->identifier, identifier);
5061 setString(&ti->name, name);
5062 setString(&ti->name_sorting, name);
5063 setString(&ti->infotext, "Loops Volume");
5065 pushTreeInfo(&volumes_loops, ti);
5067 if (value == setup.volume_loops)
5068 current_volume_loops_found = TRUE;
5071 if (!current_volume_loops_found)
5073 // add entry for non-preset volume value
5075 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5076 char identifier[32], name[32];
5077 int value = setup.volume_loops;
5079 ti->node_top = &volumes_loops;
5080 ti->sort_priority = value;
5082 sprintf(identifier, "%d", value);
5083 sprintf(name, "%d %% (Current)", value);
5085 setString(&ti->identifier, identifier);
5086 setString(&ti->name, name);
5087 setString(&ti->name_sorting, name);
5088 setString(&ti->infotext, "Loops Volume");
5090 pushTreeInfo(&volumes_loops, ti);
5093 /* sort volume values to start with lowest volume value */
5094 sortTreeInfo(&volumes_loops);
5096 /* set current volume value to configured volume value */
5097 volume_loops_current =
5098 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
5100 /* if that fails, set current volume to reliable default value */
5101 if (volume_loops_current == NULL)
5102 volume_loops_current =
5103 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
5105 /* if that also fails, set current volume to first available value */
5106 if (volume_loops_current == NULL)
5107 volume_loops_current = volumes_loops;
5110 if (volumes_music == NULL)
5112 boolean current_volume_music_found = FALSE;
5115 for (i = 0; volumes_list[i].value != -1; i++)
5117 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5118 char identifier[32], name[32];
5119 int value = volumes_list[i].value;
5120 char *text = volumes_list[i].text;
5122 ti->node_top = &volumes_music;
5123 ti->sort_priority = value;
5125 sprintf(identifier, "%d", value);
5126 sprintf(name, "%s", text);
5128 setString(&ti->identifier, identifier);
5129 setString(&ti->name, name);
5130 setString(&ti->name_sorting, name);
5131 setString(&ti->infotext, "Music Volume");
5133 pushTreeInfo(&volumes_music, ti);
5135 if (value == setup.volume_music)
5136 current_volume_music_found = TRUE;
5139 if (!current_volume_music_found)
5141 // add entry for non-preset volume value
5143 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5144 char identifier[32], name[32];
5145 int value = setup.volume_music;
5147 ti->node_top = &volumes_music;
5148 ti->sort_priority = value;
5150 sprintf(identifier, "%d", value);
5151 sprintf(name, "%d %% (Current)", value);
5153 setString(&ti->identifier, identifier);
5154 setString(&ti->name, name);
5155 setString(&ti->name_sorting, name);
5156 setString(&ti->infotext, "Music Volume");
5158 pushTreeInfo(&volumes_music, ti);
5161 /* sort volume values to start with lowest volume value */
5162 sortTreeInfo(&volumes_music);
5164 /* set current volume value to configured volume value */
5165 volume_music_current =
5166 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
5168 /* if that fails, set current volume to reliable default value */
5169 if (volume_music_current == NULL)
5170 volume_music_current =
5171 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
5173 /* if that also fails, set current volume to first available value */
5174 if (volume_music_current == NULL)
5175 volume_music_current = volumes_music;
5178 setup.volume_simple = atoi(volume_simple_current->identifier);
5179 setup.volume_loops = atoi(volume_loops_current->identifier);
5180 setup.volume_music = atoi(volume_music_current->identifier);
5182 /* needed for displaying volume text instead of identifier */
5183 volume_simple_text = volume_simple_current->name;
5184 volume_loops_text = volume_loops_current->name;
5185 volume_music_text = volume_music_current->name;
5187 setup_mode = SETUP_MODE_SOUND;
5192 static void execSetupChooseTouchControls()
5194 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
5199 static void execSetupChooseMoveDistance()
5201 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
5206 static void execSetupChooseDropDistance()
5208 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
5213 static void execSetupTouch()
5215 if (touch_controls == NULL)
5219 for (i = 0; touch_controls_list[i].value != NULL; i++)
5221 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5222 char identifier[32], name[32];
5223 char *value = touch_controls_list[i].value;
5224 char *text = touch_controls_list[i].text;
5226 ti->node_top = &touch_controls;
5227 ti->sort_priority = i;
5229 sprintf(identifier, "%s", value);
5230 sprintf(name, "%s", text);
5232 setString(&ti->identifier, identifier);
5233 setString(&ti->name, name);
5234 setString(&ti->name_sorting, name);
5235 setString(&ti->infotext, "Control Type");
5237 pushTreeInfo(&touch_controls, ti);
5240 /* sort touch control values to start with lowest touch control value */
5241 sortTreeInfo(&touch_controls);
5243 /* set current touch control value to configured touch control value */
5244 touch_control_current =
5245 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
5247 /* if that fails, set current touch control to reliable default value */
5248 if (touch_control_current == NULL)
5249 touch_control_current =
5250 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
5252 /* if that also fails, set current touch control to first available value */
5253 if (touch_control_current == NULL)
5254 touch_control_current = touch_controls;
5257 if (move_distances == NULL)
5261 for (i = 0; distances_list[i].value != -1; i++)
5263 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5264 char identifier[32], name[32];
5265 int value = distances_list[i].value;
5266 char *text = distances_list[i].text;
5268 ti->node_top = &move_distances;
5269 ti->sort_priority = value;
5271 sprintf(identifier, "%d", value);
5272 sprintf(name, "%s", text);
5274 setString(&ti->identifier, identifier);
5275 setString(&ti->name, name);
5276 setString(&ti->name_sorting, name);
5277 setString(&ti->infotext, "Move Distance");
5279 pushTreeInfo(&move_distances, ti);
5282 /* sort distance values to start with lowest distance value */
5283 sortTreeInfo(&move_distances);
5285 /* set current distance value to configured distance value */
5286 move_distance_current =
5287 getTreeInfoFromIdentifier(move_distances,
5288 i_to_a(setup.touch.move_distance));
5290 /* if that fails, set current distance to reliable default value */
5291 if (move_distance_current == NULL)
5292 move_distance_current =
5293 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
5295 /* if that also fails, set current distance to first available value */
5296 if (move_distance_current == NULL)
5297 move_distance_current = move_distances;
5300 if (drop_distances == NULL)
5304 for (i = 0; distances_list[i].value != -1; i++)
5306 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5307 char identifier[32], name[32];
5308 int value = distances_list[i].value;
5309 char *text = distances_list[i].text;
5311 ti->node_top = &drop_distances;
5312 ti->sort_priority = value;
5314 sprintf(identifier, "%d", value);
5315 sprintf(name, "%s", text);
5317 setString(&ti->identifier, identifier);
5318 setString(&ti->name, name);
5319 setString(&ti->name_sorting, name);
5320 setString(&ti->infotext, "Drop Distance");
5322 pushTreeInfo(&drop_distances, ti);
5325 /* sort distance values to start with lowest distance value */
5326 sortTreeInfo(&drop_distances);
5328 /* set current distance value to configured distance value */
5329 drop_distance_current =
5330 getTreeInfoFromIdentifier(drop_distances,
5331 i_to_a(setup.touch.drop_distance));
5333 /* if that fails, set current distance to reliable default value */
5334 if (drop_distance_current == NULL)
5335 drop_distance_current =
5336 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
5338 /* if that also fails, set current distance to first available value */
5339 if (drop_distance_current == NULL)
5340 drop_distance_current = drop_distances;
5343 setup.touch.control_type = touch_control_current->identifier;
5344 setup.touch.move_distance = atoi(move_distance_current->identifier);
5345 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
5347 /* needed for displaying volume text instead of identifier */
5348 touch_controls_text = touch_control_current->name;
5349 move_distance_text = move_distance_current->name;
5350 drop_distance_text = drop_distance_current->name;
5352 setup_mode = SETUP_MODE_TOUCH;
5357 static void execSetupArtwork()
5360 printf("::: '%s', '%s', '%s'\n",
5361 artwork.gfx_current->subdir,
5362 artwork.gfx_current->fullpath,
5363 artwork.gfx_current->basepath);
5366 setup.graphics_set = artwork.gfx_current->identifier;
5367 setup.sounds_set = artwork.snd_current->identifier;
5368 setup.music_set = artwork.mus_current->identifier;
5370 /* needed if last screen (setup choice) changed graphics, sounds or music */
5371 ReloadCustomArtwork(0);
5373 /* needed for displaying artwork name instead of artwork identifier */
5374 graphics_set_name = artwork.gfx_current->name;
5375 sounds_set_name = artwork.snd_current->name;
5376 music_set_name = artwork.mus_current->name;
5378 setup_mode = SETUP_MODE_ARTWORK;
5383 static void execSetupChooseGraphics()
5385 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
5390 static void execSetupChooseSounds()
5392 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
5397 static void execSetupChooseMusic()
5399 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
5404 static void execSetupInput()
5406 setup_mode = SETUP_MODE_INPUT;
5411 static void execSetupShortcuts()
5413 setup_mode = SETUP_MODE_SHORTCUTS;
5418 static void execSetupShortcuts1()
5420 setup_mode = SETUP_MODE_SHORTCUTS_1;
5425 static void execSetupShortcuts2()
5427 setup_mode = SETUP_MODE_SHORTCUTS_2;
5432 static void execSetupShortcuts3()
5434 setup_mode = SETUP_MODE_SHORTCUTS_3;
5439 static void execSetupShortcuts4()
5441 setup_mode = SETUP_MODE_SHORTCUTS_4;
5446 static void execSetupShortcuts5()
5448 setup_mode = SETUP_MODE_SHORTCUTS_5;
5453 static void execExitSetup()
5455 SetGameStatus(GAME_MODE_MAIN);
5460 static void execSaveAndExitSetup()
5466 static struct TokenInfo setup_info_main[] =
5468 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
5469 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
5470 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
5471 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
5472 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
5473 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
5474 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
5475 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
5476 { TYPE_EMPTY, NULL, "" },
5477 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
5478 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
5483 static struct TokenInfo setup_info_game[] =
5485 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
5486 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
5487 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
5488 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
5489 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
5490 { TYPE_SWITCH, &setup.increment_levels,"Increment Solved Levels:" },
5491 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
5492 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
5493 { TYPE_STRING, &game_speed_text, "" },
5495 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
5496 { TYPE_STRING, &scroll_delay_text, "" },
5498 { TYPE_ENTER_LIST, execSetupChooseSnapshotMode,"Game Engine Snapshot Mode:" },
5499 { TYPE_STRING, &snapshot_mode_text, "" },
5500 { TYPE_SWITCH, &setup.show_snapshot_buttons,"Show Snapshot Buttons:" },
5501 { TYPE_EMPTY, NULL, "" },
5502 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5507 static struct TokenInfo setup_info_editor[] =
5510 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
5511 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
5512 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
5513 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
5514 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
5515 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
5516 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
5517 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
5518 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
5519 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
5521 { TYPE_SWITCH, &setup.editor.el_classic, "Classic Elements:" },
5522 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
5524 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
5526 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
5527 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
5528 { TYPE_EMPTY, NULL, "" },
5530 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
5531 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
5532 { TYPE_EMPTY, NULL, "" },
5534 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
5535 { TYPE_EMPTY, NULL, "" },
5536 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5541 static struct TokenInfo setup_info_graphics[] =
5543 #if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
5544 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
5545 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
5546 { TYPE_STRING, &window_size_text, "" },
5547 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
5548 { TYPE_STRING, &scaling_type_text, "" },
5549 { TYPE_ENTER_LIST, execSetupChooseRenderingMode, "Special Rendering:" },
5550 { TYPE_STRING, &rendering_mode_text, "" },
5553 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
5554 { TYPE_STRING, &scroll_delay_text, "" },
5556 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
5557 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
5558 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
5559 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
5560 { TYPE_SWITCH, &setup.toons, "Show Menu Animations:" },
5561 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
5562 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
5563 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
5564 { TYPE_EMPTY, NULL, "" },
5565 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5570 static struct TokenInfo setup_info_sound[] =
5572 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
5573 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
5574 { TYPE_SWITCH, &setup.sound_music, "Music:" },
5575 { TYPE_EMPTY, NULL, "" },
5576 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
5577 { TYPE_STRING, &volume_simple_text, "" },
5578 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
5579 { TYPE_STRING, &volume_loops_text, "" },
5580 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
5581 { TYPE_STRING, &volume_music_text, "" },
5582 { TYPE_EMPTY, NULL, "" },
5583 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5588 static struct TokenInfo setup_info_artwork[] =
5590 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
5591 { TYPE_STRING, &graphics_set_name, "" },
5592 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
5593 { TYPE_STRING, &sounds_set_name, "" },
5594 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
5595 { TYPE_STRING, &music_set_name, "" },
5596 { TYPE_EMPTY, NULL, "" },
5597 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
5598 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
5599 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
5600 { TYPE_EMPTY, NULL, "" },
5601 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5606 static struct TokenInfo setup_info_input[] =
5608 { TYPE_SWITCH, NULL, "Player:" },
5609 { TYPE_SWITCH, NULL, "Device:" },
5610 { TYPE_SWITCH, NULL, "" },
5611 { TYPE_EMPTY, NULL, "" },
5612 { TYPE_EMPTY, NULL, "" },
5613 { TYPE_EMPTY, NULL, "" },
5614 { TYPE_EMPTY, NULL, "" },
5615 { TYPE_EMPTY, NULL, "" },
5616 { TYPE_EMPTY, NULL, "" },
5617 { TYPE_EMPTY, NULL, "" },
5618 { TYPE_EMPTY, NULL, "" },
5619 { TYPE_EMPTY, NULL, "" },
5620 { TYPE_EMPTY, NULL, "" },
5621 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5626 static struct TokenInfo setup_info_touch[] =
5628 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
5629 { TYPE_STRING, &touch_controls_text, "" },
5630 { TYPE_EMPTY, NULL, "" },
5631 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5636 static struct TokenInfo setup_info_touch_wipe_gestures[] =
5638 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
5639 { TYPE_STRING, &touch_controls_text, "" },
5640 { TYPE_EMPTY, NULL, "" },
5641 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
5642 { TYPE_STRING, &move_distance_text, "" },
5643 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
5644 { TYPE_STRING, &drop_distance_text, "" },
5645 { TYPE_EMPTY, NULL, "" },
5646 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5651 static struct TokenInfo setup_info_shortcuts[] =
5653 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
5654 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
5655 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
5656 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
5657 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
5658 { TYPE_EMPTY, NULL, "" },
5659 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5664 static struct TokenInfo setup_info_shortcuts_1[] =
5666 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
5667 { TYPE_KEY, &setup.shortcut.save_game, "" },
5668 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
5669 { TYPE_KEY, &setup.shortcut.load_game, "" },
5670 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
5671 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
5672 { TYPE_EMPTY, NULL, "" },
5673 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
5674 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
5675 { TYPE_EMPTY, NULL, "" },
5676 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5681 static struct TokenInfo setup_info_shortcuts_2[] =
5683 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
5684 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
5685 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
5686 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
5687 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
5688 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
5689 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
5690 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
5691 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
5692 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
5693 { TYPE_EMPTY, NULL, "" },
5694 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5699 static struct TokenInfo setup_info_shortcuts_3[] =
5701 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
5702 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
5703 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
5704 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
5705 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
5706 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
5707 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
5708 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
5709 { TYPE_KEYTEXT, NULL, "Record Tape:", },
5710 { TYPE_KEY, &setup.shortcut.tape_record, "" },
5711 { TYPE_KEYTEXT, NULL, "Play Tape:", },
5712 { TYPE_KEY, &setup.shortcut.tape_play, "" },
5713 { TYPE_EMPTY, NULL, "" },
5714 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5719 static struct TokenInfo setup_info_shortcuts_4[] =
5721 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
5722 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
5723 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
5724 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
5725 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
5726 { TYPE_KEY, &setup.shortcut.sound_music, "" },
5727 { TYPE_EMPTY, NULL, "" },
5728 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5733 static struct TokenInfo setup_info_shortcuts_5[] =
5735 { TYPE_KEYTEXT, NULL, "Snap Left:", },
5736 { TYPE_KEY, &setup.shortcut.snap_left, "" },
5737 { TYPE_KEYTEXT, NULL, "Snap Right:", },
5738 { TYPE_KEY, &setup.shortcut.snap_right, "" },
5739 { TYPE_KEYTEXT, NULL, "Snap Up:", },
5740 { TYPE_KEY, &setup.shortcut.snap_up, "" },
5741 { TYPE_KEYTEXT, NULL, "Snap Down:", },
5742 { TYPE_KEY, &setup.shortcut.snap_down, "" },
5743 { TYPE_EMPTY, NULL, "" },
5744 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5749 static Key getSetupKey()
5751 Key key = KSYM_UNDEFINED;
5752 boolean got_key_event = FALSE;
5754 while (!got_key_event)
5758 if (NextValidEvent(&event))
5762 case EVENT_KEYPRESS:
5764 key = GetEventKey((KeyEvent *)&event, TRUE);
5766 /* press 'Escape' or 'Enter' to keep the existing key binding */
5767 if (key == KSYM_Escape || key == KSYM_Return)
5768 key = KSYM_UNDEFINED; /* keep old value */
5770 got_key_event = TRUE;
5774 case EVENT_KEYRELEASE:
5775 key_joystick_mapping = 0;
5779 HandleOtherEvents(&event);
5790 static int getSetupValueFont(int type, void *value)
5792 if (type & TYPE_GHOSTED)
5793 return FONT_OPTION_OFF;
5794 else if (type & TYPE_KEY)
5795 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5796 else if (type & TYPE_STRING)
5797 return FONT_VALUE_2;
5798 else if (type & TYPE_ECS_AGA)
5799 return FONT_VALUE_1;
5800 else if (type & TYPE_BOOLEAN_STYLE)
5801 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5802 else if (type & TYPE_YES_NO_AUTO)
5803 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5804 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5806 return FONT_VALUE_1;
5809 static int getSetupValueFontNarrow(int type, int font_nr)
5811 return (font_nr == FONT_VALUE_1 ? FONT_VALUE_NARROW :
5812 font_nr == FONT_OPTION_ON ? FONT_OPTION_ON_NARROW :
5813 font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW :
5817 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5819 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5820 struct TokenInfo *si = &setup_info[si_pos];
5821 boolean font_draw_xoffset_modified = FALSE;
5822 boolean scrollbar_needed = (num_setup_info < max_setup_info);
5823 int font_draw_xoffset_old = -1;
5824 int xoffset = (scrollbar_needed ? -1 : 0);
5825 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5826 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5827 int xpos = menu_screen_value_xpos;
5828 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5829 int startx = mSX + xpos * 32;
5830 int starty = mSY + ypos * 32;
5831 int font_nr, font_nr_default, font_width_default;
5832 int type = si->type;
5833 void *value = si->value;
5834 char *value_string = getSetupValue(type, value);
5837 if (value_string == NULL)
5840 if (type & TYPE_KEY)
5842 xpos = MENU_SCREEN_START_XPOS;
5844 if (type & TYPE_QUERY)
5845 value_string = "<press key>";
5847 else if (type & TYPE_STRING)
5849 int max_value_len = (SCR_FIELDX - 2) * 2;
5851 xpos = MENU_SCREEN_START_XPOS;
5853 if (strlen(value_string) > max_value_len)
5854 value_string[max_value_len] = '\0';
5856 else if (type & TYPE_YES_NO_AUTO)
5858 xpos = menu_screen_value_xpos - 1;
5861 startx = mSX + xpos * 32;
5862 starty = mSY + ypos * 32;
5863 font_nr_default = getSetupValueFont(type, value);
5864 font_width_default = getFontWidth(font_nr_default);
5866 font_nr = font_nr_default;
5868 // special check if right-side setup values moved left due to scrollbar
5869 if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS)
5871 int max_menu_text_length = 26; // maximum text length for classic menu
5872 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5873 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5874 int text_font_nr = getMenuTextFont(FONT_MENU_2);
5875 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5876 int text_width = max_menu_text_length * getFontWidth(text_font_nr);
5878 if (startx + font_xoffset < text_startx + text_width + text_font_xoffset)
5881 startx = mSX + xpos * 32;
5883 font_nr = getSetupValueFontNarrow(type, font_nr);
5887 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5888 if (setup_mode != SETUP_MODE_INPUT)
5890 int max_menu_text_length_big = (menu_screen_value_xpos -
5891 MENU_SCREEN_START_XPOS);
5892 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5893 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5894 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5895 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5896 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5897 int text_font_nr = getMenuTextFont(FONT_MENU_2);
5898 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5899 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5900 boolean correct_font_draw_xoffset = FALSE;
5902 if (xpos == MENU_SCREEN_START_XPOS &&
5903 startx + font1_xoffset < text_startx + text_font_xoffset)
5904 correct_font_draw_xoffset = TRUE;
5906 if (xpos == menu_screen_value_xpos &&
5907 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5908 correct_font_draw_xoffset = TRUE;
5910 /* check if setup value would overlap with setup text when printed */
5911 /* (this can happen for extreme/wrong values for font draw offset) */
5912 if (correct_font_draw_xoffset)
5914 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5915 font_draw_xoffset_modified = TRUE;
5917 if (type & TYPE_KEY)
5918 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5919 else if (!(type & TYPE_STRING))
5920 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5921 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5925 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5926 DrawText(startx + i * font_width_default, starty, " ", font_nr_default);
5928 DrawText(startx, starty, value_string, font_nr);
5930 if (font_draw_xoffset_modified)
5931 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5934 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5936 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5937 struct TokenInfo *si = &setup_info[si_pos];
5939 if (si->type & TYPE_BOOLEAN_STYLE)
5941 *(boolean *)si->value ^= TRUE;
5943 else if (si->type & TYPE_YES_NO_AUTO)
5947 (*(int *)si->value == AUTO ? TRUE :
5948 *(int *)si->value == TRUE ? FALSE : AUTO) :
5949 (*(int *)si->value == TRUE ? AUTO :
5950 *(int *)si->value == AUTO ? FALSE : TRUE));
5952 else if (si->type & TYPE_KEY)
5956 si->type |= TYPE_QUERY;
5957 drawSetupValue(screen_pos, setup_info_pos_raw);
5958 si->type &= ~TYPE_QUERY;
5960 key = getSetupKey();
5961 if (key != KSYM_UNDEFINED)
5962 *(Key *)si->value = key;
5965 drawSetupValue(screen_pos, setup_info_pos_raw);
5967 // fullscreen state may have changed at this point
5968 if (si->value == &setup.fullscreen)
5969 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5972 static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig)
5974 static struct TokenInfo *setup_info_hide = NULL;
5979 /* determine maximum list size of target list */
5980 while (setup_info_orig[list_size++].type != 0);
5982 /* free, allocate and clear memory for target list */
5983 checked_free(setup_info_hide);
5984 setup_info_hide = checked_calloc(list_size * sizeof(struct TokenInfo));
5986 /* copy setup info list without setup entries marked as hidden */
5987 for (i = 0; setup_info_orig[i].type != 0; i++)
5988 if (!hideSetupEntry(setup_info_orig[i].value))
5989 setup_info_hide[list_pos++] = setup_info_orig[i];
5991 return setup_info_hide;
5994 static void DrawSetupScreen_Generic()
5996 int fade_mask = REDRAW_FIELD;
5997 boolean redraw_all = FALSE;
5998 char *title_string = NULL;
6001 if (CheckIfGlobalBorderHasChanged())
6002 fade_mask = REDRAW_ALL;
6005 FadeMenuSoundsAndMusic();
6007 FreeScreenGadgets();
6008 CreateScreenGadgets();
6010 if (redraw_mask & REDRAW_ALL)
6015 /* needed if different viewport properties defined for setup screen */
6016 ChangeViewportPropertiesIfNeeded();
6018 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6022 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
6024 if (setup_mode == SETUP_MODE_MAIN)
6026 setup_info = setup_info_main;
6027 title_string = "Setup";
6029 else if (setup_mode == SETUP_MODE_GAME)
6031 setup_info = setup_info_game;
6032 title_string = "Setup Game";
6034 else if (setup_mode == SETUP_MODE_EDITOR)
6036 setup_info = setup_info_editor;
6037 title_string = "Setup Editor";
6039 else if (setup_mode == SETUP_MODE_GRAPHICS)
6041 setup_info = setup_info_graphics;
6042 title_string = "Setup Graphics";
6044 else if (setup_mode == SETUP_MODE_SOUND)
6046 setup_info = setup_info_sound;
6047 title_string = "Setup Sound";
6049 else if (setup_mode == SETUP_MODE_ARTWORK)
6051 setup_info = setup_info_artwork;
6052 title_string = "Custom Artwork";
6054 else if (setup_mode == SETUP_MODE_TOUCH)
6056 setup_info = setup_info_touch;
6057 title_string = "Setup Touch Ctrls";
6059 if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
6060 setup_info = setup_info_touch_wipe_gestures;
6062 else if (setup_mode == SETUP_MODE_SHORTCUTS)
6064 setup_info = setup_info_shortcuts;
6065 title_string = "Setup Shortcuts";
6067 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
6069 setup_info = setup_info_shortcuts_1;
6070 title_string = "Setup Shortcuts";
6072 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
6074 setup_info = setup_info_shortcuts_2;
6075 title_string = "Setup Shortcuts";
6077 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
6079 setup_info = setup_info_shortcuts_3;
6080 title_string = "Setup Shortcuts";
6082 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
6084 setup_info = setup_info_shortcuts_4;
6085 title_string = "Setup Shortcuts";
6087 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
6089 setup_info = setup_info_shortcuts_5;
6090 title_string = "Setup Shortcuts";
6093 /* use modified setup info without setup entries marked as hidden */
6094 setup_info = getSetupInfoFinal(setup_info);
6096 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
6098 // determine maximal number of setup entries that can be displayed on screen
6100 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
6103 // determine maximal number of setup entries available for this setup screen
6105 for (i = 0; setup_info[i].type != 0; i++)
6108 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
6110 MapScreenGadgets(max_setup_info);
6113 redraw_mask = fade_mask = REDRAW_ALL;
6115 DrawMaskedBorder(fade_mask);
6120 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
6122 menu_info = setup_info;
6124 HandleMenuScreen(mx, my, dx, dy, button,
6125 setup_mode, num_setup_info, max_setup_info);
6128 void DrawSetupScreen_Input()
6132 FadeOut(REDRAW_FIELD);
6136 setup_info = setup_info_input;
6138 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
6140 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
6142 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
6143 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
6144 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
6145 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
6146 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
6147 initCursor(i, IMG_MENU_BUTTON);
6149 DrawCursorAndText_Setup(i, -1, FALSE);
6152 /* create gadgets for setup input menu screen */
6153 FreeScreenGadgets();
6154 CreateScreenGadgets();
6156 /* map gadgets for setup input menu screen */
6157 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
6159 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
6161 FadeIn(REDRAW_FIELD);
6164 static void setJoystickDeviceToNr(char *device_name, int device_nr)
6166 if (device_name == NULL)
6169 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
6172 if (strlen(device_name) > 1)
6174 char c1 = device_name[strlen(device_name) - 1];
6175 char c2 = device_name[strlen(device_name) - 2];
6177 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
6178 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
6181 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
6182 strlen(device_name));
6185 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
6188 static struct SetupKeyboardInfo custom_key;
6195 { &custom_key.left, "Axis/Pad Left" },
6196 { &custom_key.right, "Axis/Pad Right" },
6197 { &custom_key.up, "Axis/Pad Up" },
6198 { &custom_key.down, "Axis/Pad Down" },
6199 { &custom_key.snap, "Button 1/A/X" },
6200 { &custom_key.drop, "Button 2/B/Y" }
6202 static char *joystick_name[MAX_PLAYERS] =
6209 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
6211 custom_key = setup.input[player_nr].key;
6213 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
6214 FONT_INPUT_1_ACTIVE);
6216 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
6218 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
6219 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
6221 if (setup.input[player_nr].use_joystick)
6223 char *device_name = setup.input[player_nr].joy.device_name;
6224 int joystick_nr = getJoystickNrFromDeviceName(device_name);
6225 boolean joystick_active = CheckJoystickOpened(joystick_nr);
6226 char *text = joystick_name[joystick_nr];
6227 int font_nr = (joystick_active ? FONT_VALUE_1 : FONT_VALUE_OLD);
6229 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
6230 DrawText(mSX + 32, mSY + 4 * 32, "Configure", text_font_nr);
6234 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
6235 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
6238 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
6240 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
6241 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
6242 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
6243 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
6245 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
6246 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
6247 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
6248 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
6249 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
6250 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
6252 for (i = 0; i < 6; i++)
6254 int ypos = 6 + i + (i > 3 ? i-3 : 0);
6256 DrawText(mSX + 3 * 32, mSY + ypos * 32,
6258 DrawText(mSX + 3 * 32, mSY + ypos * 32,
6259 (setup.input[player_nr].use_joystick ?
6261 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
6265 static int input_player_nr = 0;
6267 void HandleSetupScreen_Input_Player(int step, int direction)
6269 int old_player_nr = input_player_nr;
6272 new_player_nr = old_player_nr + step * direction;
6273 if (new_player_nr < 0)
6275 if (new_player_nr > MAX_PLAYERS - 1)
6276 new_player_nr = MAX_PLAYERS - 1;
6278 if (new_player_nr != old_player_nr)
6280 input_player_nr = new_player_nr;
6282 drawPlayerSetupInputInfo(input_player_nr, FALSE);
6286 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
6288 static int choice = 0;
6291 int pos_start = SETUPINPUT_SCREEN_POS_START;
6292 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
6293 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
6294 int pos_end = SETUPINPUT_SCREEN_POS_END;
6296 if (button == MB_MENU_INITIALIZE)
6298 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
6300 DrawCursorAndText_Setup(choice, -1, TRUE);
6304 else if (button == MB_MENU_LEAVE)
6306 setup_mode = SETUP_MODE_MAIN;
6313 if (mx || my) /* mouse input */
6315 x = (mx - mSX) / 32;
6316 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
6318 else if (dx || dy) /* keyboard input */
6320 if (dx && choice == 0)
6321 x = (dx < 0 ? 10 : 12);
6322 else if ((dx && choice == 1) ||
6323 (dx == -1 && choice == pos_end))
6324 button = MB_MENU_CHOICE;
6328 if (y >= pos_empty1 && y <= pos_empty2)
6329 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
6332 if (y == 0 && dx != 0 && button)
6334 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
6336 else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
6337 y >= pos_start && y <= pos_end &&
6338 !(y >= pos_empty1 && y <= pos_empty2))
6344 DrawCursorAndText_Setup(choice, -1, FALSE);
6345 DrawCursorAndText_Setup(y, -1, TRUE);
6347 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
6356 char *device_name = setup.input[input_player_nr].joy.device_name;
6358 if (!setup.input[input_player_nr].use_joystick)
6360 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
6362 setJoystickDeviceToNr(device_name, new_device_nr);
6363 setup.input[input_player_nr].use_joystick = TRUE;
6367 int device_nr = getJoystickNrFromDeviceName(device_name);
6368 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
6370 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
6371 setup.input[input_player_nr].use_joystick = FALSE;
6373 setJoystickDeviceToNr(device_name, new_device_nr);
6376 drawPlayerSetupInputInfo(input_player_nr, FALSE);
6380 if (setup.input[input_player_nr].use_joystick)
6381 ConfigureJoystick(input_player_nr);
6383 CustomizeKeyboard(input_player_nr);
6385 else if (y == pos_end)
6391 setup_mode = SETUP_MODE_MAIN;
6398 void CustomizeKeyboard(int player_nr)
6402 boolean finished = FALSE;
6403 static struct SetupKeyboardInfo custom_key;
6408 } customize_step[] =
6410 { &custom_key.left, "Move Left" },
6411 { &custom_key.right, "Move Right" },
6412 { &custom_key.up, "Move Up" },
6413 { &custom_key.down, "Move Down" },
6414 { &custom_key.snap, "Snap Field" },
6415 { &custom_key.drop, "Drop Element" }
6418 /* read existing key bindings from player setup */
6419 custom_key = setup.input[player_nr].key;
6422 FadeOut(REDRAW_FIELD);
6426 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
6429 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6430 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6431 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6432 "Key:", FONT_INPUT_1_ACTIVE);
6433 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6434 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
6436 FadeIn(REDRAW_FIELD);
6442 if (NextValidEvent(&event))
6446 case EVENT_KEYPRESS:
6448 Key key = GetEventKey((KeyEvent *)&event, FALSE);
6450 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
6452 if (key == KSYM_Escape)
6453 FadeSkipNextFadeIn();
6459 /* all keys configured -- wait for "Escape" or "Return" key */
6463 /* press 'Enter' to keep the existing key binding */
6464 if (key == KSYM_Return)
6465 key = *customize_step[step_nr].key;
6467 /* check if key already used */
6468 for (i = 0; i < step_nr; i++)
6469 if (*customize_step[i].key == key)
6474 /* got new key binding */
6475 *customize_step[step_nr].key = key;
6476 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6478 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6479 getKeyNameFromKey(key), FONT_VALUE_1);
6482 /* un-highlight last query */
6483 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6484 customize_step[step_nr - 1].text, FONT_MENU_1);
6485 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6486 "Key:", FONT_MENU_1);
6488 /* press 'Enter' to leave */
6491 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6492 "Press Enter", FONT_TITLE_1);
6496 /* query next key binding */
6497 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6498 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6499 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6500 "Key:", FONT_INPUT_1_ACTIVE);
6501 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6502 getKeyNameFromKey(*customize_step[step_nr].key),
6507 case EVENT_KEYRELEASE:
6508 key_joystick_mapping = 0;
6512 HandleOtherEvents(&event);
6520 /* write new key bindings back to player setup */
6521 setup.input[player_nr].key = custom_key;
6523 DrawSetupScreen_Input();
6526 /* game controller mapping generator by Gabriel Jacobo <gabomdq@gmail.com> */
6528 #define MARKER_BUTTON 1
6529 #define MARKER_AXIS_X 2
6530 #define MARKER_AXIS_Y 3
6532 static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
6534 #if defined(TARGET_SDL2)
6535 static boolean bitmaps_initialized = FALSE;
6536 boolean screen_initialized = FALSE;
6537 static Bitmap *controller, *button, *axis_x, *axis_y;
6539 boolean success = TRUE;
6540 boolean done = FALSE, next = FALSE;
6542 int alpha = 200, alpha_step = -1;
6543 int alpha_ticks = 0;
6544 char mapping[4096], temp[4096];
6545 int font_name = MENU_SETUP_FONT_TITLE;
6546 int font_info = MENU_SETUP_FONT_TEXT;
6547 int spacing_name = menu.line_spacing_setup[SETUP_MODE_INPUT];
6548 int spacing_line = menu.line_spacing_setup[SETUP_MODE_INPUT];
6549 int spacing_para = menu.paragraph_spacing_setup[SETUP_MODE_INPUT];
6550 int ystep_name = getMenuTextStep(spacing_name, font_name);
6551 int ystep_line = getMenuTextStep(spacing_line, font_info);
6552 int ystep_para = getMenuTextStep(spacing_para, font_info);
6560 int axis, button, hat, hat_value;
6563 *step, *prev_step, steps[] =
6565 { 356, 155, MARKER_BUTTON, "a", },
6566 { 396, 122, MARKER_BUTTON, "b", },
6567 { 320, 125, MARKER_BUTTON, "x", },
6568 { 358, 95, MARKER_BUTTON, "y", },
6569 { 162, 125, MARKER_BUTTON, "back", },
6570 { 216, 125, MARKER_BUTTON, "guide", },
6571 { 271, 125, MARKER_BUTTON, "start", },
6572 { 110, 200, MARKER_BUTTON, "dpleft", },
6573 { 146, 228, MARKER_BUTTON, "dpdown", },
6574 { 178, 200, MARKER_BUTTON, "dpright", },
6575 { 146, 172, MARKER_BUTTON, "dpup", },
6576 { 50, 40, MARKER_BUTTON, "leftshoulder", },
6577 { 88, -10, MARKER_AXIS_Y, "lefttrigger", },
6578 { 382, 40, MARKER_BUTTON, "rightshoulder", },
6579 { 346, -10, MARKER_AXIS_Y, "righttrigger", },
6580 { 73, 141, MARKER_BUTTON, "leftstick", },
6581 { 282, 210, MARKER_BUTTON, "rightstick", },
6582 { 73, 141, MARKER_AXIS_X, "leftx", },
6583 { 73, 141, MARKER_AXIS_Y, "lefty", },
6584 { 282, 210, MARKER_AXIS_X, "rightx", },
6585 { 282, 210, MARKER_AXIS_Y, "righty", },
6588 unsigned int event_frame_delay = 0;
6589 unsigned int event_frame_delay_value = GAME_FRAME_DELAY;
6591 ResetDelayCounter(&event_frame_delay);
6593 if (!bitmaps_initialized)
6595 controller = LoadCustomImage("joystick/controller.png");
6596 button = LoadCustomImage("joystick/button.png");
6597 axis_x = LoadCustomImage("joystick/axis_x.png");
6598 axis_y = LoadCustomImage("joystick/axis_y.png");
6600 bitmaps_initialized = TRUE;
6603 name = getFormattedJoystickName(SDL_JoystickName(joystick));
6606 /* print info about the joystick we are watching */
6607 Error(ERR_DEBUG, "watching joystick %d: (%s)\n",
6608 SDL_JoystickInstanceID(joystick), name);
6609 Error(ERR_DEBUG, "joystick has %d axes, %d hats, %d balls, and %d buttons\n",
6610 SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
6611 SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
6614 /* initialize mapping with GUID and name */
6615 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), temp, sizeof(temp));
6617 snprintf(mapping, sizeof(mapping), "%s,%s,platform:%s,",
6618 temp, name, SDL_GetPlatform());
6620 /* loop through all steps (buttons and axes), getting joystick events */
6621 for (i = 0; i < SDL_arraysize(steps) && !done;)
6623 Bitmap *marker = button; /* initialize with reliable default value */
6626 strcpy(step->mapping, mapping);
6630 step->hat_value = -1;
6632 marker = (step->marker == MARKER_BUTTON ? button :
6633 step->marker == MARKER_AXIS_X ? axis_x :
6634 step->marker == MARKER_AXIS_Y ? axis_y : marker);
6638 while (!done && !next)
6640 alpha += alpha_step * (int)(SDL_GetTicks() - alpha_ticks) / 5;
6641 alpha_ticks = SDL_GetTicks();
6648 else if (alpha < 128)
6654 int controller_x = SX + (SXSIZE - controller->width) / 2;
6655 int controller_y = SY + ystep_line;
6657 int marker_x = controller_x + step->x;
6658 int marker_y = controller_y + step->y;
6660 int ystart1 = mSY - 2 * SY + controller_y + controller->height;
6661 int ystart2 = ystart1 + ystep_name + ystep_line;
6665 DrawTextSCentered(ystart1, font_name, name);
6667 DrawTextSCentered(ystart2, font_info,
6668 "Press buttons and move axes on");
6669 ystart2 += ystep_line;
6670 DrawTextSCentered(ystart2, font_info,
6671 "your controller when indicated.");
6672 ystart2 += ystep_line;
6673 DrawTextSCentered(ystart2, font_info,
6674 "(Your controller may look different.)");
6675 ystart2 += ystep_para;
6677 #if defined(PLATFORM_ANDROID)
6678 DrawTextSCentered(ystart2, font_info,
6679 "To correct a mistake,");
6680 ystart2 += ystep_line;
6681 DrawTextSCentered(ystart2, font_info,
6682 "press the 'back' button.");
6683 ystart2 += ystep_line;
6684 DrawTextSCentered(ystart2, font_info,
6685 "To skip a button or axis,");
6686 ystart2 += ystep_line;
6687 DrawTextSCentered(ystart2, font_info,
6688 "press the 'menu' button.");
6690 DrawTextSCentered(ystart2, font_info,
6691 "To correct a mistake,");
6692 ystart2 += ystep_line;
6693 DrawTextSCentered(ystart2, font_info,
6694 "press the 'backspace' key.");
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 'return' key.");
6701 ystart2 += ystep_line;
6702 DrawTextSCentered(ystart2, font_info,
6703 "To exit, press the 'escape' key.");
6706 BlitBitmapMasked(controller, drawto, 0, 0,
6707 controller->width, controller->height,
6708 controller_x, controller_y);
6710 SDL_SetSurfaceAlphaMod(marker->surface_masked, alpha);
6712 BlitBitmapMasked(marker, drawto, 0, 0,
6713 marker->width, marker->height,
6714 marker_x, marker_y);
6716 if (!screen_initialized)
6717 FadeIn(REDRAW_FIELD);
6721 screen_initialized = TRUE;
6723 while (NextValidEvent(&event))
6727 case SDL_JOYAXISMOTION:
6728 if (event.jaxis.value > 20000 ||
6729 event.jaxis.value < -20000)
6731 for (j = 0; j < i; j++)
6732 if (steps[j].axis == event.jaxis.axis)
6737 if (step->marker != MARKER_AXIS_X &&
6738 step->marker != MARKER_AXIS_Y)
6741 step->axis = event.jaxis.axis;
6742 strcat(mapping, step->field);
6743 snprintf(temp, sizeof(temp), ":a%u,", event.jaxis.axis);
6744 strcat(mapping, temp);
6752 case SDL_JOYHATMOTION:
6753 /* ignore centering; we're probably just coming back
6754 to the center from the previous item we set */
6755 if (event.jhat.value == SDL_HAT_CENTERED)
6758 for (j = 0; j < i; j++)
6759 if (steps[j].hat == event.jhat.hat &&
6760 steps[j].hat_value == event.jhat.value)
6765 step->hat = event.jhat.hat;
6766 step->hat_value = event.jhat.value;
6767 strcat(mapping, step->field);
6768 snprintf(temp, sizeof(temp), ":h%u.%u,",
6769 event.jhat.hat, event.jhat.value );
6770 strcat(mapping, temp);
6777 case SDL_JOYBALLMOTION:
6780 case SDL_JOYBUTTONUP:
6781 for (j = 0; j < i; j++)
6782 if (steps[j].button == event.jbutton.button)
6787 step->button = event.jbutton.button;
6788 strcat(mapping, step->field);
6789 snprintf(temp, sizeof(temp), ":b%u,", event.jbutton.button);
6790 strcat(mapping, temp);
6797 case SDL_FINGERDOWN:
6798 case SDL_MOUSEBUTTONDOWN:
6799 /* skip this step */
6806 if (event.key.keysym.sym == KSYM_BackSpace ||
6807 event.key.keysym.sym == KSYM_Back)
6816 /* undo this step */
6817 prev_step = &steps[i - 1];
6818 strcpy(mapping, prev_step->mapping);
6825 if (event.key.keysym.sym == KSYM_space ||
6826 event.key.keysym.sym == KSYM_Return ||
6827 event.key.keysym.sym == KSYM_Menu)
6829 /* skip this step */
6836 if (event.key.keysym.sym == KSYM_Escape)
6846 program.exit_function(0);
6853 // do not handle events for longer than standard frame delay period
6854 if (DelayReached(&event_frame_delay, event_frame_delay_value))
6863 Error(ERR_DEBUG, "New game controller mapping:\n\n%s\n\n", mapping);
6866 // activate mapping for this game
6867 SDL_GameControllerAddMapping(mapping);
6869 // save mapping to personal mappings
6870 SaveSetup_AddGameControllerMapping(mapping);
6873 /* wait until the last pending event was removed from event queue */
6874 while (NextValidEvent(&event));
6882 static int ConfigureJoystickMain(int player_nr)
6884 char *device_name = setup.input[player_nr].joy.device_name;
6885 int joystick_nr = getJoystickNrFromDeviceName(device_name);
6886 boolean joystick_active = CheckJoystickOpened(joystick_nr);
6887 int success = FALSE;
6890 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6891 return JOYSTICK_NOT_AVAILABLE;
6893 if (!joystick_active || !setup.input[player_nr].use_joystick)
6894 return JOYSTICK_NOT_AVAILABLE;
6897 FadeOut(REDRAW_FIELD);
6899 // close all joystick devices (potentially opened as game controllers)
6900 for (i = 0; i < SDL_NumJoysticks(); i++)
6901 SDLCloseJoystick(i);
6903 // open joystick device as plain joystick to configure as game controller
6904 SDL_Joystick *joystick = SDL_JoystickOpen(joystick_nr);
6906 // as the joystick was successfully opened before, this should not happen
6907 if (joystick == NULL)
6910 // create new game controller mapping (buttons and axes) for joystick device
6911 success = ConfigureJoystickMapButtonsAndAxes(joystick);
6913 // close joystick (and maybe re-open as configured game controller later)
6914 SDL_JoystickClose(joystick);
6916 // re-open all joystick devices (potentially as game controllers)
6917 for (i = 0; i < SDL_NumJoysticks(); i++)
6920 // clear all joystick input actions for all joystick devices
6921 SDLClearJoystickState();
6923 return (success ? JOYSTICK_CONFIGURED : JOYSTICK_NOT_CONFIGURED);
6926 void ConfigureJoystick(int player_nr)
6928 boolean state = ConfigureJoystickMain(player_nr);
6930 if (state != JOYSTICK_NOT_CONFIGURED)
6932 boolean success = (state == JOYSTICK_CONFIGURED);
6933 char *message = (success ? " IS CONFIGURED! " : " NOT AVAILABLE! ");
6934 char *device_name = setup.input[player_nr].joy.device_name;
6935 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6936 int xpos = mSX - SX;
6937 int ypos = mSY - SY;
6938 unsigned int wait_frame_delay = 0;
6939 unsigned int wait_frame_delay_value = 2000;
6941 ResetDelayCounter(&wait_frame_delay);
6945 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6946 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, message);
6948 while (!DelayReached(&wait_frame_delay, wait_frame_delay_value))
6954 DrawSetupScreen_Input();
6957 void DrawSetupScreen()
6959 if (setup_mode == SETUP_MODE_INPUT)
6960 DrawSetupScreen_Input();
6961 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6962 DrawChooseTree(&game_speed_current);
6963 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6964 DrawChooseTree(&scroll_delay_current);
6965 else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
6966 DrawChooseTree(&snapshot_mode_current);
6967 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6968 DrawChooseTree(&window_size_current);
6969 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6970 DrawChooseTree(&scaling_type_current);
6971 else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING)
6972 DrawChooseTree(&rendering_mode_current);
6973 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6974 DrawChooseTree(&artwork.gfx_current);
6975 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6976 DrawChooseTree(&artwork.snd_current);
6977 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6978 DrawChooseTree(&artwork.mus_current);
6979 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6980 DrawChooseTree(&volume_simple_current);
6981 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6982 DrawChooseTree(&volume_loops_current);
6983 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6984 DrawChooseTree(&volume_music_current);
6985 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6986 DrawChooseTree(&touch_control_current);
6987 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6988 DrawChooseTree(&move_distance_current);
6989 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6990 DrawChooseTree(&drop_distance_current);
6992 DrawSetupScreen_Generic();
6994 PlayMenuSoundsAndMusic();
6997 void RedrawSetupScreenAfterFullscreenToggle()
6999 if (setup_mode == SETUP_MODE_GRAPHICS ||
7000 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7002 // update list selection from "setup.window_scaling_percent"
7003 execSetupGraphics_setWindowSizes(TRUE);
7009 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
7011 if (setup_mode == SETUP_MODE_INPUT)
7012 HandleSetupScreen_Input(mx, my, dx, dy, button);
7013 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
7014 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
7015 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
7016 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
7017 else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
7018 HandleChooseTree(mx, my, dx, dy, button, &snapshot_mode_current);
7019 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7020 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
7021 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
7022 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
7023 else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING)
7024 HandleChooseTree(mx, my, dx, dy, button, &rendering_mode_current);
7025 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
7026 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
7027 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
7028 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
7029 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
7030 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
7031 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
7032 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
7033 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
7034 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
7035 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
7036 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
7037 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
7038 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
7039 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
7040 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
7041 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
7042 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
7044 HandleSetupScreen_Generic(mx, my, dx, dy, button);
7047 void HandleGameActions()
7049 if (game_status != GAME_MODE_PLAYING)
7052 GameActions(); /* main game loop */
7054 if (tape.auto_play && !tape.playing)
7055 AutoPlayTape(); /* continue automatically playing next tape */
7059 /* ---------- new screen button stuff -------------------------------------- */
7061 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
7065 case SCREEN_CTRL_ID_PREV_LEVEL:
7066 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
7067 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
7070 case SCREEN_CTRL_ID_NEXT_LEVEL:
7071 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
7072 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
7075 case SCREEN_CTRL_ID_PREV_PLAYER:
7076 *x = mSX + TILEX * 10;
7077 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
7080 case SCREEN_CTRL_ID_NEXT_PLAYER:
7081 *x = mSX + TILEX * 12;
7082 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
7086 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
7092 int gfx_unpressed, gfx_pressed;
7093 void (*get_gadget_position)(int *, int *, int);
7097 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
7100 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
7101 getScreenMenuButtonPos,
7102 SCREEN_CTRL_ID_PREV_LEVEL,
7107 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
7108 getScreenMenuButtonPos,
7109 SCREEN_CTRL_ID_NEXT_LEVEL,
7114 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
7115 getScreenMenuButtonPos,
7116 SCREEN_CTRL_ID_PREV_PLAYER,
7121 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
7122 getScreenMenuButtonPos,
7123 SCREEN_CTRL_ID_NEXT_PLAYER,
7131 int gfx_unpressed, gfx_pressed;
7135 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
7138 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
7139 -1, -1, /* these values are not constant, but can change at runtime */
7140 SCREEN_CTRL_ID_SCROLL_UP,
7144 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
7145 -1, -1, /* these values are not constant, but can change at runtime */
7146 SCREEN_CTRL_ID_SCROLL_DOWN,
7153 int gfx_unpressed, gfx_pressed;
7159 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
7162 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
7163 -1, -1, /* these values are not constant, but can change at runtime */
7164 -1, -1, /* these values are not constant, but can change at runtime */
7165 GD_TYPE_SCROLLBAR_VERTICAL,
7166 SCREEN_CTRL_ID_SCROLL_VERTICAL,
7167 "scroll level series vertically"
7171 static void CreateScreenMenubuttons()
7173 struct GadgetInfo *gi;
7174 unsigned int event_mask;
7177 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
7179 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7180 int gfx_unpressed, gfx_pressed;
7181 int x, y, width, height;
7182 int gd_x1, gd_x2, gd_y1, gd_y2;
7183 int id = menubutton_info[i].gadget_id;
7185 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7187 menubutton_info[i].get_gadget_position(&x, &y, id);
7189 width = SC_MENUBUTTON_XSIZE;
7190 height = SC_MENUBUTTON_YSIZE;
7192 gfx_unpressed = menubutton_info[i].gfx_unpressed;
7193 gfx_pressed = menubutton_info[i].gfx_pressed;
7194 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7195 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7196 gd_x1 = graphic_info[gfx_unpressed].src_x;
7197 gd_y1 = graphic_info[gfx_unpressed].src_y;
7198 gd_x2 = graphic_info[gfx_pressed].src_x;
7199 gd_y2 = graphic_info[gfx_pressed].src_y;
7201 gi = CreateGadget(GDI_CUSTOM_ID, id,
7202 GDI_CUSTOM_TYPE_ID, i,
7203 GDI_INFO_TEXT, menubutton_info[i].infotext,
7208 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7209 GDI_STATE, GD_BUTTON_UNPRESSED,
7210 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7211 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7212 GDI_DIRECT_DRAW, FALSE,
7213 GDI_EVENT_MASK, event_mask,
7214 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7218 Error(ERR_EXIT, "cannot create gadget");
7220 screen_gadget[id] = gi;
7224 static void CreateScreenScrollbuttons()
7226 struct GadgetInfo *gi;
7227 unsigned int event_mask;
7230 /* these values are not constant, but can change at runtime */
7231 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
7232 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
7233 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
7234 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
7236 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7238 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7239 int gfx_unpressed, gfx_pressed;
7240 int x, y, width, height;
7241 int gd_x1, gd_x2, gd_y1, gd_y2;
7242 int id = scrollbutton_info[i].gadget_id;
7244 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7246 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
7247 y = mSY + scrollbutton_info[i].y;
7248 width = SC_SCROLLBUTTON_XSIZE;
7249 height = SC_SCROLLBUTTON_YSIZE;
7251 /* correct scrollbar position if placed outside menu (playfield) area */
7252 if (x > SX + SC_SCROLL_UP_XPOS)
7253 x = SX + SC_SCROLL_UP_XPOS;
7255 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
7256 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
7257 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
7259 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
7260 gfx_pressed = scrollbutton_info[i].gfx_pressed;
7261 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7262 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7263 gd_x1 = graphic_info[gfx_unpressed].src_x;
7264 gd_y1 = graphic_info[gfx_unpressed].src_y;
7265 gd_x2 = graphic_info[gfx_pressed].src_x;
7266 gd_y2 = graphic_info[gfx_pressed].src_y;
7268 gi = CreateGadget(GDI_CUSTOM_ID, id,
7269 GDI_CUSTOM_TYPE_ID, i,
7270 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7275 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7276 GDI_STATE, GD_BUTTON_UNPRESSED,
7277 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7278 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7279 GDI_DIRECT_DRAW, FALSE,
7280 GDI_EVENT_MASK, event_mask,
7281 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7285 Error(ERR_EXIT, "cannot create gadget");
7287 screen_gadget[id] = gi;
7291 static void CreateScreenScrollbars()
7295 /* these values are not constant, but can change at runtime */
7296 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
7297 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
7298 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
7299 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
7301 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7303 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7304 int gfx_unpressed, gfx_pressed;
7305 int x, y, width, height;
7306 int gd_x1, gd_x2, gd_y1, gd_y2;
7307 struct GadgetInfo *gi;
7308 int items_max, items_visible, item_position;
7309 unsigned int event_mask;
7310 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
7311 int id = scrollbar_info[i].gadget_id;
7313 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7315 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
7316 y = mSY + scrollbar_info[i].y;
7317 width = scrollbar_info[i].width;
7318 height = scrollbar_info[i].height;
7320 /* correct scrollbar position if placed outside menu (playfield) area */
7321 if (x > SX + SC_SCROLL_VERTICAL_XPOS)
7322 x = SX + SC_SCROLL_VERTICAL_XPOS;
7324 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
7325 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
7327 items_max = num_page_entries;
7328 items_visible = num_page_entries;
7331 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
7332 gfx_pressed = scrollbar_info[i].gfx_pressed;
7333 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7334 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7335 gd_x1 = graphic_info[gfx_unpressed].src_x;
7336 gd_y1 = graphic_info[gfx_unpressed].src_y;
7337 gd_x2 = graphic_info[gfx_pressed].src_x;
7338 gd_y2 = graphic_info[gfx_pressed].src_y;
7340 gi = CreateGadget(GDI_CUSTOM_ID, id,
7341 GDI_CUSTOM_TYPE_ID, i,
7342 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7347 GDI_TYPE, scrollbar_info[i].type,
7348 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7349 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7350 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7351 GDI_WHEEL_AREA_X, SX,
7352 GDI_WHEEL_AREA_Y, SY,
7353 GDI_WHEEL_AREA_WIDTH, SXSIZE,
7354 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
7355 GDI_STATE, GD_BUTTON_UNPRESSED,
7356 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7357 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7358 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
7359 GDI_DIRECT_DRAW, FALSE,
7360 GDI_EVENT_MASK, event_mask,
7361 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7365 Error(ERR_EXIT, "cannot create gadget");
7367 screen_gadget[id] = gi;
7371 void CreateScreenGadgets()
7373 CreateScreenMenubuttons();
7375 CreateScreenScrollbuttons();
7376 CreateScreenScrollbars();
7379 void FreeScreenGadgets()
7383 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
7384 FreeGadget(screen_gadget[i]);
7387 void MapScreenMenuGadgets(int screen_mask)
7391 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
7392 if (screen_mask & menubutton_info[i].screen_mask)
7393 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
7396 void MapScreenGadgets(int num_entries)
7400 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
7403 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7404 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
7406 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7407 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
7410 void MapScreenTreeGadgets(TreeInfo *ti)
7412 MapScreenGadgets(numTreeInfoInGroup(ti));
7415 static void HandleScreenGadgets(struct GadgetInfo *gi)
7417 int id = gi->custom_id;
7418 int button = gi->event.button;
7419 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
7423 case SCREEN_CTRL_ID_PREV_LEVEL:
7424 HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT);
7427 case SCREEN_CTRL_ID_NEXT_LEVEL:
7428 HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT);
7431 case SCREEN_CTRL_ID_PREV_PLAYER:
7432 HandleSetupScreen_Input_Player(step, -1);
7435 case SCREEN_CTRL_ID_NEXT_PLAYER:
7436 HandleSetupScreen_Input_Player(step, +1);
7439 case SCREEN_CTRL_ID_SCROLL_UP:
7440 if (game_status == GAME_MODE_LEVELS)
7441 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7442 else if (game_status == GAME_MODE_LEVELNR)
7443 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7444 else if (game_status == GAME_MODE_SETUP)
7445 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7446 else if (game_status == GAME_MODE_INFO)
7447 HandleInfoScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7450 case SCREEN_CTRL_ID_SCROLL_DOWN:
7451 if (game_status == GAME_MODE_LEVELS)
7452 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7453 else if (game_status == GAME_MODE_LEVELNR)
7454 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7455 else if (game_status == GAME_MODE_SETUP)
7456 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7457 else if (game_status == GAME_MODE_INFO)
7458 HandleInfoScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7461 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
7462 if (game_status == GAME_MODE_LEVELS)
7463 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
7464 else if (game_status == GAME_MODE_LEVELNR)
7465 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
7466 else if (game_status == GAME_MODE_SETUP)
7467 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
7468 else if (game_status == GAME_MODE_INFO)
7469 HandleInfoScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);