1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
12 #include "libgame/libgame.h"
26 /* screens on the info screen */
27 #define INFO_MODE_MAIN 0
28 #define INFO_MODE_TITLE 1
29 #define INFO_MODE_ELEMENTS 2
30 #define INFO_MODE_MUSIC 3
31 #define INFO_MODE_CREDITS 4
32 #define INFO_MODE_PROGRAM 5
33 #define INFO_MODE_VERSION 6
34 #define INFO_MODE_LEVELSET 7
36 #define MAX_INFO_MODES 8
38 /* screens on the setup screen */
39 /* (must match GFX_SPECIAL_ARG_SETUP_* values as defined in src/main.h) */
40 /* (should also match corresponding entries in src/conf_gfx.c) */
41 #define SETUP_MODE_MAIN 0
42 #define SETUP_MODE_GAME 1
43 #define SETUP_MODE_EDITOR 2
44 #define SETUP_MODE_GRAPHICS 3
45 #define SETUP_MODE_SOUND 4
46 #define SETUP_MODE_ARTWORK 5
47 #define SETUP_MODE_INPUT 6
48 #define SETUP_MODE_TOUCH 7
49 #define SETUP_MODE_SHORTCUTS 8
50 #define SETUP_MODE_SHORTCUTS_1 9
51 #define SETUP_MODE_SHORTCUTS_2 10
52 #define SETUP_MODE_SHORTCUTS_3 11
53 #define SETUP_MODE_SHORTCUTS_4 12
54 #define SETUP_MODE_SHORTCUTS_5 13
56 /* sub-screens on the setup screen (generic) */
57 #define SETUP_MODE_CHOOSE_ARTWORK 14
58 #define SETUP_MODE_CHOOSE_OTHER 15
60 /* sub-screens on the setup screen (specific) */
61 #define SETUP_MODE_CHOOSE_GAME_SPEED 16
62 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17
63 #define SETUP_MODE_CHOOSE_SCREEN_MODE 18
64 #define SETUP_MODE_CHOOSE_WINDOW_SIZE 19
65 #define SETUP_MODE_CHOOSE_SCALING_TYPE 20
66 #define SETUP_MODE_CHOOSE_GRAPHICS 21
67 #define SETUP_MODE_CHOOSE_SOUNDS 22
68 #define SETUP_MODE_CHOOSE_MUSIC 23
69 #define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 24
70 #define SETUP_MODE_CHOOSE_VOLUME_LOOPS 25
71 #define SETUP_MODE_CHOOSE_VOLUME_MUSIC 26
72 #define SETUP_MODE_CHOOSE_TOUCH_CONTROL 27
73 #define SETUP_MODE_CHOOSE_MOVE_DISTANCE 28
74 #define SETUP_MODE_CHOOSE_DROP_DISTANCE 29
76 #define MAX_SETUP_MODES 30
78 /* for input setup functions */
79 #define SETUPINPUT_SCREEN_POS_START 0
80 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
81 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
82 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
84 /* for various menu stuff */
85 #define MENU_SCREEN_START_XPOS 1
86 #define MENU_SCREEN_START_YPOS 2
87 #define MENU_SCREEN_VALUE_XPOS (SCR_FIELDX - 3)
88 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
89 #define MENU_TITLE1_YPOS 8
90 #define MENU_TITLE2_YPOS 46
91 #define MENU_SCREEN_INFO_XSTART 16
92 #define MENU_SCREEN_INFO_YSTART1 100
93 #define MENU_SCREEN_INFO_YSTART2 128
94 #define MENU_SCREEN_INFO_YSTEP (TILEY + 4)
95 #define MENU_SCREEN_INFO_YBOTTOM (SYSIZE - 20)
96 #define MENU_SCREEN_INFO_YSIZE (MENU_SCREEN_INFO_YBOTTOM - \
97 MENU_SCREEN_INFO_YSTART2 - \
99 #define MAX_INFO_ELEMENTS_ON_SCREEN 128
100 #define NUM_INFO_ELEMENTS_ON_SCREEN MIN(MENU_SCREEN_INFO_YSIZE / \
101 MENU_SCREEN_INFO_YSTEP, \
102 MAX_INFO_ELEMENTS_ON_SCREEN)
103 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
104 #define MAX_MENU_TEXT_LENGTH_BIG 13
105 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
107 /* buttons and scrollbars identifiers */
108 #define SCREEN_CTRL_ID_PREV_LEVEL 0
109 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
110 #define SCREEN_CTRL_ID_PREV_PLAYER 2
111 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
112 #define SCREEN_CTRL_ID_SCROLL_UP 4
113 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
114 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
116 #define NUM_SCREEN_GADGETS 7
118 #define NUM_SCREEN_MENUBUTTONS 4
119 #define NUM_SCREEN_SCROLLBUTTONS 2
120 #define NUM_SCREEN_SCROLLBARS 1
122 #define SCREEN_MASK_MAIN (1 << 0)
123 #define SCREEN_MASK_INPUT (1 << 1)
125 /* graphic position and size values for buttons and scrollbars */
126 #define SC_MENUBUTTON_XSIZE TILEX
127 #define SC_MENUBUTTON_YSIZE TILEY
129 #define SC_SCROLLBUTTON_XSIZE TILEX
130 #define SC_SCROLLBUTTON_YSIZE TILEY
132 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
134 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
135 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
136 SC_SCROLLBUTTON_YSIZE)
138 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
139 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
141 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
142 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
143 SC_SCROLLBUTTON_YSIZE)
145 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
146 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
147 SC_SCROLL_VERTICAL_YSIZE)
149 #define SC_BORDER_SIZE 14
152 /* forward declarations of internal functions */
153 static void HandleScreenGadgets(struct GadgetInfo *);
154 static void HandleSetupScreen_Generic(int, int, int, int, int);
155 static void HandleSetupScreen_Input(int, int, int, int, int);
156 static void CustomizeKeyboard(int);
157 static void CalibrateJoystick(int);
158 static void execSetupGame(void);
159 static void execSetupGraphics(void);
160 static void execSetupSound(void);
161 static void execSetupTouch(void);
162 static void execSetupArtwork(void);
163 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
165 static void DrawChooseLevelSet(void);
166 static void DrawChooseLevelNr(void);
167 static void DrawInfoScreen(void);
168 static void DrawAndFadeInInfoScreen(int);
169 static void DrawSetupScreen(void);
171 static void DrawInfoScreenExt(int, int);
172 static void DrawInfoScreen_NotAvailable(char *, char *);
173 static void DrawInfoScreen_HelpAnim(int, int, boolean);
174 static void DrawInfoScreen_HelpText(int, int, int, int);
175 static void HandleInfoScreen_Main(int, int, int, int, int);
176 static void HandleInfoScreen_TitleScreen(int);
177 static void HandleInfoScreen_Elements(int);
178 static void HandleInfoScreen_Music(int);
179 static void HandleInfoScreen_Credits(int);
180 static void HandleInfoScreen_Program(int);
181 static void HandleInfoScreen_Version(int);
183 static void MapScreenMenuGadgets(int);
184 static void MapScreenGadgets(int);
185 static void MapScreenTreeGadgets(TreeInfo *);
187 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
189 static int info_mode = INFO_MODE_MAIN;
190 static int setup_mode = SETUP_MODE_MAIN;
192 static TreeInfo *screen_modes = NULL;
193 static TreeInfo *screen_mode_current = NULL;
195 static TreeInfo *window_sizes = NULL;
196 static TreeInfo *window_size_current = NULL;
198 static TreeInfo *scaling_types = NULL;
199 static TreeInfo *scaling_type_current = NULL;
201 static TreeInfo *scroll_delays = NULL;
202 static TreeInfo *scroll_delay_current = NULL;
204 static TreeInfo *game_speeds = NULL;
205 static TreeInfo *game_speed_current = NULL;
207 static TreeInfo *volumes_simple = NULL;
208 static TreeInfo *volume_simple_current = NULL;
210 static TreeInfo *volumes_loops = NULL;
211 static TreeInfo *volume_loops_current = NULL;
213 static TreeInfo *volumes_music = NULL;
214 static TreeInfo *volume_music_current = NULL;
216 static TreeInfo *touch_controls = NULL;
217 static TreeInfo *touch_control_current = NULL;
219 static TreeInfo *move_distances = NULL;
220 static TreeInfo *move_distance_current = NULL;
222 static TreeInfo *drop_distances = NULL;
223 static TreeInfo *drop_distance_current = NULL;
225 static TreeInfo *level_number = NULL;
226 static TreeInfo *level_number_current = NULL;
232 } window_sizes_list[] =
237 { 100, "100 % (Default)" },
254 } scaling_types_list[] =
256 { SCALING_QUALITY_NEAREST, "None" },
257 { SCALING_QUALITY_LINEAR, "Linear" },
258 { SCALING_QUALITY_BEST, "Anisotropic" },
267 } game_speeds_list[] =
276 { 1000, "1/1s (Extremely Slow)" },
281 { 29, "1/35s (Original Supaplex)" },
283 { 20, "1/50s (Normal Speed)" },
284 { 14, "1/70s (Maximum Supaplex)" },
288 { 1, "1/1000s (Extremely Fast)" },
298 } scroll_delays_list[] =
300 { 0, "0 Tiles (No Scroll Delay)" },
303 { 3, "3 Tiles (Default)" },
308 { 8, "8 Tiles (Maximum Scroll Delay)"},
341 } touch_controls_list[] =
343 { TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" },
344 { TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" },
368 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
369 (s) <= GAME_MODE_SETUP ? (s) : \
370 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
371 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
373 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
374 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
375 (i) <= INFO_MODE_LEVELSET ? (i) : \
378 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
379 (i) <= SETUP_MODE_SHORTCUTS_5 ? (i) : \
380 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
381 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
382 SETUP_MODE_CHOOSE_ARTWORK : \
383 SETUP_MODE_CHOOSE_OTHER)
385 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
386 menu.draw_xoffset[GAME_MODE_INFO] : \
387 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
388 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
389 menu.draw_yoffset[GAME_MODE_INFO] : \
390 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
392 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
393 menu.draw_xoffset[GAME_MODE_SETUP] : \
394 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
395 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
396 menu.draw_yoffset[GAME_MODE_SETUP] : \
397 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
399 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
400 DRAW_XOFFSET_INFO(info_mode) : \
401 (s) == GAME_MODE_SETUP ? \
402 DRAW_XOFFSET_SETUP(setup_mode) : \
403 menu.draw_xoffset[DRAW_MODE(s)])
404 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
405 DRAW_YOFFSET_INFO(info_mode) : \
406 (s) == GAME_MODE_SETUP ? \
407 DRAW_YOFFSET_SETUP(setup_mode) : \
408 menu.draw_yoffset[DRAW_MODE(s)])
410 #define mSX (SX + DRAW_XOFFSET(game_status))
411 #define mSY (SY + DRAW_YOFFSET(game_status))
413 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
414 menu.list_size[game_status] : \
415 MAX_MENU_ENTRIES_ON_SCREEN)
417 #define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \
418 NUM_MENU_ENTRIES_ON_SCREEN)
421 /* title display and control definitions */
423 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
424 2 * MAX_NUM_TITLE_MESSAGES)
426 #define NO_DIRECT_LEVEL_SELECT (-1)
429 static int num_title_screens = 0;
431 struct TitleControlInfo
439 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
441 /* main menu display and control definitions */
443 #define MAIN_CONTROL_NAME 0
444 #define MAIN_CONTROL_LEVELS 1
445 #define MAIN_CONTROL_SCORES 2
446 #define MAIN_CONTROL_EDITOR 3
447 #define MAIN_CONTROL_INFO 4
448 #define MAIN_CONTROL_GAME 5
449 #define MAIN_CONTROL_SETUP 6
450 #define MAIN_CONTROL_QUIT 7
451 #define MAIN_CONTROL_PREV_LEVEL 8
452 #define MAIN_CONTROL_NEXT_LEVEL 9
453 #define MAIN_CONTROL_FIRST_LEVEL 10
454 #define MAIN_CONTROL_LAST_LEVEL 11
455 #define MAIN_CONTROL_LEVEL_NUMBER 12
456 #define MAIN_CONTROL_LEVEL_INFO_1 13
457 #define MAIN_CONTROL_LEVEL_INFO_2 14
458 #define MAIN_CONTROL_LEVEL_NAME 15
459 #define MAIN_CONTROL_LEVEL_AUTHOR 16
460 #define MAIN_CONTROL_LEVEL_YEAR 17
461 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
462 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
463 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
464 #define MAIN_CONTROL_TITLE_1 21
465 #define MAIN_CONTROL_TITLE_2 22
466 #define MAIN_CONTROL_TITLE_3 23
468 static char str_main_text_name[10];
469 static char str_main_text_first_level[10];
470 static char str_main_text_last_level[10];
471 static char str_main_text_level_number[10];
473 static char *main_text_name = str_main_text_name;
474 static char *main_text_first_level = str_main_text_first_level;
475 static char *main_text_last_level = str_main_text_last_level;
476 static char *main_text_level_number = str_main_text_level_number;
477 static char *main_text_levels = "Levelset";
478 static char *main_text_scores = "Hall Of Fame";
479 static char *main_text_editor = "Level Creator";
480 static char *main_text_info = "Info Screen";
481 static char *main_text_game = "Start Game";
482 static char *main_text_setup = "Setup";
483 static char *main_text_quit = "Quit";
484 static char *main_text_level_name = level.name;
485 static char *main_text_level_author = level.author;
486 static char *main_text_level_year = NULL;
487 static char *main_text_level_imported_from = NULL;
488 static char *main_text_level_imported_by = NULL;
489 static char *main_text_level_tested_by = NULL;
490 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
491 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
492 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
494 struct MainControlInfo
498 struct MenuPosInfo *pos_button;
501 struct TextPosInfo *pos_text;
504 struct TextPosInfo *pos_input;
508 static struct MainControlInfo main_controls[] =
512 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
513 &menu.main.text.name, &main_text_name,
514 &menu.main.input.name, &setup.player_name,
518 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
519 &menu.main.text.levels, &main_text_levels,
524 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
525 &menu.main.text.scores, &main_text_scores,
530 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
531 &menu.main.text.editor, &main_text_editor,
536 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
537 &menu.main.text.info, &main_text_info,
542 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
543 &menu.main.text.game, &main_text_game,
548 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
549 &menu.main.text.setup, &main_text_setup,
554 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
555 &menu.main.text.quit, &main_text_quit,
559 /* (these two buttons are real gadgets) */
561 MAIN_CONTROL_PREV_LEVEL,
562 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
567 MAIN_CONTROL_NEXT_LEVEL,
568 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
574 MAIN_CONTROL_FIRST_LEVEL,
576 &menu.main.text.first_level, &main_text_first_level,
580 MAIN_CONTROL_LAST_LEVEL,
582 &menu.main.text.last_level, &main_text_last_level,
586 MAIN_CONTROL_LEVEL_NUMBER,
588 &menu.main.text.level_number, &main_text_level_number,
592 MAIN_CONTROL_LEVEL_INFO_1,
594 &menu.main.text.level_info_1, NULL,
598 MAIN_CONTROL_LEVEL_INFO_2,
600 &menu.main.text.level_info_2, NULL,
604 MAIN_CONTROL_LEVEL_NAME,
606 &menu.main.text.level_name, &main_text_level_name,
610 MAIN_CONTROL_LEVEL_AUTHOR,
612 &menu.main.text.level_author, &main_text_level_author,
616 MAIN_CONTROL_LEVEL_YEAR,
618 &menu.main.text.level_year, &main_text_level_year,
622 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
624 &menu.main.text.level_imported_from, &main_text_level_imported_from,
628 MAIN_CONTROL_LEVEL_IMPORTED_BY,
630 &menu.main.text.level_imported_by, &main_text_level_imported_by,
634 MAIN_CONTROL_LEVEL_TESTED_BY,
636 &menu.main.text.level_tested_by, &main_text_level_tested_by,
640 MAIN_CONTROL_TITLE_1,
642 &menu.main.text.title_1, &main_text_title_1,
646 MAIN_CONTROL_TITLE_2,
648 &menu.main.text.title_2, &main_text_title_2,
652 MAIN_CONTROL_TITLE_3,
654 &menu.main.text.title_3, &main_text_title_3,
667 static int getTitleScreenGraphic(int nr, boolean initial)
669 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
672 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
674 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
678 static int getTitleScreenGameMode(boolean initial)
680 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
684 static int getTitleMessageGameMode(boolean initial)
686 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
690 static int getTitleScreenBackground(boolean initial)
692 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
697 static int getTitleMessageBackground(int nr, boolean initial)
699 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
703 static int getTitleBackground(int nr, boolean initial, boolean is_image)
705 int base = (is_image ?
706 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
707 IMG_BACKGROUND_TITLESCREEN_1) :
708 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
709 IMG_BACKGROUND_TITLEMESSAGE_1));
710 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
711 IMG_BACKGROUND_TITLE);
712 int graphic_local = base + nr;
714 if (graphic_info[graphic_local].bitmap != NULL)
715 return graphic_local;
717 if (graphic_info[graphic_global].bitmap != NULL)
718 return graphic_global;
720 return IMG_UNDEFINED;
723 static int getTitleSound(struct TitleControlInfo *tci)
725 boolean is_image = tci->is_image;
726 int initial = tci->initial;
727 int nr = tci->local_nr;
728 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
729 int base = (is_image ?
730 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
731 SND_BACKGROUND_TITLESCREEN_1) :
732 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
733 SND_BACKGROUND_TITLEMESSAGE_1));
734 int sound_global = menu.sound[mode];
735 int sound_local = base + nr;
738 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
739 nr, initial, is_image,
740 sound_global, getSoundListEntry(sound_global)->filename,
741 sound_local, getSoundListEntry(sound_local)->filename);
744 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
747 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
750 return SND_UNDEFINED;
753 static int getTitleMusic(struct TitleControlInfo *tci)
755 boolean is_image = tci->is_image;
756 int initial = tci->initial;
757 int nr = tci->local_nr;
758 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
759 int base = (is_image ?
760 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
761 MUS_BACKGROUND_TITLESCREEN_1) :
762 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
763 MUS_BACKGROUND_TITLEMESSAGE_1));
764 int music_global = menu.music[mode];
765 int music_local = base + nr;
768 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
769 nr, initial, is_image,
770 music_global, getMusicListEntry(music_global)->filename,
771 music_local, getMusicListEntry(music_local)->filename);
774 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
777 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
780 return MUS_UNDEFINED;
783 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
785 boolean is_image = tci->is_image;
786 int initial = tci->initial;
787 int nr = tci->local_nr;
788 struct TitleFadingInfo ti;
792 int graphic = getTitleScreenGraphic(nr, initial);
794 /* initialize fading control values to default title config settings */
795 ti = (initial ? title_initial_default : title_default);
797 /* override default settings with image config settings, if defined */
798 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
799 ti.fade_mode = graphic_info[graphic].fade_mode;
800 if (graphic_info[graphic].fade_delay > -1)
801 ti.fade_delay = graphic_info[graphic].fade_delay;
802 if (graphic_info[graphic].post_delay > -1)
803 ti.post_delay = graphic_info[graphic].post_delay;
804 if (graphic_info[graphic].auto_delay > -1)
805 ti.auto_delay = graphic_info[graphic].auto_delay;
811 ti.fade_mode = titlemessage_initial[nr].fade_mode;
812 ti.fade_delay = titlemessage_initial[nr].fade_delay;
813 ti.post_delay = titlemessage_initial[nr].post_delay;
814 ti.auto_delay = titlemessage_initial[nr].auto_delay;
818 ti.fade_mode = titlemessage[nr].fade_mode;
819 ti.fade_delay = titlemessage[nr].fade_delay;
820 ti.post_delay = titlemessage[nr].post_delay;
821 ti.auto_delay = titlemessage[nr].auto_delay;
828 static int compareTitleControlInfo(const void *object1, const void *object2)
830 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
831 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
834 if (tci1->initial != tci2->initial)
835 compare_result = (tci1->initial ? -1 : +1);
836 else if (tci1->sort_priority != tci2->sort_priority)
837 compare_result = tci1->sort_priority - tci2->sort_priority;
838 else if (tci1->is_image != tci2->is_image)
839 compare_result = (tci1->is_image ? -1 : +1);
841 compare_result = tci1->local_nr - tci2->local_nr;
843 return compare_result;
846 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
848 int nr, int sort_priority)
850 title_controls[num_title_screens].is_image = is_image;
851 title_controls[num_title_screens].initial = initial;
852 title_controls[num_title_screens].local_nr = nr;
853 title_controls[num_title_screens].sort_priority = sort_priority;
858 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
862 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
864 int graphic = getTitleScreenGraphic(i, initial);
865 Bitmap *bitmap = graphic_info[graphic].bitmap;
866 int sort_priority = graphic_info[graphic].sort_priority;
869 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
872 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
874 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
875 char *filename = getLevelSetTitleMessageFilename(i, initial);
876 int sort_priority = tmi->sort_priority;
878 if (filename != NULL)
879 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
883 static void InitializeTitleControls(boolean show_title_initial)
885 num_title_screens = 0;
887 /* 1st step: initialize title screens for game start (only when starting) */
888 if (show_title_initial)
889 InitializeTitleControls_CheckTitleInfo(TRUE);
891 /* 2nd step: initialize title screens for current level set */
892 InitializeTitleControls_CheckTitleInfo(FALSE);
894 /* sort title screens according to sort_priority and title number */
895 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
896 compareTitleControlInfo);
899 static boolean visibleMenuPos(struct MenuPosInfo *pos)
901 return (pos != NULL && pos->x != -1 && pos->y != -1);
904 static boolean visibleTextPos(struct TextPosInfo *pos)
906 return (pos != NULL && pos->x != -1 && pos->y != -1);
909 static void InitializeMainControls()
911 boolean local_team_mode = (!options.network && setup.team_mode);
914 /* set main control text values to dynamically determined values */
915 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
917 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
918 menu.main.text.first_level.size));
919 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
920 menu.main.text.last_level.size));
921 strcpy(main_text_level_number, int2str(level_nr,
922 menu.main.text.level_number.size));
924 main_text_level_year = leveldir_current->year;
925 main_text_level_imported_from = leveldir_current->imported_from;
926 main_text_level_imported_by = leveldir_current->imported_by;
927 main_text_level_tested_by = leveldir_current->tested_by;
929 /* set main control screen positions to dynamically determined values */
930 for (i = 0; main_controls[i].nr != -1; i++)
932 struct MainControlInfo *mci = &main_controls[i];
934 struct MenuPosInfo *pos_button = mci->pos_button;
935 struct TextPosInfo *pos_text = mci->pos_text;
936 struct TextPosInfo *pos_input = mci->pos_input;
937 char *text = (mci->text ? *mci->text : NULL);
938 char *input = (mci->input ? *mci->input : NULL);
939 int button_graphic = mci->button_graphic;
940 int font_text = (pos_text ? pos_text->font : -1);
941 int font_input = (pos_input ? pos_input->font : -1);
943 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
944 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
945 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
946 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
947 int text_chars = (text != NULL ? strlen(text) : 0);
948 int input_chars = (input != NULL ? strlen(input) : 0);
951 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
953 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
954 int text_width = font_text_width * text_chars;
955 int text_height = font_text_height;
956 int input_width = font_input_width * input_chars;
957 int input_height = font_input_height;
959 if (nr == MAIN_CONTROL_NAME)
961 menu.main.input.name.width = input_width;
962 menu.main.input.name.height = input_height;
965 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
967 pos_button->width = button_width;
968 pos_button->height = button_height;
971 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
973 /* calculate size for non-clickable text -- needed for text alignment */
974 boolean calculate_text_size = (pos_button == NULL && text != NULL);
976 if (pos_text->width == -1 || calculate_text_size)
977 pos_text->width = text_width;
978 if (pos_text->height == -1 || calculate_text_size)
979 pos_text->height = text_height;
981 if (visibleMenuPos(pos_button))
983 if (pos_text->x == -1)
984 pos_text->x = pos_button->x + pos_button->width;
985 if (pos_text->y == -1)
987 pos_button->y + (pos_button->height - pos_text->height) / 2;
991 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
993 if (visibleTextPos(pos_text))
995 if (pos_input->x == -1)
996 pos_input->x = pos_text->x + pos_text->width;
997 if (pos_input->y == -1)
998 pos_input->y = pos_text->y;
1001 if (pos_input->width == -1)
1002 pos_input->width = input_width;
1003 if (pos_input->height == -1)
1004 pos_input->height = input_height;
1009 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1010 boolean active_input)
1014 for (i = 0; main_controls[i].nr != -1; i++)
1016 struct MainControlInfo *mci = &main_controls[i];
1018 if (mci->nr == nr || nr == -1)
1020 struct MenuPosInfo *pos_button = mci->pos_button;
1021 struct TextPosInfo *pos_text = mci->pos_text;
1022 struct TextPosInfo *pos_input = mci->pos_input;
1023 char *text = (mci->text ? *mci->text : NULL);
1024 char *input = (mci->input ? *mci->input : NULL);
1025 int button_graphic = mci->button_graphic;
1026 int font_text = (pos_text ? pos_text->font : -1);
1027 int font_input = (pos_input ? pos_input->font : -1);
1031 button_graphic = BUTTON_ACTIVE(button_graphic);
1032 font_text = FONT_ACTIVE(font_text);
1037 font_input = FONT_ACTIVE(font_input);
1040 if (visibleMenuPos(pos_button))
1042 struct MenuPosInfo *pos = pos_button;
1043 int x = mSX + pos->x;
1044 int y = mSY + pos->y;
1046 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1047 DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
1050 if (visibleTextPos(pos_text) && text != NULL)
1052 struct TextPosInfo *pos = pos_text;
1053 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1054 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1057 /* (check why/if this is needed) */
1058 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1060 DrawText(x, y, text, font_text);
1063 if (visibleTextPos(pos_input) && input != NULL)
1065 struct TextPosInfo *pos = pos_input;
1066 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1067 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1070 /* (check why/if this is needed) */
1071 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1073 DrawText(x, y, input, font_input);
1079 static void DrawCursorAndText_Main(int nr, boolean active_text)
1081 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1085 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1087 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1091 static struct MainControlInfo *getMainControlInfo(int nr)
1095 for (i = 0; main_controls[i].nr != -1; i++)
1096 if (main_controls[i].nr == nr)
1097 return &main_controls[i];
1102 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1107 int rect_x = ALIGNED_TEXT_XPOS(rect);
1108 int rect_y = ALIGNED_TEXT_YPOS(rect);
1110 return (x >= rect_x && x < rect_x + rect->width &&
1111 y >= rect_y && y < rect_y + rect->height);
1114 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1119 int rect_x = ALIGNED_TEXT_XPOS(rect);
1120 int rect_y = ALIGNED_TEXT_YPOS(rect);
1123 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1124 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1125 (x >= rect_x && x < rect_x + rect->width &&
1126 y >= rect_y && y < rect_y + rect->height));
1129 return (x >= rect_x && x < rect_x + rect->width &&
1130 y >= rect_y && y < rect_y + rect->height);
1133 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1135 static int cursor_array[MAX_LEV_FIELDY];
1136 int x = mSX + TILEX * xpos;
1137 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1142 cursor_array[ypos] = graphic;
1144 graphic = cursor_array[ypos];
1148 graphic = BUTTON_ACTIVE(graphic);
1150 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1151 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1154 static void initCursor(int ypos, int graphic)
1156 drawCursorExt(0, ypos, FALSE, graphic);
1159 static void drawCursor(int ypos, boolean active)
1161 drawCursorExt(0, ypos, active, -1);
1164 static void drawCursorXY(int xpos, int ypos, int graphic)
1166 drawCursorExt(xpos, ypos, FALSE, graphic);
1169 static void drawChooseTreeCursor(int ypos, boolean active)
1171 int last_game_status = game_status; /* save current game status */
1173 drawCursorExt(0, ypos, active, -1);
1175 game_status = last_game_status; /* restore current game status */
1180 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1181 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1184 int effectiveGameStatus()
1186 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1187 return GAME_MODE_TITLE;
1192 void DrawTitleScreenImage(int nr, boolean initial)
1194 int graphic = getTitleScreenGraphic(nr, initial);
1195 Bitmap *bitmap = graphic_info[graphic].bitmap;
1196 int width = graphic_info[graphic].width;
1197 int height = graphic_info[graphic].height;
1198 int src_x = graphic_info[graphic].src_x;
1199 int src_y = graphic_info[graphic].src_y;
1205 if (width > WIN_XSIZE)
1207 /* image width too large for window => center image horizontally */
1208 src_x = (width - WIN_XSIZE) / 2;
1212 if (height > WIN_YSIZE)
1214 /* image height too large for window => center image vertically */
1215 src_y = (height - WIN_YSIZE) / 2;
1219 /* always display title screens centered */
1220 dst_x = (WIN_XSIZE - width) / 2;
1221 dst_y = (WIN_YSIZE - height) / 2;
1223 SetDrawBackgroundMask(REDRAW_ALL);
1224 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1226 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1228 if (DrawingOnBackground(dst_x, dst_y))
1229 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1231 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1233 redraw_mask = REDRAW_ALL;
1236 void DrawTitleScreenMessage(int nr, boolean initial)
1238 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1239 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1240 int last_game_status = game_status; /* save current game status */
1242 if (filename == NULL)
1245 /* force TITLE font on title message screen */
1246 game_status = getTitleMessageGameMode(initial);
1248 /* if chars set to "-1", automatically determine by text and font width */
1249 if (tmi->chars == -1)
1250 tmi->chars = tmi->width / getFontWidth(tmi->font);
1252 tmi->width = tmi->chars * getFontWidth(tmi->font);
1254 /* if lines set to "-1", automatically determine by text and font height */
1255 if (tmi->lines == -1)
1256 tmi->lines = tmi->height / getFontHeight(tmi->font);
1258 tmi->height = tmi->lines * getFontHeight(tmi->font);
1260 SetDrawBackgroundMask(REDRAW_ALL);
1261 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1263 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1265 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1266 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1267 tmi->autowrap, tmi->centered, tmi->parse_comments);
1269 game_status = last_game_status; /* restore current game status */
1272 void DrawTitleScreen()
1274 KeyboardAutoRepeatOff();
1276 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1281 boolean CheckTitleScreen(boolean levelset_has_changed)
1283 static boolean show_title_initial = TRUE;
1284 boolean show_titlescreen = FALSE;
1286 /* needed to be able to skip title screen, if no image or message defined */
1287 InitializeTitleControls(show_title_initial);
1289 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1290 show_titlescreen = TRUE;
1292 /* show initial title images and messages only once at program start */
1293 show_title_initial = FALSE;
1295 return (show_titlescreen && num_title_screens > 0);
1298 void DrawMainMenuExt(int fade_mask, boolean do_fading)
1300 static LevelDirTree *leveldir_last_valid = NULL;
1301 boolean levelset_has_changed = FALSE;
1303 LimitScreenUpdates(FALSE);
1305 FadeSetLeaveScreen();
1307 /* do not fade out here -- function may continue and fade on editor screen */
1310 FadeSoundsAndMusic();
1312 KeyboardAutoRepeatOn();
1315 audio.sound_deactivated = FALSE;
1319 /* needed if last screen was the playing screen, invoked from level editor */
1320 if (level_editor_test_game)
1322 game_status = GAME_MODE_EDITOR;
1328 /* needed if last screen was the setup screen and fullscreen state changed */
1329 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1330 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1332 /* leveldir_current may be invalid (level group, parent link) */
1333 if (!validLevelSeries(leveldir_current))
1334 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1336 if (leveldir_current != leveldir_last_valid)
1337 levelset_has_changed = TRUE;
1339 /* store valid level series information */
1340 leveldir_last_valid = leveldir_current;
1342 init_last = init; /* switch to new busy animation */
1344 /* needed if last screen (level choice) changed graphics, sounds or music */
1345 ReloadCustomArtwork(0);
1347 if (redraw_mask & REDRAW_ALL)
1348 fade_mask = REDRAW_ALL;
1352 /* needed if different viewport properties defined for menues */
1353 ChangeViewportPropertiesIfNeeded();
1355 /* needed if last screen was the editor screen */
1356 UndrawSpecialEditorDoor();
1358 SetDrawtoField(DRAW_BACKBUFFER);
1360 if (CheckTitleScreen(levelset_has_changed))
1362 game_status = GAME_MODE_TITLE;
1369 /* level_nr may have been set to value over handicap with level editor */
1370 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1371 level_nr = leveldir_current->handicap_level;
1373 LoadLevel(level_nr);
1374 LoadScore(level_nr);
1376 // set this after "ChangeViewportPropertiesIfNeeded()" (which may reset it)
1377 SetDrawDeactivationMask(REDRAW_NONE);
1378 SetDrawBackgroundMask(REDRAW_FIELD);
1380 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1382 if (fade_mask == REDRAW_ALL)
1387 InitializeMainControls();
1389 DrawCursorAndText_Main(-1, FALSE);
1390 DrawPreviewLevelInitial();
1392 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1395 if (TAPE_IS_EMPTY(tape))
1397 DrawCompleteVideoDisplay();
1402 /* create gadgets for main menu screen */
1403 FreeScreenGadgets();
1404 CreateScreenGadgets();
1406 /* map gadgets for main menu screen */
1408 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1410 /* copy actual game door content to door double buffer for OpenDoor() */
1411 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1413 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1415 DrawMaskedBorder(REDRAW_ALL);
1420 /* update screen area with special editor door */
1421 redraw_mask |= REDRAW_ALL;
1424 SetMouseCursor(CURSOR_DEFAULT);
1428 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1431 void DrawAndFadeInMainMenu(int fade_mask)
1433 DrawMainMenuExt(fade_mask, TRUE);
1438 DrawMainMenuExt(REDRAW_ALL, FALSE);
1441 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1442 static void gotoTopLevelDir()
1444 /* move upwards to top level directory */
1445 while (leveldir_current->node_parent)
1447 /* write a "path" into level tree for easy navigation to last level */
1448 if (leveldir_current->node_parent->node_group->cl_first == -1)
1450 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1451 int leveldir_pos = posTreeInfo(leveldir_current);
1452 int num_page_entries;
1453 int cl_first, cl_cursor;
1455 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1456 num_page_entries = num_leveldirs;
1458 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1460 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1461 cl_cursor = leveldir_pos - cl_first;
1463 leveldir_current->node_parent->node_group->cl_first = cl_first;
1464 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1467 leveldir_current = leveldir_current->node_parent;
1472 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1474 static unsigned int title_delay = 0;
1475 static int title_screen_nr = 0;
1476 static int last_sound = -1, last_music = -1;
1477 boolean return_to_main_menu = FALSE;
1478 boolean use_fading_main_menu = TRUE;
1479 struct TitleControlInfo *tci;
1480 struct TitleFadingInfo fading_default;
1481 struct TitleFadingInfo fading_last = fading;
1482 struct TitleFadingInfo fading_next;
1485 if (button == MB_MENU_INITIALIZE)
1488 title_screen_nr = 0;
1489 tci = &title_controls[title_screen_nr];
1491 last_sound = SND_UNDEFINED;
1492 last_music = MUS_UNDEFINED;
1494 if (game_status == GAME_MODE_INFO)
1496 if (num_title_screens == 0)
1498 DrawInfoScreen_NotAvailable("Title screen information:",
1499 "No title screen for this level set.");
1504 FadeSoundsAndMusic();
1506 FadeOut(REDRAW_ALL);
1510 DrawTitleScreenImage(tci->local_nr, tci->initial);
1512 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1514 fading_default = (tci->initial ? title_initial_default : title_default);
1516 fading = fading_next = getTitleFading(tci);
1518 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1519 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1521 fading.fade_mode = FADE_MODE_FADE;
1522 fading.fade_delay = fading_default.fade_delay;
1525 sound = getTitleSound(tci);
1526 music = getTitleMusic(tci);
1528 if (sound != last_sound)
1529 PlayMenuSoundExt(sound);
1530 if (music != last_music)
1531 PlayMenuMusicExt(music);
1536 SetMouseCursor(CURSOR_NONE);
1540 fading = fading_next;
1542 DelayReached(&title_delay, 0); /* reset delay counter */
1547 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1548 button = MB_MENU_CHOICE;
1550 if (button == MB_MENU_LEAVE)
1552 return_to_main_menu = TRUE;
1553 use_fading_main_menu = FALSE;
1555 else if (button == MB_MENU_CHOICE)
1557 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1559 FadeSetEnterScreen();
1561 info_mode = INFO_MODE_MAIN;
1562 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1568 tci = &title_controls[title_screen_nr];
1570 if (title_screen_nr < num_title_screens)
1572 sound = getTitleSound(tci);
1573 music = getTitleMusic(tci);
1575 if (sound == SND_UNDEFINED || sound != last_sound)
1577 if (music == MUS_UNDEFINED || music != last_music)
1580 FadeOut(REDRAW_ALL);
1583 DrawTitleScreenImage(tci->local_nr, tci->initial);
1585 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1587 fading_next = getTitleFading(tci);
1589 sound = getTitleSound(tci);
1590 music = getTitleMusic(tci);
1592 if (sound != last_sound)
1593 PlayMenuSoundExt(sound);
1594 if (music != last_music)
1595 PlayMenuMusicExt(music);
1600 /* last screen already faded out, next screen has no animation */
1601 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1602 fading_next.fade_mode == FADE_MODE_NONE)
1603 fading = fading_next;
1607 fading = fading_next;
1609 DelayReached(&title_delay, 0); /* reset delay counter */
1613 FadeSoundsAndMusic();
1615 return_to_main_menu = TRUE;
1619 if (return_to_main_menu)
1621 SetMouseCursor(CURSOR_DEFAULT);
1623 if (game_status == GAME_MODE_INFO)
1625 int fade_mask = (num_title_screens == 0 ? REDRAW_FIELD : REDRAW_ALL);
1627 info_mode = INFO_MODE_MAIN;
1629 DrawInfoScreenExt(fade_mask, use_fading_main_menu);
1631 else /* default: return to main menu */
1633 game_status = GAME_MODE_MAIN;
1635 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1640 void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
1642 int old_level_nr = level_nr;
1645 if (selected_level_nr != NO_DIRECT_LEVEL_SELECT)
1646 new_level_nr = selected_level_nr;
1648 new_level_nr = old_level_nr + step * direction;
1650 if (new_level_nr < leveldir_current->first_level)
1651 new_level_nr = leveldir_current->first_level;
1652 if (new_level_nr > leveldir_current->last_level)
1653 new_level_nr = leveldir_current->last_level;
1655 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1657 /* skipping levels is only allowed when trying to skip single level */
1658 if (setup.skip_levels && new_level_nr == old_level_nr + 1 &&
1659 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1661 leveldir_current->handicap_level++;
1662 SaveLevelSetup_SeriesInfo();
1665 new_level_nr = leveldir_current->handicap_level;
1668 if (new_level_nr != old_level_nr)
1670 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1672 PlaySound(SND_MENU_ITEM_SELECTING);
1674 level_nr = new_level_nr;
1676 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1677 int2str(level_nr, menu.main.text.level_number.size),
1678 mci->pos_text->font);
1680 LoadLevel(level_nr);
1681 DrawPreviewLevelInitial();
1685 DrawCompleteVideoDisplay();
1687 /* needed because DrawPreviewLevelInitial() takes some time */
1689 /* SyncDisplay(); */
1693 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1695 static int choice = MAIN_CONTROL_GAME;
1699 if (button == MB_MENU_INITIALIZE)
1701 DrawCursorAndText_Main(choice, TRUE);
1706 if (mx || my) /* mouse input */
1710 for (i = 0; main_controls[i].nr != -1; i++)
1712 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1713 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1714 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1716 pos = main_controls[i].nr;
1722 else if (dx || dy) /* keyboard input */
1724 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1725 choice == MAIN_CONTROL_SETUP))
1726 button = MB_MENU_CHOICE;
1731 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1733 HandleMainMenu_SelectLevel(1, (dx < 0 ? -1 : +1), NO_DIRECT_LEVEL_SELECT);
1735 else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1737 HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
1739 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1741 HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT);
1743 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1745 game_status = GAME_MODE_LEVELNR;
1747 ChangeViewportPropertiesIfNeeded();
1749 DrawChooseLevelNr();
1751 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1757 PlaySound(SND_MENU_ITEM_ACTIVATING);
1759 DrawCursorAndText_Main(choice, FALSE);
1760 DrawCursorAndText_Main(pos, TRUE);
1767 PlaySound(SND_MENU_ITEM_SELECTING);
1769 if (pos == MAIN_CONTROL_NAME)
1771 game_status = GAME_MODE_PSEUDO_TYPENAME;
1773 HandleTypeName(strlen(setup.player_name), 0);
1775 else if (pos == MAIN_CONTROL_LEVELS)
1779 game_status = GAME_MODE_LEVELS;
1781 SaveLevelSetup_LastSeries();
1782 SaveLevelSetup_SeriesInfo();
1784 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1788 ChangeViewportPropertiesIfNeeded();
1790 DrawChooseLevelSet();
1793 else if (pos == MAIN_CONTROL_SCORES)
1795 game_status = GAME_MODE_SCORES;
1797 ChangeViewportPropertiesIfNeeded();
1801 else if (pos == MAIN_CONTROL_EDITOR)
1803 if (leveldir_current->readonly &&
1804 !strEqual(setup.player_name, "Artsoft"))
1805 Request("This level is read only!", REQ_CONFIRM);
1807 CloseDoor(DOOR_CLOSE_2);
1809 game_status = GAME_MODE_EDITOR;
1811 FadeSetEnterScreen();
1815 else if (pos == MAIN_CONTROL_INFO)
1817 game_status = GAME_MODE_INFO;
1818 info_mode = INFO_MODE_MAIN;
1820 ChangeViewportPropertiesIfNeeded();
1824 else if (pos == MAIN_CONTROL_GAME)
1826 StartGameActions(options.network, setup.autorecord, level.random_seed);
1828 else if (pos == MAIN_CONTROL_SETUP)
1830 game_status = GAME_MODE_SETUP;
1831 setup_mode = SETUP_MODE_MAIN;
1833 ChangeViewportPropertiesIfNeeded();
1837 else if (pos == MAIN_CONTROL_QUIT)
1839 SaveLevelSetup_LastSeries();
1840 SaveLevelSetup_SeriesInfo();
1842 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1843 game_status = GAME_MODE_QUIT;
1850 /* ========================================================================= */
1851 /* info screen functions */
1852 /* ========================================================================= */
1854 static struct TokenInfo *info_info;
1855 static int num_info_info;
1857 static void execInfoTitleScreen()
1859 info_mode = INFO_MODE_TITLE;
1864 static void execInfoElements()
1866 info_mode = INFO_MODE_ELEMENTS;
1871 static void execInfoMusic()
1873 info_mode = INFO_MODE_MUSIC;
1878 static void execInfoCredits()
1880 info_mode = INFO_MODE_CREDITS;
1885 static void execInfoProgram()
1887 info_mode = INFO_MODE_PROGRAM;
1892 static void execInfoVersion()
1894 info_mode = INFO_MODE_VERSION;
1899 static void execInfoLevelSet()
1901 info_mode = INFO_MODE_LEVELSET;
1906 static void execExitInfo()
1908 game_status = GAME_MODE_MAIN;
1910 DrawMainMenuExt(REDRAW_FIELD, FALSE);
1913 static struct TokenInfo info_info_main[] =
1915 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
1916 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
1917 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
1918 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
1919 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
1920 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
1921 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
1922 { TYPE_EMPTY, NULL, "" },
1923 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
1928 static void DrawCursorAndText_Info(int pos, boolean active)
1930 int xpos = MENU_SCREEN_START_XPOS;
1931 int ypos = MENU_SCREEN_START_YPOS + pos;
1932 int font_nr = FONT_MENU_1;
1935 font_nr = FONT_ACTIVE(font_nr);
1937 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
1939 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
1940 drawCursor(pos, active);
1943 static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
1948 CloseDoor(DOOR_CLOSE_2);
1950 /* (needed after displaying title screens which disable auto repeat) */
1951 KeyboardAutoRepeatOn();
1953 FadeSetLeaveScreen();
1957 if (fade_mask == REDRAW_ALL)
1961 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1966 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
1968 info_info = info_info_main;
1971 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1973 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
1974 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
1975 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
1976 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
1977 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
1978 initCursor(i, IMG_MENU_BUTTON);
1980 DrawCursorAndText_Info(i, FALSE);
1985 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
1990 DrawMaskedBorder(fade_mask);
1997 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
1999 static int choice_store[MAX_INFO_MODES];
2000 int choice = choice_store[info_mode]; /* always starts with 0 */
2004 if (button == MB_MENU_INITIALIZE)
2006 /* advance to first valid menu entry */
2007 while (choice < num_info_info &&
2008 info_info[choice].type & TYPE_SKIP_ENTRY)
2010 choice_store[info_mode] = choice;
2012 DrawCursorAndText_Info(choice, TRUE);
2016 else if (button == MB_MENU_LEAVE)
2018 for (y = 0; y < num_info_info; y++)
2020 if (info_info[y].type & TYPE_LEAVE_MENU)
2022 void (*menu_callback_function)(void) = info_info[y].value;
2026 menu_callback_function();
2028 break; /* absolutely needed because function changes 'info_info'! */
2035 if (mx || my) /* mouse input */
2037 x = (mx - mSX) / 32;
2038 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2040 else if (dx || dy) /* keyboard input */
2044 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2046 if (info_info[choice].type & menu_navigation_type ||
2047 info_info[choice].type & TYPE_ENTER_SCREEN ||
2048 info_info[choice].type & TYPE_BOOLEAN_STYLE ||
2049 info_info[choice].type & TYPE_YES_NO_AUTO)
2050 button = MB_MENU_CHOICE;
2055 /* jump to next non-empty menu entry (up or down) */
2056 while (y > 0 && y < num_info_info - 1 &&
2057 info_info[y].type & TYPE_SKIP_ENTRY)
2061 if (IN_VIS_MENU(x, y) &&
2062 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2068 PlaySound(SND_MENU_ITEM_ACTIVATING);
2070 DrawCursorAndText_Info(choice, FALSE);
2071 DrawCursorAndText_Info(y, TRUE);
2073 choice = choice_store[info_mode] = y;
2076 else if (!(info_info[y].type & TYPE_GHOSTED))
2078 PlaySound(SND_MENU_ITEM_SELECTING);
2080 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2082 void (*menu_callback_function)(void) = info_info[choice].value;
2084 FadeSetFromType(info_info[y].type);
2086 menu_callback_function();
2092 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2094 int ystart1 = mSY - SY + 100;
2095 int ystart2 = mSY - SY + 150;
2096 int ybottom = mSY - SY + SYSIZE - 20;
2098 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO);
2100 FadeOut(REDRAW_FIELD);
2105 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2106 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2108 DrawTextSCentered(ybottom, FONT_TEXT_4,
2109 "Press any key or button for info menu");
2111 FadeIn(REDRAW_FIELD);
2114 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2116 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2117 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2118 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2119 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2120 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2121 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2122 int ystep = MENU_SCREEN_INFO_YSTEP;
2123 int element, action, direction;
2131 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2132 infoscreen_step[i] = infoscreen_frame[i] = 0;
2137 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2139 DrawTextSCentered(ybottom, FONT_TEXT_4,
2140 "Press any key or button for next page");
2146 while (helpanim_info[j].element != HELPANIM_LIST_END)
2148 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2153 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2162 j += infoscreen_step[i - start];
2164 element = helpanim_info[j].element;
2165 action = helpanim_info[j].action;
2166 direction = helpanim_info[j].direction;
2169 element = EL_UNKNOWN;
2171 if (action != -1 && direction != -1)
2172 graphic = el_act_dir2img(element, action, direction);
2173 else if (action != -1)
2174 graphic = el_act2img(element, action);
2175 else if (direction != -1)
2176 graphic = el_dir2img(element, direction);
2178 graphic = el2img(element);
2180 delay = helpanim_info[j++].delay;
2185 if (infoscreen_frame[i - start] == 0)
2188 infoscreen_frame[i - start] = delay - 1;
2192 sync_frame = delay - infoscreen_frame[i - start];
2193 infoscreen_frame[i - start]--;
2196 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2198 if (!infoscreen_frame[i - start])
2199 infoscreen_step[i - start] = 0;
2203 if (!infoscreen_frame[i - start])
2204 infoscreen_step[i - start]++;
2205 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2211 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2213 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2214 graphic, sync_frame, USE_MASKING);
2217 DrawInfoScreen_HelpText(element, action, direction, i - start);
2222 redraw_mask |= REDRAW_FIELD;
2227 static char *getHelpText(int element, int action, int direction)
2229 char token[MAX_LINE_LEN];
2231 strcpy(token, element_info[element].token_name);
2234 strcat(token, element_action_info[action].suffix);
2236 if (direction != -1)
2237 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2239 return getHashEntry(helptext_info, token);
2242 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2244 int font_nr = FONT_INFO_ELEMENTS;
2245 int font_width = getFontWidth(font_nr);
2246 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2247 int sy = mSY + 65 + 2 * 32 + 1;
2248 int ystep = TILEY + 4;
2249 int pad_x = sx - SX;
2250 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2251 int max_lines_per_text = 2;
2254 if (action != -1 && direction != -1) /* element.action.direction */
2255 text = getHelpText(element, action, direction);
2257 if (text == NULL && action != -1) /* element.action */
2258 text = getHelpText(element, action, -1);
2260 if (text == NULL && direction != -1) /* element.direction */
2261 text = getHelpText(element, -1, direction);
2263 if (text == NULL) /* base element */
2264 text = getHelpText(element, -1, -1);
2266 if (text == NULL) /* not found */
2267 text = "No description available";
2269 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2270 sy += getFontHeight(font_nr) / 2;
2272 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2273 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2274 TRUE, FALSE, FALSE);
2277 void DrawInfoScreen_TitleScreen()
2282 void HandleInfoScreen_TitleScreen(int button)
2284 HandleTitleScreen(0, 0, 0, 0, button);
2287 void DrawInfoScreen_Elements()
2289 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2291 FadeOut(REDRAW_FIELD);
2296 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2298 FadeIn(REDRAW_FIELD);
2303 void HandleInfoScreen_Elements(int button)
2305 static unsigned int info_delay = 0;
2306 static int num_anims;
2307 static int num_pages;
2309 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2312 if (button == MB_MENU_INITIALIZE)
2314 boolean new_element = TRUE;
2318 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2320 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2322 else if (new_element)
2325 new_element = FALSE;
2329 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2333 if (button == MB_MENU_LEAVE)
2335 PlaySound(SND_MENU_ITEM_SELECTING);
2337 info_mode = INFO_MODE_MAIN;
2342 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2344 if (button != MB_MENU_INITIALIZE)
2346 PlaySound(SND_MENU_ITEM_SELECTING);
2351 if (page >= num_pages)
2353 FadeSoundsAndMusic();
2355 info_mode = INFO_MODE_MAIN;
2356 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2362 FadeSetNextScreen();
2364 if (button != MB_MENU_INITIALIZE)
2365 FadeOut(REDRAW_FIELD);
2367 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2369 if (button != MB_MENU_INITIALIZE)
2370 FadeIn(REDRAW_FIELD);
2374 if (DelayReached(&info_delay, GameFrameDelay))
2375 if (page < num_pages)
2376 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2378 PlayMenuSoundIfLoop();
2382 void DrawInfoScreen_Music()
2384 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2386 FadeOut(REDRAW_FIELD);
2393 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2395 FadeIn(REDRAW_FIELD);
2398 void HandleInfoScreen_Music(int button)
2400 static struct MusicFileInfo *list = NULL;
2401 int ystart1 = mSY - SY + 100;
2402 int ystart2 = mSY - SY + 150;
2403 int ybottom = mSY - SY + SYSIZE - 20;
2406 if (button == MB_MENU_INITIALIZE)
2408 list = music_file_info;
2412 FadeSoundsAndMusic();
2417 DrawTextSCentered(ystart1, FONT_TEXT_1,
2418 "No music info for this level set.");
2420 DrawTextSCentered(ybottom, FONT_TEXT_4,
2421 "Press any key or button for info menu");
2427 if (button == MB_MENU_LEAVE)
2429 PlaySound(SND_MENU_ITEM_SELECTING);
2431 FadeSoundsAndMusic();
2433 info_mode = INFO_MODE_MAIN;
2438 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2442 if (button != MB_MENU_INITIALIZE)
2444 PlaySound(SND_MENU_ITEM_SELECTING);
2452 FadeSoundsAndMusic();
2454 info_mode = INFO_MODE_MAIN;
2455 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2460 FadeSoundsAndMusic();
2462 if (list != music_file_info)
2463 FadeSetNextScreen();
2465 if (button != MB_MENU_INITIALIZE)
2466 FadeOut(REDRAW_FIELD);
2473 int sound = list->music;
2475 if (sound_info[sound].loop)
2476 PlaySoundLoop(sound);
2480 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2484 PlayMusic(list->music);
2486 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2489 if (!strEqual(list->title, UNKNOWN_NAME))
2491 if (!strEqual(list->title_header, UNKNOWN_NAME))
2492 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2494 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2497 if (!strEqual(list->artist, UNKNOWN_NAME))
2499 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2500 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2502 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2504 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2507 if (!strEqual(list->album, UNKNOWN_NAME))
2509 if (!strEqual(list->album_header, UNKNOWN_NAME))
2510 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2512 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2514 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2517 if (!strEqual(list->year, UNKNOWN_NAME))
2519 if (!strEqual(list->year_header, UNKNOWN_NAME))
2520 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2522 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2524 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2527 DrawTextSCentered(ybottom, FONT_TEXT_4,
2528 "Press any key or button for next page");
2530 if (button != MB_MENU_INITIALIZE)
2531 FadeIn(REDRAW_FIELD);
2534 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2535 PlaySoundLoop(list->music);
2538 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2540 int ystart1 = mSY - SY + 100;
2541 int ystart2 = mSY - SY + 150;
2542 int ybottom = mSY - SY + SYSIZE - 20;
2548 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2552 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2553 "Special thanks to");
2554 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2556 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2558 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2559 "\"Boulder Dash\"");
2560 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2562 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2564 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2566 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2567 "First Star Software");
2569 else if (screen_nr == 1)
2571 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2572 "Special thanks to");
2573 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2574 "Klaus Heinz & Volker Wertich");
2575 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2577 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2578 "\"Emerald Mine\"");
2579 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2581 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2583 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2585 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2588 else if (screen_nr == 2)
2590 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2591 "Special thanks to");
2592 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2593 "Michael Stopp & Philip Jespersen");
2594 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2596 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2598 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2600 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2602 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2604 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2605 "Digital Integration");
2607 else if (screen_nr == 3)
2609 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2610 "Special thanks to");
2611 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2612 "Hiroyuki Imabayashi");
2613 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2615 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2617 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2619 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2621 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2623 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2626 else if (screen_nr == 4)
2628 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2629 "Special thanks to");
2630 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2632 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2634 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2635 "J\xfcrgen Bonhagen");
2636 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2637 "for the continuous creation");
2638 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2639 "of outstanding level sets");
2641 else if (screen_nr == 5)
2643 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2645 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2647 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2648 "for ideas and inspiration by");
2649 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2652 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2654 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2656 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2657 "for ideas and inspiration by");
2658 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2661 else if (screen_nr == 6)
2663 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2665 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2668 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2669 "for the code base used for the");
2670 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
2671 "native Emerald Mine engine");
2673 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2674 "for the new Emerald Mine engine");
2677 else if (screen_nr == 7)
2679 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2681 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2683 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2684 "for the initial DOS port");
2686 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2688 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2690 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2691 "for some additional toons");
2693 else if (screen_nr == 8)
2695 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2696 "And not to forget:");
2697 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2699 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2700 "All those who contributed");
2701 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2702 "levels to this game");
2703 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2707 DrawTextSCentered(ybottom, FONT_TEXT_4,
2708 "Press any key or button for next page");
2711 void DrawInfoScreen_Credits()
2713 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2715 FadeSoundsAndMusic();
2717 FadeOut(REDRAW_FIELD);
2719 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
2721 FadeIn(REDRAW_FIELD);
2724 void HandleInfoScreen_Credits(int button)
2726 static int screen_nr = 0;
2727 int num_screens = 9;
2729 if (button == MB_MENU_INITIALIZE)
2733 // DrawInfoScreen_CreditsScreen(screen_nr);
2736 if (button == MB_MENU_LEAVE)
2738 PlaySound(SND_MENU_ITEM_SELECTING);
2740 info_mode = INFO_MODE_MAIN;
2745 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2747 if (button != MB_MENU_INITIALIZE)
2749 PlaySound(SND_MENU_ITEM_SELECTING);
2754 if (screen_nr >= num_screens)
2756 FadeSoundsAndMusic();
2758 info_mode = INFO_MODE_MAIN;
2759 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2765 FadeSetNextScreen();
2767 if (button != MB_MENU_INITIALIZE)
2768 FadeOut(REDRAW_FIELD);
2770 DrawInfoScreen_CreditsScreen(screen_nr);
2772 if (button != MB_MENU_INITIALIZE)
2773 FadeIn(REDRAW_FIELD);
2777 PlayMenuSoundIfLoop();
2781 void DrawInfoScreen_Program()
2783 int ystart1 = mSY - SY + 100;
2784 int ystart2 = mSY - SY + 150;
2785 int ybottom = mSY - SY + SYSIZE - 20;
2788 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
2790 FadeOut(REDRAW_FIELD);
2795 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
2797 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2798 "This game is Freeware!");
2799 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2800 "If you like it, send e-mail to:");
2801 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2802 PROGRAM_EMAIL_STRING);
2803 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2804 "More information and levels:");
2805 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2806 PROGRAM_WEBSITE_STRING);
2807 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2808 "If you have created new levels,");
2809 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
2810 "send them to me to include them!");
2811 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
2814 DrawTextSCentered(ybottom, FONT_TEXT_4,
2815 "Press any key or button for info menu");
2817 FadeIn(REDRAW_FIELD);
2820 void HandleInfoScreen_Program(int button)
2822 if (button == MB_MENU_LEAVE)
2824 PlaySound(SND_MENU_ITEM_SELECTING);
2826 info_mode = INFO_MODE_MAIN;
2831 else if (button == MB_MENU_CHOICE)
2833 PlaySound(SND_MENU_ITEM_SELECTING);
2835 FadeSoundsAndMusic();
2837 info_mode = INFO_MODE_MAIN;
2838 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2842 PlayMenuSoundIfLoop();
2846 void DrawInfoScreen_Version()
2848 int font_header = FONT_TEXT_3;
2849 int font_text = FONT_TEXT_2;
2850 int xstep = getFontWidth(font_text);
2851 int ystep = getFontHeight(font_text);
2852 int ystart1 = mSY - SY + 100;
2853 int ystart2 = mSY - SY + 150;
2854 int ybottom = mSY - SY + SYSIZE - 20;
2855 int xstart1 = mSX - SX + 2 * xstep;
2856 int xstart2 = mSX - SX + 18 * xstep;
2857 int xstart3 = mSX - SX + 28 * xstep;
2858 SDL_version sdl_version_compiled;
2859 const SDL_version *sdl_version_linked;
2860 int driver_name_len = 10;
2861 #if defined(TARGET_SDL2)
2862 SDL_version sdl_version_linked_ext;
2863 const char *driver_name = NULL;
2865 char driver_name[driver_name_len];
2868 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
2870 FadeOut(REDRAW_FIELD);
2875 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
2877 DrawTextF(xstart1, ystart2, font_header, "Name");
2878 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
2881 DrawTextF(xstart1, ystart2, font_header, "Version");
2882 DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
2885 DrawTextF(xstart1, ystart2, font_header, "Platform");
2886 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
2889 DrawTextF(xstart1, ystart2, font_header, "Target");
2890 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
2893 DrawTextF(xstart1, ystart2, font_header, "Compile time");
2894 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
2896 ystart2 += 3 * ystep;
2897 DrawTextF(xstart1, ystart2, font_header, "Library");
2898 DrawTextF(xstart2, ystart2, font_header, "compiled");
2899 DrawTextF(xstart3, ystart2, font_header, "linked");
2901 SDL_VERSION(&sdl_version_compiled);
2902 #if defined(TARGET_SDL2)
2903 SDL_GetVersion(&sdl_version_linked_ext);
2904 sdl_version_linked = &sdl_version_linked_ext;
2906 sdl_version_linked = SDL_Linked_Version();
2909 ystart2 += 2 * ystep;
2910 DrawTextF(xstart1, ystart2, font_text, "SDL");
2911 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2912 sdl_version_compiled.major,
2913 sdl_version_compiled.minor,
2914 sdl_version_compiled.patch);
2915 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2916 sdl_version_linked->major,
2917 sdl_version_linked->minor,
2918 sdl_version_linked->patch);
2920 SDL_IMAGE_VERSION(&sdl_version_compiled);
2921 sdl_version_linked = IMG_Linked_Version();
2924 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
2925 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2926 sdl_version_compiled.major,
2927 sdl_version_compiled.minor,
2928 sdl_version_compiled.patch);
2929 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2930 sdl_version_linked->major,
2931 sdl_version_linked->minor,
2932 sdl_version_linked->patch);
2934 SDL_MIXER_VERSION(&sdl_version_compiled);
2935 sdl_version_linked = Mix_Linked_Version();
2938 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
2939 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2940 sdl_version_compiled.major,
2941 sdl_version_compiled.minor,
2942 sdl_version_compiled.patch);
2943 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2944 sdl_version_linked->major,
2945 sdl_version_linked->minor,
2946 sdl_version_linked->patch);
2948 SDL_NET_VERSION(&sdl_version_compiled);
2949 sdl_version_linked = SDLNet_Linked_Version();
2952 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
2953 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2954 sdl_version_compiled.major,
2955 sdl_version_compiled.minor,
2956 sdl_version_compiled.patch);
2957 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2958 sdl_version_linked->major,
2959 sdl_version_linked->minor,
2960 sdl_version_linked->patch);
2962 ystart2 += 3 * ystep;
2963 DrawTextF(xstart1, ystart2, font_header, "Driver");
2964 DrawTextF(xstart2, ystart2, font_header, "Requested");
2965 DrawTextF(xstart3, ystart2, font_header, "Used");
2967 #if defined(TARGET_SDL2)
2968 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
2970 SDL_VideoDriverName(driver_name, driver_name_len);
2973 ystart2 += 2 * ystep;
2974 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
2975 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
2976 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2978 #if defined(TARGET_SDL2)
2979 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
2981 SDL_AudioDriverName(driver_name, driver_name_len);
2985 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
2986 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
2987 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2989 DrawTextSCentered(ybottom, FONT_TEXT_4,
2990 "Press any key or button for info menu");
2992 FadeIn(REDRAW_FIELD);
2995 void HandleInfoScreen_Version(int button)
2997 if (button == MB_MENU_LEAVE)
2999 PlaySound(SND_MENU_ITEM_SELECTING);
3001 info_mode = INFO_MODE_MAIN;
3006 else if (button == MB_MENU_CHOICE)
3008 PlaySound(SND_MENU_ITEM_SELECTING);
3010 FadeSoundsAndMusic();
3012 info_mode = INFO_MODE_MAIN;
3013 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3017 PlayMenuSoundIfLoop();
3021 void DrawInfoScreen_LevelSet()
3023 struct TitleMessageInfo *tmi = &readme;
3024 char *filename = getLevelSetInfoFilename();
3025 char *title = "Level Set Information:";
3026 int ystart1 = mSY - SY + 100;
3027 int ybottom = mSY - SY + SYSIZE - 20;
3029 if (filename == NULL)
3031 DrawInfoScreen_NotAvailable(title, "No information for this level set.");
3036 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3038 FadeOut(REDRAW_FIELD);
3043 DrawTextSCentered(ystart1, FONT_TEXT_1, title);
3045 /* if x position set to "-1", automatically determine by playfield width */
3047 tmi->x = SXSIZE / 2;
3049 /* if y position set to "-1", use static default value */
3053 /* if width set to "-1", automatically determine by playfield width */
3054 if (tmi->width == -1)
3055 tmi->width = SXSIZE - 2 * TILEX;
3057 /* if height set to "-1", automatically determine by playfield height */
3058 if (tmi->height == -1)
3059 tmi->height = SYSIZE - 20 - tmi->y - 10;
3061 /* if chars set to "-1", automatically determine by text and font width */
3062 if (tmi->chars == -1)
3063 tmi->chars = tmi->width / getFontWidth(tmi->font);
3065 tmi->width = tmi->chars * getFontWidth(tmi->font);
3067 /* if lines set to "-1", automatically determine by text and font height */
3068 if (tmi->lines == -1)
3069 tmi->lines = tmi->height / getFontHeight(tmi->font);
3071 tmi->height = tmi->lines * getFontHeight(tmi->font);
3073 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3074 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3075 tmi->autowrap, tmi->centered, tmi->parse_comments);
3077 DrawTextSCentered(ybottom, FONT_TEXT_4,
3078 "Press any key or button for info menu");
3080 FadeIn(REDRAW_FIELD);
3083 void HandleInfoScreen_LevelSet(int button)
3085 if (button == MB_MENU_LEAVE)
3087 PlaySound(SND_MENU_ITEM_SELECTING);
3089 info_mode = INFO_MODE_MAIN;
3094 else if (button == MB_MENU_CHOICE)
3096 PlaySound(SND_MENU_ITEM_SELECTING);
3098 FadeSoundsAndMusic();
3100 info_mode = INFO_MODE_MAIN;
3101 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3105 PlayMenuSoundIfLoop();
3109 static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
3111 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3113 if (info_mode == INFO_MODE_TITLE)
3114 DrawInfoScreen_TitleScreen();
3115 else if (info_mode == INFO_MODE_ELEMENTS)
3116 DrawInfoScreen_Elements();
3117 else if (info_mode == INFO_MODE_MUSIC)
3118 DrawInfoScreen_Music();
3119 else if (info_mode == INFO_MODE_CREDITS)
3120 DrawInfoScreen_Credits();
3121 else if (info_mode == INFO_MODE_PROGRAM)
3122 DrawInfoScreen_Program();
3123 else if (info_mode == INFO_MODE_VERSION)
3124 DrawInfoScreen_Version();
3125 else if (info_mode == INFO_MODE_LEVELSET)
3126 DrawInfoScreen_LevelSet();
3128 DrawInfoScreen_Main(fade_mask, do_fading);
3130 if (info_mode != INFO_MODE_MAIN &&
3131 info_mode != INFO_MODE_TITLE &&
3132 info_mode != INFO_MODE_MUSIC)
3139 void DrawAndFadeInInfoScreen(int fade_mask)
3141 DrawInfoScreenExt(fade_mask, TRUE);
3144 void DrawInfoScreen()
3146 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3149 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3151 if (info_mode == INFO_MODE_TITLE)
3152 HandleInfoScreen_TitleScreen(button);
3153 else if (info_mode == INFO_MODE_ELEMENTS)
3154 HandleInfoScreen_Elements(button);
3155 else if (info_mode == INFO_MODE_MUSIC)
3156 HandleInfoScreen_Music(button);
3157 else if (info_mode == INFO_MODE_CREDITS)
3158 HandleInfoScreen_Credits(button);
3159 else if (info_mode == INFO_MODE_PROGRAM)
3160 HandleInfoScreen_Program(button);
3161 else if (info_mode == INFO_MODE_VERSION)
3162 HandleInfoScreen_Version(button);
3163 else if (info_mode == INFO_MODE_LEVELSET)
3164 HandleInfoScreen_LevelSet(button);
3166 HandleInfoScreen_Main(mx, my, dx, dy, button);
3170 /* ========================================================================= */
3171 /* type name functions */
3172 /* ========================================================================= */
3174 void HandleTypeName(int newxpos, Key key)
3176 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3177 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3178 struct TextPosInfo *pos = mci->pos_input;
3179 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3180 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3181 static int xpos = 0;
3182 int font_nr = pos->font;
3183 int font_active_nr = FONT_ACTIVE(font_nr);
3184 int font_width = getFontWidth(font_active_nr);
3185 char key_char = getValidConfigValueChar(getCharFromKey(key));
3186 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3187 boolean is_active = TRUE;
3189 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3193 strcpy(last_player_name, setup.player_name);
3197 #if defined(TARGET_SDL2)
3198 SDL_StartTextInput();
3201 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3203 setup.player_name[xpos] = key_char;
3204 setup.player_name[xpos + 1] = 0;
3208 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3212 setup.player_name[xpos] = 0;
3214 else if (key == KSYM_Return && xpos > 0)
3220 game_status = GAME_MODE_MAIN;
3222 else if (key == KSYM_Escape)
3224 strcpy(setup.player_name, last_player_name);
3228 game_status = GAME_MODE_MAIN;
3233 pos->width = (strlen(setup.player_name) + 1) * font_width;
3234 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3236 DrawText(startx, starty, setup.player_name, font_active_nr);
3237 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3241 pos->width = strlen(setup.player_name) * font_width;
3242 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3244 DrawText(startx, starty, setup.player_name, font_nr);
3246 #if defined(TARGET_SDL2)
3247 SDL_StopTextInput();
3253 /* ========================================================================= */
3254 /* tree menu functions */
3255 /* ========================================================================= */
3257 static void DrawChooseTree(TreeInfo **ti_ptr)
3259 int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
3263 FreeScreenGadgets();
3264 CreateScreenGadgets();
3266 CloseDoor(DOOR_CLOSE_2);
3272 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3273 MapScreenTreeGadgets(*ti_ptr);
3280 static void AdjustScrollbar(int id, int items_max, int items_visible,
3283 struct GadgetInfo *gi = screen_gadget[id];
3285 if (item_position > items_max - items_visible)
3286 item_position = items_max - items_visible;
3288 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3289 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3290 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3293 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3295 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3299 static void clearMenuListArea()
3301 int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3303 /* correct scrollbar position if placed outside menu (playfield) area */
3304 if (scrollbar_xpos > SX + SC_SCROLLBAR_XPOS)
3305 scrollbar_xpos = SX + SC_SCROLLBAR_XPOS;
3307 /* clear menu list area, but not title or scrollbar */
3308 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3309 scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
3312 static void drawChooseTreeList(int first_entry, int num_page_entries,
3316 char *title_string = NULL;
3317 int yoffset_sets = MENU_TITLE1_YPOS;
3318 int yoffset_setup = 16;
3319 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3320 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3321 int last_game_status = game_status; /* save current game status */
3323 title_string = ti->infotext;
3325 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3327 clearMenuListArea();
3329 for (i = 0; i < num_page_entries; i++)
3331 TreeInfo *node, *node_first;
3332 int entry_pos = first_entry + i;
3333 int xpos = MENU_SCREEN_START_XPOS;
3334 int ypos = MENU_SCREEN_START_YPOS + i;
3335 int startx = mSX + xpos * 32;
3336 int starty = mSY + ypos * 32;
3337 int font_nr = FONT_TEXT_1;
3338 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3339 int startx_text = startx + font_xoffset;
3340 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3341 int text_size = startx_scrollbar - startx_text;
3342 int max_buffer_len = text_size / getFontWidth(font_nr);
3343 char buffer[max_buffer_len + 1];
3345 node_first = getTreeInfoFirstGroupEntry(ti);
3346 node = getTreeInfoFromPos(node_first, entry_pos);
3348 strncpy(buffer, node->name, max_buffer_len);
3349 buffer[max_buffer_len] = '\0';
3351 DrawText(startx, starty, buffer, font_nr + node->color);
3353 if (node->parent_link)
3354 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3355 else if (node->level_group)
3356 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3358 initCursor(i, IMG_MENU_BUTTON);
3361 game_status = last_game_status; /* restore current game status */
3363 redraw_mask |= REDRAW_FIELD;
3366 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3368 TreeInfo *node, *node_first;
3369 int x, last_redraw_mask = redraw_mask;
3370 int ypos = MENU_TITLE2_YPOS;
3371 int font_nr = FONT_TITLE_2;
3373 if (ti->type == TREE_TYPE_LEVEL_NR)
3374 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3376 if (ti->type != TREE_TYPE_LEVEL_DIR)
3379 node_first = getTreeInfoFirstGroupEntry(ti);
3380 node = getTreeInfoFromPos(node_first, entry_pos);
3382 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3384 if (node->parent_link)
3385 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3386 node->node_parent->name);
3387 else if (node->level_group)
3388 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3390 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3391 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3392 node->levels, (node->levels > 1 ? "levels" : "level"),
3395 /* let BackToFront() redraw only what is needed */
3396 redraw_mask = last_redraw_mask | REDRAW_TILES;
3397 for (x = 0; x < SCR_FIELDX; x++)
3398 MarkTileDirty(x, 1);
3401 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3404 TreeInfo *ti = *ti_ptr;
3406 int y = ti->cl_cursor;
3407 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3408 int num_entries = numTreeInfoInGroup(ti);
3409 int num_page_entries;
3410 int last_game_status = game_status; /* save current game status */
3411 boolean position_set_by_scrollbar = (dx == 999);
3413 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3414 num_page_entries = num_entries;
3416 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3418 game_status = last_game_status; /* restore current game status */
3420 if (button == MB_MENU_INITIALIZE)
3422 int num_entries = numTreeInfoInGroup(ti);
3423 int entry_pos = posTreeInfo(ti);
3425 if (ti->cl_first == -1)
3427 /* only on initialization */
3428 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3429 ti->cl_cursor = entry_pos - ti->cl_first;
3431 else if (ti->cl_cursor >= num_page_entries ||
3432 (num_entries > num_page_entries &&
3433 num_entries - ti->cl_first < num_page_entries))
3435 /* only after change of list size (by custom graphic configuration) */
3436 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3437 ti->cl_cursor = entry_pos - ti->cl_first;
3440 if (position_set_by_scrollbar)
3443 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3446 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3447 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3448 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3452 else if (button == MB_MENU_LEAVE)
3456 PlaySound(SND_MENU_ITEM_SELECTING);
3458 if (ti->node_parent)
3460 *ti_ptr = ti->node_parent;
3461 DrawChooseTree(ti_ptr);
3463 else if (game_status == GAME_MODE_SETUP)
3465 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3466 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3468 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3469 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3470 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3471 execSetupGraphics();
3472 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3473 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3474 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3476 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3477 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3478 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3485 if (game_status == GAME_MODE_LEVELNR)
3487 int new_level_nr = atoi(level_number_current->identifier);
3489 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
3492 game_status = GAME_MODE_MAIN;
3494 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3500 if (mx || my) /* mouse input */
3502 int last_game_status = game_status; /* save current game status */
3504 x = (mx - mSX) / 32;
3505 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3507 game_status = last_game_status; /* restore current game status */
3509 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3511 /* move cursor instead of scrolling when already at start/end of list */
3512 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3514 else if (dy == +1 * SCROLL_LINE &&
3515 ti->cl_first + num_page_entries == num_entries)
3518 /* handle scrolling screen one line or page */
3519 if (ti->cl_cursor + dy < 0 ||
3520 ti->cl_cursor + dy > num_page_entries - 1)
3522 boolean redraw = FALSE;
3524 if (ABS(dy) == SCROLL_PAGE)
3525 step = num_page_entries - 1;
3527 if (dy < 0 && ti->cl_first > 0)
3529 /* scroll page/line up */
3531 ti->cl_first -= step;
3532 if (ti->cl_first < 0)
3537 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3539 /* scroll page/line down */
3541 ti->cl_first += step;
3542 if (ti->cl_first + num_page_entries > num_entries)
3543 ti->cl_first = MAX(0, num_entries - num_page_entries);
3550 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3551 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3552 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3554 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3562 /* handle moving cursor one line */
3563 y = ti->cl_cursor + dy;
3568 TreeInfo *node_first, *node_cursor;
3569 int entry_pos = ti->cl_first + y;
3571 node_first = getTreeInfoFirstGroupEntry(ti);
3572 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3574 if (node_cursor->node_group)
3578 PlaySound(SND_MENU_ITEM_SELECTING);
3580 node_cursor->cl_first = ti->cl_first;
3581 node_cursor->cl_cursor = ti->cl_cursor;
3582 *ti_ptr = node_cursor->node_group;
3583 DrawChooseTree(ti_ptr);
3588 else if (dx == -1 && ti->node_parent)
3592 PlaySound(SND_MENU_ITEM_SELECTING);
3594 *ti_ptr = ti->node_parent;
3595 DrawChooseTree(ti_ptr);
3600 if (!anyScrollbarGadgetActive() &&
3601 IN_VIS_MENU(x, y) &&
3602 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3603 y >= 0 && y < num_page_entries)
3607 if (y != ti->cl_cursor)
3609 PlaySound(SND_MENU_ITEM_ACTIVATING);
3611 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3612 drawChooseTreeCursor(y, TRUE);
3613 drawChooseTreeInfo(ti->cl_first + y, ti);
3620 TreeInfo *node_first, *node_cursor;
3621 int entry_pos = ti->cl_first + y;
3623 PlaySound(SND_MENU_ITEM_SELECTING);
3625 node_first = getTreeInfoFirstGroupEntry(ti);
3626 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3628 if (node_cursor->node_group)
3632 node_cursor->cl_first = ti->cl_first;
3633 node_cursor->cl_cursor = ti->cl_cursor;
3634 *ti_ptr = node_cursor->node_group;
3635 DrawChooseTree(ti_ptr);
3637 else if (node_cursor->parent_link)
3641 *ti_ptr = node_cursor->node_parent;
3642 DrawChooseTree(ti_ptr);
3648 node_cursor->cl_first = ti->cl_first;
3649 node_cursor->cl_cursor = ti->cl_cursor;
3650 *ti_ptr = node_cursor;
3652 if (ti->type == TREE_TYPE_LEVEL_DIR)
3654 LoadLevelSetup_SeriesInfo();
3656 SaveLevelSetup_LastSeries();
3657 SaveLevelSetup_SeriesInfo();
3661 if (game_status == GAME_MODE_SETUP)
3663 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3664 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3666 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3667 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3668 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3669 execSetupGraphics();
3670 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3671 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3672 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3674 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3675 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3676 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3683 if (game_status == GAME_MODE_LEVELNR)
3685 int new_level_nr = atoi(level_number_current->identifier);
3687 HandleMainMenu_SelectLevel(0, 0, new_level_nr);
3690 game_status = GAME_MODE_MAIN;
3699 void DrawChooseLevelSet()
3701 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3703 DrawChooseTree(&leveldir_current);
3709 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
3711 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
3714 void DrawChooseLevelNr()
3718 if (level_number != NULL)
3720 freeTreeInfo(level_number);
3722 level_number = NULL;
3725 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
3727 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
3728 char identifier[32], name[32];
3731 /* temporarily load level info to get level name */
3732 LoadLevelInfoOnly(i);
3734 ti->node_top = &level_number;
3735 ti->sort_priority = 10000 + value;
3736 ti->color = (level.no_valid_file ? FC_BLUE :
3737 LevelStats_getSolved(i) ? FC_GREEN :
3738 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
3740 sprintf(identifier, "%d", value);
3741 sprintf(name, "%03d: %s", value,
3742 (level.no_valid_file ? "(no file)" : level.name));
3744 setString(&ti->identifier, identifier);
3745 setString(&ti->name, name);
3746 setString(&ti->name_sorting, name);
3748 pushTreeInfo(&level_number, ti);
3751 /* sort level number values to start with lowest level number */
3752 sortTreeInfo(&level_number);
3754 /* set current level number to current level number */
3755 level_number_current =
3756 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
3758 /* if that also fails, set current level number to first available level */
3759 if (level_number_current == NULL)
3760 level_number_current = level_number;
3762 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3764 DrawChooseTree(&level_number_current);
3770 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
3772 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
3775 void DrawHallOfFame(int highlight_position)
3777 int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
3780 FadeSoundsAndMusic();
3782 /* (this is needed when called from GameEnd() after winning a game) */
3783 KeyboardAutoRepeatOn();
3786 /* (this is needed when called from GameEnd() after winning a game) */
3787 SetDrawDeactivationMask(REDRAW_NONE);
3788 SetDrawBackgroundMask(REDRAW_FIELD);
3790 CloseDoor(DOOR_CLOSE_2);
3792 if (highlight_position < 0)
3793 LoadScore(level_nr);
3795 FadeSetEnterScreen();
3804 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
3809 static void drawHallOfFameList(int first_entry, int highlight_position)
3813 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
3816 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
3817 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
3818 "HighScores of Level %d", level_nr);
3820 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
3822 int entry = first_entry + i;
3823 boolean active = (entry == highlight_position);
3824 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
3825 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
3826 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
3827 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
3828 int dx1 = 3 * getFontWidth(font_nr1);
3829 int dx2 = dx1 + getFontWidth(font_nr1);
3830 int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
3831 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
3832 int sy = mSY + 64 + i * 32;
3834 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
3835 DrawText(mSX + dx1, sy, ".", font_nr1);
3837 for (j = 0; j < num_dots; j++)
3838 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
3840 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
3841 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
3843 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
3846 redraw_mask |= REDRAW_FIELD;
3849 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
3851 static int first_entry = 0;
3852 static int highlight_position = 0;
3853 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3855 if (button == MB_MENU_INITIALIZE)
3858 highlight_position = mx;
3859 drawHallOfFameList(first_entry, highlight_position);
3864 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
3865 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
3869 if (first_entry > 0)
3871 first_entry -= step;
3872 if (first_entry < 0)
3875 drawHallOfFameList(first_entry, highlight_position);
3880 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
3882 first_entry += step;
3883 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
3884 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
3886 drawHallOfFameList(first_entry, highlight_position);
3889 else if (button == MB_MENU_LEAVE)
3891 PlaySound(SND_MENU_ITEM_SELECTING);
3893 FadeSound(SND_BACKGROUND_SCORES);
3895 game_status = GAME_MODE_MAIN;
3899 else if (button == MB_MENU_CHOICE)
3901 PlaySound(SND_MENU_ITEM_SELECTING);
3903 FadeSound(SND_BACKGROUND_SCORES);
3905 game_status = GAME_MODE_MAIN;
3907 DrawAndFadeInMainMenu(REDRAW_FIELD);
3910 if (game_status == GAME_MODE_SCORES)
3911 PlayMenuSoundIfLoop();
3915 /* ========================================================================= */
3916 /* setup screen functions */
3917 /* ========================================================================= */
3919 static struct TokenInfo *setup_info;
3920 static int num_setup_info; /* number of setup entries shown on screen */
3921 static int max_setup_info; /* total number of setup entries in list */
3923 static char *screen_mode_text;
3924 static char *window_size_text;
3925 static char *scaling_type_text;
3926 static char *scroll_delay_text;
3927 static char *game_speed_text;
3928 static char *graphics_set_name;
3929 static char *sounds_set_name;
3930 static char *music_set_name;
3931 static char *volume_simple_text;
3932 static char *volume_loops_text;
3933 static char *volume_music_text;
3934 static char *touch_controls_text;
3935 static char *move_distance_text;
3936 static char *drop_distance_text;
3938 static void execSetupMain()
3940 setup_mode = SETUP_MODE_MAIN;
3945 static void execSetupGame_setGameSpeeds()
3947 if (game_speeds == NULL)
3951 for (i = 0; game_speeds_list[i].value != -1; i++)
3953 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3954 char identifier[32], name[32];
3955 int value = game_speeds_list[i].value;
3956 char *text = game_speeds_list[i].text;
3958 ti->node_top = &game_speeds;
3959 ti->sort_priority = 10000 - value;
3961 sprintf(identifier, "%d", value);
3962 sprintf(name, "%s", text);
3964 setString(&ti->identifier, identifier);
3965 setString(&ti->name, name);
3966 setString(&ti->name_sorting, name);
3967 setString(&ti->infotext, "Game Speed");
3969 pushTreeInfo(&game_speeds, ti);
3972 /* sort game speed values to start with slowest game speed */
3973 sortTreeInfo(&game_speeds);
3975 /* set current game speed to configured game speed value */
3976 game_speed_current =
3977 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
3979 /* if that fails, set current game speed to reliable default value */
3980 if (game_speed_current == NULL)
3981 game_speed_current =
3982 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
3984 /* if that also fails, set current game speed to first available speed */
3985 if (game_speed_current == NULL)
3986 game_speed_current = game_speeds;
3989 setup.game_frame_delay = atoi(game_speed_current->identifier);
3991 /* needed for displaying game speed text instead of identifier */
3992 game_speed_text = game_speed_current->name;
3995 static void execSetupGame_setScrollDelays()
3997 if (scroll_delays == NULL)
4001 for (i = 0; scroll_delays_list[i].value != -1; i++)
4003 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4004 char identifier[32], name[32];
4005 int value = scroll_delays_list[i].value;
4006 char *text = scroll_delays_list[i].text;
4008 ti->node_top = &scroll_delays;
4009 ti->sort_priority = value;
4011 sprintf(identifier, "%d", value);
4012 sprintf(name, "%s", text);
4014 setString(&ti->identifier, identifier);
4015 setString(&ti->name, name);
4016 setString(&ti->name_sorting, name);
4017 setString(&ti->infotext, "Scaling Type");
4019 pushTreeInfo(&scroll_delays, ti);
4022 /* sort scaling type values to start with lowest scaling type value */
4023 sortTreeInfo(&scroll_delays);
4025 /* set current scaling type value to configured scaling type value */
4026 scroll_delay_current =
4027 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4029 /* if that fails, set current scaling type to reliable default value */
4030 if (scroll_delay_current == NULL)
4031 scroll_delay_current =
4032 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4034 /* if that also fails, set current scaling type to first available value */
4035 if (scroll_delay_current == NULL)
4036 scroll_delay_current = scroll_delays;
4039 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4041 /* needed for displaying scaling type text instead of identifier */
4042 scroll_delay_text = scroll_delay_current->name;
4045 static void execSetupGame()
4047 execSetupGame_setGameSpeeds();
4048 execSetupGame_setScrollDelays();
4050 setup_mode = SETUP_MODE_GAME;
4055 static void execSetupChooseGameSpeed()
4057 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4062 static void execSetupChooseScrollDelay()
4064 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4069 static void execSetupEditor()
4071 setup_mode = SETUP_MODE_EDITOR;
4076 static void execSetupGraphics_setWindowSizes(boolean update_list)
4078 if (window_sizes != NULL && update_list)
4080 freeTreeInfo(window_sizes);
4082 window_sizes = NULL;
4085 if (window_sizes == NULL)
4087 boolean current_window_size_found = FALSE;
4090 for (i = 0; window_sizes_list[i].value != -1; i++)
4092 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4093 char identifier[32], name[32];
4094 int value = window_sizes_list[i].value;
4095 char *text = window_sizes_list[i].text;
4097 ti->node_top = &window_sizes;
4098 ti->sort_priority = value;
4100 sprintf(identifier, "%d", value);
4101 sprintf(name, "%s", text);
4103 setString(&ti->identifier, identifier);
4104 setString(&ti->name, name);
4105 setString(&ti->name_sorting, name);
4106 setString(&ti->infotext, "Window Scaling");
4108 pushTreeInfo(&window_sizes, ti);
4110 if (value == setup.window_scaling_percent)
4111 current_window_size_found = TRUE;
4114 if (!current_window_size_found)
4116 // add entry for non-preset window scaling value
4118 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4119 char identifier[32], name[32];
4120 int value = setup.window_scaling_percent;
4122 ti->node_top = &window_sizes;
4123 ti->sort_priority = value;
4125 sprintf(identifier, "%d", value);
4126 sprintf(name, "%d %% (Current)", value);
4128 setString(&ti->identifier, identifier);
4129 setString(&ti->name, name);
4130 setString(&ti->name_sorting, name);
4131 setString(&ti->infotext, "Window Scaling");
4133 pushTreeInfo(&window_sizes, ti);
4136 /* sort window size values to start with lowest window size value */
4137 sortTreeInfo(&window_sizes);
4139 /* set current window size value to configured window size value */
4140 window_size_current =
4141 getTreeInfoFromIdentifier(window_sizes,
4142 i_to_a(setup.window_scaling_percent));
4144 /* if that fails, set current window size to reliable default value */
4145 if (window_size_current == NULL)
4146 window_size_current =
4147 getTreeInfoFromIdentifier(window_sizes,
4148 i_to_a(STD_WINDOW_SCALING_PERCENT));
4150 /* if that also fails, set current window size to first available value */
4151 if (window_size_current == NULL)
4152 window_size_current = window_sizes;
4155 setup.window_scaling_percent = atoi(window_size_current->identifier);
4157 /* needed for displaying window size text instead of identifier */
4158 window_size_text = window_size_current->name;
4161 static void execSetupGraphics_setScalingTypes()
4163 if (scaling_types == NULL)
4167 for (i = 0; scaling_types_list[i].value != NULL; i++)
4169 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4170 char identifier[32], name[32];
4171 char *value = scaling_types_list[i].value;
4172 char *text = scaling_types_list[i].text;
4174 ti->node_top = &scaling_types;
4175 ti->sort_priority = i;
4177 sprintf(identifier, "%s", value);
4178 sprintf(name, "%s", text);
4180 setString(&ti->identifier, identifier);
4181 setString(&ti->name, name);
4182 setString(&ti->name_sorting, name);
4183 setString(&ti->infotext, "Anti-Aliasing");
4185 pushTreeInfo(&scaling_types, ti);
4188 /* sort scaling type values to start with lowest scaling type value */
4189 sortTreeInfo(&scaling_types);
4191 /* set current scaling type value to configured scaling type value */
4192 scaling_type_current =
4193 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4195 /* if that fails, set current scaling type to reliable default value */
4196 if (scaling_type_current == NULL)
4197 scaling_type_current =
4198 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4200 /* if that also fails, set current scaling type to first available value */
4201 if (scaling_type_current == NULL)
4202 scaling_type_current = scaling_types;
4205 setup.window_scaling_quality = scaling_type_current->identifier;
4207 /* needed for displaying scaling type text instead of identifier */
4208 scaling_type_text = scaling_type_current->name;
4211 static void execSetupGraphics_setScreenModes()
4213 // if (screen_modes == NULL && video.fullscreen_available)
4214 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4218 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4220 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4221 char identifier[32], name[32];
4222 int x = video.fullscreen_modes[i].width;
4223 int y = video.fullscreen_modes[i].height;
4226 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4228 ti->node_top = &screen_modes;
4229 ti->sort_priority = x * 10000 + y;
4231 sprintf(identifier, "%dx%d", x, y);
4232 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4234 setString(&ti->identifier, identifier);
4235 setString(&ti->name, name);
4236 setString(&ti->name_sorting, name);
4237 setString(&ti->infotext, "Fullscreen Mode");
4239 pushTreeInfo(&screen_modes, ti);
4242 /* sort fullscreen modes to start with lowest available screen resolution */
4243 sortTreeInfo(&screen_modes);
4245 /* set current screen mode for fullscreen mode to configured setup value */
4246 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4247 setup.fullscreen_mode);
4249 /* if that fails, set current screen mode to reliable default value */
4250 if (screen_mode_current == NULL)
4251 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4252 DEFAULT_FULLSCREEN_MODE);
4254 /* if that also fails, set current screen mode to first available mode */
4255 if (screen_mode_current == NULL)
4256 screen_mode_current = screen_modes;
4258 if (screen_mode_current == NULL)
4259 video.fullscreen_available = FALSE;
4262 // if (video.fullscreen_available)
4263 if (screen_mode_current != NULL)
4265 setup.fullscreen_mode = screen_mode_current->identifier;
4267 /* needed for displaying screen mode name instead of identifier */
4268 screen_mode_text = screen_mode_current->name;
4272 static void execSetupGraphics()
4274 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4276 // update "setup.window_scaling_percent" from list selection
4277 execSetupGraphics_setWindowSizes(FALSE);
4281 // update list selection from "setup.window_scaling_percent"
4282 execSetupGraphics_setWindowSizes(TRUE);
4285 execSetupGraphics_setScalingTypes();
4286 execSetupGraphics_setScreenModes();
4288 setup_mode = SETUP_MODE_GRAPHICS;
4292 #if defined(TARGET_SDL2)
4293 // window scaling may have changed at this point
4294 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4296 // window scaling quality may have changed at this point
4297 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4298 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4302 #if !defined(PLATFORM_ANDROID)
4303 #if defined(TARGET_SDL2)
4304 static void execSetupChooseWindowSize()
4306 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4311 static void execSetupChooseScalingType()
4313 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4318 static void execSetupChooseScreenMode()
4320 if (!video.fullscreen_available)
4323 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4330 static void execSetupChooseVolumeSimple()
4332 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4337 static void execSetupChooseVolumeLoops()
4339 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4344 static void execSetupChooseVolumeMusic()
4346 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4351 static void execSetupSound()
4353 if (volumes_simple == NULL)
4357 for (i = 0; volumes_list[i].value != -1; i++)
4359 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4360 char identifier[32], name[32];
4361 int value = volumes_list[i].value;
4362 char *text = volumes_list[i].text;
4364 ti->node_top = &volumes_simple;
4365 ti->sort_priority = value;
4367 sprintf(identifier, "%d", value);
4368 sprintf(name, "%s", text);
4370 setString(&ti->identifier, identifier);
4371 setString(&ti->name, name);
4372 setString(&ti->name_sorting, name);
4373 setString(&ti->infotext, "Sound Volume");
4375 pushTreeInfo(&volumes_simple, ti);
4378 /* sort volume values to start with lowest volume value */
4379 sortTreeInfo(&volumes_simple);
4381 /* set current volume value to configured volume value */
4382 volume_simple_current =
4383 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4385 /* if that fails, set current volume to reliable default value */
4386 if (volume_simple_current == NULL)
4387 volume_simple_current =
4388 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4390 /* if that also fails, set current volume to first available value */
4391 if (volume_simple_current == NULL)
4392 volume_simple_current = volumes_simple;
4395 if (volumes_loops == NULL)
4399 for (i = 0; volumes_list[i].value != -1; i++)
4401 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4402 char identifier[32], name[32];
4403 int value = volumes_list[i].value;
4404 char *text = volumes_list[i].text;
4406 ti->node_top = &volumes_loops;
4407 ti->sort_priority = value;
4409 sprintf(identifier, "%d", value);
4410 sprintf(name, "%s", text);
4412 setString(&ti->identifier, identifier);
4413 setString(&ti->name, name);
4414 setString(&ti->name_sorting, name);
4415 setString(&ti->infotext, "Loops Volume");
4417 pushTreeInfo(&volumes_loops, ti);
4420 /* sort volume values to start with lowest volume value */
4421 sortTreeInfo(&volumes_loops);
4423 /* set current volume value to configured volume value */
4424 volume_loops_current =
4425 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4427 /* if that fails, set current volume to reliable default value */
4428 if (volume_loops_current == NULL)
4429 volume_loops_current =
4430 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4432 /* if that also fails, set current volume to first available value */
4433 if (volume_loops_current == NULL)
4434 volume_loops_current = volumes_loops;
4437 if (volumes_music == NULL)
4441 for (i = 0; volumes_list[i].value != -1; i++)
4443 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4444 char identifier[32], name[32];
4445 int value = volumes_list[i].value;
4446 char *text = volumes_list[i].text;
4448 ti->node_top = &volumes_music;
4449 ti->sort_priority = value;
4451 sprintf(identifier, "%d", value);
4452 sprintf(name, "%s", text);
4454 setString(&ti->identifier, identifier);
4455 setString(&ti->name, name);
4456 setString(&ti->name_sorting, name);
4457 setString(&ti->infotext, "Music Volume");
4459 pushTreeInfo(&volumes_music, ti);
4462 /* sort volume values to start with lowest volume value */
4463 sortTreeInfo(&volumes_music);
4465 /* set current volume value to configured volume value */
4466 volume_music_current =
4467 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4469 /* if that fails, set current volume to reliable default value */
4470 if (volume_music_current == NULL)
4471 volume_music_current =
4472 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4474 /* if that also fails, set current volume to first available value */
4475 if (volume_music_current == NULL)
4476 volume_music_current = volumes_music;
4479 setup.volume_simple = atoi(volume_simple_current->identifier);
4480 setup.volume_loops = atoi(volume_loops_current->identifier);
4481 setup.volume_music = atoi(volume_music_current->identifier);
4483 /* needed for displaying volume text instead of identifier */
4484 volume_simple_text = volume_simple_current->name;
4485 volume_loops_text = volume_loops_current->name;
4486 volume_music_text = volume_music_current->name;
4488 setup_mode = SETUP_MODE_SOUND;
4493 static void execSetupChooseTouchControls()
4495 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4500 static void execSetupChooseMoveDistance()
4502 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4507 static void execSetupChooseDropDistance()
4509 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4514 static void execSetupTouch()
4516 if (touch_controls == NULL)
4520 for (i = 0; touch_controls_list[i].value != NULL; i++)
4522 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4523 char identifier[32], name[32];
4524 char *value = touch_controls_list[i].value;
4525 char *text = touch_controls_list[i].text;
4527 ti->node_top = &touch_controls;
4528 ti->sort_priority = i;
4530 sprintf(identifier, "%s", value);
4531 sprintf(name, "%s", text);
4533 setString(&ti->identifier, identifier);
4534 setString(&ti->name, name);
4535 setString(&ti->name_sorting, name);
4536 setString(&ti->infotext, "Control Type");
4538 pushTreeInfo(&touch_controls, ti);
4541 /* sort touch control values to start with lowest touch control value */
4542 sortTreeInfo(&touch_controls);
4544 /* set current touch control value to configured touch control value */
4545 touch_control_current =
4546 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4548 /* if that fails, set current touch control to reliable default value */
4549 if (touch_control_current == NULL)
4550 touch_control_current =
4551 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4553 /* if that also fails, set current touch control to first available value */
4554 if (touch_control_current == NULL)
4555 touch_control_current = touch_controls;
4558 if (move_distances == NULL)
4562 for (i = 0; distances_list[i].value != -1; i++)
4564 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4565 char identifier[32], name[32];
4566 int value = distances_list[i].value;
4567 char *text = distances_list[i].text;
4569 ti->node_top = &move_distances;
4570 ti->sort_priority = value;
4572 sprintf(identifier, "%d", value);
4573 sprintf(name, "%s", text);
4575 setString(&ti->identifier, identifier);
4576 setString(&ti->name, name);
4577 setString(&ti->name_sorting, name);
4578 setString(&ti->infotext, "Move Distance");
4580 pushTreeInfo(&move_distances, ti);
4583 /* sort distance values to start with lowest distance value */
4584 sortTreeInfo(&move_distances);
4586 /* set current distance value to configured distance value */
4587 move_distance_current =
4588 getTreeInfoFromIdentifier(move_distances,
4589 i_to_a(setup.touch.move_distance));
4591 /* if that fails, set current distance to reliable default value */
4592 if (move_distance_current == NULL)
4593 move_distance_current =
4594 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4596 /* if that also fails, set current distance to first available value */
4597 if (move_distance_current == NULL)
4598 move_distance_current = move_distances;
4601 if (drop_distances == NULL)
4605 for (i = 0; distances_list[i].value != -1; i++)
4607 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4608 char identifier[32], name[32];
4609 int value = distances_list[i].value;
4610 char *text = distances_list[i].text;
4612 ti->node_top = &drop_distances;
4613 ti->sort_priority = value;
4615 sprintf(identifier, "%d", value);
4616 sprintf(name, "%s", text);
4618 setString(&ti->identifier, identifier);
4619 setString(&ti->name, name);
4620 setString(&ti->name_sorting, name);
4621 setString(&ti->infotext, "Drop Distance");
4623 pushTreeInfo(&drop_distances, ti);
4626 /* sort distance values to start with lowest distance value */
4627 sortTreeInfo(&drop_distances);
4629 /* set current distance value to configured distance value */
4630 drop_distance_current =
4631 getTreeInfoFromIdentifier(drop_distances,
4632 i_to_a(setup.touch.drop_distance));
4634 /* if that fails, set current distance to reliable default value */
4635 if (drop_distance_current == NULL)
4636 drop_distance_current =
4637 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
4639 /* if that also fails, set current distance to first available value */
4640 if (drop_distance_current == NULL)
4641 drop_distance_current = drop_distances;
4644 setup.touch.control_type = touch_control_current->identifier;
4645 setup.touch.move_distance = atoi(move_distance_current->identifier);
4646 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
4648 /* needed for displaying volume text instead of identifier */
4649 touch_controls_text = touch_control_current->name;
4650 move_distance_text = move_distance_current->name;
4651 drop_distance_text = drop_distance_current->name;
4653 setup_mode = SETUP_MODE_TOUCH;
4658 static void execSetupArtwork()
4661 printf("::: '%s', '%s', '%s'\n",
4662 artwork.gfx_current->subdir,
4663 artwork.gfx_current->fullpath,
4664 artwork.gfx_current->basepath);
4667 setup.graphics_set = artwork.gfx_current->identifier;
4668 setup.sounds_set = artwork.snd_current->identifier;
4669 setup.music_set = artwork.mus_current->identifier;
4671 /* needed if last screen (setup choice) changed graphics, sounds or music */
4672 ReloadCustomArtwork(0);
4674 /* needed for displaying artwork name instead of artwork identifier */
4675 graphics_set_name = artwork.gfx_current->name;
4676 sounds_set_name = artwork.snd_current->name;
4677 music_set_name = artwork.mus_current->name;
4679 setup_mode = SETUP_MODE_ARTWORK;
4684 static void execSetupChooseGraphics()
4686 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4691 static void execSetupChooseSounds()
4693 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4698 static void execSetupChooseMusic()
4700 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4705 #if !defined(PLATFORM_ANDROID)
4706 static void execSetupInput()
4708 setup_mode = SETUP_MODE_INPUT;
4714 static void execSetupShortcuts()
4716 setup_mode = SETUP_MODE_SHORTCUTS;
4721 static void execSetupShortcuts1()
4723 setup_mode = SETUP_MODE_SHORTCUTS_1;
4728 static void execSetupShortcuts2()
4730 setup_mode = SETUP_MODE_SHORTCUTS_2;
4735 static void execSetupShortcuts3()
4737 setup_mode = SETUP_MODE_SHORTCUTS_3;
4742 static void execSetupShortcuts4()
4744 setup_mode = SETUP_MODE_SHORTCUTS_4;
4749 static void execSetupShortcuts5()
4751 setup_mode = SETUP_MODE_SHORTCUTS_5;
4756 static void execExitSetup()
4758 game_status = GAME_MODE_MAIN;
4760 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4763 static void execSaveAndExitSetup()
4769 static struct TokenInfo setup_info_main[] =
4771 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4772 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4773 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4774 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4775 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4776 #if !defined(PLATFORM_ANDROID)
4777 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4778 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4780 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4782 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
4783 { TYPE_EMPTY, NULL, "" },
4784 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4785 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4790 static struct TokenInfo setup_info_game[] =
4792 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4793 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4794 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4795 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4796 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4797 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4798 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4799 { TYPE_STRING, &game_speed_text, "" },
4801 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4802 { TYPE_STRING, &scroll_delay_text, "" },
4804 { TYPE_EMPTY, NULL, "" },
4805 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4810 static struct TokenInfo setup_info_editor[] =
4813 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4814 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4815 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4816 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4817 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4818 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4819 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4820 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4822 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4823 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4824 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4826 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4828 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4829 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4830 { TYPE_EMPTY, NULL, "" },
4832 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4833 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4834 { TYPE_EMPTY, NULL, "" },
4836 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4837 { TYPE_EMPTY, NULL, "" },
4838 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4843 static struct TokenInfo setup_info_graphics[] =
4845 #if !defined(PLATFORM_ANDROID)
4846 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4847 #if defined(TARGET_SDL2)
4848 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
4849 { TYPE_STRING, &window_size_text, "" },
4850 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
4851 { TYPE_STRING, &scaling_type_text, "" },
4853 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4854 { TYPE_STRING, &screen_mode_text, "" },
4858 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4859 { TYPE_STRING, &scroll_delay_text, "" },
4861 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4862 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4863 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4864 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4865 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4866 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4867 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
4868 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
4869 { TYPE_EMPTY, NULL, "" },
4870 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4875 static struct TokenInfo setup_info_sound[] =
4877 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4878 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4879 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4880 { TYPE_EMPTY, NULL, "" },
4881 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
4882 { TYPE_STRING, &volume_simple_text, "" },
4883 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
4884 { TYPE_STRING, &volume_loops_text, "" },
4885 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
4886 { TYPE_STRING, &volume_music_text, "" },
4887 { TYPE_EMPTY, NULL, "" },
4888 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4893 static struct TokenInfo setup_info_artwork[] =
4895 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4896 { TYPE_STRING, &graphics_set_name, "" },
4897 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4898 { TYPE_STRING, &sounds_set_name, "" },
4899 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4900 { TYPE_STRING, &music_set_name, "" },
4901 { TYPE_EMPTY, NULL, "" },
4902 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
4903 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
4904 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
4905 { TYPE_EMPTY, NULL, "" },
4906 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4911 static struct TokenInfo setup_info_input[] =
4913 { TYPE_SWITCH, NULL, "Player:" },
4914 { TYPE_SWITCH, NULL, "Device:" },
4915 { TYPE_ENTER_MENU, NULL, "" },
4916 { TYPE_EMPTY, NULL, "" },
4917 { TYPE_EMPTY, NULL, "" },
4918 { TYPE_EMPTY, NULL, "" },
4919 { TYPE_EMPTY, NULL, "" },
4920 { TYPE_EMPTY, NULL, "" },
4921 { TYPE_EMPTY, NULL, "" },
4922 { TYPE_EMPTY, NULL, "" },
4923 { TYPE_EMPTY, NULL, "" },
4924 { TYPE_EMPTY, NULL, "" },
4925 { TYPE_EMPTY, NULL, "" },
4926 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4931 static struct TokenInfo setup_info_touch[] =
4933 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
4934 { TYPE_STRING, &touch_controls_text, "" },
4935 { TYPE_EMPTY, NULL, "" },
4936 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
4937 { TYPE_STRING, &move_distance_text, "" },
4938 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
4939 { TYPE_STRING, &drop_distance_text, "" },
4940 { TYPE_EMPTY, NULL, "" },
4941 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4946 static struct TokenInfo setup_info_shortcuts[] =
4948 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
4949 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
4950 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
4951 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
4952 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
4953 { TYPE_EMPTY, NULL, "" },
4954 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4959 static struct TokenInfo setup_info_shortcuts_1[] =
4961 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4962 { TYPE_KEY, &setup.shortcut.save_game, "" },
4963 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4964 { TYPE_KEY, &setup.shortcut.load_game, "" },
4965 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4966 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4967 { TYPE_EMPTY, NULL, "" },
4968 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4969 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4970 { TYPE_EMPTY, NULL, "" },
4971 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4976 static struct TokenInfo setup_info_shortcuts_2[] =
4978 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4979 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4980 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4981 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4982 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4983 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4984 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4985 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4986 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4987 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4988 { TYPE_EMPTY, NULL, "" },
4989 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4994 static struct TokenInfo setup_info_shortcuts_3[] =
4996 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
4997 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
4998 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
4999 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
5000 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
5001 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
5002 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
5003 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
5004 { TYPE_KEYTEXT, NULL, "Record Tape:", },
5005 { TYPE_KEY, &setup.shortcut.tape_record, "" },
5006 { TYPE_KEYTEXT, NULL, "Play Tape:", },
5007 { TYPE_KEY, &setup.shortcut.tape_play, "" },
5008 { TYPE_EMPTY, NULL, "" },
5009 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5014 static struct TokenInfo setup_info_shortcuts_4[] =
5016 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
5017 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
5018 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
5019 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
5020 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
5021 { TYPE_KEY, &setup.shortcut.sound_music, "" },
5022 { TYPE_EMPTY, NULL, "" },
5023 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5028 static struct TokenInfo setup_info_shortcuts_5[] =
5030 { TYPE_KEYTEXT, NULL, "Snap Left:", },
5031 { TYPE_KEY, &setup.shortcut.snap_left, "" },
5032 { TYPE_KEYTEXT, NULL, "Snap Right:", },
5033 { TYPE_KEY, &setup.shortcut.snap_right, "" },
5034 { TYPE_KEYTEXT, NULL, "Snap Up:", },
5035 { TYPE_KEY, &setup.shortcut.snap_up, "" },
5036 { TYPE_KEYTEXT, NULL, "Snap Down:", },
5037 { TYPE_KEY, &setup.shortcut.snap_down, "" },
5038 { TYPE_EMPTY, NULL, "" },
5039 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5044 static Key getSetupKey()
5046 Key key = KSYM_UNDEFINED;
5047 boolean got_key_event = FALSE;
5049 while (!got_key_event)
5051 if (PendingEvent()) /* got event */
5059 case EVENT_KEYPRESS:
5061 key = GetEventKey((KeyEvent *)&event, TRUE);
5063 /* press 'Escape' or 'Enter' to keep the existing key binding */
5064 if (key == KSYM_Escape || key == KSYM_Return)
5065 key = KSYM_UNDEFINED; /* keep old value */
5067 got_key_event = TRUE;
5071 case EVENT_KEYRELEASE:
5072 key_joystick_mapping = 0;
5076 HandleOtherEvents(&event);
5084 /* don't eat all CPU time */
5091 static int getSetupTextFont(int type)
5093 if (type & (TYPE_SWITCH |
5105 static int getSetupValueFont(int type, void *value)
5107 if (type & TYPE_KEY)
5108 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5109 else if (type & TYPE_STRING)
5110 return FONT_VALUE_2;
5111 else if (type & TYPE_ECS_AGA)
5112 return FONT_VALUE_1;
5113 else if (type & TYPE_BOOLEAN_STYLE)
5114 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5115 else if (type & TYPE_YES_NO_AUTO)
5116 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5117 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5119 return FONT_VALUE_1;
5122 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5124 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5125 struct TokenInfo *si = &setup_info[si_pos];
5126 boolean font_draw_xoffset_modified = FALSE;
5127 int font_draw_xoffset_old = -1;
5128 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5129 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5130 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5131 int xpos = menu_screen_value_xpos;
5132 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5133 int startx = mSX + xpos * 32;
5134 int starty = mSY + ypos * 32;
5135 int font_nr, font_width;
5136 int type = si->type;
5137 void *value = si->value;
5138 char *value_string = getSetupValue(type, value);
5141 if (value_string == NULL)
5144 if (type & TYPE_KEY)
5146 xpos = MENU_SCREEN_START_XPOS;
5148 if (type & TYPE_QUERY)
5149 value_string = "<press key>";
5151 else if (type & TYPE_STRING)
5153 int max_value_len = (SCR_FIELDX - 2) * 2;
5155 xpos = MENU_SCREEN_START_XPOS;
5157 if (strlen(value_string) > max_value_len)
5158 value_string[max_value_len] = '\0';
5160 else if (type & TYPE_YES_NO_AUTO)
5162 xpos = menu_screen_value_xpos - 1;
5165 startx = mSX + xpos * 32;
5166 starty = mSY + ypos * 32;
5167 font_nr = getSetupValueFont(type, value);
5168 font_width = getFontWidth(font_nr);
5170 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5171 if (setup_mode != SETUP_MODE_INPUT)
5173 int max_menu_text_length_big = (menu_screen_value_xpos -
5174 MENU_SCREEN_START_XPOS);
5175 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5176 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5177 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5178 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5179 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5180 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5181 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5182 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5183 boolean correct_font_draw_xoffset = FALSE;
5185 if (xpos == MENU_SCREEN_START_XPOS &&
5186 startx + font1_xoffset < text_startx + text_font_xoffset)
5187 correct_font_draw_xoffset = TRUE;
5189 if (xpos == menu_screen_value_xpos &&
5190 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5191 correct_font_draw_xoffset = TRUE;
5193 /* check if setup value would overlap with setup text when printed */
5194 /* (this can happen for extreme/wrong values for font draw offset) */
5195 if (correct_font_draw_xoffset)
5197 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5198 font_draw_xoffset_modified = TRUE;
5200 if (type & TYPE_KEY)
5201 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5202 else if (!(type & TYPE_STRING))
5203 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5204 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5208 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5209 DrawText(startx + i * font_width, starty, " ", font_nr);
5211 DrawText(startx, starty, value_string, font_nr);
5213 if (font_draw_xoffset_modified)
5214 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5217 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5219 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5220 struct TokenInfo *si = &setup_info[si_pos];
5222 if (si->type & TYPE_BOOLEAN_STYLE)
5224 *(boolean *)si->value ^= TRUE;
5226 else if (si->type & TYPE_YES_NO_AUTO)
5230 (*(int *)si->value == AUTO ? TRUE :
5231 *(int *)si->value == TRUE ? FALSE : AUTO) :
5232 (*(int *)si->value == TRUE ? AUTO :
5233 *(int *)si->value == AUTO ? FALSE : TRUE));
5235 else if (si->type & TYPE_KEY)
5239 si->type |= TYPE_QUERY;
5240 drawSetupValue(screen_pos, setup_info_pos_raw);
5241 si->type &= ~TYPE_QUERY;
5243 key = getSetupKey();
5244 if (key != KSYM_UNDEFINED)
5245 *(Key *)si->value = key;
5248 drawSetupValue(screen_pos, setup_info_pos_raw);
5250 // fullscreen state may have changed at this point
5251 if (si->value == &setup.fullscreen)
5252 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5255 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5258 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5259 struct TokenInfo *si = &setup_info[si_pos];
5260 int xpos = MENU_SCREEN_START_XPOS;
5261 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5262 int font_nr = getSetupTextFont(si->type);
5264 if (setup_info == setup_info_input)
5265 font_nr = FONT_MENU_1;
5268 font_nr = FONT_ACTIVE(font_nr);
5270 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5272 if (si->type & ~TYPE_SKIP_ENTRY)
5273 drawCursor(screen_pos, active);
5276 static void drawSetupInfoList(struct TokenInfo *setup_info,
5277 int first_entry, int num_page_entries)
5281 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5282 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5284 if (num_page_entries > max_setup_info)
5285 num_page_entries = max_setup_info;
5287 if (first_entry + num_page_entries > max_setup_info)
5290 clearMenuListArea();
5292 for (i = 0; i < num_page_entries; i++)
5294 int setup_info_pos = first_entry + i;
5295 struct TokenInfo *si = &setup_info[setup_info_pos];
5296 void *value_ptr = si->value;
5298 /* set some entries to "unchangeable" according to other variables */
5299 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5300 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5301 (value_ptr == &setup.sound_music && !audio.music_available) ||
5302 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5303 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5304 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5305 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5306 si->type |= TYPE_GHOSTED;
5308 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5309 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5310 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5311 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5312 else if (si->type & ~TYPE_SKIP_ENTRY)
5313 initCursor(i, IMG_MENU_BUTTON);
5315 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5317 if (si->type & TYPE_VALUE)
5318 drawSetupValue(i, setup_info_pos);
5322 static void DrawSetupScreen_Generic()
5324 int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
5325 boolean redraw_all = FALSE;
5326 char *title_string = NULL;
5331 FreeScreenGadgets();
5332 CreateScreenGadgets();
5334 CloseDoor(DOOR_CLOSE_2);
5336 if (redraw_mask & REDRAW_ALL)
5343 if (setup_mode == SETUP_MODE_MAIN)
5345 setup_info = setup_info_main;
5346 title_string = "Setup";
5348 else if (setup_mode == SETUP_MODE_GAME)
5350 setup_info = setup_info_game;
5351 title_string = "Setup Game";
5353 else if (setup_mode == SETUP_MODE_EDITOR)
5355 setup_info = setup_info_editor;
5356 title_string = "Setup Editor";
5358 else if (setup_mode == SETUP_MODE_GRAPHICS)
5360 setup_info = setup_info_graphics;
5361 title_string = "Setup Graphics";
5363 else if (setup_mode == SETUP_MODE_SOUND)
5365 setup_info = setup_info_sound;
5366 title_string = "Setup Sound";
5368 else if (setup_mode == SETUP_MODE_ARTWORK)
5370 setup_info = setup_info_artwork;
5371 title_string = "Custom Artwork";
5373 else if (setup_mode == SETUP_MODE_TOUCH)
5375 setup_info = setup_info_touch;
5376 title_string = "Setup Touch Ctrls";
5378 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5380 setup_info = setup_info_shortcuts;
5381 title_string = "Setup Shortcuts";
5383 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5385 setup_info = setup_info_shortcuts_1;
5386 title_string = "Setup Shortcuts";
5388 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5390 setup_info = setup_info_shortcuts_2;
5391 title_string = "Setup Shortcuts";
5393 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
5395 setup_info = setup_info_shortcuts_3;
5396 title_string = "Setup Shortcuts";
5398 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
5400 setup_info = setup_info_shortcuts_4;
5401 title_string = "Setup Shortcuts";
5403 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
5405 setup_info = setup_info_shortcuts_5;
5406 title_string = "Setup Shortcuts";
5409 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5411 // determine maximal number of setup entries that can be displayed on screen
5413 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5416 // determine maximal number of setup entries available for this setup screen
5418 for (i = 0; setup_info[i].type != 0; i++)
5421 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5423 MapScreenGadgets(max_setup_info);
5426 redraw_mask = fade_mask = REDRAW_ALL;
5433 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5435 static int choice_store[MAX_SETUP_MODES];
5436 static int first_entry_store[MAX_SETUP_MODES];
5437 int choice = choice_store[setup_mode]; /* starts with 0 */
5438 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
5440 int y = choice - first_entry;
5442 boolean position_set_by_scrollbar = (dx == 999);
5443 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
5444 int num_page_entries;
5446 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
5448 if (button == MB_MENU_INITIALIZE)
5450 /* advance to first valid menu entry */
5451 while (choice < num_setup_info &&
5452 setup_info[choice].type & TYPE_SKIP_ENTRY)
5455 if (position_set_by_scrollbar)
5456 first_entry = first_entry_store[setup_mode] = dy;
5458 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5459 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5461 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5463 if (choice < first_entry)
5465 choice = first_entry;
5467 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5470 else if (choice > first_entry + num_page_entries - 1)
5472 choice = first_entry + num_page_entries - 1;
5474 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5478 choice_store[setup_mode] = choice;
5480 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5484 else if (button == MB_MENU_LEAVE)
5488 PlaySound(SND_MENU_ITEM_SELECTING);
5490 for (i = 0; setup_info[i].type != 0; i++)
5492 if (setup_info[i].type & TYPE_LEAVE_MENU)
5494 void (*menu_callback_function)(void) = setup_info[i].value;
5498 menu_callback_function();
5500 break; /* absolutely needed because function changes 'setup_info'! */
5507 if (mx || my) /* mouse input */
5509 x = (mx - mSX) / 32;
5510 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5512 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
5514 /* move cursor instead of scrolling when already at start/end of list */
5515 if (dy == -1 * SCROLL_LINE && first_entry == 0)
5517 else if (dy == +1 * SCROLL_LINE &&
5518 first_entry + num_page_entries == max_setup_info)
5521 /* handle scrolling screen one line or page */
5523 y + dy > num_page_entries - 1)
5525 boolean redraw = FALSE;
5527 if (ABS(dy) == SCROLL_PAGE)
5528 step = num_page_entries - 1;
5530 if (dy < 0 && first_entry > 0)
5532 /* scroll page/line up */
5534 first_entry -= step;
5535 if (first_entry < 0)
5540 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
5542 /* scroll page/line down */
5544 first_entry += step;
5545 if (first_entry + num_page_entries > max_setup_info)
5546 first_entry = MAX(0, max_setup_info - num_page_entries);
5553 choice += first_entry - first_entry_store[setup_mode];
5555 if (choice < first_entry)
5557 choice = first_entry;
5559 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5562 else if (choice > first_entry + num_page_entries - 1)
5564 choice = first_entry + num_page_entries - 1;
5566 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5569 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5573 if (choice < first_entry ||
5574 choice > first_entry + num_page_entries - 1)
5575 first_entry += SIGN(dy);
5578 first_entry_store[setup_mode] = first_entry;
5579 choice_store[setup_mode] = choice;
5581 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5583 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5585 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5586 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5594 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5596 if (setup_info[choice].type & menu_navigation_type ||
5597 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
5598 setup_info[choice].type & TYPE_YES_NO_AUTO)
5599 button = MB_MENU_CHOICE;
5604 /* jump to next non-empty menu entry (up or down) */
5605 while (first_entry + y > 0 &&
5606 first_entry + y < max_setup_info - 1 &&
5607 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
5610 if (!IN_VIS_MENU(x, y))
5612 choice += y - y_old;
5614 if (choice < first_entry)
5615 first_entry = choice;
5616 else if (choice > first_entry + num_page_entries - 1)
5617 first_entry = choice - num_page_entries + 1;
5619 if (first_entry >= 0 &&
5620 first_entry + num_page_entries <= max_setup_info)
5622 first_entry_store[setup_mode] = first_entry;
5624 if (choice < first_entry)
5625 choice = first_entry;
5626 else if (choice > first_entry + num_page_entries - 1)
5627 choice = first_entry + num_page_entries - 1;
5629 choice_store[setup_mode] = choice;
5631 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5633 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5635 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5636 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5643 if (!anyScrollbarGadgetActive() &&
5644 IN_VIS_MENU(x, y) &&
5645 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
5646 y >= 0 && y < num_page_entries)
5650 if (first_entry + y != choice &&
5651 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
5653 PlaySound(SND_MENU_ITEM_ACTIVATING);
5655 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
5656 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
5658 choice = choice_store[setup_mode] = first_entry + y;
5661 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
5663 PlaySound(SND_MENU_ITEM_SELECTING);
5665 /* when selecting key headline, execute function for key value change */
5666 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
5667 setup_info[first_entry + y + 1].type & TYPE_KEY)
5670 /* when selecting string value, execute function for list selection */
5671 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
5672 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
5675 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
5677 void (*menu_callback_function)(void) =
5678 setup_info[first_entry + y].value;
5680 FadeSetFromType(setup_info[first_entry + y].type);
5682 menu_callback_function();
5686 if (setup_info[first_entry + y].type & TYPE_VALUE)
5687 changeSetupValue(y, first_entry + y, dx);
5693 void DrawSetupScreen_Input()
5697 FadeOut(REDRAW_FIELD);
5701 setup_info = setup_info_input;
5703 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5705 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5706 "Joysticks deactivated on this screen");
5708 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5710 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5711 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5712 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5713 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5714 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5715 initCursor(i, IMG_MENU_BUTTON);
5717 DrawCursorAndText_Setup(i, -1, FALSE);
5720 /* create gadgets for setup input menu screen */
5721 FreeScreenGadgets();
5722 CreateScreenGadgets();
5724 /* map gadgets for setup input menu screen */
5725 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5727 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5729 FadeIn(REDRAW_FIELD);
5734 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5736 if (device_name == NULL)
5739 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5742 if (strlen(device_name) > 1)
5744 char c1 = device_name[strlen(device_name) - 1];
5745 char c2 = device_name[strlen(device_name) - 2];
5747 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5748 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5751 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5752 strlen(device_name));
5755 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5758 static struct SetupKeyboardInfo custom_key;
5765 { &custom_key.left, "Joystick Left" },
5766 { &custom_key.right, "Joystick Right" },
5767 { &custom_key.up, "Joystick Up" },
5768 { &custom_key.down, "Joystick Down" },
5769 { &custom_key.snap, "Button 1" },
5770 { &custom_key.drop, "Button 2" }
5772 static char *joystick_name[MAX_PLAYERS] =
5779 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5783 custom_key = setup.input[player_nr].key;
5785 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5786 FONT_INPUT_1_ACTIVE);
5788 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5790 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5791 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5793 if (setup.input[player_nr].use_joystick)
5795 char *device_name = setup.input[player_nr].joy.device_name;
5796 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5797 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5799 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5800 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5804 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5805 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5808 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5810 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5811 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5812 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5813 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5815 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5816 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5817 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5818 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5819 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5820 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5822 for (i = 0; i < 6; i++)
5824 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5826 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5828 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5829 (setup.input[player_nr].use_joystick ?
5831 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5835 static int input_player_nr = 0;
5837 void HandleSetupScreen_Input_Player(int step, int direction)
5839 int old_player_nr = input_player_nr;
5842 new_player_nr = old_player_nr + step * direction;
5843 if (new_player_nr < 0)
5845 if (new_player_nr > MAX_PLAYERS - 1)
5846 new_player_nr = MAX_PLAYERS - 1;
5848 if (new_player_nr != old_player_nr)
5850 input_player_nr = new_player_nr;
5852 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5856 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5858 static int choice = 0;
5861 int pos_start = SETUPINPUT_SCREEN_POS_START;
5862 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5863 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5864 int pos_end = SETUPINPUT_SCREEN_POS_END;
5866 if (button == MB_MENU_INITIALIZE)
5868 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5870 DrawCursorAndText_Setup(choice, -1, TRUE);
5874 else if (button == MB_MENU_LEAVE)
5876 setup_mode = SETUP_MODE_MAIN;
5883 if (mx || my) /* mouse input */
5885 x = (mx - mSX) / 32;
5886 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5888 else if (dx || dy) /* keyboard input */
5890 if (dx && choice == 0)
5891 x = (dx < 0 ? 10 : 12);
5892 else if ((dx && choice == 1) ||
5893 (dx == +1 && choice == 2) ||
5894 (dx == -1 && choice == pos_end))
5895 button = MB_MENU_CHOICE;
5899 if (y >= pos_empty1 && y <= pos_empty2)
5900 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5903 if (y == 0 && dx != 0 && button)
5905 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5907 else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
5908 y >= pos_start && y <= pos_end &&
5909 !(y >= pos_empty1 && y <= pos_empty2))
5915 DrawCursorAndText_Setup(choice, -1, FALSE);
5916 DrawCursorAndText_Setup(y, -1, TRUE);
5918 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5927 char *device_name = setup.input[input_player_nr].joy.device_name;
5929 if (!setup.input[input_player_nr].use_joystick)
5931 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5933 setJoystickDeviceToNr(device_name, new_device_nr);
5934 setup.input[input_player_nr].use_joystick = TRUE;
5938 int device_nr = getJoystickNrFromDeviceName(device_name);
5939 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5941 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5942 setup.input[input_player_nr].use_joystick = FALSE;
5944 setJoystickDeviceToNr(device_name, new_device_nr);
5947 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5951 if (setup.input[input_player_nr].use_joystick)
5954 CalibrateJoystick(input_player_nr);
5957 CustomizeKeyboard(input_player_nr);
5959 else if (y == pos_end)
5965 setup_mode = SETUP_MODE_MAIN;
5972 void CustomizeKeyboard(int player_nr)
5976 boolean finished = FALSE;
5977 static struct SetupKeyboardInfo custom_key;
5982 } customize_step[] =
5984 { &custom_key.left, "Move Left" },
5985 { &custom_key.right, "Move Right" },
5986 { &custom_key.up, "Move Up" },
5987 { &custom_key.down, "Move Down" },
5988 { &custom_key.snap, "Snap Field" },
5989 { &custom_key.drop, "Drop Element" }
5992 /* read existing key bindings from player setup */
5993 custom_key = setup.input[player_nr].key;
5996 FadeOut(REDRAW_FIELD);
6000 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
6003 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6004 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6005 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6006 "Key:", FONT_INPUT_1_ACTIVE);
6007 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6008 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
6010 FadeIn(REDRAW_FIELD);
6016 if (PendingEvent()) /* got event */
6024 case EVENT_KEYPRESS:
6026 Key key = GetEventKey((KeyEvent *)&event, FALSE);
6028 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
6030 if (key == KSYM_Escape)
6031 FadeSkipNextFadeIn();
6037 /* all keys configured -- wait for "Escape" or "Return" key */
6041 /* press 'Enter' to keep the existing key binding */
6042 if (key == KSYM_Return)
6043 key = *customize_step[step_nr].key;
6045 /* check if key already used */
6046 for (i = 0; i < step_nr; i++)
6047 if (*customize_step[i].key == key)
6052 /* got new key binding */
6053 *customize_step[step_nr].key = key;
6054 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6056 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6057 getKeyNameFromKey(key), FONT_VALUE_1);
6060 /* un-highlight last query */
6061 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6062 customize_step[step_nr - 1].text, FONT_MENU_1);
6063 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6064 "Key:", FONT_MENU_1);
6066 /* press 'Enter' to leave */
6069 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6070 "Press Enter", FONT_TITLE_1);
6074 /* query next key binding */
6075 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6076 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6077 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6078 "Key:", FONT_INPUT_1_ACTIVE);
6079 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6080 getKeyNameFromKey(*customize_step[step_nr].key),
6085 case EVENT_KEYRELEASE:
6086 key_joystick_mapping = 0;
6090 HandleOtherEvents(&event);
6098 /* don't eat all CPU time */
6102 /* write new key bindings back to player setup */
6103 setup.input[player_nr].key = custom_key;
6106 DrawSetupScreen_Input();
6109 static boolean CalibrateJoystickMain(int player_nr)
6111 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6112 int new_joystick_xright = JOYSTICK_XMIDDLE;
6113 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6114 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6115 int new_joystick_xmiddle, new_joystick_ymiddle;
6117 int joystick_fd = joystick.fd[player_nr];
6118 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6119 boolean check[3][3];
6120 int check_remaining = 3 * 3;
6125 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6128 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6132 FadeOut(REDRAW_FIELD);
6136 for (y = 0; y < 3; y++)
6138 for (x = 0; x < 3; x++)
6140 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6141 check[x][y] = FALSE;
6145 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6146 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6147 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6148 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6149 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6150 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6151 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6153 joy_value = Joystick(player_nr);
6154 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6155 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6157 /* eventually uncalibrated center position (joystick could be uncentered) */
6158 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6161 new_joystick_xmiddle = joy_x;
6162 new_joystick_ymiddle = joy_y;
6164 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6166 FadeIn(REDRAW_FIELD);
6168 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6173 if (PendingEvent()) /* got event */
6181 case EVENT_KEYPRESS:
6182 switch (GetEventKey((KeyEvent *)&event, TRUE))
6185 if (check_remaining == 0)
6190 FadeSkipNextFadeIn();
6199 case EVENT_KEYRELEASE:
6200 key_joystick_mapping = 0;
6204 HandleOtherEvents(&event);
6209 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6212 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
6213 new_joystick_xright = MAX(new_joystick_xright, joy_x);
6214 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
6215 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
6217 setup.input[player_nr].joy.xleft = new_joystick_xleft;
6218 setup.input[player_nr].joy.yupper = new_joystick_yupper;
6219 setup.input[player_nr].joy.xright = new_joystick_xright;
6220 setup.input[player_nr].joy.ylower = new_joystick_ylower;
6221 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
6222 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
6224 CheckJoystickData();
6226 joy_value = Joystick(player_nr);
6228 if (joy_value & JOY_BUTTON && check_remaining == 0)
6231 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6232 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6234 if (x != last_x || y != last_y)
6236 DrawFixedGraphic(xpos + last_x, ypos + last_y,
6237 IMG_MENU_CALIBRATE_YELLOW, 0);
6238 DrawFixedGraphic(xpos + x, ypos + y,
6239 IMG_MENU_CALIBRATE_RED, 0);
6244 if (check_remaining > 0 && !check[x+1][y+1])
6246 check[x+1][y+1] = TRUE;
6254 /* don't eat all CPU time */
6258 /* calibrated center position (joystick should now be centered) */
6259 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6262 new_joystick_xmiddle = joy_x;
6263 new_joystick_ymiddle = joy_y;
6267 /* wait until the last pressed button was released */
6268 while (Joystick(player_nr) & JOY_BUTTON)
6270 if (PendingEvent()) /* got event */
6275 HandleOtherEvents(&event);
6284 void CalibrateJoystick(int player_nr)
6286 if (!CalibrateJoystickMain(player_nr))
6288 char *device_name = setup.input[player_nr].joy.device_name;
6289 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6290 int xpos = mSX - SX;
6291 int ypos = mSY - SY;
6295 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6296 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
6299 Delay(2000); /* show error message for a short time */
6304 DrawSetupScreen_Input();
6307 void DrawSetupScreen()
6309 DeactivateJoystick();
6311 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6313 if (setup_mode == SETUP_MODE_INPUT)
6314 DrawSetupScreen_Input();
6315 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6316 DrawChooseTree(&game_speed_current);
6317 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6318 DrawChooseTree(&scroll_delay_current);
6319 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6320 DrawChooseTree(&screen_mode_current);
6321 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6322 DrawChooseTree(&window_size_current);
6323 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6324 DrawChooseTree(&scaling_type_current);
6325 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6326 DrawChooseTree(&artwork.gfx_current);
6327 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6328 DrawChooseTree(&artwork.snd_current);
6329 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6330 DrawChooseTree(&artwork.mus_current);
6331 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6332 DrawChooseTree(&volume_simple_current);
6333 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6334 DrawChooseTree(&volume_loops_current);
6335 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6336 DrawChooseTree(&volume_music_current);
6337 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6338 DrawChooseTree(&touch_control_current);
6339 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6340 DrawChooseTree(&move_distance_current);
6341 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6342 DrawChooseTree(&drop_distance_current);
6344 DrawSetupScreen_Generic();
6350 void RedrawSetupScreenAfterFullscreenToggle()
6352 if (setup_mode == SETUP_MODE_GRAPHICS ||
6353 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6355 // update list selection from "setup.window_scaling_percent"
6356 execSetupGraphics_setWindowSizes(TRUE);
6362 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
6364 if (setup_mode == SETUP_MODE_INPUT)
6365 HandleSetupScreen_Input(mx, my, dx, dy, button);
6366 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6367 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
6368 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6369 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
6370 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6371 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
6372 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6373 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
6374 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6375 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
6376 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6377 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
6378 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6379 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
6380 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6381 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
6382 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6383 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
6384 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6385 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
6386 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6387 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
6388 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6389 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
6390 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6391 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
6392 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6393 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
6395 HandleSetupScreen_Generic(mx, my, dx, dy, button);
6398 void HandleGameActions()
6400 if (game_status != GAME_MODE_PLAYING)
6403 GameActions(); /* main game loop */
6405 if (tape.auto_play && !tape.playing)
6406 AutoPlayTape(); /* continue automatically playing next tape */
6410 /* ---------- new screen button stuff -------------------------------------- */
6412 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6416 case SCREEN_CTRL_ID_PREV_LEVEL:
6417 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
6418 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
6421 case SCREEN_CTRL_ID_NEXT_LEVEL:
6422 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
6423 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
6426 case SCREEN_CTRL_ID_PREV_PLAYER:
6427 *x = mSX + TILEX * 10;
6428 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6431 case SCREEN_CTRL_ID_NEXT_PLAYER:
6432 *x = mSX + TILEX * 12;
6433 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6437 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6443 int gfx_unpressed, gfx_pressed;
6444 void (*get_gadget_position)(int *, int *, int);
6448 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6451 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6452 getScreenMenuButtonPos,
6453 SCREEN_CTRL_ID_PREV_LEVEL,
6458 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6459 getScreenMenuButtonPos,
6460 SCREEN_CTRL_ID_NEXT_LEVEL,
6465 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6466 getScreenMenuButtonPos,
6467 SCREEN_CTRL_ID_PREV_PLAYER,
6472 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6473 getScreenMenuButtonPos,
6474 SCREEN_CTRL_ID_NEXT_PLAYER,
6482 int gfx_unpressed, gfx_pressed;
6486 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6489 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6490 -1, -1, /* these values are not constant, but can change at runtime */
6491 SCREEN_CTRL_ID_SCROLL_UP,
6495 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6496 -1, -1, /* these values are not constant, but can change at runtime */
6497 SCREEN_CTRL_ID_SCROLL_DOWN,
6504 int gfx_unpressed, gfx_pressed;
6510 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6513 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6514 -1, -1, /* these values are not constant, but can change at runtime */
6515 -1, -1, /* these values are not constant, but can change at runtime */
6516 GD_TYPE_SCROLLBAR_VERTICAL,
6517 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6518 "scroll level series vertically"
6522 static void CreateScreenMenubuttons()
6524 struct GadgetInfo *gi;
6525 unsigned int event_mask;
6528 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6530 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6531 int gfx_unpressed, gfx_pressed;
6532 int x, y, width, height;
6533 int gd_x1, gd_x2, gd_y1, gd_y2;
6534 int id = menubutton_info[i].gadget_id;
6536 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6538 menubutton_info[i].get_gadget_position(&x, &y, id);
6540 width = SC_MENUBUTTON_XSIZE;
6541 height = SC_MENUBUTTON_YSIZE;
6543 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6544 gfx_pressed = menubutton_info[i].gfx_pressed;
6545 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6546 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6547 gd_x1 = graphic_info[gfx_unpressed].src_x;
6548 gd_y1 = graphic_info[gfx_unpressed].src_y;
6549 gd_x2 = graphic_info[gfx_pressed].src_x;
6550 gd_y2 = graphic_info[gfx_pressed].src_y;
6552 gi = CreateGadget(GDI_CUSTOM_ID, id,
6553 GDI_CUSTOM_TYPE_ID, i,
6554 GDI_INFO_TEXT, menubutton_info[i].infotext,
6559 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6560 GDI_STATE, GD_BUTTON_UNPRESSED,
6561 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6562 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6563 GDI_DIRECT_DRAW, FALSE,
6564 GDI_EVENT_MASK, event_mask,
6565 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6569 Error(ERR_EXIT, "cannot create gadget");
6571 screen_gadget[id] = gi;
6575 static void CreateScreenScrollbuttons()
6577 struct GadgetInfo *gi;
6578 unsigned int event_mask;
6581 /* these values are not constant, but can change at runtime */
6582 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
6583 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
6584 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
6585 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
6587 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6589 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6590 int gfx_unpressed, gfx_pressed;
6591 int x, y, width, height;
6592 int gd_x1, gd_x2, gd_y1, gd_y2;
6593 int id = scrollbutton_info[i].gadget_id;
6595 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6597 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6598 y = mSY + scrollbutton_info[i].y;
6599 width = SC_SCROLLBUTTON_XSIZE;
6600 height = SC_SCROLLBUTTON_YSIZE;
6602 /* correct scrollbar position if placed outside menu (playfield) area */
6603 if (x > SX + SC_SCROLL_UP_XPOS)
6604 x = SX + SC_SCROLL_UP_XPOS;
6606 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6607 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6608 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6610 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6611 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6612 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6613 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6614 gd_x1 = graphic_info[gfx_unpressed].src_x;
6615 gd_y1 = graphic_info[gfx_unpressed].src_y;
6616 gd_x2 = graphic_info[gfx_pressed].src_x;
6617 gd_y2 = graphic_info[gfx_pressed].src_y;
6619 gi = CreateGadget(GDI_CUSTOM_ID, id,
6620 GDI_CUSTOM_TYPE_ID, i,
6621 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6626 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6627 GDI_STATE, GD_BUTTON_UNPRESSED,
6628 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6629 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6630 GDI_DIRECT_DRAW, FALSE,
6631 GDI_EVENT_MASK, event_mask,
6632 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6636 Error(ERR_EXIT, "cannot create gadget");
6638 screen_gadget[id] = gi;
6642 static void CreateScreenScrollbars()
6646 /* these values are not constant, but can change at runtime */
6647 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
6648 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
6649 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
6650 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
6652 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6654 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6655 int gfx_unpressed, gfx_pressed;
6656 int x, y, width, height;
6657 int gd_x1, gd_x2, gd_y1, gd_y2;
6658 struct GadgetInfo *gi;
6659 int items_max, items_visible, item_position;
6660 unsigned int event_mask;
6661 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6662 int id = scrollbar_info[i].gadget_id;
6664 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6666 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6667 y = mSY + scrollbar_info[i].y;
6668 width = scrollbar_info[i].width;
6669 height = scrollbar_info[i].height;
6671 /* correct scrollbar position if placed outside menu (playfield) area */
6672 if (x > SX + SC_SCROLL_VERTICAL_XPOS)
6673 x = SX + SC_SCROLL_VERTICAL_XPOS;
6675 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6676 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6678 items_max = num_page_entries;
6679 items_visible = num_page_entries;
6682 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6683 gfx_pressed = scrollbar_info[i].gfx_pressed;
6684 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6685 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6686 gd_x1 = graphic_info[gfx_unpressed].src_x;
6687 gd_y1 = graphic_info[gfx_unpressed].src_y;
6688 gd_x2 = graphic_info[gfx_pressed].src_x;
6689 gd_y2 = graphic_info[gfx_pressed].src_y;
6691 gi = CreateGadget(GDI_CUSTOM_ID, id,
6692 GDI_CUSTOM_TYPE_ID, i,
6693 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6698 GDI_TYPE, scrollbar_info[i].type,
6699 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6700 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6701 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6702 GDI_WHEEL_AREA_X, SX,
6703 GDI_WHEEL_AREA_Y, SY,
6704 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6705 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6706 GDI_STATE, GD_BUTTON_UNPRESSED,
6707 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6708 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6709 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6710 GDI_DIRECT_DRAW, FALSE,
6711 GDI_EVENT_MASK, event_mask,
6712 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6716 Error(ERR_EXIT, "cannot create gadget");
6718 screen_gadget[id] = gi;
6722 void CreateScreenGadgets()
6724 int last_game_status = game_status; /* save current game status */
6726 CreateScreenMenubuttons();
6728 CreateScreenScrollbuttons();
6729 CreateScreenScrollbars();
6731 game_status = last_game_status; /* restore current game status */
6734 void FreeScreenGadgets()
6738 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6739 FreeGadget(screen_gadget[i]);
6742 void MapScreenMenuGadgets(int screen_mask)
6746 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6747 if (screen_mask & menubutton_info[i].screen_mask)
6748 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6751 void MapScreenGadgets(int num_entries)
6755 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6758 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6759 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6761 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6762 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6765 void MapScreenTreeGadgets(TreeInfo *ti)
6767 MapScreenGadgets(numTreeInfoInGroup(ti));
6770 static void HandleScreenGadgets(struct GadgetInfo *gi)
6772 int id = gi->custom_id;
6773 int button = gi->event.button;
6774 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6778 case SCREEN_CTRL_ID_PREV_LEVEL:
6779 HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT);
6782 case SCREEN_CTRL_ID_NEXT_LEVEL:
6783 HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT);
6786 case SCREEN_CTRL_ID_PREV_PLAYER:
6787 HandleSetupScreen_Input_Player(step, -1);
6790 case SCREEN_CTRL_ID_NEXT_PLAYER:
6791 HandleSetupScreen_Input_Player(step, +1);
6794 case SCREEN_CTRL_ID_SCROLL_UP:
6795 if (game_status == GAME_MODE_LEVELS)
6796 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6797 else if (game_status == GAME_MODE_LEVELNR)
6798 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6799 else if (game_status == GAME_MODE_SETUP)
6800 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6803 case SCREEN_CTRL_ID_SCROLL_DOWN:
6804 if (game_status == GAME_MODE_LEVELS)
6805 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6806 else if (game_status == GAME_MODE_LEVELNR)
6807 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6808 else if (game_status == GAME_MODE_SETUP)
6809 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6812 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6813 if (game_status == GAME_MODE_LEVELS)
6814 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6815 else if (game_status == GAME_MODE_LEVELNR)
6816 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6817 else if (game_status == GAME_MODE_SETUP)
6818 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);