1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
12 #include "libgame/libgame.h"
26 /* screens on the info screen */
27 #define INFO_MODE_MAIN 0
28 #define INFO_MODE_TITLE 1
29 #define INFO_MODE_ELEMENTS 2
30 #define INFO_MODE_MUSIC 3
31 #define INFO_MODE_CREDITS 4
32 #define INFO_MODE_PROGRAM 5
33 #define INFO_MODE_VERSION 6
34 #define INFO_MODE_LEVELSET 7
36 #define MAX_INFO_MODES 8
38 /* screens on the setup screen */
39 /* (must match GFX_SPECIAL_ARG_SETUP_* values as defined in src/main.h) */
40 /* (should also match corresponding entries in src/conf_gfx.c) */
41 #define SETUP_MODE_MAIN 0
42 #define SETUP_MODE_GAME 1
43 #define SETUP_MODE_EDITOR 2
44 #define SETUP_MODE_GRAPHICS 3
45 #define SETUP_MODE_SOUND 4
46 #define SETUP_MODE_ARTWORK 5
47 #define SETUP_MODE_INPUT 6
48 #define SETUP_MODE_TOUCH 7
49 #define SETUP_MODE_SHORTCUTS 8
50 #define SETUP_MODE_SHORTCUTS_1 9
51 #define SETUP_MODE_SHORTCUTS_2 10
52 #define SETUP_MODE_SHORTCUTS_3 11
53 #define SETUP_MODE_SHORTCUTS_4 12
54 #define SETUP_MODE_SHORTCUTS_5 13
56 /* sub-screens on the setup screen (generic) */
57 #define SETUP_MODE_CHOOSE_ARTWORK 14
58 #define SETUP_MODE_CHOOSE_OTHER 15
60 /* sub-screens on the setup screen (specific) */
61 #define SETUP_MODE_CHOOSE_GAME_SPEED 16
62 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17
63 #define SETUP_MODE_CHOOSE_SCREEN_MODE 18
64 #define SETUP_MODE_CHOOSE_WINDOW_SIZE 19
65 #define SETUP_MODE_CHOOSE_SCALING_TYPE 20
66 #define SETUP_MODE_CHOOSE_GRAPHICS 21
67 #define SETUP_MODE_CHOOSE_SOUNDS 22
68 #define SETUP_MODE_CHOOSE_MUSIC 23
69 #define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 24
70 #define SETUP_MODE_CHOOSE_VOLUME_LOOPS 25
71 #define SETUP_MODE_CHOOSE_VOLUME_MUSIC 26
72 #define SETUP_MODE_CHOOSE_TOUCH_CONTROL 27
73 #define SETUP_MODE_CHOOSE_MOVE_DISTANCE 28
74 #define SETUP_MODE_CHOOSE_DROP_DISTANCE 29
76 #define MAX_SETUP_MODES 30
78 /* for input setup functions */
79 #define SETUPINPUT_SCREEN_POS_START 0
80 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
81 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
82 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
84 /* for various menu stuff */
85 #define MENU_SCREEN_START_XPOS 1
86 #define MENU_SCREEN_START_YPOS 2
87 #define MENU_SCREEN_VALUE_XPOS (SCR_FIELDX - 3)
88 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
89 #define MENU_TITLE1_YPOS 8
90 #define MENU_TITLE2_YPOS 46
91 #define MENU_SCREEN_INFO_XSTART 16
92 #define MENU_SCREEN_INFO_YSTART1 100
93 #define MENU_SCREEN_INFO_YSTART2 128
94 #define MENU_SCREEN_INFO_YSTEP (TILEY + 4)
95 #define MENU_SCREEN_INFO_YBOTTOM (SYSIZE - 20)
96 #define MENU_SCREEN_INFO_YSIZE (MENU_SCREEN_INFO_YBOTTOM - \
97 MENU_SCREEN_INFO_YSTART2 - \
99 #define MAX_INFO_ELEMENTS_ON_SCREEN 128
100 #define NUM_INFO_ELEMENTS_ON_SCREEN MIN(MENU_SCREEN_INFO_YSIZE / \
101 MENU_SCREEN_INFO_YSTEP, \
102 MAX_INFO_ELEMENTS_ON_SCREEN)
103 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
104 #define MAX_MENU_TEXT_LENGTH_BIG 13
105 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
107 /* buttons and scrollbars identifiers */
108 #define SCREEN_CTRL_ID_PREV_LEVEL 0
109 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
110 #define SCREEN_CTRL_ID_PREV_PLAYER 2
111 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
112 #define SCREEN_CTRL_ID_SCROLL_UP 4
113 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
114 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
116 #define NUM_SCREEN_GADGETS 7
118 #define NUM_SCREEN_MENUBUTTONS 4
119 #define NUM_SCREEN_SCROLLBUTTONS 2
120 #define NUM_SCREEN_SCROLLBARS 1
122 #define SCREEN_MASK_MAIN (1 << 0)
123 #define SCREEN_MASK_INPUT (1 << 1)
125 /* graphic position and size values for buttons and scrollbars */
126 #define SC_MENUBUTTON_XSIZE TILEX
127 #define SC_MENUBUTTON_YSIZE TILEY
129 #define SC_SCROLLBUTTON_XSIZE TILEX
130 #define SC_SCROLLBUTTON_YSIZE TILEY
132 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
134 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
135 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
136 SC_SCROLLBUTTON_YSIZE)
138 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
139 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
141 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
142 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
143 SC_SCROLLBUTTON_YSIZE)
145 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
146 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
147 SC_SCROLL_VERTICAL_YSIZE)
149 #define SC_BORDER_SIZE 14
152 /* forward declarations of internal functions */
153 static void HandleScreenGadgets(struct GadgetInfo *);
154 static void HandleSetupScreen_Generic(int, int, int, int, int);
155 static void HandleSetupScreen_Input(int, int, int, int, int);
156 static void CustomizeKeyboard(int);
157 static void CalibrateJoystick(int);
158 static void execSetupGame(void);
159 static void execSetupGraphics(void);
160 static void execSetupSound(void);
161 static void execSetupTouch(void);
162 static void execSetupArtwork(void);
163 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
165 static void DrawChooseLevelSet(void);
166 static void DrawChooseLevelNr(void);
167 static void DrawInfoScreen(void);
168 static void DrawAndFadeInInfoScreen(int);
169 static void DrawSetupScreen(void);
171 static void DrawInfoScreenExt(int, int);
172 static void DrawInfoScreen_NotAvailable(char *, char *);
173 static void DrawInfoScreen_HelpAnim(int, int, boolean);
174 static void DrawInfoScreen_HelpText(int, int, int, int);
175 static void HandleInfoScreen_Main(int, int, int, int, int);
176 static void HandleInfoScreen_TitleScreen(int);
177 static void HandleInfoScreen_Elements(int);
178 static void HandleInfoScreen_Music(int);
179 static void HandleInfoScreen_Credits(int);
180 static void HandleInfoScreen_Program(int);
181 static void HandleInfoScreen_Version(int);
183 static void MapScreenMenuGadgets(int);
184 static void MapScreenGadgets(int);
185 static void MapScreenTreeGadgets(TreeInfo *);
187 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
189 static int info_mode = INFO_MODE_MAIN;
190 static int setup_mode = SETUP_MODE_MAIN;
192 static TreeInfo *screen_modes = NULL;
193 static TreeInfo *screen_mode_current = NULL;
195 static TreeInfo *window_sizes = NULL;
196 static TreeInfo *window_size_current = NULL;
198 static TreeInfo *scaling_types = NULL;
199 static TreeInfo *scaling_type_current = NULL;
201 static TreeInfo *scroll_delays = NULL;
202 static TreeInfo *scroll_delay_current = NULL;
204 static TreeInfo *game_speeds = NULL;
205 static TreeInfo *game_speed_current = NULL;
207 static TreeInfo *volumes_simple = NULL;
208 static TreeInfo *volume_simple_current = NULL;
210 static TreeInfo *volumes_loops = NULL;
211 static TreeInfo *volume_loops_current = NULL;
213 static TreeInfo *volumes_music = NULL;
214 static TreeInfo *volume_music_current = NULL;
216 static TreeInfo *touch_controls = NULL;
217 static TreeInfo *touch_control_current = NULL;
219 static TreeInfo *move_distances = NULL;
220 static TreeInfo *move_distance_current = NULL;
222 static TreeInfo *drop_distances = NULL;
223 static TreeInfo *drop_distance_current = NULL;
225 static TreeInfo *level_number = NULL;
226 static TreeInfo *level_number_current = NULL;
232 } window_sizes_list[] =
237 { 100, "100 % (Default)" },
254 } scaling_types_list[] =
256 { SCALING_QUALITY_NEAREST, "None" },
257 { SCALING_QUALITY_LINEAR, "Linear" },
258 { SCALING_QUALITY_BEST, "Anisotropic" },
267 } game_speeds_list[] =
276 { 1000, "1/1s (Extremely Slow)" },
281 { 29, "1/35s (Original Supaplex)" },
283 { 20, "1/50s (Normal Speed)" },
284 { 14, "1/70s (Maximum Supaplex)" },
288 { 1, "1/1000s (Extremely Fast)" },
298 } scroll_delays_list[] =
300 { 0, "0 Tiles (No Scroll Delay)" },
303 { 3, "3 Tiles (Default)" },
308 { 8, "8 Tiles (Maximum Scroll Delay)"},
338 } touch_controls_list[] =
340 { TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" },
341 { TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" },
365 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
366 (s) <= GAME_MODE_SETUP ? (s) : \
367 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
368 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
370 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
371 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
372 (i) <= INFO_MODE_LEVELSET ? (i) : \
375 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
376 (i) <= SETUP_MODE_SHORTCUTS_5 ? (i) : \
377 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
378 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
379 SETUP_MODE_CHOOSE_ARTWORK : \
380 SETUP_MODE_CHOOSE_OTHER)
382 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
383 menu.draw_xoffset[GAME_MODE_INFO] : \
384 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
385 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
386 menu.draw_yoffset[GAME_MODE_INFO] : \
387 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
389 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
390 menu.draw_xoffset[GAME_MODE_SETUP] : \
391 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
392 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
393 menu.draw_yoffset[GAME_MODE_SETUP] : \
394 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
396 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
397 DRAW_XOFFSET_INFO(info_mode) : \
398 (s) == GAME_MODE_SETUP ? \
399 DRAW_XOFFSET_SETUP(setup_mode) : \
400 menu.draw_xoffset[DRAW_MODE(s)])
401 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
402 DRAW_YOFFSET_INFO(info_mode) : \
403 (s) == GAME_MODE_SETUP ? \
404 DRAW_YOFFSET_SETUP(setup_mode) : \
405 menu.draw_yoffset[DRAW_MODE(s)])
407 #define mSX (SX + DRAW_XOFFSET(game_status))
408 #define mSY (SY + DRAW_YOFFSET(game_status))
410 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
411 menu.list_size[game_status] : \
412 MAX_MENU_ENTRIES_ON_SCREEN)
414 #define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \
415 NUM_MENU_ENTRIES_ON_SCREEN)
418 /* title display and control definitions */
420 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
421 2 * MAX_NUM_TITLE_MESSAGES)
423 static int num_title_screens = 0;
425 struct TitleControlInfo
433 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
435 /* main menu display and control definitions */
437 #define MAIN_CONTROL_NAME 0
438 #define MAIN_CONTROL_LEVELS 1
439 #define MAIN_CONTROL_SCORES 2
440 #define MAIN_CONTROL_EDITOR 3
441 #define MAIN_CONTROL_INFO 4
442 #define MAIN_CONTROL_GAME 5
443 #define MAIN_CONTROL_SETUP 6
444 #define MAIN_CONTROL_QUIT 7
445 #define MAIN_CONTROL_PREV_LEVEL 8
446 #define MAIN_CONTROL_NEXT_LEVEL 9
447 #define MAIN_CONTROL_FIRST_LEVEL 10
448 #define MAIN_CONTROL_LAST_LEVEL 11
449 #define MAIN_CONTROL_LEVEL_NUMBER 12
450 #define MAIN_CONTROL_LEVEL_INFO_1 13
451 #define MAIN_CONTROL_LEVEL_INFO_2 14
452 #define MAIN_CONTROL_LEVEL_NAME 15
453 #define MAIN_CONTROL_LEVEL_AUTHOR 16
454 #define MAIN_CONTROL_LEVEL_YEAR 17
455 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
456 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
457 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
458 #define MAIN_CONTROL_TITLE_1 21
459 #define MAIN_CONTROL_TITLE_2 22
460 #define MAIN_CONTROL_TITLE_3 23
462 static char str_main_text_name[10];
463 static char str_main_text_first_level[10];
464 static char str_main_text_last_level[10];
465 static char str_main_text_level_number[10];
467 static char *main_text_name = str_main_text_name;
468 static char *main_text_first_level = str_main_text_first_level;
469 static char *main_text_last_level = str_main_text_last_level;
470 static char *main_text_level_number = str_main_text_level_number;
471 static char *main_text_levels = "Levelset";
472 static char *main_text_scores = "Hall Of Fame";
473 static char *main_text_editor = "Level Creator";
474 static char *main_text_info = "Info Screen";
475 static char *main_text_game = "Start Game";
476 static char *main_text_setup = "Setup";
477 static char *main_text_quit = "Quit";
478 static char *main_text_level_name = level.name;
479 static char *main_text_level_author = level.author;
480 static char *main_text_level_year = NULL;
481 static char *main_text_level_imported_from = NULL;
482 static char *main_text_level_imported_by = NULL;
483 static char *main_text_level_tested_by = NULL;
484 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
485 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
486 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
488 struct MainControlInfo
492 struct MenuPosInfo *pos_button;
495 struct TextPosInfo *pos_text;
498 struct TextPosInfo *pos_input;
502 static struct MainControlInfo main_controls[] =
506 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
507 &menu.main.text.name, &main_text_name,
508 &menu.main.input.name, &setup.player_name,
512 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
513 &menu.main.text.levels, &main_text_levels,
518 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
519 &menu.main.text.scores, &main_text_scores,
524 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
525 &menu.main.text.editor, &main_text_editor,
530 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
531 &menu.main.text.info, &main_text_info,
536 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
537 &menu.main.text.game, &main_text_game,
542 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
543 &menu.main.text.setup, &main_text_setup,
548 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
549 &menu.main.text.quit, &main_text_quit,
553 /* (these two buttons are real gadgets) */
555 MAIN_CONTROL_PREV_LEVEL,
556 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
561 MAIN_CONTROL_NEXT_LEVEL,
562 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
568 MAIN_CONTROL_FIRST_LEVEL,
570 &menu.main.text.first_level, &main_text_first_level,
574 MAIN_CONTROL_LAST_LEVEL,
576 &menu.main.text.last_level, &main_text_last_level,
580 MAIN_CONTROL_LEVEL_NUMBER,
582 &menu.main.text.level_number, &main_text_level_number,
586 MAIN_CONTROL_LEVEL_INFO_1,
588 &menu.main.text.level_info_1, NULL,
592 MAIN_CONTROL_LEVEL_INFO_2,
594 &menu.main.text.level_info_2, NULL,
598 MAIN_CONTROL_LEVEL_NAME,
600 &menu.main.text.level_name, &main_text_level_name,
604 MAIN_CONTROL_LEVEL_AUTHOR,
606 &menu.main.text.level_author, &main_text_level_author,
610 MAIN_CONTROL_LEVEL_YEAR,
612 &menu.main.text.level_year, &main_text_level_year,
616 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
618 &menu.main.text.level_imported_from, &main_text_level_imported_from,
622 MAIN_CONTROL_LEVEL_IMPORTED_BY,
624 &menu.main.text.level_imported_by, &main_text_level_imported_by,
628 MAIN_CONTROL_LEVEL_TESTED_BY,
630 &menu.main.text.level_tested_by, &main_text_level_tested_by,
634 MAIN_CONTROL_TITLE_1,
636 &menu.main.text.title_1, &main_text_title_1,
640 MAIN_CONTROL_TITLE_2,
642 &menu.main.text.title_2, &main_text_title_2,
646 MAIN_CONTROL_TITLE_3,
648 &menu.main.text.title_3, &main_text_title_3,
661 static int getTitleScreenGraphic(int nr, boolean initial)
663 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
666 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
668 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
672 static int getTitleScreenGameMode(boolean initial)
674 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
678 static int getTitleMessageGameMode(boolean initial)
680 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
684 static int getTitleScreenBackground(boolean initial)
686 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
691 static int getTitleMessageBackground(int nr, boolean initial)
693 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
697 static int getTitleBackground(int nr, boolean initial, boolean is_image)
699 int base = (is_image ?
700 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
701 IMG_BACKGROUND_TITLESCREEN_1) :
702 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
703 IMG_BACKGROUND_TITLEMESSAGE_1));
704 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
705 IMG_BACKGROUND_TITLE);
706 int graphic_local = base + nr;
708 if (graphic_info[graphic_local].bitmap != NULL)
709 return graphic_local;
711 if (graphic_info[graphic_global].bitmap != NULL)
712 return graphic_global;
714 return IMG_UNDEFINED;
717 static int getTitleSound(struct TitleControlInfo *tci)
719 boolean is_image = tci->is_image;
720 int initial = tci->initial;
721 int nr = tci->local_nr;
722 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
723 int base = (is_image ?
724 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
725 SND_BACKGROUND_TITLESCREEN_1) :
726 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
727 SND_BACKGROUND_TITLEMESSAGE_1));
728 int sound_global = menu.sound[mode];
729 int sound_local = base + nr;
732 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
733 nr, initial, is_image,
734 sound_global, getSoundListEntry(sound_global)->filename,
735 sound_local, getSoundListEntry(sound_local)->filename);
738 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
741 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
744 return SND_UNDEFINED;
747 static int getTitleMusic(struct TitleControlInfo *tci)
749 boolean is_image = tci->is_image;
750 int initial = tci->initial;
751 int nr = tci->local_nr;
752 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
753 int base = (is_image ?
754 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
755 MUS_BACKGROUND_TITLESCREEN_1) :
756 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
757 MUS_BACKGROUND_TITLEMESSAGE_1));
758 int music_global = menu.music[mode];
759 int music_local = base + nr;
762 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
763 nr, initial, is_image,
764 music_global, getMusicListEntry(music_global)->filename,
765 music_local, getMusicListEntry(music_local)->filename);
768 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
771 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
774 return MUS_UNDEFINED;
777 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
779 boolean is_image = tci->is_image;
780 int initial = tci->initial;
781 int nr = tci->local_nr;
782 struct TitleFadingInfo ti;
786 int graphic = getTitleScreenGraphic(nr, initial);
788 /* initialize fading control values to default title config settings */
789 ti = (initial ? title_initial_default : title_default);
791 /* override default settings with image config settings, if defined */
792 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
793 ti.fade_mode = graphic_info[graphic].fade_mode;
794 if (graphic_info[graphic].fade_delay > -1)
795 ti.fade_delay = graphic_info[graphic].fade_delay;
796 if (graphic_info[graphic].post_delay > -1)
797 ti.post_delay = graphic_info[graphic].post_delay;
798 if (graphic_info[graphic].auto_delay > -1)
799 ti.auto_delay = graphic_info[graphic].auto_delay;
805 ti.fade_mode = titlemessage_initial[nr].fade_mode;
806 ti.fade_delay = titlemessage_initial[nr].fade_delay;
807 ti.post_delay = titlemessage_initial[nr].post_delay;
808 ti.auto_delay = titlemessage_initial[nr].auto_delay;
812 ti.fade_mode = titlemessage[nr].fade_mode;
813 ti.fade_delay = titlemessage[nr].fade_delay;
814 ti.post_delay = titlemessage[nr].post_delay;
815 ti.auto_delay = titlemessage[nr].auto_delay;
822 static int compareTitleControlInfo(const void *object1, const void *object2)
824 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
825 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
828 if (tci1->initial != tci2->initial)
829 compare_result = (tci1->initial ? -1 : +1);
830 else if (tci1->sort_priority != tci2->sort_priority)
831 compare_result = tci1->sort_priority - tci2->sort_priority;
832 else if (tci1->is_image != tci2->is_image)
833 compare_result = (tci1->is_image ? -1 : +1);
835 compare_result = tci1->local_nr - tci2->local_nr;
837 return compare_result;
840 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
842 int nr, int sort_priority)
844 title_controls[num_title_screens].is_image = is_image;
845 title_controls[num_title_screens].initial = initial;
846 title_controls[num_title_screens].local_nr = nr;
847 title_controls[num_title_screens].sort_priority = sort_priority;
852 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
856 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
858 int graphic = getTitleScreenGraphic(i, initial);
859 Bitmap *bitmap = graphic_info[graphic].bitmap;
860 int sort_priority = graphic_info[graphic].sort_priority;
863 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
866 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
868 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
869 char *filename = getLevelSetTitleMessageFilename(i, initial);
870 int sort_priority = tmi->sort_priority;
872 if (filename != NULL)
873 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
877 static void InitializeTitleControls(boolean show_title_initial)
879 num_title_screens = 0;
881 /* 1st step: initialize title screens for game start (only when starting) */
882 if (show_title_initial)
883 InitializeTitleControls_CheckTitleInfo(TRUE);
885 /* 2nd step: initialize title screens for current level set */
886 InitializeTitleControls_CheckTitleInfo(FALSE);
888 /* sort title screens according to sort_priority and title number */
889 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
890 compareTitleControlInfo);
893 static boolean visibleMenuPos(struct MenuPosInfo *pos)
895 return (pos != NULL && pos->x != -1 && pos->y != -1);
898 static boolean visibleTextPos(struct TextPosInfo *pos)
900 return (pos != NULL && pos->x != -1 && pos->y != -1);
903 static void InitializeMainControls()
905 boolean local_team_mode = (!options.network && setup.team_mode);
908 /* set main control text values to dynamically determined values */
909 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
911 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
912 menu.main.text.first_level.size));
913 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
914 menu.main.text.last_level.size));
915 strcpy(main_text_level_number, int2str(level_nr,
916 menu.main.text.level_number.size));
918 main_text_level_year = leveldir_current->year;
919 main_text_level_imported_from = leveldir_current->imported_from;
920 main_text_level_imported_by = leveldir_current->imported_by;
921 main_text_level_tested_by = leveldir_current->tested_by;
923 /* set main control screen positions to dynamically determined values */
924 for (i = 0; main_controls[i].nr != -1; i++)
926 struct MainControlInfo *mci = &main_controls[i];
928 struct MenuPosInfo *pos_button = mci->pos_button;
929 struct TextPosInfo *pos_text = mci->pos_text;
930 struct TextPosInfo *pos_input = mci->pos_input;
931 char *text = (mci->text ? *mci->text : NULL);
932 char *input = (mci->input ? *mci->input : NULL);
933 int button_graphic = mci->button_graphic;
934 int font_text = (pos_text ? pos_text->font : -1);
935 int font_input = (pos_input ? pos_input->font : -1);
937 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
938 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
939 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
940 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
941 int text_chars = (text != NULL ? strlen(text) : 0);
942 int input_chars = (input != NULL ? strlen(input) : 0);
945 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
947 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
948 int text_width = font_text_width * text_chars;
949 int text_height = font_text_height;
950 int input_width = font_input_width * input_chars;
951 int input_height = font_input_height;
953 if (nr == MAIN_CONTROL_NAME)
955 menu.main.input.name.width = input_width;
956 menu.main.input.name.height = input_height;
959 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
961 if (pos_button->width == 0)
962 pos_button->width = button_width;
963 if (pos_button->height == 0)
964 pos_button->height = button_height;
967 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
969 /* calculate size for non-clickable text -- needed for text alignment */
970 boolean calculate_text_size = (pos_button == NULL && text != NULL);
972 if (visibleMenuPos(pos_button))
974 if (pos_text->x == -1)
975 pos_text->x = pos_button->x + pos_button->width;
976 if (pos_text->y == -1)
977 pos_text->y = pos_button->y;
980 if (pos_text->width == -1 || calculate_text_size)
981 pos_text->width = text_width;
982 if (pos_text->height == -1 || calculate_text_size)
983 pos_text->height = text_height;
986 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
988 if (visibleTextPos(pos_text))
990 if (pos_input->x == -1)
991 pos_input->x = pos_text->x + pos_text->width;
992 if (pos_input->y == -1)
993 pos_input->y = pos_text->y;
996 if (pos_input->width == -1)
997 pos_input->width = input_width;
998 if (pos_input->height == -1)
999 pos_input->height = input_height;
1004 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1005 boolean active_input)
1009 for (i = 0; main_controls[i].nr != -1; i++)
1011 struct MainControlInfo *mci = &main_controls[i];
1013 if (mci->nr == nr || nr == -1)
1015 struct MenuPosInfo *pos_button = mci->pos_button;
1016 struct TextPosInfo *pos_text = mci->pos_text;
1017 struct TextPosInfo *pos_input = mci->pos_input;
1018 char *text = (mci->text ? *mci->text : NULL);
1019 char *input = (mci->input ? *mci->input : NULL);
1020 int button_graphic = mci->button_graphic;
1021 int font_text = (pos_text ? pos_text->font : -1);
1022 int font_input = (pos_input ? pos_input->font : -1);
1026 button_graphic = BUTTON_ACTIVE(button_graphic);
1027 font_text = FONT_ACTIVE(font_text);
1032 font_input = FONT_ACTIVE(font_input);
1035 if (visibleMenuPos(pos_button))
1037 struct MenuPosInfo *pos = pos_button;
1038 int x = mSX + pos->x;
1039 int y = mSY + pos->y;
1041 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1042 DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
1045 if (visibleTextPos(pos_text) && text != NULL)
1047 struct TextPosInfo *pos = pos_text;
1048 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1049 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1052 /* (check why/if this is needed) */
1053 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1055 DrawText(x, y, text, font_text);
1058 if (visibleTextPos(pos_input) && input != NULL)
1060 struct TextPosInfo *pos = pos_input;
1061 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1062 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1065 /* (check why/if this is needed) */
1066 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1068 DrawText(x, y, input, font_input);
1074 static void DrawCursorAndText_Main(int nr, boolean active_text)
1076 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1080 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1082 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1086 static struct MainControlInfo *getMainControlInfo(int nr)
1090 for (i = 0; main_controls[i].nr != -1; i++)
1091 if (main_controls[i].nr == nr)
1092 return &main_controls[i];
1097 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1102 int rect_x = ALIGNED_TEXT_XPOS(rect);
1103 int rect_y = ALIGNED_TEXT_YPOS(rect);
1105 return (x >= rect_x && x < rect_x + rect->width &&
1106 y >= rect_y && y < rect_y + rect->height);
1109 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1114 int rect_x = ALIGNED_TEXT_XPOS(rect);
1115 int rect_y = ALIGNED_TEXT_YPOS(rect);
1118 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1119 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1120 (x >= rect_x && x < rect_x + rect->width &&
1121 y >= rect_y && y < rect_y + rect->height));
1124 return (x >= rect_x && x < rect_x + rect->width &&
1125 y >= rect_y && y < rect_y + rect->height);
1128 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1130 static int cursor_array[MAX_LEV_FIELDY];
1131 int x = mSX + TILEX * xpos;
1132 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1137 cursor_array[ypos] = graphic;
1139 graphic = cursor_array[ypos];
1143 graphic = BUTTON_ACTIVE(graphic);
1145 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1146 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1149 static void initCursor(int ypos, int graphic)
1151 drawCursorExt(0, ypos, FALSE, graphic);
1154 static void drawCursor(int ypos, boolean active)
1156 drawCursorExt(0, ypos, active, -1);
1159 static void drawCursorXY(int xpos, int ypos, int graphic)
1161 drawCursorExt(xpos, ypos, FALSE, graphic);
1164 static void drawChooseTreeCursor(int ypos, boolean active)
1166 int last_game_status = game_status; /* save current game status */
1168 drawCursorExt(0, ypos, active, -1);
1170 game_status = last_game_status; /* restore current game status */
1175 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1176 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1179 int effectiveGameStatus()
1181 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1182 return GAME_MODE_TITLE;
1187 void DrawTitleScreenImage(int nr, boolean initial)
1189 int graphic = getTitleScreenGraphic(nr, initial);
1190 Bitmap *bitmap = graphic_info[graphic].bitmap;
1191 int width = graphic_info[graphic].width;
1192 int height = graphic_info[graphic].height;
1193 int src_x = graphic_info[graphic].src_x;
1194 int src_y = graphic_info[graphic].src_y;
1200 if (width > WIN_XSIZE)
1202 /* image width too large for window => center image horizontally */
1203 src_x = (width - WIN_XSIZE) / 2;
1207 if (height > WIN_YSIZE)
1209 /* image height too large for window => center image vertically */
1210 src_y = (height - WIN_YSIZE) / 2;
1214 /* always display title screens centered */
1215 dst_x = (WIN_XSIZE - width) / 2;
1216 dst_y = (WIN_YSIZE - height) / 2;
1218 SetDrawBackgroundMask(REDRAW_ALL);
1219 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1221 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1223 if (DrawingOnBackground(dst_x, dst_y))
1225 SetClipOrigin(bitmap, bitmap->stored_clip_gc, dst_x - src_x, dst_y - src_y);
1226 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1229 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1231 redraw_mask = REDRAW_ALL;
1234 void DrawTitleScreenMessage(int nr, boolean initial)
1236 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1237 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1238 int last_game_status = game_status; /* save current game status */
1240 if (filename == NULL)
1243 /* force TITLE font on title message screen */
1244 game_status = getTitleMessageGameMode(initial);
1246 /* if chars set to "-1", automatically determine by text and font width */
1247 if (tmi->chars == -1)
1248 tmi->chars = tmi->width / getFontWidth(tmi->font);
1250 tmi->width = tmi->chars * getFontWidth(tmi->font);
1252 /* if lines set to "-1", automatically determine by text and font height */
1253 if (tmi->lines == -1)
1254 tmi->lines = tmi->height / getFontHeight(tmi->font);
1256 tmi->height = tmi->lines * getFontHeight(tmi->font);
1258 SetDrawBackgroundMask(REDRAW_ALL);
1259 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1261 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1263 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1264 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1265 tmi->autowrap, tmi->centered, tmi->parse_comments);
1267 game_status = last_game_status; /* restore current game status */
1270 void DrawTitleScreen()
1272 KeyboardAutoRepeatOff();
1274 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1279 boolean CheckTitleScreen(boolean levelset_has_changed)
1281 static boolean show_title_initial = TRUE;
1282 boolean show_titlescreen = FALSE;
1284 /* needed to be able to skip title screen, if no image or message defined */
1285 InitializeTitleControls(show_title_initial);
1287 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1288 show_titlescreen = TRUE;
1290 /* show initial title images and messages only once at program start */
1291 show_title_initial = FALSE;
1293 return (show_titlescreen && num_title_screens > 0);
1296 void DrawMainMenuExt(int fade_mask, boolean do_fading)
1298 static LevelDirTree *leveldir_last_valid = NULL;
1299 boolean levelset_has_changed = FALSE;
1301 LimitScreenUpdates(FALSE);
1303 FadeSetLeaveScreen();
1305 /* do not fade out here -- function may continue and fade on editor screen */
1308 FadeSoundsAndMusic();
1310 KeyboardAutoRepeatOn();
1313 SetDrawDeactivationMask(REDRAW_NONE);
1314 SetDrawBackgroundMask(REDRAW_FIELD);
1316 audio.sound_deactivated = FALSE;
1320 /* needed if last screen was the playing screen, invoked from level editor */
1321 if (level_editor_test_game)
1323 game_status = GAME_MODE_EDITOR;
1329 /* needed if last screen was the setup screen and fullscreen state changed */
1330 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1331 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1333 /* leveldir_current may be invalid (level group, parent link) */
1334 if (!validLevelSeries(leveldir_current))
1335 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1337 if (leveldir_current != leveldir_last_valid)
1338 levelset_has_changed = TRUE;
1340 /* store valid level series information */
1341 leveldir_last_valid = leveldir_current;
1343 init_last = init; /* switch to new busy animation */
1345 /* needed if last screen (level choice) changed graphics, sounds or music */
1346 ReloadCustomArtwork(0);
1348 if (redraw_mask & REDRAW_ALL)
1349 fade_mask = REDRAW_ALL;
1353 /* needed if different viewport properties defined for menues */
1354 ChangeViewportPropertiesIfNeeded();
1356 /* needed if last screen was the editor screen */
1357 UndrawSpecialEditorDoor();
1359 SetDrawtoField(DRAW_BACKBUFFER);
1361 if (CheckTitleScreen(levelset_has_changed))
1363 game_status = GAME_MODE_TITLE;
1370 /* level_nr may have been set to value over handicap with level editor */
1371 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1372 level_nr = leveldir_current->handicap_level;
1374 LoadLevel(level_nr);
1375 LoadScore(level_nr);
1377 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1379 if (fade_mask == REDRAW_ALL)
1384 InitializeMainControls();
1386 DrawCursorAndText_Main(-1, FALSE);
1387 DrawPreviewLevelInitial();
1389 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1392 if (TAPE_IS_EMPTY(tape))
1394 DrawCompleteVideoDisplay();
1399 /* create gadgets for main menu screen */
1400 FreeScreenGadgets();
1401 CreateScreenGadgets();
1403 /* map gadgets for main menu screen */
1405 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1407 /* copy actual game door content to door double buffer for OpenDoor() */
1408 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1410 OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1412 DrawMaskedBorder(REDRAW_ALL);
1417 /* update screen area with special editor door */
1418 redraw_mask |= REDRAW_ALL;
1421 SetMouseCursor(CURSOR_DEFAULT);
1425 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1428 void DrawAndFadeInMainMenu(int fade_mask)
1430 DrawMainMenuExt(fade_mask, TRUE);
1435 DrawMainMenuExt(REDRAW_ALL, FALSE);
1438 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1439 static void gotoTopLevelDir()
1441 /* move upwards to top level directory */
1442 while (leveldir_current->node_parent)
1444 /* write a "path" into level tree for easy navigation to last level */
1445 if (leveldir_current->node_parent->node_group->cl_first == -1)
1447 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1448 int leveldir_pos = posTreeInfo(leveldir_current);
1449 int num_page_entries;
1450 int cl_first, cl_cursor;
1452 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1453 num_page_entries = num_leveldirs;
1455 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1457 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1458 cl_cursor = leveldir_pos - cl_first;
1460 leveldir_current->node_parent->node_group->cl_first = cl_first;
1461 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1464 leveldir_current = leveldir_current->node_parent;
1469 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1471 static unsigned int title_delay = 0;
1472 static int title_screen_nr = 0;
1473 static int last_sound = -1, last_music = -1;
1474 boolean return_to_main_menu = FALSE;
1475 boolean use_fading_main_menu = TRUE;
1476 struct TitleControlInfo *tci;
1477 struct TitleFadingInfo fading_default;
1478 struct TitleFadingInfo fading_last = fading;
1479 struct TitleFadingInfo fading_next;
1482 if (button == MB_MENU_INITIALIZE)
1485 title_screen_nr = 0;
1486 tci = &title_controls[title_screen_nr];
1488 last_sound = SND_UNDEFINED;
1489 last_music = MUS_UNDEFINED;
1491 if (game_status == GAME_MODE_INFO)
1493 if (num_title_screens == 0)
1495 DrawInfoScreen_NotAvailable("Title screen information:",
1496 "No title screen for this level set.");
1501 FadeSoundsAndMusic();
1503 FadeOut(REDRAW_ALL);
1507 DrawTitleScreenImage(tci->local_nr, tci->initial);
1509 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1511 fading_default = (tci->initial ? title_initial_default : title_default);
1513 fading = fading_next = getTitleFading(tci);
1515 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1516 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1518 fading.fade_mode = FADE_MODE_FADE;
1519 fading.fade_delay = fading_default.fade_delay;
1522 sound = getTitleSound(tci);
1523 music = getTitleMusic(tci);
1525 if (sound != last_sound)
1526 PlayMenuSoundExt(sound);
1527 if (music != last_music)
1528 PlayMenuMusicExt(music);
1533 SetMouseCursor(CURSOR_NONE);
1537 fading = fading_next;
1539 DelayReached(&title_delay, 0); /* reset delay counter */
1544 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1545 button = MB_MENU_CHOICE;
1547 if (button == MB_MENU_LEAVE)
1549 return_to_main_menu = TRUE;
1550 use_fading_main_menu = FALSE;
1552 else if (button == MB_MENU_CHOICE)
1554 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1556 FadeSetEnterScreen();
1558 info_mode = INFO_MODE_MAIN;
1559 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1565 tci = &title_controls[title_screen_nr];
1567 if (title_screen_nr < num_title_screens)
1569 sound = getTitleSound(tci);
1570 music = getTitleMusic(tci);
1572 if (sound == SND_UNDEFINED || sound != last_sound)
1574 if (music == MUS_UNDEFINED || music != last_music)
1577 FadeOut(REDRAW_ALL);
1580 DrawTitleScreenImage(tci->local_nr, tci->initial);
1582 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1584 fading_next = getTitleFading(tci);
1586 sound = getTitleSound(tci);
1587 music = getTitleMusic(tci);
1589 if (sound != last_sound)
1590 PlayMenuSoundExt(sound);
1591 if (music != last_music)
1592 PlayMenuMusicExt(music);
1597 /* last screen already faded out, next screen has no animation */
1598 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1599 fading_next.fade_mode == FADE_MODE_NONE)
1600 fading = fading_next;
1604 fading = fading_next;
1606 DelayReached(&title_delay, 0); /* reset delay counter */
1610 FadeSoundsAndMusic();
1612 return_to_main_menu = TRUE;
1616 if (return_to_main_menu)
1618 SetMouseCursor(CURSOR_DEFAULT);
1620 if (game_status == GAME_MODE_INFO)
1622 info_mode = INFO_MODE_MAIN;
1624 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1626 else /* default: return to main menu */
1628 game_status = GAME_MODE_MAIN;
1630 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1635 void HandleMainMenu_SelectLevel(int step, int direction)
1637 int old_level_nr = level_nr;
1640 new_level_nr = old_level_nr + step * direction;
1641 if (new_level_nr < leveldir_current->first_level)
1642 new_level_nr = leveldir_current->first_level;
1643 if (new_level_nr > leveldir_current->last_level)
1644 new_level_nr = leveldir_current->last_level;
1646 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1648 /* skipping levels is only allowed when trying to skip single level */
1649 if (setup.skip_levels && step == 1 &&
1650 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1652 leveldir_current->handicap_level++;
1653 SaveLevelSetup_SeriesInfo();
1656 new_level_nr = leveldir_current->handicap_level;
1659 if (new_level_nr != old_level_nr)
1661 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1663 PlaySound(SND_MENU_ITEM_SELECTING);
1665 level_nr = new_level_nr;
1667 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1668 int2str(level_nr, menu.main.text.level_number.size),
1669 mci->pos_text->font);
1671 LoadLevel(level_nr);
1672 DrawPreviewLevelInitial();
1676 DrawCompleteVideoDisplay();
1678 /* needed because DrawPreviewLevelInitial() takes some time */
1684 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1686 static int choice = MAIN_CONTROL_GAME;
1690 if (button == MB_MENU_INITIALIZE)
1692 DrawCursorAndText_Main(choice, TRUE);
1697 if (mx || my) /* mouse input */
1701 for (i = 0; main_controls[i].nr != -1; i++)
1703 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1704 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1705 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1707 pos = main_controls[i].nr;
1713 else if (dx || dy) /* keyboard input */
1715 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1716 choice == MAIN_CONTROL_SETUP))
1717 button = MB_MENU_CHOICE;
1722 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1724 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1726 else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1728 HandleMainMenu_SelectLevel(MAX_LEVELS, -1);
1730 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1732 HandleMainMenu_SelectLevel(MAX_LEVELS, +1);
1734 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1736 game_status = GAME_MODE_LEVELNR;
1738 ChangeViewportPropertiesIfNeeded();
1740 DrawChooseLevelNr();
1742 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1748 PlaySound(SND_MENU_ITEM_ACTIVATING);
1750 DrawCursorAndText_Main(choice, FALSE);
1751 DrawCursorAndText_Main(pos, TRUE);
1758 PlaySound(SND_MENU_ITEM_SELECTING);
1760 if (pos == MAIN_CONTROL_NAME)
1762 game_status = GAME_MODE_PSEUDO_TYPENAME;
1764 HandleTypeName(strlen(setup.player_name), 0);
1766 else if (pos == MAIN_CONTROL_LEVELS)
1770 game_status = GAME_MODE_LEVELS;
1772 SaveLevelSetup_LastSeries();
1773 SaveLevelSetup_SeriesInfo();
1775 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1779 ChangeViewportPropertiesIfNeeded();
1781 DrawChooseLevelSet();
1784 else if (pos == MAIN_CONTROL_SCORES)
1786 game_status = GAME_MODE_SCORES;
1788 ChangeViewportPropertiesIfNeeded();
1792 else if (pos == MAIN_CONTROL_EDITOR)
1794 if (leveldir_current->readonly &&
1795 !strEqual(setup.player_name, "Artsoft"))
1796 Request("This level is read only!", REQ_CONFIRM);
1798 CloseDoor(DOOR_CLOSE_2);
1800 game_status = GAME_MODE_EDITOR;
1802 FadeSetEnterScreen();
1806 else if (pos == MAIN_CONTROL_INFO)
1808 game_status = GAME_MODE_INFO;
1809 info_mode = INFO_MODE_MAIN;
1811 ChangeViewportPropertiesIfNeeded();
1815 else if (pos == MAIN_CONTROL_GAME)
1817 StartGameActions(options.network, setup.autorecord, level.random_seed);
1819 else if (pos == MAIN_CONTROL_SETUP)
1821 game_status = GAME_MODE_SETUP;
1822 setup_mode = SETUP_MODE_MAIN;
1824 ChangeViewportPropertiesIfNeeded();
1828 else if (pos == MAIN_CONTROL_QUIT)
1830 SaveLevelSetup_LastSeries();
1831 SaveLevelSetup_SeriesInfo();
1833 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
1834 game_status = GAME_MODE_QUIT;
1841 /* ========================================================================= */
1842 /* info screen functions */
1843 /* ========================================================================= */
1845 static struct TokenInfo *info_info;
1846 static int num_info_info;
1848 static void execInfoTitleScreen()
1850 info_mode = INFO_MODE_TITLE;
1855 static void execInfoElements()
1857 info_mode = INFO_MODE_ELEMENTS;
1862 static void execInfoMusic()
1864 info_mode = INFO_MODE_MUSIC;
1869 static void execInfoCredits()
1871 info_mode = INFO_MODE_CREDITS;
1876 static void execInfoProgram()
1878 info_mode = INFO_MODE_PROGRAM;
1883 static void execInfoVersion()
1885 info_mode = INFO_MODE_VERSION;
1890 static void execInfoLevelSet()
1892 info_mode = INFO_MODE_LEVELSET;
1897 static void execExitInfo()
1899 game_status = GAME_MODE_MAIN;
1901 DrawMainMenuExt(REDRAW_FIELD, FALSE);
1904 static struct TokenInfo info_info_main[] =
1906 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
1907 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
1908 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
1909 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
1910 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
1911 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
1912 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
1913 { TYPE_EMPTY, NULL, "" },
1914 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
1919 static void DrawCursorAndText_Info(int pos, boolean active)
1921 int xpos = MENU_SCREEN_START_XPOS;
1922 int ypos = MENU_SCREEN_START_YPOS + pos;
1923 int font_nr = FONT_MENU_1;
1926 font_nr = FONT_ACTIVE(font_nr);
1928 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
1930 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
1931 drawCursor(pos, active);
1934 static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
1939 CloseDoor(DOOR_CLOSE_2);
1941 /* (needed after displaying title screens which disable auto repeat) */
1942 KeyboardAutoRepeatOn();
1944 FadeSetLeaveScreen();
1948 if (fade_mask == REDRAW_ALL)
1952 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1957 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
1959 info_info = info_info_main;
1962 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1964 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
1965 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
1966 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
1967 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
1968 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
1969 initCursor(i, IMG_MENU_BUTTON);
1971 DrawCursorAndText_Info(i, FALSE);
1976 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
1981 DrawMaskedBorder(fade_mask);
1988 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
1990 static int choice_store[MAX_INFO_MODES];
1991 int choice = choice_store[info_mode]; /* always starts with 0 */
1995 if (button == MB_MENU_INITIALIZE)
1997 /* advance to first valid menu entry */
1998 while (choice < num_info_info &&
1999 info_info[choice].type & TYPE_SKIP_ENTRY)
2001 choice_store[info_mode] = choice;
2003 DrawCursorAndText_Info(choice, TRUE);
2007 else if (button == MB_MENU_LEAVE)
2009 for (y = 0; y < num_info_info; y++)
2011 if (info_info[y].type & TYPE_LEAVE_MENU)
2013 void (*menu_callback_function)(void) = info_info[y].value;
2017 menu_callback_function();
2019 break; /* absolutely needed because function changes 'info_info'! */
2026 if (mx || my) /* mouse input */
2028 x = (mx - mSX) / 32;
2029 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2031 else if (dx || dy) /* keyboard input */
2035 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2037 if (info_info[choice].type & menu_navigation_type ||
2038 info_info[choice].type & TYPE_ENTER_SCREEN ||
2039 info_info[choice].type & TYPE_BOOLEAN_STYLE ||
2040 info_info[choice].type & TYPE_YES_NO_AUTO)
2041 button = MB_MENU_CHOICE;
2046 /* jump to next non-empty menu entry (up or down) */
2047 while (y > 0 && y < num_info_info - 1 &&
2048 info_info[y].type & TYPE_SKIP_ENTRY)
2052 if (IN_VIS_MENU(x, y) &&
2053 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2059 PlaySound(SND_MENU_ITEM_ACTIVATING);
2061 DrawCursorAndText_Info(choice, FALSE);
2062 DrawCursorAndText_Info(y, TRUE);
2064 choice = choice_store[info_mode] = y;
2067 else if (!(info_info[y].type & TYPE_GHOSTED))
2069 PlaySound(SND_MENU_ITEM_SELECTING);
2071 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2073 void (*menu_callback_function)(void) = info_info[choice].value;
2075 FadeSetFromType(info_info[y].type);
2077 menu_callback_function();
2083 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2085 int ystart1 = mSY - SY + 100;
2086 int ystart2 = mSY - SY + 150;
2087 int ybottom = mSY - SY + SYSIZE - 20;
2089 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2091 FadeOut(REDRAW_FIELD);
2096 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2097 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2099 DrawTextSCentered(ybottom, FONT_TEXT_4,
2100 "Press any key or button for info menu");
2102 FadeIn(REDRAW_FIELD);
2105 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2107 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2108 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2109 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2110 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2111 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2112 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2113 int ystep = MENU_SCREEN_INFO_YSTEP;
2114 int element, action, direction;
2122 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2123 infoscreen_step[i] = infoscreen_frame[i] = 0;
2128 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2130 DrawTextSCentered(ybottom, FONT_TEXT_4,
2131 "Press any key or button for next page");
2137 while (helpanim_info[j].element != HELPANIM_LIST_END)
2139 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2144 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2153 j += infoscreen_step[i - start];
2155 element = helpanim_info[j].element;
2156 action = helpanim_info[j].action;
2157 direction = helpanim_info[j].direction;
2160 element = EL_UNKNOWN;
2162 if (action != -1 && direction != -1)
2163 graphic = el_act_dir2img(element, action, direction);
2164 else if (action != -1)
2165 graphic = el_act2img(element, action);
2166 else if (direction != -1)
2167 graphic = el_dir2img(element, direction);
2169 graphic = el2img(element);
2171 delay = helpanim_info[j++].delay;
2176 if (infoscreen_frame[i - start] == 0)
2179 infoscreen_frame[i - start] = delay - 1;
2183 sync_frame = delay - infoscreen_frame[i - start];
2184 infoscreen_frame[i - start]--;
2187 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2189 if (!infoscreen_frame[i - start])
2190 infoscreen_step[i - start] = 0;
2194 if (!infoscreen_frame[i - start])
2195 infoscreen_step[i - start]++;
2196 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2202 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2204 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2205 graphic, sync_frame, USE_MASKING);
2208 DrawInfoScreen_HelpText(element, action, direction, i - start);
2213 redraw_mask |= REDRAW_FIELD;
2218 static char *getHelpText(int element, int action, int direction)
2220 char token[MAX_LINE_LEN];
2222 strcpy(token, element_info[element].token_name);
2225 strcat(token, element_action_info[action].suffix);
2227 if (direction != -1)
2228 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2230 return getHashEntry(helptext_info, token);
2233 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2235 int font_nr = FONT_INFO_ELEMENTS;
2236 int font_width = getFontWidth(font_nr);
2237 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2238 int sy = mSY + 65 + 2 * 32 + 1;
2239 int ystep = TILEY + 4;
2240 int pad_x = sx - SX;
2241 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2242 int max_lines_per_text = 2;
2245 if (action != -1 && direction != -1) /* element.action.direction */
2246 text = getHelpText(element, action, direction);
2248 if (text == NULL && action != -1) /* element.action */
2249 text = getHelpText(element, action, -1);
2251 if (text == NULL && direction != -1) /* element.direction */
2252 text = getHelpText(element, -1, direction);
2254 if (text == NULL) /* base element */
2255 text = getHelpText(element, -1, -1);
2257 if (text == NULL) /* not found */
2258 text = "No description available";
2260 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2261 sy += getFontHeight(font_nr) / 2;
2263 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2264 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2265 TRUE, FALSE, FALSE);
2268 void DrawInfoScreen_TitleScreen()
2273 void HandleInfoScreen_TitleScreen(int button)
2275 HandleTitleScreen(0, 0, 0, 0, button);
2278 void DrawInfoScreen_Elements()
2280 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2282 FadeOut(REDRAW_FIELD);
2287 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2289 FadeIn(REDRAW_FIELD);
2294 void HandleInfoScreen_Elements(int button)
2296 static unsigned int info_delay = 0;
2297 static int num_anims;
2298 static int num_pages;
2300 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2303 if (button == MB_MENU_INITIALIZE)
2305 boolean new_element = TRUE;
2309 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2311 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2313 else if (new_element)
2316 new_element = FALSE;
2320 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2324 if (button == MB_MENU_LEAVE)
2326 PlaySound(SND_MENU_ITEM_SELECTING);
2328 info_mode = INFO_MODE_MAIN;
2333 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2335 if (button != MB_MENU_INITIALIZE)
2337 PlaySound(SND_MENU_ITEM_SELECTING);
2342 if (page >= num_pages)
2344 FadeSoundsAndMusic();
2346 info_mode = INFO_MODE_MAIN;
2347 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2353 FadeSetNextScreen();
2355 if (button != MB_MENU_INITIALIZE)
2356 FadeOut(REDRAW_FIELD);
2358 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2360 if (button != MB_MENU_INITIALIZE)
2361 FadeIn(REDRAW_FIELD);
2365 if (DelayReached(&info_delay, GameFrameDelay))
2366 if (page < num_pages)
2367 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2369 PlayMenuSoundIfLoop();
2373 void DrawInfoScreen_Music()
2375 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2377 FadeOut(REDRAW_FIELD);
2384 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2386 FadeIn(REDRAW_FIELD);
2389 void HandleInfoScreen_Music(int button)
2391 static struct MusicFileInfo *list = NULL;
2392 int ystart1 = mSY - SY + 100;
2393 int ystart2 = mSY - SY + 150;
2394 int ybottom = mSY - SY + SYSIZE - 20;
2397 if (button == MB_MENU_INITIALIZE)
2399 list = music_file_info;
2403 FadeSoundsAndMusic();
2408 DrawTextSCentered(ystart1, FONT_TEXT_1,
2409 "No music info for this level set.");
2411 DrawTextSCentered(ybottom, FONT_TEXT_4,
2412 "Press any key or button for info menu");
2418 if (button == MB_MENU_LEAVE)
2420 PlaySound(SND_MENU_ITEM_SELECTING);
2422 FadeSoundsAndMusic();
2424 info_mode = INFO_MODE_MAIN;
2429 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2433 if (button != MB_MENU_INITIALIZE)
2435 PlaySound(SND_MENU_ITEM_SELECTING);
2443 FadeSoundsAndMusic();
2445 info_mode = INFO_MODE_MAIN;
2446 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2451 FadeSoundsAndMusic();
2453 if (list != music_file_info)
2454 FadeSetNextScreen();
2456 if (button != MB_MENU_INITIALIZE)
2457 FadeOut(REDRAW_FIELD);
2464 int sound = list->music;
2466 if (sound_info[sound].loop)
2467 PlaySoundLoop(sound);
2471 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2475 PlayMusic(list->music);
2477 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2480 if (!strEqual(list->title, UNKNOWN_NAME))
2482 if (!strEqual(list->title_header, UNKNOWN_NAME))
2483 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2485 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2488 if (!strEqual(list->artist, UNKNOWN_NAME))
2490 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2491 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2493 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2495 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2498 if (!strEqual(list->album, UNKNOWN_NAME))
2500 if (!strEqual(list->album_header, UNKNOWN_NAME))
2501 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2503 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2505 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2508 if (!strEqual(list->year, UNKNOWN_NAME))
2510 if (!strEqual(list->year_header, UNKNOWN_NAME))
2511 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2513 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2515 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2518 DrawTextSCentered(ybottom, FONT_TEXT_4,
2519 "Press any key or button for next page");
2521 if (button != MB_MENU_INITIALIZE)
2522 FadeIn(REDRAW_FIELD);
2525 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2526 PlaySoundLoop(list->music);
2529 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2531 int ystart1 = mSY - SY + 100;
2532 int ystart2 = mSY - SY + 150;
2533 int ybottom = mSY - SY + SYSIZE - 20;
2539 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2543 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2544 "Special thanks to");
2545 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2547 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2549 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2550 "\"Boulder Dash\"");
2551 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2553 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2555 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2557 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2558 "First Star Software");
2560 else if (screen_nr == 1)
2562 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2563 "Special thanks to");
2564 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2565 "Klaus Heinz & Volker Wertich");
2566 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2568 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2569 "\"Emerald Mine\"");
2570 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2572 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2574 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2576 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2579 else if (screen_nr == 2)
2581 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2582 "Special thanks to");
2583 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2584 "Michael Stopp & Philip Jespersen");
2585 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2587 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2589 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2591 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2593 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2595 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2596 "Digital Integration");
2598 else if (screen_nr == 3)
2600 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2601 "Special thanks to");
2602 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2603 "Hiroyuki Imabayashi");
2604 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2606 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2608 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2610 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2612 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2614 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2617 else if (screen_nr == 4)
2619 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2620 "Special thanks to");
2621 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2623 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2625 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2626 "J\xfcrgen Bonhagen");
2627 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2628 "for the continuous creation");
2629 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2630 "of outstanding level sets");
2632 else if (screen_nr == 5)
2634 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2636 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2638 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2639 "for ideas and inspiration by");
2640 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2643 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2645 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2647 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2648 "for ideas and inspiration by");
2649 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2652 else if (screen_nr == 6)
2654 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2656 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2659 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2660 "for the code base used for the");
2661 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
2662 "native Emerald Mine engine");
2664 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2665 "for the new Emerald Mine engine");
2668 else if (screen_nr == 7)
2670 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2672 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2674 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2675 "for the initial DOS port");
2677 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2679 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2681 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2682 "for some additional toons");
2684 else if (screen_nr == 8)
2686 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2687 "And not to forget:");
2688 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2690 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2691 "All those who contributed");
2692 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2693 "levels to this game");
2694 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2698 DrawTextSCentered(ybottom, FONT_TEXT_4,
2699 "Press any key or button for next page");
2702 void DrawInfoScreen_Credits()
2704 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2706 FadeSoundsAndMusic();
2708 FadeOut(REDRAW_FIELD);
2710 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
2712 FadeIn(REDRAW_FIELD);
2715 void HandleInfoScreen_Credits(int button)
2717 static int screen_nr = 0;
2718 int num_screens = 9;
2720 if (button == MB_MENU_INITIALIZE)
2724 // DrawInfoScreen_CreditsScreen(screen_nr);
2727 if (button == MB_MENU_LEAVE)
2729 PlaySound(SND_MENU_ITEM_SELECTING);
2731 info_mode = INFO_MODE_MAIN;
2736 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2738 if (button != MB_MENU_INITIALIZE)
2740 PlaySound(SND_MENU_ITEM_SELECTING);
2745 if (screen_nr >= num_screens)
2747 FadeSoundsAndMusic();
2749 info_mode = INFO_MODE_MAIN;
2750 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2756 FadeSetNextScreen();
2758 if (button != MB_MENU_INITIALIZE)
2759 FadeOut(REDRAW_FIELD);
2761 DrawInfoScreen_CreditsScreen(screen_nr);
2763 if (button != MB_MENU_INITIALIZE)
2764 FadeIn(REDRAW_FIELD);
2768 PlayMenuSoundIfLoop();
2772 void DrawInfoScreen_Program()
2774 int ystart1 = mSY - SY + 100;
2775 int ystart2 = mSY - SY + 150;
2776 int ybottom = mSY - SY + SYSIZE - 20;
2779 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
2781 FadeOut(REDRAW_FIELD);
2786 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
2788 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2789 "This game is Freeware!");
2790 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2791 "If you like it, send e-mail to:");
2792 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2793 PROGRAM_EMAIL_STRING);
2794 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2795 "More information and levels:");
2796 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2797 PROGRAM_WEBSITE_STRING);
2798 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2799 "If you have created new levels,");
2800 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
2801 "send them to me to include them!");
2802 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
2805 DrawTextSCentered(ybottom, FONT_TEXT_4,
2806 "Press any key or button for info menu");
2808 FadeIn(REDRAW_FIELD);
2811 void HandleInfoScreen_Program(int button)
2813 if (button == MB_MENU_LEAVE)
2815 PlaySound(SND_MENU_ITEM_SELECTING);
2817 info_mode = INFO_MODE_MAIN;
2822 else if (button == MB_MENU_CHOICE)
2824 PlaySound(SND_MENU_ITEM_SELECTING);
2826 FadeSoundsAndMusic();
2828 info_mode = INFO_MODE_MAIN;
2829 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2833 PlayMenuSoundIfLoop();
2837 void DrawInfoScreen_Version()
2839 int font_header = FONT_TEXT_3;
2840 int font_text = FONT_TEXT_2;
2841 int xstep = getFontWidth(font_text);
2842 int ystep = getFontHeight(font_text);
2843 int ystart1 = mSY - SY + 100;
2844 int ystart2 = mSY - SY + 150;
2845 int ybottom = mSY - SY + SYSIZE - 20;
2846 int xstart1 = mSX - SX + 2 * xstep;
2847 int xstart2 = mSX - SX + 18 * xstep;
2848 int xstart3 = mSX - SX + 28 * xstep;
2849 SDL_version sdl_version_compiled;
2850 const SDL_version *sdl_version_linked;
2851 int driver_name_len = 10;
2852 #if defined(TARGET_SDL2)
2853 SDL_version sdl_version_linked_ext;
2854 const char *driver_name = NULL;
2856 char driver_name[driver_name_len];
2859 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
2861 FadeOut(REDRAW_FIELD);
2866 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
2868 DrawTextF(xstart1, ystart2, font_header, "Name");
2869 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
2872 DrawTextF(xstart1, ystart2, font_header, "Version");
2873 DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
2876 DrawTextF(xstart1, ystart2, font_header, "Platform");
2877 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
2880 DrawTextF(xstart1, ystart2, font_header, "Target");
2881 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
2884 DrawTextF(xstart1, ystart2, font_header, "Compile time");
2885 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
2887 ystart2 += 3 * ystep;
2888 DrawTextF(xstart1, ystart2, font_header, "Library");
2889 DrawTextF(xstart2, ystart2, font_header, "compiled");
2890 DrawTextF(xstart3, ystart2, font_header, "linked");
2892 SDL_VERSION(&sdl_version_compiled);
2893 #if defined(TARGET_SDL2)
2894 SDL_GetVersion(&sdl_version_linked_ext);
2895 sdl_version_linked = &sdl_version_linked_ext;
2897 sdl_version_linked = SDL_Linked_Version();
2900 ystart2 += 2 * ystep;
2901 DrawTextF(xstart1, ystart2, font_text, "SDL");
2902 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2903 sdl_version_compiled.major,
2904 sdl_version_compiled.minor,
2905 sdl_version_compiled.patch);
2906 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2907 sdl_version_linked->major,
2908 sdl_version_linked->minor,
2909 sdl_version_linked->patch);
2911 SDL_IMAGE_VERSION(&sdl_version_compiled);
2912 sdl_version_linked = IMG_Linked_Version();
2915 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
2916 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2917 sdl_version_compiled.major,
2918 sdl_version_compiled.minor,
2919 sdl_version_compiled.patch);
2920 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2921 sdl_version_linked->major,
2922 sdl_version_linked->minor,
2923 sdl_version_linked->patch);
2925 SDL_MIXER_VERSION(&sdl_version_compiled);
2926 sdl_version_linked = Mix_Linked_Version();
2929 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
2930 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2931 sdl_version_compiled.major,
2932 sdl_version_compiled.minor,
2933 sdl_version_compiled.patch);
2934 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2935 sdl_version_linked->major,
2936 sdl_version_linked->minor,
2937 sdl_version_linked->patch);
2939 SDL_NET_VERSION(&sdl_version_compiled);
2940 sdl_version_linked = SDLNet_Linked_Version();
2943 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
2944 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
2945 sdl_version_compiled.major,
2946 sdl_version_compiled.minor,
2947 sdl_version_compiled.patch);
2948 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
2949 sdl_version_linked->major,
2950 sdl_version_linked->minor,
2951 sdl_version_linked->patch);
2953 ystart2 += 3 * ystep;
2954 DrawTextF(xstart1, ystart2, font_header, "Driver");
2955 DrawTextF(xstart2, ystart2, font_header, "Requested");
2956 DrawTextF(xstart3, ystart2, font_header, "Used");
2958 #if defined(TARGET_SDL2)
2959 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
2961 SDL_VideoDriverName(driver_name, driver_name_len);
2964 ystart2 += 2 * ystep;
2965 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
2966 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
2967 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2969 #if defined(TARGET_SDL2)
2970 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
2972 SDL_AudioDriverName(driver_name, driver_name_len);
2976 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
2977 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
2978 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
2980 DrawTextSCentered(ybottom, FONT_TEXT_4,
2981 "Press any key or button for info menu");
2983 FadeIn(REDRAW_FIELD);
2986 void HandleInfoScreen_Version(int button)
2988 if (button == MB_MENU_LEAVE)
2990 PlaySound(SND_MENU_ITEM_SELECTING);
2992 info_mode = INFO_MODE_MAIN;
2997 else if (button == MB_MENU_CHOICE)
2999 PlaySound(SND_MENU_ITEM_SELECTING);
3001 FadeSoundsAndMusic();
3003 info_mode = INFO_MODE_MAIN;
3004 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3008 PlayMenuSoundIfLoop();
3012 void DrawInfoScreen_LevelSet()
3014 struct TitleMessageInfo *tmi = &readme;
3015 char *filename = getLevelSetInfoFilename();
3017 /* if chars set to "-1", automatically determine by text and font width */
3018 if (tmi->chars == -1)
3019 tmi->chars = tmi->width / getFontWidth(tmi->font);
3021 tmi->width = tmi->chars * getFontWidth(tmi->font);
3023 /* if lines set to "-1", automatically determine by text and font height */
3024 if (tmi->lines == -1)
3025 tmi->lines = tmi->height / getFontHeight(tmi->font);
3027 tmi->height = tmi->lines * getFontHeight(tmi->font);
3029 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3031 FadeOut(REDRAW_FIELD);
3036 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3038 if (filename != NULL)
3039 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3040 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3041 tmi->autowrap, tmi->centered, tmi->parse_comments);
3043 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3044 "No information for this level set.");
3046 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3047 "Press any key or button for info menu");
3049 FadeIn(REDRAW_FIELD);
3052 void HandleInfoScreen_LevelSet(int button)
3054 if (button == MB_MENU_LEAVE)
3056 PlaySound(SND_MENU_ITEM_SELECTING);
3058 info_mode = INFO_MODE_MAIN;
3063 else if (button == MB_MENU_CHOICE)
3065 PlaySound(SND_MENU_ITEM_SELECTING);
3067 FadeSoundsAndMusic();
3069 info_mode = INFO_MODE_MAIN;
3070 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3074 PlayMenuSoundIfLoop();
3078 static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
3080 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3082 if (info_mode == INFO_MODE_TITLE)
3083 DrawInfoScreen_TitleScreen();
3084 else if (info_mode == INFO_MODE_ELEMENTS)
3085 DrawInfoScreen_Elements();
3086 else if (info_mode == INFO_MODE_MUSIC)
3087 DrawInfoScreen_Music();
3088 else if (info_mode == INFO_MODE_CREDITS)
3089 DrawInfoScreen_Credits();
3090 else if (info_mode == INFO_MODE_PROGRAM)
3091 DrawInfoScreen_Program();
3092 else if (info_mode == INFO_MODE_VERSION)
3093 DrawInfoScreen_Version();
3094 else if (info_mode == INFO_MODE_LEVELSET)
3095 DrawInfoScreen_LevelSet();
3097 DrawInfoScreen_Main(fade_mask, do_fading);
3099 if (info_mode != INFO_MODE_MAIN &&
3100 info_mode != INFO_MODE_TITLE &&
3101 info_mode != INFO_MODE_MUSIC)
3108 void DrawAndFadeInInfoScreen(int fade_mask)
3110 DrawInfoScreenExt(fade_mask, TRUE);
3113 void DrawInfoScreen()
3115 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3118 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3120 if (info_mode == INFO_MODE_TITLE)
3121 HandleInfoScreen_TitleScreen(button);
3122 else if (info_mode == INFO_MODE_ELEMENTS)
3123 HandleInfoScreen_Elements(button);
3124 else if (info_mode == INFO_MODE_MUSIC)
3125 HandleInfoScreen_Music(button);
3126 else if (info_mode == INFO_MODE_CREDITS)
3127 HandleInfoScreen_Credits(button);
3128 else if (info_mode == INFO_MODE_PROGRAM)
3129 HandleInfoScreen_Program(button);
3130 else if (info_mode == INFO_MODE_VERSION)
3131 HandleInfoScreen_Version(button);
3132 else if (info_mode == INFO_MODE_LEVELSET)
3133 HandleInfoScreen_LevelSet(button);
3135 HandleInfoScreen_Main(mx, my, dx, dy, button);
3139 /* ========================================================================= */
3140 /* type name functions */
3141 /* ========================================================================= */
3143 void HandleTypeName(int newxpos, Key key)
3145 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3146 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3147 struct TextPosInfo *pos = mci->pos_input;
3148 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3149 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3150 static int xpos = 0;
3151 int font_nr = pos->font;
3152 int font_active_nr = FONT_ACTIVE(font_nr);
3153 int font_width = getFontWidth(font_active_nr);
3154 char key_char = getValidConfigValueChar(getCharFromKey(key));
3155 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3156 boolean is_active = TRUE;
3158 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3162 strcpy(last_player_name, setup.player_name);
3166 #if defined(TARGET_SDL2)
3167 SDL_StartTextInput();
3170 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3172 setup.player_name[xpos] = key_char;
3173 setup.player_name[xpos + 1] = 0;
3177 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3181 setup.player_name[xpos] = 0;
3183 else if (key == KSYM_Return && xpos > 0)
3189 game_status = GAME_MODE_MAIN;
3191 else if (key == KSYM_Escape)
3193 strcpy(setup.player_name, last_player_name);
3197 game_status = GAME_MODE_MAIN;
3202 pos->width = (strlen(setup.player_name) + 1) * font_width;
3203 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3205 DrawText(startx, starty, setup.player_name, font_active_nr);
3206 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3210 pos->width = strlen(setup.player_name) * font_width;
3211 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3213 DrawText(startx, starty, setup.player_name, font_nr);
3215 #if defined(TARGET_SDL2)
3216 SDL_StopTextInput();
3222 /* ========================================================================= */
3223 /* tree menu functions */
3224 /* ========================================================================= */
3226 static void DrawChooseTree(TreeInfo **ti_ptr)
3230 FreeScreenGadgets();
3231 CreateScreenGadgets();
3233 CloseDoor(DOOR_CLOSE_2);
3235 FadeOut(REDRAW_FIELD);
3239 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3240 MapScreenTreeGadgets(*ti_ptr);
3242 FadeIn(REDRAW_FIELD);
3247 static void AdjustScrollbar(int id, int items_max, int items_visible,
3250 struct GadgetInfo *gi = screen_gadget[id];
3252 if (item_position > items_max - items_visible)
3253 item_position = items_max - items_visible;
3255 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3256 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3257 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3260 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3262 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3266 static void clearMenuListArea()
3268 int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3270 /* correct scrollbar position if placed outside menu (playfield) area */
3271 if (scrollbar_xpos > SC_SCROLLBAR_XPOS)
3272 scrollbar_xpos = SC_SCROLLBAR_XPOS;
3274 /* clear menu list area, but not title or scrollbar */
3275 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3276 scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
3279 static void drawChooseTreeList(int first_entry, int num_page_entries,
3283 char *title_string = NULL;
3284 int yoffset_sets = MENU_TITLE1_YPOS;
3285 int yoffset_setup = 16;
3286 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3287 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3288 int last_game_status = game_status; /* save current game status */
3290 title_string = ti->infotext;
3292 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3294 clearMenuListArea();
3296 for (i = 0; i < num_page_entries; i++)
3298 TreeInfo *node, *node_first;
3299 int entry_pos = first_entry + i;
3300 int xpos = MENU_SCREEN_START_XPOS;
3301 int ypos = MENU_SCREEN_START_YPOS + i;
3302 int startx = mSX + xpos * 32;
3303 int starty = mSY + ypos * 32;
3304 int font_nr = FONT_TEXT_1;
3305 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3306 int startx_text = startx + font_xoffset;
3307 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3308 int text_size = startx_scrollbar - startx_text;
3309 int max_buffer_len = text_size / getFontWidth(font_nr);
3310 char buffer[max_buffer_len + 1];
3312 node_first = getTreeInfoFirstGroupEntry(ti);
3313 node = getTreeInfoFromPos(node_first, entry_pos);
3315 strncpy(buffer, node->name, max_buffer_len);
3316 buffer[max_buffer_len] = '\0';
3318 DrawText(startx, starty, buffer, font_nr + node->color);
3320 if (node->parent_link)
3321 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3322 else if (node->level_group)
3323 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3325 initCursor(i, IMG_MENU_BUTTON);
3328 game_status = last_game_status; /* restore current game status */
3330 redraw_mask |= REDRAW_FIELD;
3333 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3335 TreeInfo *node, *node_first;
3336 int x, last_redraw_mask = redraw_mask;
3337 int ypos = MENU_TITLE2_YPOS;
3338 int font_nr = FONT_TITLE_2;
3340 if (ti->type == TREE_TYPE_LEVEL_NR)
3341 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3343 if (ti->type != TREE_TYPE_LEVEL_DIR)
3346 node_first = getTreeInfoFirstGroupEntry(ti);
3347 node = getTreeInfoFromPos(node_first, entry_pos);
3349 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3351 if (node->parent_link)
3352 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3353 node->node_parent->name);
3354 else if (node->level_group)
3355 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3357 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3358 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3359 node->levels, (node->levels > 1 ? "levels" : "level"),
3362 /* let BackToFront() redraw only what is needed */
3363 redraw_mask = last_redraw_mask | REDRAW_TILES;
3364 for (x = 0; x < SCR_FIELDX; x++)
3365 MarkTileDirty(x, 1);
3368 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3371 TreeInfo *ti = *ti_ptr;
3373 int y = ti->cl_cursor;
3374 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3375 int num_entries = numTreeInfoInGroup(ti);
3376 int num_page_entries;
3377 int last_game_status = game_status; /* save current game status */
3378 boolean position_set_by_scrollbar = (dx == 999);
3380 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3381 num_page_entries = num_entries;
3383 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3385 game_status = last_game_status; /* restore current game status */
3387 if (button == MB_MENU_INITIALIZE)
3389 int num_entries = numTreeInfoInGroup(ti);
3390 int entry_pos = posTreeInfo(ti);
3392 if (ti->cl_first == -1)
3394 /* only on initialization */
3395 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3396 ti->cl_cursor = entry_pos - ti->cl_first;
3398 else if (ti->cl_cursor >= num_page_entries ||
3399 (num_entries > num_page_entries &&
3400 num_entries - ti->cl_first < num_page_entries))
3402 /* only after change of list size (by custom graphic configuration) */
3403 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3404 ti->cl_cursor = entry_pos - ti->cl_first;
3407 if (position_set_by_scrollbar)
3410 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3413 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3414 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3415 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3419 else if (button == MB_MENU_LEAVE)
3423 PlaySound(SND_MENU_ITEM_SELECTING);
3425 if (ti->node_parent)
3427 *ti_ptr = ti->node_parent;
3428 DrawChooseTree(ti_ptr);
3430 else if (game_status == GAME_MODE_SETUP)
3432 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3433 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3435 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3436 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3437 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3438 execSetupGraphics();
3439 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3440 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3441 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3443 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3444 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3445 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3452 if (game_status == GAME_MODE_LEVELNR)
3453 level_nr = atoi(level_number_current->identifier);
3455 game_status = GAME_MODE_MAIN;
3457 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3463 if (mx || my) /* mouse input */
3465 int last_game_status = game_status; /* save current game status */
3467 x = (mx - mSX) / 32;
3468 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3470 game_status = last_game_status; /* restore current game status */
3472 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3474 /* move cursor instead of scrolling when already at start/end of list */
3475 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3477 else if (dy == +1 * SCROLL_LINE &&
3478 ti->cl_first + num_page_entries == num_entries)
3481 /* handle scrolling screen one line or page */
3482 if (ti->cl_cursor + dy < 0 ||
3483 ti->cl_cursor + dy > num_page_entries - 1)
3485 boolean redraw = FALSE;
3487 if (ABS(dy) == SCROLL_PAGE)
3488 step = num_page_entries - 1;
3490 if (dy < 0 && ti->cl_first > 0)
3492 /* scroll page/line up */
3494 ti->cl_first -= step;
3495 if (ti->cl_first < 0)
3500 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3502 /* scroll page/line down */
3504 ti->cl_first += step;
3505 if (ti->cl_first + num_page_entries > num_entries)
3506 ti->cl_first = MAX(0, num_entries - num_page_entries);
3513 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3514 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3515 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3517 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3525 /* handle moving cursor one line */
3526 y = ti->cl_cursor + dy;
3531 TreeInfo *node_first, *node_cursor;
3532 int entry_pos = ti->cl_first + y;
3534 node_first = getTreeInfoFirstGroupEntry(ti);
3535 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3537 if (node_cursor->node_group)
3541 PlaySound(SND_MENU_ITEM_SELECTING);
3543 node_cursor->cl_first = ti->cl_first;
3544 node_cursor->cl_cursor = ti->cl_cursor;
3545 *ti_ptr = node_cursor->node_group;
3546 DrawChooseTree(ti_ptr);
3551 else if (dx == -1 && ti->node_parent)
3555 PlaySound(SND_MENU_ITEM_SELECTING);
3557 *ti_ptr = ti->node_parent;
3558 DrawChooseTree(ti_ptr);
3563 if (!anyScrollbarGadgetActive() &&
3564 IN_VIS_MENU(x, y) &&
3565 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3566 y >= 0 && y < num_page_entries)
3570 if (y != ti->cl_cursor)
3572 PlaySound(SND_MENU_ITEM_ACTIVATING);
3574 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3575 drawChooseTreeCursor(y, TRUE);
3576 drawChooseTreeInfo(ti->cl_first + y, ti);
3583 TreeInfo *node_first, *node_cursor;
3584 int entry_pos = ti->cl_first + y;
3586 PlaySound(SND_MENU_ITEM_SELECTING);
3588 node_first = getTreeInfoFirstGroupEntry(ti);
3589 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3591 if (node_cursor->node_group)
3595 node_cursor->cl_first = ti->cl_first;
3596 node_cursor->cl_cursor = ti->cl_cursor;
3597 *ti_ptr = node_cursor->node_group;
3598 DrawChooseTree(ti_ptr);
3600 else if (node_cursor->parent_link)
3604 *ti_ptr = node_cursor->node_parent;
3605 DrawChooseTree(ti_ptr);
3611 node_cursor->cl_first = ti->cl_first;
3612 node_cursor->cl_cursor = ti->cl_cursor;
3613 *ti_ptr = node_cursor;
3615 if (ti->type == TREE_TYPE_LEVEL_DIR)
3617 LoadLevelSetup_SeriesInfo();
3619 SaveLevelSetup_LastSeries();
3620 SaveLevelSetup_SeriesInfo();
3624 if (game_status == GAME_MODE_SETUP)
3626 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3627 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3629 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3630 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3631 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3632 execSetupGraphics();
3633 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3634 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3635 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3637 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3638 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3639 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3646 if (game_status == GAME_MODE_LEVELNR)
3647 level_nr = atoi(level_number_current->identifier);
3649 game_status = GAME_MODE_MAIN;
3658 void DrawChooseLevelSet()
3660 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
3662 DrawChooseTree(&leveldir_current);
3668 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
3670 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
3673 void DrawChooseLevelNr()
3677 if (level_number != NULL)
3679 freeTreeInfo(level_number);
3681 level_number = NULL;
3684 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
3686 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
3687 char identifier[32], name[32];
3690 /* temporarily load level info to get level name */
3691 LoadLevelInfoOnly(i);
3693 ti->node_top = &level_number;
3694 ti->sort_priority = 10000 + value;
3695 ti->color = (level.no_valid_file ? FC_BLUE :
3696 LevelStats_getSolved(i) ? FC_GREEN :
3697 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
3699 sprintf(identifier, "%d", value);
3700 sprintf(name, "%03d: %s", value,
3701 (level.no_valid_file ? "(no file)" : level.name));
3703 setString(&ti->identifier, identifier);
3704 setString(&ti->name, name);
3705 setString(&ti->name_sorting, name);
3707 pushTreeInfo(&level_number, ti);
3710 /* sort level number values to start with lowest level number */
3711 sortTreeInfo(&level_number);
3713 /* set current level number to current level number */
3714 level_number_current =
3715 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
3717 /* if that also fails, set current level number to first available level */
3718 if (level_number_current == NULL)
3719 level_number_current = level_number;
3721 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
3723 DrawChooseTree(&level_number_current);
3729 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
3731 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
3734 void DrawHallOfFame(int highlight_position)
3737 FadeSoundsAndMusic();
3739 /* (this is needed when called from GameEnd() after winning a game) */
3740 KeyboardAutoRepeatOn();
3743 /* (this is needed when called from GameEnd() after winning a game) */
3744 SetDrawDeactivationMask(REDRAW_NONE);
3745 SetDrawBackgroundMask(REDRAW_FIELD);
3747 CloseDoor(DOOR_CLOSE_2);
3749 if (highlight_position < 0)
3750 LoadScore(level_nr);
3752 FadeSetEnterScreen();
3754 FadeOut(REDRAW_FIELD);
3761 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
3763 FadeIn(REDRAW_FIELD);
3766 static void drawHallOfFameList(int first_entry, int highlight_position)
3770 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
3773 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
3774 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
3775 "HighScores of Level %d", level_nr);
3777 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
3779 int entry = first_entry + i;
3780 boolean active = (entry == highlight_position);
3781 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
3782 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
3783 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
3784 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
3785 int dx1 = 3 * getFontWidth(font_nr1);
3786 int dx2 = dx1 + getFontWidth(font_nr1);
3787 int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
3788 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
3789 int sy = mSY + 64 + i * 32;
3791 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
3792 DrawText(mSX + dx1, sy, ".", font_nr1);
3794 for (j = 0; j < num_dots; j++)
3795 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
3797 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
3798 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
3800 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
3803 redraw_mask |= REDRAW_FIELD;
3806 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
3808 static int first_entry = 0;
3809 static int highlight_position = 0;
3810 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3812 if (button == MB_MENU_INITIALIZE)
3815 highlight_position = mx;
3816 drawHallOfFameList(first_entry, highlight_position);
3821 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
3822 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
3826 if (first_entry > 0)
3828 first_entry -= step;
3829 if (first_entry < 0)
3832 drawHallOfFameList(first_entry, highlight_position);
3837 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
3839 first_entry += step;
3840 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
3841 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
3843 drawHallOfFameList(first_entry, highlight_position);
3846 else if (button == MB_MENU_LEAVE)
3848 PlaySound(SND_MENU_ITEM_SELECTING);
3850 FadeSound(SND_BACKGROUND_SCORES);
3852 game_status = GAME_MODE_MAIN;
3856 else if (button == MB_MENU_CHOICE)
3858 PlaySound(SND_MENU_ITEM_SELECTING);
3860 FadeSound(SND_BACKGROUND_SCORES);
3862 game_status = GAME_MODE_MAIN;
3864 DrawAndFadeInMainMenu(REDRAW_FIELD);
3867 if (game_status == GAME_MODE_SCORES)
3868 PlayMenuSoundIfLoop();
3872 /* ========================================================================= */
3873 /* setup screen functions */
3874 /* ========================================================================= */
3876 static struct TokenInfo *setup_info;
3877 static int num_setup_info; /* number of setup entries shown on screen */
3878 static int max_setup_info; /* total number of setup entries in list */
3880 static char *screen_mode_text;
3881 static char *window_size_text;
3882 static char *scaling_type_text;
3883 static char *scroll_delay_text;
3884 static char *game_speed_text;
3885 static char *graphics_set_name;
3886 static char *sounds_set_name;
3887 static char *music_set_name;
3888 static char *volume_simple_text;
3889 static char *volume_loops_text;
3890 static char *volume_music_text;
3891 static char *touch_controls_text;
3892 static char *move_distance_text;
3893 static char *drop_distance_text;
3895 static void execSetupMain()
3897 setup_mode = SETUP_MODE_MAIN;
3902 static void execSetupGame_setGameSpeeds()
3904 if (game_speeds == NULL)
3908 for (i = 0; game_speeds_list[i].value != -1; i++)
3910 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3911 char identifier[32], name[32];
3912 int value = game_speeds_list[i].value;
3913 char *text = game_speeds_list[i].text;
3915 ti->node_top = &game_speeds;
3916 ti->sort_priority = 10000 - value;
3918 sprintf(identifier, "%d", value);
3919 sprintf(name, "%s", text);
3921 setString(&ti->identifier, identifier);
3922 setString(&ti->name, name);
3923 setString(&ti->name_sorting, name);
3924 setString(&ti->infotext, "Game Speed");
3926 pushTreeInfo(&game_speeds, ti);
3929 /* sort game speed values to start with slowest game speed */
3930 sortTreeInfo(&game_speeds);
3932 /* set current game speed to configured game speed value */
3933 game_speed_current =
3934 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
3936 /* if that fails, set current game speed to reliable default value */
3937 if (game_speed_current == NULL)
3938 game_speed_current =
3939 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
3941 /* if that also fails, set current game speed to first available speed */
3942 if (game_speed_current == NULL)
3943 game_speed_current = game_speeds;
3946 setup.game_frame_delay = atoi(game_speed_current->identifier);
3948 /* needed for displaying game speed text instead of identifier */
3949 game_speed_text = game_speed_current->name;
3952 static void execSetupGame_setScrollDelays()
3954 if (scroll_delays == NULL)
3958 for (i = 0; scroll_delays_list[i].value != -1; i++)
3960 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
3961 char identifier[32], name[32];
3962 int value = scroll_delays_list[i].value;
3963 char *text = scroll_delays_list[i].text;
3965 ti->node_top = &scroll_delays;
3966 ti->sort_priority = value;
3968 sprintf(identifier, "%d", value);
3969 sprintf(name, "%s", text);
3971 setString(&ti->identifier, identifier);
3972 setString(&ti->name, name);
3973 setString(&ti->name_sorting, name);
3974 setString(&ti->infotext, "Scaling Type");
3976 pushTreeInfo(&scroll_delays, ti);
3979 /* sort scaling type values to start with lowest scaling type value */
3980 sortTreeInfo(&scroll_delays);
3982 /* set current scaling type value to configured scaling type value */
3983 scroll_delay_current =
3984 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
3986 /* if that fails, set current scaling type to reliable default value */
3987 if (scroll_delay_current == NULL)
3988 scroll_delay_current =
3989 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
3991 /* if that also fails, set current scaling type to first available value */
3992 if (scroll_delay_current == NULL)
3993 scroll_delay_current = scroll_delays;
3996 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
3998 /* needed for displaying scaling type text instead of identifier */
3999 scroll_delay_text = scroll_delay_current->name;
4002 static void execSetupGame()
4004 execSetupGame_setGameSpeeds();
4005 execSetupGame_setScrollDelays();
4007 setup_mode = SETUP_MODE_GAME;
4012 static void execSetupChooseGameSpeed()
4014 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4019 static void execSetupChooseScrollDelay()
4021 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4026 static void execSetupEditor()
4028 setup_mode = SETUP_MODE_EDITOR;
4033 static void execSetupGraphics_setWindowSizes(boolean update_list)
4035 if (window_sizes != NULL && update_list)
4037 freeTreeInfo(window_sizes);
4039 window_sizes = NULL;
4042 if (window_sizes == NULL)
4044 boolean current_window_size_found = FALSE;
4047 for (i = 0; window_sizes_list[i].value != -1; i++)
4049 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4050 char identifier[32], name[32];
4051 int value = window_sizes_list[i].value;
4052 char *text = window_sizes_list[i].text;
4054 ti->node_top = &window_sizes;
4055 ti->sort_priority = value;
4057 sprintf(identifier, "%d", value);
4058 sprintf(name, "%s", text);
4060 setString(&ti->identifier, identifier);
4061 setString(&ti->name, name);
4062 setString(&ti->name_sorting, name);
4063 setString(&ti->infotext, "Window Scaling");
4065 pushTreeInfo(&window_sizes, ti);
4067 if (value == setup.window_scaling_percent)
4068 current_window_size_found = TRUE;
4071 if (!current_window_size_found)
4073 // add entry for non-preset window scaling value
4075 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4076 char identifier[32], name[32];
4077 int value = setup.window_scaling_percent;
4079 ti->node_top = &window_sizes;
4080 ti->sort_priority = value;
4082 sprintf(identifier, "%d", value);
4083 sprintf(name, "%d %% (Current)", value);
4085 setString(&ti->identifier, identifier);
4086 setString(&ti->name, name);
4087 setString(&ti->name_sorting, name);
4088 setString(&ti->infotext, "Window Scaling");
4090 pushTreeInfo(&window_sizes, ti);
4093 /* sort window size values to start with lowest window size value */
4094 sortTreeInfo(&window_sizes);
4096 /* set current window size value to configured window size value */
4097 window_size_current =
4098 getTreeInfoFromIdentifier(window_sizes,
4099 i_to_a(setup.window_scaling_percent));
4101 /* if that fails, set current window size to reliable default value */
4102 if (window_size_current == NULL)
4103 window_size_current =
4104 getTreeInfoFromIdentifier(window_sizes,
4105 i_to_a(STD_WINDOW_SCALING_PERCENT));
4107 /* if that also fails, set current window size to first available value */
4108 if (window_size_current == NULL)
4109 window_size_current = window_sizes;
4112 setup.window_scaling_percent = atoi(window_size_current->identifier);
4114 /* needed for displaying window size text instead of identifier */
4115 window_size_text = window_size_current->name;
4118 static void execSetupGraphics_setScalingTypes()
4120 if (scaling_types == NULL)
4124 for (i = 0; scaling_types_list[i].value != NULL; i++)
4126 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4127 char identifier[32], name[32];
4128 char *value = scaling_types_list[i].value;
4129 char *text = scaling_types_list[i].text;
4131 ti->node_top = &scaling_types;
4132 ti->sort_priority = i;
4134 sprintf(identifier, "%s", value);
4135 sprintf(name, "%s", text);
4137 setString(&ti->identifier, identifier);
4138 setString(&ti->name, name);
4139 setString(&ti->name_sorting, name);
4140 setString(&ti->infotext, "Anti-Aliasing");
4142 pushTreeInfo(&scaling_types, ti);
4145 /* sort scaling type values to start with lowest scaling type value */
4146 sortTreeInfo(&scaling_types);
4148 /* set current scaling type value to configured scaling type value */
4149 scaling_type_current =
4150 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4152 /* if that fails, set current scaling type to reliable default value */
4153 if (scaling_type_current == NULL)
4154 scaling_type_current =
4155 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4157 /* if that also fails, set current scaling type to first available value */
4158 if (scaling_type_current == NULL)
4159 scaling_type_current = scaling_types;
4162 setup.window_scaling_quality = scaling_type_current->identifier;
4164 /* needed for displaying scaling type text instead of identifier */
4165 scaling_type_text = scaling_type_current->name;
4168 static void execSetupGraphics_setScreenModes()
4170 // if (screen_modes == NULL && video.fullscreen_available)
4171 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4175 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4177 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4178 char identifier[32], name[32];
4179 int x = video.fullscreen_modes[i].width;
4180 int y = video.fullscreen_modes[i].height;
4183 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4185 ti->node_top = &screen_modes;
4186 ti->sort_priority = x * 10000 + y;
4188 sprintf(identifier, "%dx%d", x, y);
4189 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4191 setString(&ti->identifier, identifier);
4192 setString(&ti->name, name);
4193 setString(&ti->name_sorting, name);
4194 setString(&ti->infotext, "Fullscreen Mode");
4196 pushTreeInfo(&screen_modes, ti);
4199 /* sort fullscreen modes to start with lowest available screen resolution */
4200 sortTreeInfo(&screen_modes);
4202 /* set current screen mode for fullscreen mode to configured setup value */
4203 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4204 setup.fullscreen_mode);
4206 /* if that fails, set current screen mode to reliable default value */
4207 if (screen_mode_current == NULL)
4208 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4209 DEFAULT_FULLSCREEN_MODE);
4211 /* if that also fails, set current screen mode to first available mode */
4212 if (screen_mode_current == NULL)
4213 screen_mode_current = screen_modes;
4215 if (screen_mode_current == NULL)
4216 video.fullscreen_available = FALSE;
4219 // if (video.fullscreen_available)
4220 if (screen_mode_current != NULL)
4222 setup.fullscreen_mode = screen_mode_current->identifier;
4224 /* needed for displaying screen mode name instead of identifier */
4225 screen_mode_text = screen_mode_current->name;
4229 static void execSetupGraphics()
4231 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4233 // update "setup.window_scaling_percent" from list selection
4234 execSetupGraphics_setWindowSizes(FALSE);
4238 // update list selection from "setup.window_scaling_percent"
4239 execSetupGraphics_setWindowSizes(TRUE);
4242 execSetupGraphics_setScalingTypes();
4243 execSetupGraphics_setScreenModes();
4245 setup_mode = SETUP_MODE_GRAPHICS;
4249 #if defined(TARGET_SDL2)
4250 // window scaling may have changed at this point
4251 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4253 // window scaling quality may have changed at this point
4254 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4255 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4259 #if !defined(PLATFORM_ANDROID)
4260 #if defined(TARGET_SDL2)
4261 static void execSetupChooseWindowSize()
4263 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4268 static void execSetupChooseScalingType()
4270 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4275 static void execSetupChooseScreenMode()
4277 if (!video.fullscreen_available)
4280 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4287 static void execSetupChooseVolumeSimple()
4289 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4294 static void execSetupChooseVolumeLoops()
4296 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4301 static void execSetupChooseVolumeMusic()
4303 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4308 static void execSetupSound()
4310 if (volumes_simple == NULL)
4314 for (i = 0; volumes_list[i].value != -1; i++)
4316 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4317 char identifier[32], name[32];
4318 int value = volumes_list[i].value;
4319 char *text = volumes_list[i].text;
4321 ti->node_top = &volumes_simple;
4322 ti->sort_priority = value;
4324 sprintf(identifier, "%d", value);
4325 sprintf(name, "%s", text);
4327 setString(&ti->identifier, identifier);
4328 setString(&ti->name, name);
4329 setString(&ti->name_sorting, name);
4330 setString(&ti->infotext, "Sound Volume");
4332 pushTreeInfo(&volumes_simple, ti);
4335 /* sort volume values to start with lowest volume value */
4336 sortTreeInfo(&volumes_simple);
4338 /* set current volume value to configured volume value */
4339 volume_simple_current =
4340 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4342 /* if that fails, set current volume to reliable default value */
4343 if (volume_simple_current == NULL)
4344 volume_simple_current =
4345 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4347 /* if that also fails, set current volume to first available value */
4348 if (volume_simple_current == NULL)
4349 volume_simple_current = volumes_simple;
4352 if (volumes_loops == NULL)
4356 for (i = 0; volumes_list[i].value != -1; i++)
4358 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4359 char identifier[32], name[32];
4360 int value = volumes_list[i].value;
4361 char *text = volumes_list[i].text;
4363 ti->node_top = &volumes_loops;
4364 ti->sort_priority = value;
4366 sprintf(identifier, "%d", value);
4367 sprintf(name, "%s", text);
4369 setString(&ti->identifier, identifier);
4370 setString(&ti->name, name);
4371 setString(&ti->name_sorting, name);
4372 setString(&ti->infotext, "Loops Volume");
4374 pushTreeInfo(&volumes_loops, ti);
4377 /* sort volume values to start with lowest volume value */
4378 sortTreeInfo(&volumes_loops);
4380 /* set current volume value to configured volume value */
4381 volume_loops_current =
4382 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4384 /* if that fails, set current volume to reliable default value */
4385 if (volume_loops_current == NULL)
4386 volume_loops_current =
4387 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4389 /* if that also fails, set current volume to first available value */
4390 if (volume_loops_current == NULL)
4391 volume_loops_current = volumes_loops;
4394 if (volumes_music == NULL)
4398 for (i = 0; volumes_list[i].value != -1; i++)
4400 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4401 char identifier[32], name[32];
4402 int value = volumes_list[i].value;
4403 char *text = volumes_list[i].text;
4405 ti->node_top = &volumes_music;
4406 ti->sort_priority = value;
4408 sprintf(identifier, "%d", value);
4409 sprintf(name, "%s", text);
4411 setString(&ti->identifier, identifier);
4412 setString(&ti->name, name);
4413 setString(&ti->name_sorting, name);
4414 setString(&ti->infotext, "Music Volume");
4416 pushTreeInfo(&volumes_music, ti);
4419 /* sort volume values to start with lowest volume value */
4420 sortTreeInfo(&volumes_music);
4422 /* set current volume value to configured volume value */
4423 volume_music_current =
4424 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4426 /* if that fails, set current volume to reliable default value */
4427 if (volume_music_current == NULL)
4428 volume_music_current =
4429 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4431 /* if that also fails, set current volume to first available value */
4432 if (volume_music_current == NULL)
4433 volume_music_current = volumes_music;
4436 setup.volume_simple = atoi(volume_simple_current->identifier);
4437 setup.volume_loops = atoi(volume_loops_current->identifier);
4438 setup.volume_music = atoi(volume_music_current->identifier);
4440 /* needed for displaying volume text instead of identifier */
4441 volume_simple_text = volume_simple_current->name;
4442 volume_loops_text = volume_loops_current->name;
4443 volume_music_text = volume_music_current->name;
4445 setup_mode = SETUP_MODE_SOUND;
4450 static void execSetupChooseTouchControls()
4452 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4457 static void execSetupChooseMoveDistance()
4459 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4464 static void execSetupChooseDropDistance()
4466 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4471 static void execSetupTouch()
4473 if (touch_controls == NULL)
4477 for (i = 0; touch_controls_list[i].value != NULL; i++)
4479 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4480 char identifier[32], name[32];
4481 char *value = touch_controls_list[i].value;
4482 char *text = touch_controls_list[i].text;
4484 ti->node_top = &touch_controls;
4485 ti->sort_priority = i;
4487 sprintf(identifier, "%s", value);
4488 sprintf(name, "%s", text);
4490 setString(&ti->identifier, identifier);
4491 setString(&ti->name, name);
4492 setString(&ti->name_sorting, name);
4493 setString(&ti->infotext, "Control Type");
4495 pushTreeInfo(&touch_controls, ti);
4498 /* sort touch control values to start with lowest touch control value */
4499 sortTreeInfo(&touch_controls);
4501 /* set current touch control value to configured touch control value */
4502 touch_control_current =
4503 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4505 /* if that fails, set current touch control to reliable default value */
4506 if (touch_control_current == NULL)
4507 touch_control_current =
4508 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4510 /* if that also fails, set current touch control to first available value */
4511 if (touch_control_current == NULL)
4512 touch_control_current = touch_controls;
4515 if (move_distances == NULL)
4519 for (i = 0; distances_list[i].value != -1; i++)
4521 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4522 char identifier[32], name[32];
4523 int value = distances_list[i].value;
4524 char *text = distances_list[i].text;
4526 ti->node_top = &move_distances;
4527 ti->sort_priority = value;
4529 sprintf(identifier, "%d", value);
4530 sprintf(name, "%s", text);
4532 setString(&ti->identifier, identifier);
4533 setString(&ti->name, name);
4534 setString(&ti->name_sorting, name);
4535 setString(&ti->infotext, "Move Distance");
4537 pushTreeInfo(&move_distances, ti);
4540 /* sort distance values to start with lowest distance value */
4541 sortTreeInfo(&move_distances);
4543 /* set current distance value to configured distance value */
4544 move_distance_current =
4545 getTreeInfoFromIdentifier(move_distances,
4546 i_to_a(setup.touch.move_distance));
4548 /* if that fails, set current distance to reliable default value */
4549 if (move_distance_current == NULL)
4550 move_distance_current =
4551 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4553 /* if that also fails, set current distance to first available value */
4554 if (move_distance_current == NULL)
4555 move_distance_current = move_distances;
4558 if (drop_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 = &drop_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, "Drop Distance");
4580 pushTreeInfo(&drop_distances, ti);
4583 /* sort distance values to start with lowest distance value */
4584 sortTreeInfo(&drop_distances);
4586 /* set current distance value to configured distance value */
4587 drop_distance_current =
4588 getTreeInfoFromIdentifier(drop_distances,
4589 i_to_a(setup.touch.drop_distance));
4591 /* if that fails, set current distance to reliable default value */
4592 if (drop_distance_current == NULL)
4593 drop_distance_current =
4594 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
4596 /* if that also fails, set current distance to first available value */
4597 if (drop_distance_current == NULL)
4598 drop_distance_current = drop_distances;
4601 setup.touch.control_type = touch_control_current->identifier;
4602 setup.touch.move_distance = atoi(move_distance_current->identifier);
4603 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
4605 /* needed for displaying volume text instead of identifier */
4606 touch_controls_text = touch_control_current->name;
4607 move_distance_text = move_distance_current->name;
4608 drop_distance_text = drop_distance_current->name;
4610 setup_mode = SETUP_MODE_TOUCH;
4615 static void execSetupArtwork()
4618 printf("::: '%s', '%s', '%s'\n",
4619 artwork.gfx_current->subdir,
4620 artwork.gfx_current->fullpath,
4621 artwork.gfx_current->basepath);
4624 setup.graphics_set = artwork.gfx_current->identifier;
4625 setup.sounds_set = artwork.snd_current->identifier;
4626 setup.music_set = artwork.mus_current->identifier;
4628 /* needed if last screen (setup choice) changed graphics, sounds or music */
4629 ReloadCustomArtwork(0);
4631 /* needed for displaying artwork name instead of artwork identifier */
4632 graphics_set_name = artwork.gfx_current->name;
4633 sounds_set_name = artwork.snd_current->name;
4634 music_set_name = artwork.mus_current->name;
4636 setup_mode = SETUP_MODE_ARTWORK;
4641 static void execSetupChooseGraphics()
4643 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
4648 static void execSetupChooseSounds()
4650 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
4655 static void execSetupChooseMusic()
4657 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
4662 #if !defined(PLATFORM_ANDROID)
4663 static void execSetupInput()
4665 setup_mode = SETUP_MODE_INPUT;
4671 static void execSetupShortcuts()
4673 setup_mode = SETUP_MODE_SHORTCUTS;
4678 static void execSetupShortcuts1()
4680 setup_mode = SETUP_MODE_SHORTCUTS_1;
4685 static void execSetupShortcuts2()
4687 setup_mode = SETUP_MODE_SHORTCUTS_2;
4692 static void execSetupShortcuts3()
4694 setup_mode = SETUP_MODE_SHORTCUTS_3;
4699 static void execSetupShortcuts4()
4701 setup_mode = SETUP_MODE_SHORTCUTS_4;
4706 static void execSetupShortcuts5()
4708 setup_mode = SETUP_MODE_SHORTCUTS_5;
4713 static void execExitSetup()
4715 game_status = GAME_MODE_MAIN;
4717 DrawMainMenuExt(REDRAW_FIELD, FALSE);
4720 static void execSaveAndExitSetup()
4726 static struct TokenInfo setup_info_main[] =
4728 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
4729 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
4730 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
4731 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
4732 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
4733 #if !defined(PLATFORM_ANDROID)
4734 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
4735 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4737 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
4739 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
4740 { TYPE_EMPTY, NULL, "" },
4741 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
4742 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
4747 static struct TokenInfo setup_info_game[] =
4749 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
4750 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
4751 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
4752 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
4753 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
4754 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
4755 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
4756 { TYPE_STRING, &game_speed_text, "" },
4758 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4759 { TYPE_STRING, &scroll_delay_text, "" },
4761 { TYPE_EMPTY, NULL, "" },
4762 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4767 static struct TokenInfo setup_info_editor[] =
4770 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
4771 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
4772 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
4773 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
4774 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
4775 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
4776 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
4777 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
4779 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
4780 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
4781 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
4783 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
4785 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
4786 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
4787 { TYPE_EMPTY, NULL, "" },
4789 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
4790 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
4791 { TYPE_EMPTY, NULL, "" },
4793 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
4794 { TYPE_EMPTY, NULL, "" },
4795 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4800 static struct TokenInfo setup_info_graphics[] =
4802 #if !defined(PLATFORM_ANDROID)
4803 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
4804 #if defined(TARGET_SDL2)
4805 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
4806 { TYPE_STRING, &window_size_text, "" },
4807 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
4808 { TYPE_STRING, &scaling_type_text, "" },
4810 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
4811 { TYPE_STRING, &screen_mode_text, "" },
4815 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
4816 { TYPE_STRING, &scroll_delay_text, "" },
4818 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
4819 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
4820 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
4821 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
4822 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
4823 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
4824 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
4825 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
4826 { TYPE_EMPTY, NULL, "" },
4827 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4832 static struct TokenInfo setup_info_sound[] =
4834 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
4835 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
4836 { TYPE_SWITCH, &setup.sound_music, "Music:" },
4837 { TYPE_EMPTY, NULL, "" },
4838 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
4839 { TYPE_STRING, &volume_simple_text, "" },
4840 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
4841 { TYPE_STRING, &volume_loops_text, "" },
4842 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
4843 { TYPE_STRING, &volume_music_text, "" },
4844 { TYPE_EMPTY, NULL, "" },
4845 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4850 static struct TokenInfo setup_info_artwork[] =
4852 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
4853 { TYPE_STRING, &graphics_set_name, "" },
4854 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
4855 { TYPE_STRING, &sounds_set_name, "" },
4856 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
4857 { TYPE_STRING, &music_set_name, "" },
4858 { TYPE_EMPTY, NULL, "" },
4859 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
4860 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
4861 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
4862 { TYPE_EMPTY, NULL, "" },
4863 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4868 static struct TokenInfo setup_info_input[] =
4870 { TYPE_SWITCH, NULL, "Player:" },
4871 { TYPE_SWITCH, NULL, "Device:" },
4872 { TYPE_ENTER_MENU, NULL, "" },
4873 { TYPE_EMPTY, NULL, "" },
4874 { TYPE_EMPTY, NULL, "" },
4875 { TYPE_EMPTY, NULL, "" },
4876 { TYPE_EMPTY, NULL, "" },
4877 { TYPE_EMPTY, NULL, "" },
4878 { TYPE_EMPTY, NULL, "" },
4879 { TYPE_EMPTY, NULL, "" },
4880 { TYPE_EMPTY, NULL, "" },
4881 { TYPE_EMPTY, NULL, "" },
4882 { TYPE_EMPTY, NULL, "" },
4883 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4888 static struct TokenInfo setup_info_touch[] =
4890 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
4891 { TYPE_STRING, &touch_controls_text, "" },
4892 { TYPE_EMPTY, NULL, "" },
4893 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
4894 { TYPE_STRING, &move_distance_text, "" },
4895 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
4896 { TYPE_STRING, &drop_distance_text, "" },
4897 { TYPE_EMPTY, NULL, "" },
4898 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4903 static struct TokenInfo setup_info_shortcuts[] =
4905 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
4906 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
4907 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
4908 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
4909 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
4910 { TYPE_EMPTY, NULL, "" },
4911 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
4916 static struct TokenInfo setup_info_shortcuts_1[] =
4918 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
4919 { TYPE_KEY, &setup.shortcut.save_game, "" },
4920 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
4921 { TYPE_KEY, &setup.shortcut.load_game, "" },
4922 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
4923 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
4924 { TYPE_EMPTY, NULL, "" },
4925 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
4926 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
4927 { TYPE_EMPTY, NULL, "" },
4928 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4933 static struct TokenInfo setup_info_shortcuts_2[] =
4935 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
4936 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
4937 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
4938 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
4939 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
4940 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
4941 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
4942 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
4943 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
4944 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
4945 { TYPE_EMPTY, NULL, "" },
4946 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4951 static struct TokenInfo setup_info_shortcuts_3[] =
4953 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
4954 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
4955 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
4956 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
4957 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
4958 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
4959 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
4960 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
4961 { TYPE_KEYTEXT, NULL, "Record Tape:", },
4962 { TYPE_KEY, &setup.shortcut.tape_record, "" },
4963 { TYPE_KEYTEXT, NULL, "Play Tape:", },
4964 { TYPE_KEY, &setup.shortcut.tape_play, "" },
4965 { TYPE_EMPTY, NULL, "" },
4966 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4971 static struct TokenInfo setup_info_shortcuts_4[] =
4973 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
4974 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
4975 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
4976 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
4977 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
4978 { TYPE_KEY, &setup.shortcut.sound_music, "" },
4979 { TYPE_EMPTY, NULL, "" },
4980 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
4985 static struct TokenInfo setup_info_shortcuts_5[] =
4987 { TYPE_KEYTEXT, NULL, "Snap Left:", },
4988 { TYPE_KEY, &setup.shortcut.snap_left, "" },
4989 { TYPE_KEYTEXT, NULL, "Snap Right:", },
4990 { TYPE_KEY, &setup.shortcut.snap_right, "" },
4991 { TYPE_KEYTEXT, NULL, "Snap Up:", },
4992 { TYPE_KEY, &setup.shortcut.snap_up, "" },
4993 { TYPE_KEYTEXT, NULL, "Snap Down:", },
4994 { TYPE_KEY, &setup.shortcut.snap_down, "" },
4995 { TYPE_EMPTY, NULL, "" },
4996 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5001 static Key getSetupKey()
5003 Key key = KSYM_UNDEFINED;
5004 boolean got_key_event = FALSE;
5006 while (!got_key_event)
5008 if (PendingEvent()) /* got event */
5016 case EVENT_KEYPRESS:
5018 key = GetEventKey((KeyEvent *)&event, TRUE);
5020 /* press 'Escape' or 'Enter' to keep the existing key binding */
5021 if (key == KSYM_Escape || key == KSYM_Return)
5022 key = KSYM_UNDEFINED; /* keep old value */
5024 got_key_event = TRUE;
5028 case EVENT_KEYRELEASE:
5029 key_joystick_mapping = 0;
5033 HandleOtherEvents(&event);
5041 /* don't eat all CPU time */
5048 static int getSetupTextFont(int type)
5050 if (type & (TYPE_SWITCH |
5062 static int getSetupValueFont(int type, void *value)
5064 if (type & TYPE_KEY)
5065 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5066 else if (type & TYPE_STRING)
5067 return FONT_VALUE_2;
5068 else if (type & TYPE_ECS_AGA)
5069 return FONT_VALUE_1;
5070 else if (type & TYPE_BOOLEAN_STYLE)
5071 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5072 else if (type & TYPE_YES_NO_AUTO)
5073 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5074 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5076 return FONT_VALUE_1;
5079 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5081 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5082 struct TokenInfo *si = &setup_info[si_pos];
5083 boolean font_draw_xoffset_modified = FALSE;
5084 int font_draw_xoffset_old = -1;
5085 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5086 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5087 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5088 int xpos = menu_screen_value_xpos;
5089 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5090 int startx = mSX + xpos * 32;
5091 int starty = mSY + ypos * 32;
5092 int font_nr, font_width;
5093 int type = si->type;
5094 void *value = si->value;
5095 char *value_string = getSetupValue(type, value);
5098 if (value_string == NULL)
5101 if (type & TYPE_KEY)
5103 xpos = MENU_SCREEN_START_XPOS;
5105 if (type & TYPE_QUERY)
5106 value_string = "<press key>";
5108 else if (type & TYPE_STRING)
5110 int max_value_len = (SCR_FIELDX - 2) * 2;
5112 xpos = MENU_SCREEN_START_XPOS;
5114 if (strlen(value_string) > max_value_len)
5115 value_string[max_value_len] = '\0';
5117 else if (type & TYPE_YES_NO_AUTO)
5119 xpos = menu_screen_value_xpos - 1;
5122 startx = mSX + xpos * 32;
5123 starty = mSY + ypos * 32;
5124 font_nr = getSetupValueFont(type, value);
5125 font_width = getFontWidth(font_nr);
5127 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5128 if (setup_mode != SETUP_MODE_INPUT)
5130 int max_menu_text_length_big = (menu_screen_value_xpos -
5131 MENU_SCREEN_START_XPOS);
5132 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5133 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5134 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5135 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5136 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5137 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5138 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5139 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5140 boolean correct_font_draw_xoffset = FALSE;
5142 if (xpos == MENU_SCREEN_START_XPOS &&
5143 startx + font1_xoffset < text_startx + text_font_xoffset)
5144 correct_font_draw_xoffset = TRUE;
5146 if (xpos == menu_screen_value_xpos &&
5147 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5148 correct_font_draw_xoffset = TRUE;
5150 /* check if setup value would overlap with setup text when printed */
5151 /* (this can happen for extreme/wrong values for font draw offset) */
5152 if (correct_font_draw_xoffset)
5154 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5155 font_draw_xoffset_modified = TRUE;
5157 if (type & TYPE_KEY)
5158 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5159 else if (!(type & TYPE_STRING))
5160 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5161 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5165 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5166 DrawText(startx + i * font_width, starty, " ", font_nr);
5168 DrawText(startx, starty, value_string, font_nr);
5170 if (font_draw_xoffset_modified)
5171 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5174 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5176 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5177 struct TokenInfo *si = &setup_info[si_pos];
5179 if (si->type & TYPE_BOOLEAN_STYLE)
5181 *(boolean *)si->value ^= TRUE;
5183 else if (si->type & TYPE_YES_NO_AUTO)
5187 (*(int *)si->value == AUTO ? TRUE :
5188 *(int *)si->value == TRUE ? FALSE : AUTO) :
5189 (*(int *)si->value == TRUE ? AUTO :
5190 *(int *)si->value == AUTO ? FALSE : TRUE));
5192 else if (si->type & TYPE_KEY)
5196 si->type |= TYPE_QUERY;
5197 drawSetupValue(screen_pos, setup_info_pos_raw);
5198 si->type &= ~TYPE_QUERY;
5200 key = getSetupKey();
5201 if (key != KSYM_UNDEFINED)
5202 *(Key *)si->value = key;
5205 drawSetupValue(screen_pos, setup_info_pos_raw);
5207 // fullscreen state may have changed at this point
5208 if (si->value == &setup.fullscreen)
5209 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5212 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5215 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5216 struct TokenInfo *si = &setup_info[si_pos];
5217 int xpos = MENU_SCREEN_START_XPOS;
5218 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5219 int font_nr = getSetupTextFont(si->type);
5221 if (setup_info == setup_info_input)
5222 font_nr = FONT_MENU_1;
5225 font_nr = FONT_ACTIVE(font_nr);
5227 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5229 if (si->type & ~TYPE_SKIP_ENTRY)
5230 drawCursor(screen_pos, active);
5233 static void drawSetupInfoList(struct TokenInfo *setup_info,
5234 int first_entry, int num_page_entries)
5238 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5239 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5241 if (num_page_entries > max_setup_info)
5242 num_page_entries = max_setup_info;
5244 if (first_entry + num_page_entries > max_setup_info)
5247 clearMenuListArea();
5249 for (i = 0; i < num_page_entries; i++)
5251 int setup_info_pos = first_entry + i;
5252 struct TokenInfo *si = &setup_info[setup_info_pos];
5253 void *value_ptr = si->value;
5255 /* set some entries to "unchangeable" according to other variables */
5256 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5257 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5258 (value_ptr == &setup.sound_music && !audio.music_available) ||
5259 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5260 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5261 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5262 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5263 si->type |= TYPE_GHOSTED;
5265 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5266 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5267 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5268 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5269 else if (si->type & ~TYPE_SKIP_ENTRY)
5270 initCursor(i, IMG_MENU_BUTTON);
5272 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5274 if (si->type & TYPE_VALUE)
5275 drawSetupValue(i, setup_info_pos);
5279 static void DrawSetupScreen_Generic()
5281 boolean redraw_all = FALSE;
5282 char *title_string = NULL;
5287 FreeScreenGadgets();
5288 CreateScreenGadgets();
5290 CloseDoor(DOOR_CLOSE_2);
5292 if (redraw_mask & REDRAW_ALL)
5295 FadeOut(REDRAW_FIELD);
5299 if (setup_mode == SETUP_MODE_MAIN)
5301 setup_info = setup_info_main;
5302 title_string = "Setup";
5304 else if (setup_mode == SETUP_MODE_GAME)
5306 setup_info = setup_info_game;
5307 title_string = "Setup Game";
5309 else if (setup_mode == SETUP_MODE_EDITOR)
5311 setup_info = setup_info_editor;
5312 title_string = "Setup Editor";
5314 else if (setup_mode == SETUP_MODE_GRAPHICS)
5316 setup_info = setup_info_graphics;
5317 title_string = "Setup Graphics";
5319 else if (setup_mode == SETUP_MODE_SOUND)
5321 setup_info = setup_info_sound;
5322 title_string = "Setup Sound";
5324 else if (setup_mode == SETUP_MODE_ARTWORK)
5326 setup_info = setup_info_artwork;
5327 title_string = "Custom Artwork";
5329 else if (setup_mode == SETUP_MODE_TOUCH)
5331 setup_info = setup_info_touch;
5332 title_string = "Setup Touch Ctrls";
5334 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5336 setup_info = setup_info_shortcuts;
5337 title_string = "Setup Shortcuts";
5339 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5341 setup_info = setup_info_shortcuts_1;
5342 title_string = "Setup Shortcuts";
5344 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
5346 setup_info = setup_info_shortcuts_2;
5347 title_string = "Setup Shortcuts";
5349 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
5351 setup_info = setup_info_shortcuts_3;
5352 title_string = "Setup Shortcuts";
5354 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
5356 setup_info = setup_info_shortcuts_4;
5357 title_string = "Setup Shortcuts";
5359 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
5361 setup_info = setup_info_shortcuts_5;
5362 title_string = "Setup Shortcuts";
5365 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
5367 // determine maximal number of setup entries that can be displayed on screen
5369 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
5372 // determine maximal number of setup entries available for this setup screen
5374 for (i = 0; setup_info[i].type != 0; i++)
5377 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
5379 MapScreenGadgets(max_setup_info);
5382 redraw_mask = REDRAW_ALL;
5384 FadeIn(redraw_mask);
5389 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
5391 static int choice_store[MAX_SETUP_MODES];
5392 static int first_entry_store[MAX_SETUP_MODES];
5393 int choice = choice_store[setup_mode]; /* starts with 0 */
5394 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
5396 int y = choice - first_entry;
5398 boolean position_set_by_scrollbar = (dx == 999);
5399 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
5400 int num_page_entries;
5402 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
5404 if (button == MB_MENU_INITIALIZE)
5406 /* advance to first valid menu entry */
5407 while (choice < num_setup_info &&
5408 setup_info[choice].type & TYPE_SKIP_ENTRY)
5411 if (position_set_by_scrollbar)
5412 first_entry = first_entry_store[setup_mode] = dy;
5414 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5415 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5417 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5419 if (choice < first_entry)
5421 choice = first_entry;
5423 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5426 else if (choice > first_entry + num_page_entries - 1)
5428 choice = first_entry + num_page_entries - 1;
5430 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5434 choice_store[setup_mode] = choice;
5436 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5440 else if (button == MB_MENU_LEAVE)
5444 PlaySound(SND_MENU_ITEM_SELECTING);
5446 for (i = 0; setup_info[i].type != 0; i++)
5448 if (setup_info[i].type & TYPE_LEAVE_MENU)
5450 void (*menu_callback_function)(void) = setup_info[i].value;
5454 menu_callback_function();
5456 break; /* absolutely needed because function changes 'setup_info'! */
5463 if (mx || my) /* mouse input */
5465 x = (mx - mSX) / 32;
5466 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5468 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
5470 /* move cursor instead of scrolling when already at start/end of list */
5471 if (dy == -1 * SCROLL_LINE && first_entry == 0)
5473 else if (dy == +1 * SCROLL_LINE &&
5474 first_entry + num_page_entries == max_setup_info)
5477 /* handle scrolling screen one line or page */
5479 y + dy > num_page_entries - 1)
5481 boolean redraw = FALSE;
5483 if (ABS(dy) == SCROLL_PAGE)
5484 step = num_page_entries - 1;
5486 if (dy < 0 && first_entry > 0)
5488 /* scroll page/line up */
5490 first_entry -= step;
5491 if (first_entry < 0)
5496 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
5498 /* scroll page/line down */
5500 first_entry += step;
5501 if (first_entry + num_page_entries > max_setup_info)
5502 first_entry = MAX(0, max_setup_info - num_page_entries);
5509 choice += first_entry - first_entry_store[setup_mode];
5511 if (choice < first_entry)
5513 choice = first_entry;
5515 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5518 else if (choice > first_entry + num_page_entries - 1)
5520 choice = first_entry + num_page_entries - 1;
5522 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5525 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
5529 if (choice < first_entry ||
5530 choice > first_entry + num_page_entries - 1)
5531 first_entry += SIGN(dy);
5534 first_entry_store[setup_mode] = first_entry;
5535 choice_store[setup_mode] = choice;
5537 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5539 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5541 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5542 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5550 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
5552 if (setup_info[choice].type & menu_navigation_type ||
5553 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
5554 setup_info[choice].type & TYPE_YES_NO_AUTO)
5555 button = MB_MENU_CHOICE;
5560 /* jump to next non-empty menu entry (up or down) */
5561 while (first_entry + y > 0 &&
5562 first_entry + y < max_setup_info - 1 &&
5563 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
5566 if (!IN_VIS_MENU(x, y))
5568 choice += y - y_old;
5570 if (choice < first_entry)
5571 first_entry = choice;
5572 else if (choice > first_entry + num_page_entries - 1)
5573 first_entry = choice - num_page_entries + 1;
5575 if (first_entry >= 0 &&
5576 first_entry + num_page_entries <= max_setup_info)
5578 first_entry_store[setup_mode] = first_entry;
5580 if (choice < first_entry)
5581 choice = first_entry;
5582 else if (choice > first_entry + num_page_entries - 1)
5583 choice = first_entry + num_page_entries - 1;
5585 choice_store[setup_mode] = choice;
5587 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
5589 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
5591 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
5592 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
5599 if (!anyScrollbarGadgetActive() &&
5600 IN_VIS_MENU(x, y) &&
5601 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
5602 y >= 0 && y < num_page_entries)
5606 if (first_entry + y != choice &&
5607 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
5609 PlaySound(SND_MENU_ITEM_ACTIVATING);
5611 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
5612 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
5614 choice = choice_store[setup_mode] = first_entry + y;
5617 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
5619 PlaySound(SND_MENU_ITEM_SELECTING);
5621 /* when selecting key headline, execute function for key value change */
5622 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
5623 setup_info[first_entry + y + 1].type & TYPE_KEY)
5626 /* when selecting string value, execute function for list selection */
5627 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
5628 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
5631 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
5633 void (*menu_callback_function)(void) =
5634 setup_info[first_entry + y].value;
5636 FadeSetFromType(setup_info[first_entry + y].type);
5638 menu_callback_function();
5642 if (setup_info[first_entry + y].type & TYPE_VALUE)
5643 changeSetupValue(y, first_entry + y, dx);
5649 void DrawSetupScreen_Input()
5653 FadeOut(REDRAW_FIELD);
5657 setup_info = setup_info_input;
5659 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
5661 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
5662 "Joysticks deactivated on this screen");
5664 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
5666 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5667 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5668 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5669 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5670 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
5671 initCursor(i, IMG_MENU_BUTTON);
5673 DrawCursorAndText_Setup(i, -1, FALSE);
5676 /* create gadgets for setup input menu screen */
5677 FreeScreenGadgets();
5678 CreateScreenGadgets();
5680 /* map gadgets for setup input menu screen */
5681 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
5683 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
5685 FadeIn(REDRAW_FIELD);
5690 static void setJoystickDeviceToNr(char *device_name, int device_nr)
5692 if (device_name == NULL)
5695 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
5698 if (strlen(device_name) > 1)
5700 char c1 = device_name[strlen(device_name) - 1];
5701 char c2 = device_name[strlen(device_name) - 2];
5703 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
5704 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
5707 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
5708 strlen(device_name));
5711 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
5714 static struct SetupKeyboardInfo custom_key;
5721 { &custom_key.left, "Joystick Left" },
5722 { &custom_key.right, "Joystick Right" },
5723 { &custom_key.up, "Joystick Up" },
5724 { &custom_key.down, "Joystick Down" },
5725 { &custom_key.snap, "Button 1" },
5726 { &custom_key.drop, "Button 2" }
5728 static char *joystick_name[MAX_PLAYERS] =
5735 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
5739 custom_key = setup.input[player_nr].key;
5741 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
5742 FONT_INPUT_1_ACTIVE);
5744 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5746 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
5747 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
5749 if (setup.input[player_nr].use_joystick)
5751 char *device_name = setup.input[player_nr].joy.device_name;
5752 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
5753 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
5755 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
5756 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
5760 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
5761 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
5764 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
5766 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
5767 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
5768 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
5769 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
5771 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
5772 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
5773 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
5774 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
5775 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
5776 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
5778 for (i = 0; i < 6; i++)
5780 int ypos = 6 + i + (i > 3 ? i-3 : 0);
5782 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5784 DrawText(mSX + 3 * 32, mSY + ypos * 32,
5785 (setup.input[player_nr].use_joystick ?
5787 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
5791 static int input_player_nr = 0;
5793 void HandleSetupScreen_Input_Player(int step, int direction)
5795 int old_player_nr = input_player_nr;
5798 new_player_nr = old_player_nr + step * direction;
5799 if (new_player_nr < 0)
5801 if (new_player_nr > MAX_PLAYERS - 1)
5802 new_player_nr = MAX_PLAYERS - 1;
5804 if (new_player_nr != old_player_nr)
5806 input_player_nr = new_player_nr;
5808 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5812 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
5814 static int choice = 0;
5817 int pos_start = SETUPINPUT_SCREEN_POS_START;
5818 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
5819 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
5820 int pos_end = SETUPINPUT_SCREEN_POS_END;
5822 if (button == MB_MENU_INITIALIZE)
5824 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
5826 DrawCursorAndText_Setup(choice, -1, TRUE);
5830 else if (button == MB_MENU_LEAVE)
5832 setup_mode = SETUP_MODE_MAIN;
5839 if (mx || my) /* mouse input */
5841 x = (mx - mSX) / 32;
5842 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
5844 else if (dx || dy) /* keyboard input */
5846 if (dx && choice == 0)
5847 x = (dx < 0 ? 10 : 12);
5848 else if ((dx && choice == 1) ||
5849 (dx == +1 && choice == 2) ||
5850 (dx == -1 && choice == pos_end))
5851 button = MB_MENU_CHOICE;
5855 if (y >= pos_empty1 && y <= pos_empty2)
5856 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
5859 if (y == 0 && dx != 0 && button)
5861 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
5863 else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
5864 y >= pos_start && y <= pos_end &&
5865 !(y >= pos_empty1 && y <= pos_empty2))
5871 DrawCursorAndText_Setup(choice, -1, FALSE);
5872 DrawCursorAndText_Setup(y, -1, TRUE);
5874 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
5883 char *device_name = setup.input[input_player_nr].joy.device_name;
5885 if (!setup.input[input_player_nr].use_joystick)
5887 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
5889 setJoystickDeviceToNr(device_name, new_device_nr);
5890 setup.input[input_player_nr].use_joystick = TRUE;
5894 int device_nr = getJoystickNrFromDeviceName(device_name);
5895 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
5897 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
5898 setup.input[input_player_nr].use_joystick = FALSE;
5900 setJoystickDeviceToNr(device_name, new_device_nr);
5903 drawPlayerSetupInputInfo(input_player_nr, FALSE);
5907 if (setup.input[input_player_nr].use_joystick)
5910 CalibrateJoystick(input_player_nr);
5913 CustomizeKeyboard(input_player_nr);
5915 else if (y == pos_end)
5921 setup_mode = SETUP_MODE_MAIN;
5928 void CustomizeKeyboard(int player_nr)
5932 boolean finished = FALSE;
5933 static struct SetupKeyboardInfo custom_key;
5938 } customize_step[] =
5940 { &custom_key.left, "Move Left" },
5941 { &custom_key.right, "Move Right" },
5942 { &custom_key.up, "Move Up" },
5943 { &custom_key.down, "Move Down" },
5944 { &custom_key.snap, "Snap Field" },
5945 { &custom_key.drop, "Drop Element" }
5948 /* read existing key bindings from player setup */
5949 custom_key = setup.input[player_nr].key;
5952 FadeOut(REDRAW_FIELD);
5956 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
5959 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
5960 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
5961 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
5962 "Key:", FONT_INPUT_1_ACTIVE);
5963 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
5964 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
5966 FadeIn(REDRAW_FIELD);
5972 if (PendingEvent()) /* got event */
5980 case EVENT_KEYPRESS:
5982 Key key = GetEventKey((KeyEvent *)&event, FALSE);
5984 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
5986 if (key == KSYM_Escape)
5987 FadeSkipNextFadeIn();
5993 /* all keys configured -- wait for "Escape" or "Return" key */
5997 /* press 'Enter' to keep the existing key binding */
5998 if (key == KSYM_Return)
5999 key = *customize_step[step_nr].key;
6001 /* check if key already used */
6002 for (i = 0; i < step_nr; i++)
6003 if (*customize_step[i].key == key)
6008 /* got new key binding */
6009 *customize_step[step_nr].key = key;
6010 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6012 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6013 getKeyNameFromKey(key), FONT_VALUE_1);
6016 /* un-highlight last query */
6017 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6018 customize_step[step_nr - 1].text, FONT_MENU_1);
6019 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6020 "Key:", FONT_MENU_1);
6022 /* press 'Enter' to leave */
6025 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6026 "Press Enter", FONT_TITLE_1);
6030 /* query next key binding */
6031 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6032 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6033 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6034 "Key:", FONT_INPUT_1_ACTIVE);
6035 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6036 getKeyNameFromKey(*customize_step[step_nr].key),
6041 case EVENT_KEYRELEASE:
6042 key_joystick_mapping = 0;
6046 HandleOtherEvents(&event);
6054 /* don't eat all CPU time */
6058 /* write new key bindings back to player setup */
6059 setup.input[player_nr].key = custom_key;
6062 DrawSetupScreen_Input();
6065 static boolean CalibrateJoystickMain(int player_nr)
6067 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6068 int new_joystick_xright = JOYSTICK_XMIDDLE;
6069 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6070 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6071 int new_joystick_xmiddle, new_joystick_ymiddle;
6073 int joystick_fd = joystick.fd[player_nr];
6074 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6075 boolean check[3][3];
6076 int check_remaining = 3 * 3;
6081 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6084 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6088 FadeOut(REDRAW_FIELD);
6092 for (y = 0; y < 3; y++)
6094 for (x = 0; x < 3; x++)
6096 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6097 check[x][y] = FALSE;
6101 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6102 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6103 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6104 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6105 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6106 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6107 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6109 joy_value = Joystick(player_nr);
6110 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6111 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6113 /* eventually uncalibrated center position (joystick could be uncentered) */
6114 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6117 new_joystick_xmiddle = joy_x;
6118 new_joystick_ymiddle = joy_y;
6120 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6122 FadeIn(REDRAW_FIELD);
6124 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6129 if (PendingEvent()) /* got event */
6137 case EVENT_KEYPRESS:
6138 switch (GetEventKey((KeyEvent *)&event, TRUE))
6141 if (check_remaining == 0)
6146 FadeSkipNextFadeIn();
6155 case EVENT_KEYRELEASE:
6156 key_joystick_mapping = 0;
6160 HandleOtherEvents(&event);
6165 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6168 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
6169 new_joystick_xright = MAX(new_joystick_xright, joy_x);
6170 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
6171 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
6173 setup.input[player_nr].joy.xleft = new_joystick_xleft;
6174 setup.input[player_nr].joy.yupper = new_joystick_yupper;
6175 setup.input[player_nr].joy.xright = new_joystick_xright;
6176 setup.input[player_nr].joy.ylower = new_joystick_ylower;
6177 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
6178 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
6180 CheckJoystickData();
6182 joy_value = Joystick(player_nr);
6184 if (joy_value & JOY_BUTTON && check_remaining == 0)
6187 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6188 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6190 if (x != last_x || y != last_y)
6192 DrawFixedGraphic(xpos + last_x, ypos + last_y,
6193 IMG_MENU_CALIBRATE_YELLOW, 0);
6194 DrawFixedGraphic(xpos + x, ypos + y,
6195 IMG_MENU_CALIBRATE_RED, 0);
6200 if (check_remaining > 0 && !check[x+1][y+1])
6202 check[x+1][y+1] = TRUE;
6210 /* don't eat all CPU time */
6214 /* calibrated center position (joystick should now be centered) */
6215 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6218 new_joystick_xmiddle = joy_x;
6219 new_joystick_ymiddle = joy_y;
6223 /* wait until the last pressed button was released */
6224 while (Joystick(player_nr) & JOY_BUTTON)
6226 if (PendingEvent()) /* got event */
6231 HandleOtherEvents(&event);
6240 void CalibrateJoystick(int player_nr)
6242 if (!CalibrateJoystickMain(player_nr))
6244 char *device_name = setup.input[player_nr].joy.device_name;
6245 int nr = getJoystickNrFromDeviceName(device_name) + 1;
6246 int xpos = mSX - SX;
6247 int ypos = mSY - SY;
6251 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
6252 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
6255 Delay(2000); /* show error message for a short time */
6260 DrawSetupScreen_Input();
6263 void DrawSetupScreen()
6265 DeactivateJoystick();
6267 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
6269 if (setup_mode == SETUP_MODE_INPUT)
6270 DrawSetupScreen_Input();
6271 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6272 DrawChooseTree(&game_speed_current);
6273 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6274 DrawChooseTree(&scroll_delay_current);
6275 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6276 DrawChooseTree(&screen_mode_current);
6277 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6278 DrawChooseTree(&window_size_current);
6279 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6280 DrawChooseTree(&scaling_type_current);
6281 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6282 DrawChooseTree(&artwork.gfx_current);
6283 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6284 DrawChooseTree(&artwork.snd_current);
6285 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6286 DrawChooseTree(&artwork.mus_current);
6287 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6288 DrawChooseTree(&volume_simple_current);
6289 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6290 DrawChooseTree(&volume_loops_current);
6291 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6292 DrawChooseTree(&volume_music_current);
6293 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6294 DrawChooseTree(&touch_control_current);
6295 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6296 DrawChooseTree(&move_distance_current);
6297 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6298 DrawChooseTree(&drop_distance_current);
6300 DrawSetupScreen_Generic();
6306 void RedrawSetupScreenAfterFullscreenToggle()
6308 if (setup_mode == SETUP_MODE_GRAPHICS ||
6309 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6311 // update list selection from "setup.window_scaling_percent"
6312 execSetupGraphics_setWindowSizes(TRUE);
6318 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
6320 if (setup_mode == SETUP_MODE_INPUT)
6321 HandleSetupScreen_Input(mx, my, dx, dy, button);
6322 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
6323 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
6324 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
6325 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
6326 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
6327 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
6328 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
6329 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
6330 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
6331 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
6332 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
6333 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
6334 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
6335 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
6336 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
6337 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
6338 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
6339 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
6340 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
6341 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
6342 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
6343 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
6344 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
6345 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
6346 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
6347 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
6348 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
6349 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
6351 HandleSetupScreen_Generic(mx, my, dx, dy, button);
6354 void HandleGameActions()
6356 if (game_status != GAME_MODE_PLAYING)
6359 GameActions(); /* main game loop */
6361 if (tape.auto_play && !tape.playing)
6362 AutoPlayTape(); /* continue automatically playing next tape */
6366 /* ---------- new screen button stuff -------------------------------------- */
6368 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
6372 case SCREEN_CTRL_ID_PREV_LEVEL:
6373 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
6374 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
6377 case SCREEN_CTRL_ID_NEXT_LEVEL:
6378 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
6379 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
6382 case SCREEN_CTRL_ID_PREV_PLAYER:
6383 *x = mSX + TILEX * 10;
6384 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6387 case SCREEN_CTRL_ID_NEXT_PLAYER:
6388 *x = mSX + TILEX * 12;
6389 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
6393 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
6399 int gfx_unpressed, gfx_pressed;
6400 void (*get_gadget_position)(int *, int *, int);
6404 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
6407 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
6408 getScreenMenuButtonPos,
6409 SCREEN_CTRL_ID_PREV_LEVEL,
6414 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
6415 getScreenMenuButtonPos,
6416 SCREEN_CTRL_ID_NEXT_LEVEL,
6421 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
6422 getScreenMenuButtonPos,
6423 SCREEN_CTRL_ID_PREV_PLAYER,
6428 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
6429 getScreenMenuButtonPos,
6430 SCREEN_CTRL_ID_NEXT_PLAYER,
6438 int gfx_unpressed, gfx_pressed;
6442 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
6445 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
6446 -1, -1, /* these values are not constant, but can change at runtime */
6447 SCREEN_CTRL_ID_SCROLL_UP,
6451 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
6452 -1, -1, /* these values are not constant, but can change at runtime */
6453 SCREEN_CTRL_ID_SCROLL_DOWN,
6460 int gfx_unpressed, gfx_pressed;
6466 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
6469 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
6470 -1, -1, /* these values are not constant, but can change at runtime */
6471 -1, -1, /* these values are not constant, but can change at runtime */
6472 GD_TYPE_SCROLLBAR_VERTICAL,
6473 SCREEN_CTRL_ID_SCROLL_VERTICAL,
6474 "scroll level series vertically"
6478 static void CreateScreenMenubuttons()
6480 struct GadgetInfo *gi;
6481 unsigned int event_mask;
6484 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6486 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6487 int gfx_unpressed, gfx_pressed;
6488 int x, y, width, height;
6489 int gd_x1, gd_x2, gd_y1, gd_y2;
6490 int id = menubutton_info[i].gadget_id;
6492 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6494 menubutton_info[i].get_gadget_position(&x, &y, id);
6496 width = SC_MENUBUTTON_XSIZE;
6497 height = SC_MENUBUTTON_YSIZE;
6499 gfx_unpressed = menubutton_info[i].gfx_unpressed;
6500 gfx_pressed = menubutton_info[i].gfx_pressed;
6501 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6502 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6503 gd_x1 = graphic_info[gfx_unpressed].src_x;
6504 gd_y1 = graphic_info[gfx_unpressed].src_y;
6505 gd_x2 = graphic_info[gfx_pressed].src_x;
6506 gd_y2 = graphic_info[gfx_pressed].src_y;
6508 gi = CreateGadget(GDI_CUSTOM_ID, id,
6509 GDI_CUSTOM_TYPE_ID, i,
6510 GDI_INFO_TEXT, menubutton_info[i].infotext,
6515 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6516 GDI_STATE, GD_BUTTON_UNPRESSED,
6517 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6518 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6519 GDI_DIRECT_DRAW, FALSE,
6520 GDI_EVENT_MASK, event_mask,
6521 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6525 Error(ERR_EXIT, "cannot create gadget");
6527 screen_gadget[id] = gi;
6531 static void CreateScreenScrollbuttons()
6533 struct GadgetInfo *gi;
6534 unsigned int event_mask;
6537 /* these values are not constant, but can change at runtime */
6538 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
6539 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
6540 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
6541 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
6543 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6545 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6546 int gfx_unpressed, gfx_pressed;
6547 int x, y, width, height;
6548 int gd_x1, gd_x2, gd_y1, gd_y2;
6549 int id = scrollbutton_info[i].gadget_id;
6551 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
6553 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
6554 y = mSY + scrollbutton_info[i].y;
6555 width = SC_SCROLLBUTTON_XSIZE;
6556 height = SC_SCROLLBUTTON_YSIZE;
6558 /* correct scrollbar position if placed outside menu (playfield) area */
6559 if (x > SC_SCROLL_UP_XPOS)
6560 x = SC_SCROLL_UP_XPOS;
6562 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
6563 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
6564 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
6566 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
6567 gfx_pressed = scrollbutton_info[i].gfx_pressed;
6568 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6569 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6570 gd_x1 = graphic_info[gfx_unpressed].src_x;
6571 gd_y1 = graphic_info[gfx_unpressed].src_y;
6572 gd_x2 = graphic_info[gfx_pressed].src_x;
6573 gd_y2 = graphic_info[gfx_pressed].src_y;
6575 gi = CreateGadget(GDI_CUSTOM_ID, id,
6576 GDI_CUSTOM_TYPE_ID, i,
6577 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
6582 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6583 GDI_STATE, GD_BUTTON_UNPRESSED,
6584 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6585 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6586 GDI_DIRECT_DRAW, FALSE,
6587 GDI_EVENT_MASK, event_mask,
6588 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6592 Error(ERR_EXIT, "cannot create gadget");
6594 screen_gadget[id] = gi;
6598 static void CreateScreenScrollbars()
6602 /* these values are not constant, but can change at runtime */
6603 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
6604 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
6605 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
6606 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
6608 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6610 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
6611 int gfx_unpressed, gfx_pressed;
6612 int x, y, width, height;
6613 int gd_x1, gd_x2, gd_y1, gd_y2;
6614 struct GadgetInfo *gi;
6615 int items_max, items_visible, item_position;
6616 unsigned int event_mask;
6617 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
6618 int id = scrollbar_info[i].gadget_id;
6620 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
6622 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
6623 y = mSY + scrollbar_info[i].y;
6624 width = scrollbar_info[i].width;
6625 height = scrollbar_info[i].height;
6627 /* correct scrollbar position if placed outside menu (playfield) area */
6628 if (x > SC_SCROLL_VERTICAL_XPOS)
6629 x = SC_SCROLL_VERTICAL_XPOS;
6631 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
6632 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
6634 items_max = num_page_entries;
6635 items_visible = num_page_entries;
6638 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
6639 gfx_pressed = scrollbar_info[i].gfx_pressed;
6640 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
6641 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
6642 gd_x1 = graphic_info[gfx_unpressed].src_x;
6643 gd_y1 = graphic_info[gfx_unpressed].src_y;
6644 gd_x2 = graphic_info[gfx_pressed].src_x;
6645 gd_y2 = graphic_info[gfx_pressed].src_y;
6647 gi = CreateGadget(GDI_CUSTOM_ID, id,
6648 GDI_CUSTOM_TYPE_ID, i,
6649 GDI_INFO_TEXT, scrollbar_info[i].infotext,
6654 GDI_TYPE, scrollbar_info[i].type,
6655 GDI_SCROLLBAR_ITEMS_MAX, items_max,
6656 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
6657 GDI_SCROLLBAR_ITEM_POSITION, item_position,
6658 GDI_WHEEL_AREA_X, SX,
6659 GDI_WHEEL_AREA_Y, SY,
6660 GDI_WHEEL_AREA_WIDTH, SXSIZE,
6661 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
6662 GDI_STATE, GD_BUTTON_UNPRESSED,
6663 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
6664 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
6665 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
6666 GDI_DIRECT_DRAW, FALSE,
6667 GDI_EVENT_MASK, event_mask,
6668 GDI_CALLBACK_ACTION, HandleScreenGadgets,
6672 Error(ERR_EXIT, "cannot create gadget");
6674 screen_gadget[id] = gi;
6678 void CreateScreenGadgets()
6680 int last_game_status = game_status; /* save current game status */
6682 CreateScreenMenubuttons();
6684 CreateScreenScrollbuttons();
6685 CreateScreenScrollbars();
6687 game_status = last_game_status; /* restore current game status */
6690 void FreeScreenGadgets()
6694 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
6695 FreeGadget(screen_gadget[i]);
6698 void MapScreenMenuGadgets(int screen_mask)
6702 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
6703 if (screen_mask & menubutton_info[i].screen_mask)
6704 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
6707 void MapScreenGadgets(int num_entries)
6711 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
6714 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
6715 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
6717 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
6718 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
6721 void MapScreenTreeGadgets(TreeInfo *ti)
6723 MapScreenGadgets(numTreeInfoInGroup(ti));
6726 static void HandleScreenGadgets(struct GadgetInfo *gi)
6728 int id = gi->custom_id;
6729 int button = gi->event.button;
6730 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6734 case SCREEN_CTRL_ID_PREV_LEVEL:
6735 HandleMainMenu_SelectLevel(step, -1);
6738 case SCREEN_CTRL_ID_NEXT_LEVEL:
6739 HandleMainMenu_SelectLevel(step, +1);
6742 case SCREEN_CTRL_ID_PREV_PLAYER:
6743 HandleSetupScreen_Input_Player(step, -1);
6746 case SCREEN_CTRL_ID_NEXT_PLAYER:
6747 HandleSetupScreen_Input_Player(step, +1);
6750 case SCREEN_CTRL_ID_SCROLL_UP:
6751 if (game_status == GAME_MODE_LEVELS)
6752 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6753 else if (game_status == GAME_MODE_LEVELNR)
6754 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6755 else if (game_status == GAME_MODE_SETUP)
6756 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
6759 case SCREEN_CTRL_ID_SCROLL_DOWN:
6760 if (game_status == GAME_MODE_LEVELS)
6761 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6762 else if (game_status == GAME_MODE_LEVELNR)
6763 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6764 else if (game_status == GAME_MODE_SETUP)
6765 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
6768 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
6769 if (game_status == GAME_MODE_LEVELS)
6770 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6771 else if (game_status == GAME_MODE_LEVELNR)
6772 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
6773 else if (game_status == GAME_MODE_SETUP)
6774 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);