1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
28 /* screens on the info screen */
29 #define INFO_MODE_MAIN 0
30 #define INFO_MODE_TITLE 1
31 #define INFO_MODE_ELEMENTS 2
32 #define INFO_MODE_MUSIC 3
33 #define INFO_MODE_CREDITS 4
34 #define INFO_MODE_PROGRAM 5
35 #define INFO_MODE_VERSION 6
36 #define INFO_MODE_LEVELSET 7
38 #define MAX_INFO_MODES 8
40 /* screens on the setup screen */
41 /* (must match GFX_SPECIAL_ARG_SETUP_* values as defined in src/main.h) */
42 /* (should also match corresponding entries in src/conf_gfx.c) */
43 #define SETUP_MODE_MAIN 0
44 #define SETUP_MODE_GAME 1
45 #define SETUP_MODE_EDITOR 2
46 #define SETUP_MODE_GRAPHICS 3
47 #define SETUP_MODE_SOUND 4
48 #define SETUP_MODE_ARTWORK 5
49 #define SETUP_MODE_INPUT 6
50 #define SETUP_MODE_TOUCH 7
51 #define SETUP_MODE_SHORTCUTS 8
52 #define SETUP_MODE_SHORTCUTS_1 9
53 #define SETUP_MODE_SHORTCUTS_2 10
54 #define SETUP_MODE_SHORTCUTS_3 11
55 #define SETUP_MODE_SHORTCUTS_4 12
56 #define SETUP_MODE_SHORTCUTS_5 13
58 /* sub-screens on the setup screen (generic) */
59 #define SETUP_MODE_CHOOSE_ARTWORK 14
60 #define SETUP_MODE_CHOOSE_OTHER 15
62 /* sub-screens on the setup screen (specific) */
63 #define SETUP_MODE_CHOOSE_GAME_SPEED 16
64 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17
65 #define SETUP_MODE_CHOOSE_SCREEN_MODE 18
66 #define SETUP_MODE_CHOOSE_WINDOW_SIZE 19
67 #define SETUP_MODE_CHOOSE_SCALING_TYPE 20
68 #define SETUP_MODE_CHOOSE_GRAPHICS 21
69 #define SETUP_MODE_CHOOSE_SOUNDS 22
70 #define SETUP_MODE_CHOOSE_MUSIC 23
71 #define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 24
72 #define SETUP_MODE_CHOOSE_VOLUME_LOOPS 25
73 #define SETUP_MODE_CHOOSE_VOLUME_MUSIC 26
74 #define SETUP_MODE_CHOOSE_TOUCH_CONTROL 27
75 #define SETUP_MODE_CHOOSE_MOVE_DISTANCE 28
76 #define SETUP_MODE_CHOOSE_DROP_DISTANCE 29
78 #define MAX_SETUP_MODES 30
80 /* for input setup functions */
81 #define SETUPINPUT_SCREEN_POS_START 0
82 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
83 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
84 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
86 /* for various menu stuff */
87 #define MENU_SCREEN_START_XPOS 1
88 #define MENU_SCREEN_START_YPOS 2
90 #define MENU_SCREEN_VALUE_XPOS (SCR_FIELDX - 3)
91 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
93 #define MENU_SCREEN_VALUE_XPOS 14
94 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1)
96 #define MENU_TITLE1_YPOS 8
97 #define MENU_TITLE2_YPOS 46
98 #define MENU_SCREEN_INFO_XSTART 16
99 #define MENU_SCREEN_INFO_YSTART1 100
100 #define MENU_SCREEN_INFO_YSTART2 128
101 #define MENU_SCREEN_INFO_YSTEP (TILEY + 4)
102 #define MENU_SCREEN_INFO_YBOTTOM (SYSIZE - 20)
103 #define MENU_SCREEN_INFO_YSIZE (MENU_SCREEN_INFO_YBOTTOM - \
104 MENU_SCREEN_INFO_YSTART2 - \
106 #define MAX_INFO_ELEMENTS_ON_SCREEN 128
108 #define NUM_INFO_ELEMENTS_ON_SCREEN MIN(MENU_SCREEN_INFO_YSIZE / \
109 MENU_SCREEN_INFO_YSTEP, \
110 MAX_INFO_ELEMENTS_ON_SCREEN)
112 #define NUM_INFO_ELEMENTS_ON_SCREEN 10
114 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS)
116 #define MAX_MENU_TEXT_LENGTH_BIG 13
117 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
119 #define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \
120 MENU_SCREEN_START_XPOS)
121 #define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2)
124 /* buttons and scrollbars identifiers */
125 #define SCREEN_CTRL_ID_PREV_LEVEL 0
126 #define SCREEN_CTRL_ID_NEXT_LEVEL 1
127 #define SCREEN_CTRL_ID_PREV_PLAYER 2
128 #define SCREEN_CTRL_ID_NEXT_PLAYER 3
129 #define SCREEN_CTRL_ID_SCROLL_UP 4
130 #define SCREEN_CTRL_ID_SCROLL_DOWN 5
131 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 6
133 #define NUM_SCREEN_GADGETS 7
135 #define NUM_SCREEN_MENUBUTTONS 4
136 #define NUM_SCREEN_SCROLLBUTTONS 2
137 #define NUM_SCREEN_SCROLLBARS 1
139 #define SCREEN_MASK_MAIN (1 << 0)
140 #define SCREEN_MASK_INPUT (1 << 1)
142 /* graphic position and size values for buttons and scrollbars */
143 #define SC_MENUBUTTON_XSIZE TILEX
144 #define SC_MENUBUTTON_YSIZE TILEY
146 #define SC_SCROLLBUTTON_XSIZE TILEX
147 #define SC_SCROLLBUTTON_YSIZE TILEY
149 #define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
151 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
152 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
153 SC_SCROLLBUTTON_YSIZE)
155 #define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS
156 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
158 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS
159 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
160 SC_SCROLLBUTTON_YSIZE)
162 #define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS
163 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
164 SC_SCROLL_VERTICAL_YSIZE)
166 #define SC_BORDER_SIZE 14
169 /* forward declarations of internal functions */
170 static void HandleScreenGadgets(struct GadgetInfo *);
171 static void HandleSetupScreen_Generic(int, int, int, int, int);
172 static void HandleSetupScreen_Input(int, int, int, int, int);
173 static void CustomizeKeyboard(int);
174 static void CalibrateJoystick(int);
175 static void execSetupGame(void);
176 static void execSetupGraphics(void);
177 static void execSetupSound(void);
178 static void execSetupTouch(void);
179 static void execSetupArtwork(void);
180 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
182 static void DrawChooseLevelSet(void);
183 static void DrawChooseLevelNr(void);
184 static void DrawInfoScreen(void);
185 static void DrawAndFadeInInfoScreen(int);
186 static void DrawSetupScreen(void);
188 static void DrawInfoScreenExt(int, int);
189 static void DrawInfoScreen_NotAvailable(char *, char *);
190 static void DrawInfoScreen_HelpAnim(int, int, boolean);
191 static void DrawInfoScreen_HelpText(int, int, int, int);
192 static void HandleInfoScreen_Main(int, int, int, int, int);
193 static void HandleInfoScreen_TitleScreen(int);
194 static void HandleInfoScreen_Elements(int);
195 static void HandleInfoScreen_Music(int);
196 static void HandleInfoScreen_Credits(int);
197 static void HandleInfoScreen_Program(int);
198 static void HandleInfoScreen_Version(int);
200 static void MapScreenMenuGadgets(int);
201 static void MapScreenGadgets(int);
202 static void MapScreenTreeGadgets(TreeInfo *);
204 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
206 static int info_mode = INFO_MODE_MAIN;
207 static int setup_mode = SETUP_MODE_MAIN;
209 static TreeInfo *screen_modes = NULL;
210 static TreeInfo *screen_mode_current = NULL;
212 static TreeInfo *window_sizes = NULL;
213 static TreeInfo *window_size_current = NULL;
215 static TreeInfo *scaling_types = NULL;
216 static TreeInfo *scaling_type_current = NULL;
218 static TreeInfo *scroll_delays = NULL;
219 static TreeInfo *scroll_delay_current = NULL;
221 static TreeInfo *game_speeds = NULL;
222 static TreeInfo *game_speed_current = NULL;
224 static TreeInfo *volumes_simple = NULL;
225 static TreeInfo *volume_simple_current = NULL;
227 static TreeInfo *volumes_loops = NULL;
228 static TreeInfo *volume_loops_current = NULL;
230 static TreeInfo *volumes_music = NULL;
231 static TreeInfo *volume_music_current = NULL;
233 static TreeInfo *touch_controls = NULL;
234 static TreeInfo *touch_control_current = NULL;
236 static TreeInfo *move_distances = NULL;
237 static TreeInfo *move_distance_current = NULL;
239 static TreeInfo *drop_distances = NULL;
240 static TreeInfo *drop_distance_current = NULL;
242 static TreeInfo *level_number = NULL;
243 static TreeInfo *level_number_current = NULL;
249 } window_sizes_list[] =
254 { 100, "100 % (Default)" },
271 } scaling_types_list[] =
273 { SCALING_QUALITY_NEAREST, "None" },
274 { SCALING_QUALITY_LINEAR, "Linear" },
275 { SCALING_QUALITY_BEST, "Anisotropic" },
284 } game_speeds_list[] =
293 { 1000, "1/1s (Extremely Slow)" },
298 { 29, "1/35s (Original Supaplex)" },
300 { 20, "1/50s (Normal Speed)" },
301 { 14, "1/70s (Maximum Supaplex)" },
305 { 1, "1/1000s (Extremely Fast)" },
315 } scroll_delays_list[] =
317 { 0, "0 Tiles (No Scroll Delay)" },
320 { 3, "3 Tiles (Default)" },
325 { 8, "8 Tiles (Maximum Scroll Delay)"},
355 } touch_controls_list[] =
357 { TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" },
358 { TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" },
382 #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \
383 (s) <= GAME_MODE_SETUP ? (s) : \
384 (s) == GAME_MODE_PSEUDO_TYPENAME ? \
385 GAME_MODE_MAIN : GAME_MODE_DEFAULT)
387 /* (there are no draw offset definitions needed for INFO_MODE_TITLE) */
388 #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_ELEMENTS && \
389 (i) <= INFO_MODE_LEVELSET ? (i) : \
392 #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \
393 (i) <= SETUP_MODE_SHORTCUTS_5 ? (i) : \
394 (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \
395 (i) <= SETUP_MODE_CHOOSE_MUSIC ? \
396 SETUP_MODE_CHOOSE_ARTWORK : \
397 SETUP_MODE_CHOOSE_OTHER)
399 #define DRAW_XOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
400 menu.draw_xoffset[GAME_MODE_INFO] : \
401 menu.draw_xoffset_info[DRAW_MODE_INFO(i)])
402 #define DRAW_YOFFSET_INFO(i) (DRAW_MODE_INFO(i) == INFO_MODE_MAIN ? \
403 menu.draw_yoffset[GAME_MODE_INFO] : \
404 menu.draw_yoffset_info[DRAW_MODE_INFO(i)])
406 #define DRAW_XOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
407 menu.draw_xoffset[GAME_MODE_SETUP] : \
408 menu.draw_xoffset_setup[DRAW_MODE_SETUP(i)])
409 #define DRAW_YOFFSET_SETUP(i) (DRAW_MODE_SETUP(i) == SETUP_MODE_MAIN ? \
410 menu.draw_yoffset[GAME_MODE_SETUP] : \
411 menu.draw_yoffset_setup[DRAW_MODE_SETUP(i)])
413 #define DRAW_XOFFSET(s) ((s) == GAME_MODE_INFO ? \
414 DRAW_XOFFSET_INFO(info_mode) : \
415 (s) == GAME_MODE_SETUP ? \
416 DRAW_XOFFSET_SETUP(setup_mode) : \
417 menu.draw_xoffset[DRAW_MODE(s)])
418 #define DRAW_YOFFSET(s) ((s) == GAME_MODE_INFO ? \
419 DRAW_YOFFSET_INFO(info_mode) : \
420 (s) == GAME_MODE_SETUP ? \
421 DRAW_YOFFSET_SETUP(setup_mode) : \
422 menu.draw_yoffset[DRAW_MODE(s)])
424 #define mSX (SX + DRAW_XOFFSET(game_status))
425 #define mSY (SY + DRAW_YOFFSET(game_status))
427 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \
428 menu.list_size[game_status] : \
429 MAX_MENU_ENTRIES_ON_SCREEN)
431 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
432 #define NUM_SCROLLBAR_BITMAPS 2
433 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS];
437 /* title display and control definitions */
439 #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
440 2 * MAX_NUM_TITLE_MESSAGES)
442 static int num_title_screens = 0;
444 struct TitleControlInfo
452 struct TitleControlInfo title_controls[MAX_NUM_TITLE_SCREENS];
454 /* main menu display and control definitions */
456 #define MAIN_CONTROL_NAME 0
457 #define MAIN_CONTROL_LEVELS 1
458 #define MAIN_CONTROL_SCORES 2
459 #define MAIN_CONTROL_EDITOR 3
460 #define MAIN_CONTROL_INFO 4
461 #define MAIN_CONTROL_GAME 5
462 #define MAIN_CONTROL_SETUP 6
463 #define MAIN_CONTROL_QUIT 7
464 #define MAIN_CONTROL_PREV_LEVEL 8
465 #define MAIN_CONTROL_NEXT_LEVEL 9
466 #define MAIN_CONTROL_FIRST_LEVEL 10
467 #define MAIN_CONTROL_LAST_LEVEL 11
468 #define MAIN_CONTROL_LEVEL_NUMBER 12
469 #define MAIN_CONTROL_LEVEL_INFO_1 13
470 #define MAIN_CONTROL_LEVEL_INFO_2 14
471 #define MAIN_CONTROL_LEVEL_NAME 15
472 #define MAIN_CONTROL_LEVEL_AUTHOR 16
473 #define MAIN_CONTROL_LEVEL_YEAR 17
474 #define MAIN_CONTROL_LEVEL_IMPORTED_FROM 18
475 #define MAIN_CONTROL_LEVEL_IMPORTED_BY 19
476 #define MAIN_CONTROL_LEVEL_TESTED_BY 20
477 #define MAIN_CONTROL_TITLE_1 21
478 #define MAIN_CONTROL_TITLE_2 22
479 #define MAIN_CONTROL_TITLE_3 23
481 static char str_main_text_name[10];
482 static char str_main_text_first_level[10];
483 static char str_main_text_last_level[10];
484 static char str_main_text_level_number[10];
486 static char *main_text_name = str_main_text_name;
487 static char *main_text_first_level = str_main_text_first_level;
488 static char *main_text_last_level = str_main_text_last_level;
489 static char *main_text_level_number = str_main_text_level_number;
490 static char *main_text_levels = "Levelset";
491 static char *main_text_scores = "Hall Of Fame";
492 static char *main_text_editor = "Level Creator";
493 static char *main_text_info = "Info Screen";
494 static char *main_text_game = "Start Game";
495 static char *main_text_setup = "Setup";
496 static char *main_text_quit = "Quit";
497 static char *main_text_level_name = level.name;
498 static char *main_text_level_author = level.author;
499 static char *main_text_level_year = NULL;
500 static char *main_text_level_imported_from = NULL;
501 static char *main_text_level_imported_by = NULL;
502 static char *main_text_level_tested_by = NULL;
503 static char *main_text_title_1 = PROGRAM_TITLE_STRING;
504 static char *main_text_title_2 = PROGRAM_COPYRIGHT_STRING;
505 static char *main_text_title_3 = PROGRAM_GAME_BY_STRING;
507 struct MainControlInfo
511 struct MenuPosInfo *pos_button;
514 struct TextPosInfo *pos_text;
517 struct TextPosInfo *pos_input;
521 static struct MainControlInfo main_controls[] =
525 &menu.main.button.name, IMG_MENU_BUTTON_NAME,
526 &menu.main.text.name, &main_text_name,
527 &menu.main.input.name, &setup.player_name,
531 &menu.main.button.levels, IMG_MENU_BUTTON_LEVELS,
532 &menu.main.text.levels, &main_text_levels,
537 &menu.main.button.scores, IMG_MENU_BUTTON_SCORES,
538 &menu.main.text.scores, &main_text_scores,
543 &menu.main.button.editor, IMG_MENU_BUTTON_EDITOR,
544 &menu.main.text.editor, &main_text_editor,
549 &menu.main.button.info, IMG_MENU_BUTTON_INFO,
550 &menu.main.text.info, &main_text_info,
555 &menu.main.button.game, IMG_MENU_BUTTON_GAME,
556 &menu.main.text.game, &main_text_game,
561 &menu.main.button.setup, IMG_MENU_BUTTON_SETUP,
562 &menu.main.text.setup, &main_text_setup,
567 &menu.main.button.quit, IMG_MENU_BUTTON_QUIT,
568 &menu.main.text.quit, &main_text_quit,
572 /* (these two buttons are real gadgets) */
574 MAIN_CONTROL_PREV_LEVEL,
575 &menu.main.button.prev_level, IMG_MENU_BUTTON_PREV_LEVEL,
580 MAIN_CONTROL_NEXT_LEVEL,
581 &menu.main.button.next_level, IMG_MENU_BUTTON_NEXT_LEVEL,
587 MAIN_CONTROL_FIRST_LEVEL,
589 &menu.main.text.first_level, &main_text_first_level,
593 MAIN_CONTROL_LAST_LEVEL,
595 &menu.main.text.last_level, &main_text_last_level,
599 MAIN_CONTROL_LEVEL_NUMBER,
601 &menu.main.text.level_number, &main_text_level_number,
605 MAIN_CONTROL_LEVEL_INFO_1,
607 &menu.main.text.level_info_1, NULL,
611 MAIN_CONTROL_LEVEL_INFO_2,
613 &menu.main.text.level_info_2, NULL,
617 MAIN_CONTROL_LEVEL_NAME,
619 &menu.main.text.level_name, &main_text_level_name,
623 MAIN_CONTROL_LEVEL_AUTHOR,
625 &menu.main.text.level_author, &main_text_level_author,
629 MAIN_CONTROL_LEVEL_YEAR,
631 &menu.main.text.level_year, &main_text_level_year,
635 MAIN_CONTROL_LEVEL_IMPORTED_FROM,
637 &menu.main.text.level_imported_from, &main_text_level_imported_from,
641 MAIN_CONTROL_LEVEL_IMPORTED_BY,
643 &menu.main.text.level_imported_by, &main_text_level_imported_by,
647 MAIN_CONTROL_LEVEL_TESTED_BY,
649 &menu.main.text.level_tested_by, &main_text_level_tested_by,
653 MAIN_CONTROL_TITLE_1,
655 &menu.main.text.title_1, &main_text_title_1,
659 MAIN_CONTROL_TITLE_2,
661 &menu.main.text.title_2, &main_text_title_2,
665 MAIN_CONTROL_TITLE_3,
667 &menu.main.text.title_3, &main_text_title_3,
680 static int getTitleScreenGraphic(int nr, boolean initial)
682 return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr;
685 static struct TitleMessageInfo *getTitleMessageInfo(int nr, boolean initial)
687 return (initial ? &titlemessage_initial[nr] : &titlemessage[nr]);
691 static int getTitleScreenGameMode(boolean initial)
693 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
697 static int getTitleMessageGameMode(boolean initial)
699 return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
703 static int getTitleScreenBackground(boolean initial)
705 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
710 static int getTitleMessageBackground(int nr, boolean initial)
712 return (initial ? IMG_BACKGROUND_TITLE_INITIAL : IMG_BACKGROUND_TITLE);
716 static int getTitleBackground(int nr, boolean initial, boolean is_image)
718 int base = (is_image ?
719 (initial ? IMG_BACKGROUND_TITLESCREEN_INITIAL_1 :
720 IMG_BACKGROUND_TITLESCREEN_1) :
721 (initial ? IMG_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
722 IMG_BACKGROUND_TITLEMESSAGE_1));
723 int graphic_global = (initial ? IMG_BACKGROUND_TITLE_INITIAL :
724 IMG_BACKGROUND_TITLE);
725 int graphic_local = base + nr;
727 if (graphic_info[graphic_local].bitmap != NULL)
728 return graphic_local;
730 if (graphic_info[graphic_global].bitmap != NULL)
731 return graphic_global;
733 return IMG_UNDEFINED;
736 static int getTitleSound(struct TitleControlInfo *tci)
738 boolean is_image = tci->is_image;
739 int initial = tci->initial;
740 int nr = tci->local_nr;
741 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
742 int base = (is_image ?
743 (initial ? SND_BACKGROUND_TITLESCREEN_INITIAL_1 :
744 SND_BACKGROUND_TITLESCREEN_1) :
745 (initial ? SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
746 SND_BACKGROUND_TITLEMESSAGE_1));
747 int sound_global = menu.sound[mode];
748 int sound_local = base + nr;
751 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
752 nr, initial, is_image,
753 sound_global, getSoundListEntry(sound_global)->filename,
754 sound_local, getSoundListEntry(sound_local)->filename);
757 if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME))
760 if (!strEqual(getSoundListEntry(sound_global)->filename, UNDEFINED_FILENAME))
763 return SND_UNDEFINED;
766 static int getTitleMusic(struct TitleControlInfo *tci)
768 boolean is_image = tci->is_image;
769 int initial = tci->initial;
770 int nr = tci->local_nr;
771 int mode = (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
772 int base = (is_image ?
773 (initial ? MUS_BACKGROUND_TITLESCREEN_INITIAL_1 :
774 MUS_BACKGROUND_TITLESCREEN_1) :
775 (initial ? MUS_BACKGROUND_TITLEMESSAGE_INITIAL_1 :
776 MUS_BACKGROUND_TITLEMESSAGE_1));
777 int music_global = menu.music[mode];
778 int music_local = base + nr;
781 printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n",
782 nr, initial, is_image,
783 music_global, getMusicListEntry(music_global)->filename,
784 music_local, getMusicListEntry(music_local)->filename);
787 if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME))
790 if (!strEqual(getMusicListEntry(music_global)->filename, UNDEFINED_FILENAME))
793 return MUS_UNDEFINED;
796 static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
798 boolean is_image = tci->is_image;
799 int initial = tci->initial;
800 int nr = tci->local_nr;
801 struct TitleFadingInfo ti;
805 int graphic = getTitleScreenGraphic(nr, initial);
807 /* initialize fading control values to default title config settings */
808 ti = (initial ? title_initial_default : title_default);
810 /* override default settings with image config settings, if defined */
811 if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT)
812 ti.fade_mode = graphic_info[graphic].fade_mode;
813 if (graphic_info[graphic].fade_delay > -1)
814 ti.fade_delay = graphic_info[graphic].fade_delay;
815 if (graphic_info[graphic].post_delay > -1)
816 ti.post_delay = graphic_info[graphic].post_delay;
817 if (graphic_info[graphic].auto_delay > -1)
818 ti.auto_delay = graphic_info[graphic].auto_delay;
824 ti.fade_mode = titlemessage_initial[nr].fade_mode;
825 ti.fade_delay = titlemessage_initial[nr].fade_delay;
826 ti.post_delay = titlemessage_initial[nr].post_delay;
827 ti.auto_delay = titlemessage_initial[nr].auto_delay;
831 ti.fade_mode = titlemessage[nr].fade_mode;
832 ti.fade_delay = titlemessage[nr].fade_delay;
833 ti.post_delay = titlemessage[nr].post_delay;
834 ti.auto_delay = titlemessage[nr].auto_delay;
839 if (ti.anim_mode == ANIM_NONE)
840 ti.fade_delay = ti.post_delay = 0;
846 static int compareTitleControlInfo(const void *object1, const void *object2)
848 const struct TitleControlInfo *tci1 = (struct TitleControlInfo *)object1;
849 const struct TitleControlInfo *tci2 = (struct TitleControlInfo *)object2;
852 if (tci1->initial != tci2->initial)
853 compare_result = (tci1->initial ? -1 : +1);
854 else if (tci1->sort_priority != tci2->sort_priority)
855 compare_result = tci1->sort_priority - tci2->sort_priority;
856 else if (tci1->is_image != tci2->is_image)
857 compare_result = (tci1->is_image ? -1 : +1);
859 compare_result = tci1->local_nr - tci2->local_nr;
861 return compare_result;
864 static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image,
866 int nr, int sort_priority)
868 title_controls[num_title_screens].is_image = is_image;
869 title_controls[num_title_screens].initial = initial;
870 title_controls[num_title_screens].local_nr = nr;
871 title_controls[num_title_screens].sort_priority = sort_priority;
876 static void InitializeTitleControls_CheckTitleInfo(boolean initial)
880 for (i = 0; i < MAX_NUM_TITLE_IMAGES; i++)
882 int graphic = getTitleScreenGraphic(i, initial);
883 Bitmap *bitmap = graphic_info[graphic].bitmap;
884 int sort_priority = graphic_info[graphic].sort_priority;
887 /* skip images and messages (fonts!) when using forced custom graphics */
888 if (setup.override_level_graphics && !initial)
893 InitializeTitleControlsExt_AddTitleInfo(TRUE, initial, i, sort_priority);
896 for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++)
898 struct TitleMessageInfo *tmi = getTitleMessageInfo(i, initial);
899 char *filename = getLevelSetTitleMessageFilename(i, initial);
900 int sort_priority = tmi->sort_priority;
903 /* skip images and messages (fonts!) when using forced custom graphics */
904 if (setup.override_level_graphics)
908 if (filename != NULL)
909 InitializeTitleControlsExt_AddTitleInfo(FALSE, initial, i, sort_priority);
913 static void InitializeTitleControls(boolean show_title_initial)
915 num_title_screens = 0;
918 /* 1st step: initialize title screens for game start (only when starting) */
919 if (show_title_initial)
920 InitializeTitleControls_CheckTitleInfo(TRUE);
923 /* 2nd step: initialize title screens for current level set */
924 InitializeTitleControls_CheckTitleInfo(FALSE);
926 /* sort title screens according to sort_priority and title number */
927 qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo),
928 compareTitleControlInfo);
931 static boolean visibleMenuPos(struct MenuPosInfo *pos)
933 return (pos != NULL && pos->x != -1 && pos->y != -1);
936 static boolean visibleTextPos(struct TextPosInfo *pos)
938 return (pos != NULL && pos->x != -1 && pos->y != -1);
941 static void InitializeMainControls()
943 boolean local_team_mode = (!options.network && setup.team_mode);
946 /* set main control text values to dynamically determined values */
947 sprintf(main_text_name, "%s", local_team_mode ? "Team:" : "Name:");
949 strcpy(main_text_first_level, int2str(leveldir_current->first_level,
950 menu.main.text.first_level.size));
951 strcpy(main_text_last_level, int2str(leveldir_current->last_level,
952 menu.main.text.last_level.size));
953 strcpy(main_text_level_number, int2str(level_nr,
954 menu.main.text.level_number.size));
956 main_text_level_year = leveldir_current->year;
957 main_text_level_imported_from = leveldir_current->imported_from;
958 main_text_level_imported_by = leveldir_current->imported_by;
959 main_text_level_tested_by = leveldir_current->tested_by;
961 /* set main control screen positions to dynamically determined values */
962 for (i = 0; main_controls[i].nr != -1; i++)
964 struct MainControlInfo *mci = &main_controls[i];
966 struct MenuPosInfo *pos_button = mci->pos_button;
967 struct TextPosInfo *pos_text = mci->pos_text;
968 struct TextPosInfo *pos_input = mci->pos_input;
969 char *text = (mci->text ? *mci->text : NULL);
970 char *input = (mci->input ? *mci->input : NULL);
971 int button_graphic = mci->button_graphic;
973 int font_text = (pos_text ? pos_text->font : -1);
974 int font_input = (pos_input ? pos_input->font : -1);
976 int font_text = mci->font_text;
977 int font_input = mci->font_input;
980 int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0);
981 int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0);
982 int font_input_width = (font_input != -1 ? getFontWidth(font_input) : 0);
983 int font_input_height = (font_input != -1 ? getFontHeight(font_input) : 0);
984 int text_chars = (text != NULL ? strlen(text) : 0);
985 int input_chars = (input != NULL ? strlen(input) : 0);
988 (button_graphic != -1 ? graphic_info[button_graphic].width : 0);
990 (button_graphic != -1 ? graphic_info[button_graphic].height : 0);
991 int text_width = font_text_width * text_chars;
992 int text_height = font_text_height;
993 int input_width = font_input_width * input_chars;
994 int input_height = font_input_height;
996 if (nr == MAIN_CONTROL_NAME)
999 if (menu.main.input.name.x == -1)
1000 menu.main.input.name.x = menu.main.text.name.x + text_width;
1001 if (menu.main.input.name.y == -1)
1002 menu.main.input.name.y = menu.main.text.name.y;
1006 menu.main.input.name.width = input_width;
1007 menu.main.input.name.height = input_height;
1009 menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
1010 menu.main.input.name.height = font_input_height;
1014 if (pos_button != NULL) /* (x/y may be -1/-1 here) */
1016 if (pos_button->width == 0)
1017 pos_button->width = button_width;
1018 if (pos_button->height == 0)
1019 pos_button->height = button_height;
1022 if (pos_text != NULL) /* (x/y may be -1/-1 here) */
1025 /* calculate size for non-clickable text -- needed for text alignment */
1026 boolean calculate_text_size = (pos_button == NULL && text != NULL);
1028 /* calculate width for non-clickable text -- needed for text alignment */
1029 boolean calculate_text_width = (pos_button == NULL && text != NULL);
1032 if (visibleMenuPos(pos_button))
1034 if (pos_text->x == -1)
1035 pos_text->x = pos_button->x + pos_button->width;
1036 if (pos_text->y == -1)
1037 pos_text->y = pos_button->y;
1041 if (pos_text->width == -1 || calculate_text_size)
1042 pos_text->width = text_width;
1043 if (pos_text->height == -1 || calculate_text_size)
1044 pos_text->height = text_height;
1046 if (pos_text->width == -1 || calculate_text_width)
1047 pos_text->width = text_width;
1048 if (pos_text->height == -1)
1049 pos_text->height = text_height;
1053 if (pos_input != NULL) /* (x/y may be -1/-1 here) */
1055 if (visibleTextPos(pos_text))
1057 if (pos_input->x == -1)
1058 pos_input->x = pos_text->x + pos_text->width;
1059 if (pos_input->y == -1)
1060 pos_input->y = pos_text->y;
1063 if (pos_input->width == -1)
1064 pos_input->width = input_width;
1065 if (pos_input->height == -1)
1066 pos_input->height = input_height;
1071 static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
1072 boolean active_input)
1076 for (i = 0; main_controls[i].nr != -1; i++)
1078 struct MainControlInfo *mci = &main_controls[i];
1080 if (mci->nr == nr || nr == -1)
1082 struct MenuPosInfo *pos_button = mci->pos_button;
1083 struct TextPosInfo *pos_text = mci->pos_text;
1084 struct TextPosInfo *pos_input = mci->pos_input;
1085 char *text = (mci->text ? *mci->text : NULL);
1086 char *input = (mci->input ? *mci->input : NULL);
1087 int button_graphic = mci->button_graphic;
1089 int font_text = (pos_text ? pos_text->font : -1);
1090 int font_input = (pos_input ? pos_input->font : -1);
1092 int font_text = mci->font_text;
1093 int font_input = mci->font_input;
1098 button_graphic = BUTTON_ACTIVE(button_graphic);
1099 font_text = FONT_ACTIVE(font_text);
1104 font_input = FONT_ACTIVE(font_input);
1107 if (visibleMenuPos(pos_button))
1109 struct MenuPosInfo *pos = pos_button;
1110 int x = mSX + pos->x;
1111 int y = mSY + pos->y;
1113 DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
1114 DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
1117 if (visibleTextPos(pos_text) && text != NULL)
1119 struct TextPosInfo *pos = pos_text;
1120 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1121 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1124 /* (check why/if this is needed) */
1125 DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
1127 DrawText(x, y, text, font_text);
1130 if (visibleTextPos(pos_input) && input != NULL)
1132 struct TextPosInfo *pos = pos_input;
1133 int x = mSX + ALIGNED_TEXT_XPOS(pos);
1134 int y = mSY + ALIGNED_TEXT_YPOS(pos);
1137 /* (check why/if this is needed) */
1138 DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
1140 DrawText(x, y, input, font_input);
1146 static void DrawCursorAndText_Main(int nr, boolean active_text)
1148 DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
1152 static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
1154 DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
1158 static struct MainControlInfo *getMainControlInfo(int nr)
1162 for (i = 0; main_controls[i].nr != -1; i++)
1163 if (main_controls[i].nr == nr)
1164 return &main_controls[i];
1169 static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y)
1174 int rect_x = ALIGNED_TEXT_XPOS(rect);
1175 int rect_y = ALIGNED_TEXT_YPOS(rect);
1177 return (x >= rect_x && x < rect_x + rect->width &&
1178 y >= rect_y && y < rect_y + rect->height);
1181 static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
1186 int rect_x = ALIGNED_TEXT_XPOS(rect);
1187 int rect_y = ALIGNED_TEXT_YPOS(rect);
1190 printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n",
1191 x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height,
1192 (x >= rect_x && x < rect_x + rect->width &&
1193 y >= rect_y && y < rect_y + rect->height));
1196 return (x >= rect_x && x < rect_x + rect->width &&
1197 y >= rect_y && y < rect_y + rect->height);
1200 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
1203 static int cursor_array[MAX_LEV_FIELDY];
1205 static int cursor_array[SCR_FIELDY];
1207 int x = mSX + TILEX * xpos;
1208 int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
1213 cursor_array[ypos] = graphic;
1215 graphic = cursor_array[ypos];
1219 graphic = BUTTON_ACTIVE(graphic);
1221 DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
1222 DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0);
1225 static void initCursor(int ypos, int graphic)
1227 drawCursorExt(0, ypos, FALSE, graphic);
1230 static void drawCursor(int ypos, boolean active)
1232 drawCursorExt(0, ypos, active, -1);
1235 static void drawCursorXY(int xpos, int ypos, int graphic)
1237 drawCursorExt(xpos, ypos, FALSE, graphic);
1240 static void drawChooseTreeCursor(int ypos, boolean active)
1242 int last_game_status = game_status; /* save current game status */
1245 /* force LEVELS draw offset on artwork setup screen */
1246 game_status = GAME_MODE_LEVELS;
1249 drawCursorExt(0, ypos, active, -1);
1251 game_status = last_game_status; /* restore current game status */
1256 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING);
1257 DrawTextSCentered(MENU_TITLE2_YPOS, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
1261 static int getPrevlevelButtonPos()
1266 static int getCurrentLevelTextPos()
1268 return (getPrevlevelButtonPos() + 1);
1271 static int getNextLevelButtonPos()
1273 return getPrevlevelButtonPos() + 3 + 1;
1276 static int getLevelRangeTextPos()
1278 return getNextLevelButtonPos() + 1;
1282 int effectiveGameStatus()
1284 if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
1285 return GAME_MODE_TITLE;
1290 void DrawTitleScreenImage(int nr, boolean initial)
1292 int graphic = getTitleScreenGraphic(nr, initial);
1293 Bitmap *bitmap = graphic_info[graphic].bitmap;
1294 int width = graphic_info[graphic].width;
1295 int height = graphic_info[graphic].height;
1296 int src_x = graphic_info[graphic].src_x;
1297 int src_y = graphic_info[graphic].src_y;
1303 if (width > WIN_XSIZE)
1305 /* image width too large for window => center image horizontally */
1306 src_x = (width - WIN_XSIZE) / 2;
1310 if (height > WIN_YSIZE)
1312 /* image height too large for window => center image vertically */
1313 src_y = (height - WIN_YSIZE) / 2;
1317 /* always display title screens centered */
1318 dst_x = (WIN_XSIZE - width) / 2;
1319 dst_y = (WIN_YSIZE - height) / 2;
1321 SetDrawBackgroundMask(REDRAW_ALL);
1322 SetWindowBackgroundImage(getTitleBackground(nr, initial, TRUE));
1324 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1326 if (DrawingOnBackground(dst_x, dst_y))
1328 SetClipOrigin(bitmap, bitmap->stored_clip_gc, dst_x - src_x, dst_y - src_y);
1329 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1332 BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
1334 redraw_mask = REDRAW_ALL;
1337 void DrawTitleScreenMessage(int nr, boolean initial)
1339 char *filename = getLevelSetTitleMessageFilename(nr, initial);
1340 struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
1341 int last_game_status = game_status; /* save current game status */
1343 if (filename == NULL)
1346 /* force TITLE font on title message screen */
1347 game_status = getTitleMessageGameMode(initial);
1349 /* if chars set to "-1", automatically determine by text and font width */
1350 if (tmi->chars == -1)
1351 tmi->chars = tmi->width / getFontWidth(tmi->font);
1353 tmi->width = tmi->chars * getFontWidth(tmi->font);
1355 /* if lines set to "-1", automatically determine by text and font height */
1356 if (tmi->lines == -1)
1357 tmi->lines = tmi->height / getFontHeight(tmi->font);
1359 tmi->height = tmi->lines * getFontHeight(tmi->font);
1361 SetDrawBackgroundMask(REDRAW_ALL);
1362 SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
1364 ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
1366 DrawTextFile(ALIGNED_TEXT_XPOS(tmi), ALIGNED_TEXT_YPOS(tmi),
1367 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
1368 tmi->autowrap, tmi->centered, tmi->parse_comments);
1370 game_status = last_game_status; /* restore current game status */
1373 void DrawTitleScreen()
1375 KeyboardAutoRepeatOff();
1378 SetMainBackgroundImage(IMG_BACKGROUND_TITLE);
1381 HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
1386 boolean CheckTitleScreen(boolean levelset_has_changed)
1388 static boolean show_title_initial = TRUE;
1389 boolean show_titlescreen = FALSE;
1391 /* needed to be able to skip title screen, if no image or message defined */
1392 InitializeTitleControls(show_title_initial);
1394 if (setup.show_titlescreen && (show_title_initial || levelset_has_changed))
1395 show_titlescreen = TRUE;
1397 /* show initial title images and messages only once at program start */
1398 show_title_initial = FALSE;
1400 return (show_titlescreen && num_title_screens > 0);
1403 void DrawMainMenuExt(int fade_mask, boolean do_fading)
1405 static LevelDirTree *leveldir_last_valid = NULL;
1406 boolean levelset_has_changed = FALSE;
1408 LimitScreenUpdates(FALSE);
1410 FadeSetLeaveScreen();
1412 /* do not fade out here -- function may continue and fade on editor screen */
1415 FadeSoundsAndMusic();
1417 KeyboardAutoRepeatOn();
1420 SetDrawDeactivationMask(REDRAW_NONE);
1421 SetDrawBackgroundMask(REDRAW_FIELD);
1423 audio.sound_deactivated = FALSE;
1427 /* needed if last screen was the playing screen, invoked from level editor */
1428 if (level_editor_test_game)
1430 game_status = GAME_MODE_EDITOR;
1436 /* needed if last screen was the setup screen and fullscreen state changed */
1437 // (moved to "execSetupGraphics()" to change fullscreen state directly)
1438 // ToggleFullscreenOrChangeWindowScalingIfNeeded();
1440 /* leveldir_current may be invalid (level group, parent link) */
1441 if (!validLevelSeries(leveldir_current))
1442 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
1444 if (leveldir_current != leveldir_last_valid)
1445 levelset_has_changed = TRUE;
1447 /* store valid level series information */
1448 leveldir_last_valid = leveldir_current;
1450 init_last = init; /* switch to new busy animation */
1452 /* needed if last screen (level choice) changed graphics, sounds or music */
1453 ReloadCustomArtwork(0);
1455 if (redraw_mask & REDRAW_ALL)
1456 fade_mask = REDRAW_ALL;
1462 /* needed if last screen was the editor screen */
1463 UndrawSpecialEditorDoor();
1467 if (fade_mask == REDRAW_FIELD)
1473 /* needed if different viewport properties defined for menues */
1474 ChangeViewportPropertiesIfNeeded();
1478 /* needed if last screen was the editor screen */
1479 UndrawSpecialEditorDoor();
1482 #if defined(TARGET_SDL)
1483 SetDrawtoField(DRAW_BACKBUFFER);
1486 if (CheckTitleScreen(levelset_has_changed))
1488 game_status = GAME_MODE_TITLE;
1495 /* level_nr may have been set to value over handicap with level editor */
1496 if (setup.handicap && level_nr > leveldir_current->handicap_level)
1497 level_nr = leveldir_current->handicap_level;
1499 LoadLevel(level_nr);
1500 LoadScore(level_nr);
1502 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
1505 if (fade_mask == REDRAW_ALL)
1507 // int door_state = GetDoorState();
1511 // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1517 InitializeMainControls();
1519 DrawCursorAndText_Main(-1, FALSE);
1520 DrawPreviewLevelInitial();
1522 HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
1525 if (TAPE_IS_EMPTY(tape))
1527 DrawCompleteVideoDisplay();
1532 /* create gadgets for main menu screen */
1533 FreeScreenGadgets();
1534 CreateScreenGadgets();
1536 /* map gadgets for main menu screen */
1538 MapScreenMenuGadgets(SCREEN_MASK_MAIN);
1541 /* copy actual game door content to door double buffer for OpenDoor() */
1542 BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0);
1546 // if (fade_mask == REDRAW_ALL)
1547 // (always redraw current door state)
1549 int door_state = GetDoorState();
1551 // RedrawBackground();
1553 OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1558 redraw_mask |= REDRAW_ALL;
1563 DrawMaskedBorder(REDRAW_ALL);
1569 /* update screen area with special editor door */
1570 redraw_mask |= REDRAW_ALL;
1574 SetMouseCursor(CURSOR_DEFAULT);
1578 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
1581 void DrawAndFadeInMainMenu(int fade_mask)
1583 DrawMainMenuExt(fade_mask, TRUE);
1588 DrawMainMenuExt(REDRAW_ALL, FALSE);
1591 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1592 static void gotoTopLevelDir()
1594 /* move upwards to top level directory */
1595 while (leveldir_current->node_parent)
1597 /* write a "path" into level tree for easy navigation to last level */
1598 if (leveldir_current->node_parent->node_group->cl_first == -1)
1600 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
1601 int leveldir_pos = posTreeInfo(leveldir_current);
1602 int num_page_entries;
1603 int cl_first, cl_cursor;
1605 if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
1606 num_page_entries = num_leveldirs;
1608 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
1610 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1611 cl_cursor = leveldir_pos - cl_first;
1613 leveldir_current->node_parent->node_group->cl_first = cl_first;
1614 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
1617 leveldir_current = leveldir_current->node_parent;
1622 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
1624 static unsigned int title_delay = 0;
1625 static int title_screen_nr = 0;
1626 static int last_sound = -1, last_music = -1;
1627 boolean return_to_main_menu = FALSE;
1628 boolean use_fading_main_menu = TRUE;
1629 struct TitleControlInfo *tci;
1630 struct TitleFadingInfo fading_default;
1631 struct TitleFadingInfo fading_last = fading;
1632 struct TitleFadingInfo fading_next;
1635 if (button == MB_MENU_INITIALIZE)
1638 title_screen_nr = 0;
1639 tci = &title_controls[title_screen_nr];
1641 last_sound = SND_UNDEFINED;
1642 last_music = MUS_UNDEFINED;
1644 if (game_status == GAME_MODE_INFO)
1646 if (num_title_screens == 0)
1648 DrawInfoScreen_NotAvailable("Title screen information:",
1649 "No title screen for this level set.");
1654 FadeSoundsAndMusic();
1657 FadeOut(REDRAW_ALL);
1662 DrawTitleScreenImage(tci->local_nr, tci->initial);
1664 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1666 fading_default = (tci->initial ? title_initial_default : title_default);
1668 fading = fading_next = getTitleFading(tci);
1672 if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
1673 fading_next.fade_mode & FADE_TYPE_TRANSFORM)
1675 fading.fade_mode = FADE_MODE_FADE;
1676 fading.fade_delay = fading_default.fade_delay;
1679 if (fading_last.fade_mode != FADE_MODE_CROSSFADE &&
1680 fading_next.fade_mode == FADE_MODE_CROSSFADE)
1681 fading.fade_mode = FADE_MODE_FADE;
1686 sound = getTitleSound(tci);
1687 music = getTitleMusic(tci);
1689 if (sound != last_sound)
1690 PlayMenuSoundExt(sound);
1691 if (music != last_music)
1692 PlayMenuMusicExt(music);
1698 SetMouseCursor(CURSOR_NONE);
1704 fading = fading_next;
1706 DelayReached(&title_delay, 0); /* reset delay counter */
1712 if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
1713 button = MB_MENU_CHOICE;
1715 if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
1716 button = MB_MENU_CHOICE;
1719 if (button == MB_MENU_LEAVE)
1721 return_to_main_menu = TRUE;
1722 use_fading_main_menu = FALSE;
1724 else if (button == MB_MENU_CHOICE)
1726 if (game_status == GAME_MODE_INFO && num_title_screens == 0)
1729 FadeOut(REDRAW_FIELD);
1732 FadeSetEnterScreen();
1734 info_mode = INFO_MODE_MAIN;
1735 DrawAndFadeInInfoScreen(REDRAW_FIELD);
1741 tci = &title_controls[title_screen_nr];
1743 if (title_screen_nr < num_title_screens)
1745 sound = getTitleSound(tci);
1746 music = getTitleMusic(tci);
1748 if (sound == SND_UNDEFINED || sound != last_sound)
1750 if (music == MUS_UNDEFINED || music != last_music)
1754 FadeOut(REDRAW_ALL);
1758 DrawTitleScreenImage(tci->local_nr, tci->initial);
1760 DrawTitleScreenMessage(tci->local_nr, tci->initial);
1762 fading_next = getTitleFading(tci);
1765 sound = getTitleSound(tci);
1766 music = getTitleMusic(tci);
1768 if (sound != last_sound)
1769 PlayMenuSoundExt(sound);
1770 if (music != last_music)
1771 PlayMenuMusicExt(music);
1778 /* last screen already faded out, next screen has no animation */
1779 if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
1780 fading_next.fade_mode == FADE_MODE_NONE)
1781 fading = fading_next;
1783 /* last screen already faded out, next screen has no animation */
1784 if (fading.fade_mode != FADE_MODE_CROSSFADE &&
1785 fading_next.fade_mode == FADE_MODE_NONE)
1786 fading = fading_next;
1793 fading = fading_next;
1795 DelayReached(&title_delay, 0); /* reset delay counter */
1799 FadeSoundsAndMusic();
1801 return_to_main_menu = TRUE;
1805 if (return_to_main_menu)
1811 SetMouseCursor(CURSOR_DEFAULT);
1813 if (game_status == GAME_MODE_INFO)
1816 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1819 info_mode = INFO_MODE_MAIN;
1820 DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
1822 else /* default: return to main menu */
1825 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
1828 game_status = GAME_MODE_MAIN;
1829 DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
1834 void HandleMainMenu_SelectLevel(int step, int direction)
1836 int old_level_nr = level_nr;
1839 new_level_nr = old_level_nr + step * direction;
1840 if (new_level_nr < leveldir_current->first_level)
1841 new_level_nr = leveldir_current->first_level;
1842 if (new_level_nr > leveldir_current->last_level)
1843 new_level_nr = leveldir_current->last_level;
1845 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
1847 /* skipping levels is only allowed when trying to skip single level */
1848 if (setup.skip_levels && step == 1 &&
1849 Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
1851 leveldir_current->handicap_level++;
1852 SaveLevelSetup_SeriesInfo();
1855 new_level_nr = leveldir_current->handicap_level;
1858 if (new_level_nr != old_level_nr)
1860 struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
1862 PlaySound(SND_MENU_ITEM_SELECTING);
1864 level_nr = new_level_nr;
1866 DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
1867 int2str(level_nr, menu.main.text.level_number.size),
1868 mci->pos_text->font);
1870 LoadLevel(level_nr);
1871 DrawPreviewLevelInitial();
1875 DrawCompleteVideoDisplay();
1877 /* needed because DrawPreviewLevelInitial() takes some time */
1883 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
1885 static int choice = MAIN_CONTROL_GAME;
1889 if (button == MB_MENU_INITIALIZE)
1891 DrawCursorAndText_Main(choice, TRUE);
1896 if (mx || my) /* mouse input */
1900 for (i = 0; main_controls[i].nr != -1; i++)
1903 printf("::: check click (%d, %d) for %d [%d] ...\n",
1904 mx - mSX, my - mSY, i, main_controls[i].nr);
1907 if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
1908 insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
1909 insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
1912 printf("::: inside %d\n", i);
1915 pos = main_controls[i].nr;
1921 else if (dx || dy) /* keyboard input */
1923 if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
1924 choice == MAIN_CONTROL_SETUP))
1925 button = MB_MENU_CHOICE;
1930 if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
1932 HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
1934 else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
1936 HandleMainMenu_SelectLevel(MAX_LEVELS, -1);
1938 else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
1940 HandleMainMenu_SelectLevel(MAX_LEVELS, +1);
1942 else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
1944 game_status = GAME_MODE_LEVELNR;
1947 ChangeViewportPropertiesIfNeeded();
1950 DrawChooseLevelNr();
1952 else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
1958 PlaySound(SND_MENU_ITEM_ACTIVATING);
1960 DrawCursorAndText_Main(choice, FALSE);
1961 DrawCursorAndText_Main(pos, TRUE);
1968 PlaySound(SND_MENU_ITEM_SELECTING);
1970 if (pos == MAIN_CONTROL_NAME)
1972 game_status = GAME_MODE_PSEUDO_TYPENAME;
1974 HandleTypeName(strlen(setup.player_name), 0);
1976 else if (pos == MAIN_CONTROL_LEVELS)
1980 game_status = GAME_MODE_LEVELS;
1982 SaveLevelSetup_LastSeries();
1983 SaveLevelSetup_SeriesInfo();
1985 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
1990 ChangeViewportPropertiesIfNeeded();
1993 DrawChooseLevelSet();
1996 else if (pos == MAIN_CONTROL_SCORES)
1998 game_status = GAME_MODE_SCORES;
2001 ChangeViewportPropertiesIfNeeded();
2006 else if (pos == MAIN_CONTROL_EDITOR)
2008 if (leveldir_current->readonly &&
2009 !strEqual(setup.player_name, "Artsoft"))
2010 Request("This level is read only!", REQ_CONFIRM);
2012 CloseDoor(DOOR_CLOSE_2);
2014 game_status = GAME_MODE_EDITOR;
2016 FadeSetEnterScreen();
2019 /* needed if different viewport properties defined for editor */
2020 ChangeViewportPropertiesIfNeeded();
2025 else if (pos == MAIN_CONTROL_INFO)
2027 game_status = GAME_MODE_INFO;
2028 info_mode = INFO_MODE_MAIN;
2031 ChangeViewportPropertiesIfNeeded();
2036 else if (pos == MAIN_CONTROL_GAME)
2038 StartGameActions(options.network, setup.autorecord, level.random_seed);
2040 else if (pos == MAIN_CONTROL_SETUP)
2042 game_status = GAME_MODE_SETUP;
2043 setup_mode = SETUP_MODE_MAIN;
2046 ChangeViewportPropertiesIfNeeded();
2051 else if (pos == MAIN_CONTROL_QUIT)
2053 SaveLevelSetup_LastSeries();
2054 SaveLevelSetup_SeriesInfo();
2056 if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
2057 game_status = GAME_MODE_QUIT;
2063 if (game_status == GAME_MODE_MAIN)
2065 DrawPreviewLevelAnimation();
2072 /* ========================================================================= */
2073 /* info screen functions */
2074 /* ========================================================================= */
2076 static struct TokenInfo *info_info;
2077 static int num_info_info;
2079 static void execInfoTitleScreen()
2081 info_mode = INFO_MODE_TITLE;
2086 static void execInfoElements()
2088 info_mode = INFO_MODE_ELEMENTS;
2093 static void execInfoMusic()
2095 info_mode = INFO_MODE_MUSIC;
2100 static void execInfoCredits()
2102 info_mode = INFO_MODE_CREDITS;
2107 static void execInfoProgram()
2109 info_mode = INFO_MODE_PROGRAM;
2114 static void execInfoVersion()
2116 info_mode = INFO_MODE_VERSION;
2121 static void execInfoLevelSet()
2123 info_mode = INFO_MODE_LEVELSET;
2128 static void execExitInfo()
2130 game_status = GAME_MODE_MAIN;
2132 DrawMainMenuExt(REDRAW_FIELD, FALSE);
2135 static struct TokenInfo info_info_main[] =
2137 { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
2138 { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
2139 { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
2140 { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
2141 { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
2142 { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
2143 { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
2144 { TYPE_EMPTY, NULL, "" },
2145 { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
2150 static void DrawCursorAndText_Info(int pos, boolean active)
2152 int xpos = MENU_SCREEN_START_XPOS;
2153 int ypos = MENU_SCREEN_START_YPOS + pos;
2154 int font_nr = FONT_MENU_1;
2157 font_nr = FONT_ACTIVE(font_nr);
2159 DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
2161 if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
2162 drawCursor(pos, active);
2165 static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
2170 CloseDoor(DOOR_CLOSE_2);
2172 /* (needed after displaying title screens which disable auto repeat) */
2173 KeyboardAutoRepeatOn();
2175 FadeSetLeaveScreen();
2182 if (fade_mask == REDRAW_ALL)
2186 OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
2192 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
2194 info_info = info_info_main;
2198 for (i = 0; info_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
2200 for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
2203 if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
2204 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
2205 else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
2206 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
2207 else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
2208 initCursor(i, IMG_MENU_BUTTON);
2210 DrawCursorAndText_Info(i, FALSE);
2215 HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
2220 DrawMaskedBorder(fade_mask);
2227 void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
2229 static int choice_store[MAX_INFO_MODES];
2230 int choice = choice_store[info_mode]; /* always starts with 0 */
2234 if (button == MB_MENU_INITIALIZE)
2236 /* advance to first valid menu entry */
2237 while (choice < num_info_info &&
2238 info_info[choice].type & TYPE_SKIP_ENTRY)
2240 choice_store[info_mode] = choice;
2242 DrawCursorAndText_Info(choice, TRUE);
2246 else if (button == MB_MENU_LEAVE)
2248 for (y = 0; y < num_info_info; y++)
2250 if (info_info[y].type & TYPE_LEAVE_MENU)
2252 void (*menu_callback_function)(void) = info_info[y].value;
2256 menu_callback_function();
2258 break; /* absolutely needed because function changes 'info_info'! */
2265 if (mx || my) /* mouse input */
2267 x = (mx - mSX) / 32;
2268 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2270 else if (dx || dy) /* keyboard input */
2274 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
2276 if (info_info[choice].type & menu_navigation_type ||
2277 info_info[choice].type & TYPE_ENTER_SCREEN ||
2278 info_info[choice].type & TYPE_BOOLEAN_STYLE ||
2279 info_info[choice].type & TYPE_YES_NO_AUTO)
2280 button = MB_MENU_CHOICE;
2285 /* jump to next non-empty menu entry (up or down) */
2286 while (y > 0 && y < num_info_info - 1 &&
2287 info_info[y].type & TYPE_SKIP_ENTRY)
2291 if (IN_VIS_FIELD(x, y) &&
2292 y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
2298 PlaySound(SND_MENU_ITEM_ACTIVATING);
2300 DrawCursorAndText_Info(choice, FALSE);
2301 DrawCursorAndText_Info(y, TRUE);
2303 choice = choice_store[info_mode] = y;
2306 else if (!(info_info[y].type & TYPE_GHOSTED))
2308 PlaySound(SND_MENU_ITEM_SELECTING);
2310 if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
2312 void (*menu_callback_function)(void) = info_info[choice].value;
2314 FadeSetFromType(info_info[y].type);
2316 menu_callback_function();
2322 void DrawInfoScreen_NotAvailable(char *text_title, char *text_error)
2324 int ystart1 = mSY - SY + 100;
2325 int ystart2 = mSY - SY + 150;
2326 int ybottom = mSY - SY + SYSIZE - 20;
2328 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
2330 FadeOut(REDRAW_FIELD);
2335 DrawTextSCentered(ystart1, FONT_TEXT_1, text_title);
2336 DrawTextSCentered(ystart2, FONT_TEXT_2, text_error);
2338 DrawTextSCentered(ybottom, FONT_TEXT_4,
2339 "Press any key or button for info menu");
2341 FadeIn(REDRAW_FIELD);
2344 void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
2346 static int infoscreen_step[MAX_INFO_ELEMENTS_ON_SCREEN];
2347 static int infoscreen_frame[MAX_INFO_ELEMENTS_ON_SCREEN];
2348 int xstart = mSX + MENU_SCREEN_INFO_XSTART;
2349 int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
2350 int ystart2 = mSY + MENU_SCREEN_INFO_YSTART2;
2351 int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
2352 int ystep = MENU_SCREEN_INFO_YSTEP;
2353 int element, action, direction;
2361 for (i = 0; i < NUM_INFO_ELEMENTS_ON_SCREEN; i++)
2362 infoscreen_step[i] = infoscreen_frame[i] = 0;
2367 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Elements:");
2369 DrawTextSCentered(ybottom, FONT_TEXT_4,
2370 "Press any key or button for next page");
2376 while (helpanim_info[j].element != HELPANIM_LIST_END)
2378 if (i >= start + NUM_INFO_ELEMENTS_ON_SCREEN ||
2383 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2392 j += infoscreen_step[i - start];
2394 element = helpanim_info[j].element;
2395 action = helpanim_info[j].action;
2396 direction = helpanim_info[j].direction;
2399 element = EL_UNKNOWN;
2401 if (action != -1 && direction != -1)
2402 graphic = el_act_dir2img(element, action, direction);
2403 else if (action != -1)
2404 graphic = el_act2img(element, action);
2405 else if (direction != -1)
2406 graphic = el_dir2img(element, direction);
2408 graphic = el2img(element);
2410 delay = helpanim_info[j++].delay;
2415 if (infoscreen_frame[i - start] == 0)
2418 infoscreen_frame[i - start] = delay - 1;
2422 sync_frame = delay - infoscreen_frame[i - start];
2423 infoscreen_frame[i - start]--;
2426 if (helpanim_info[j].element == HELPANIM_LIST_NEXT)
2428 if (!infoscreen_frame[i - start])
2429 infoscreen_step[i - start] = 0;
2433 if (!infoscreen_frame[i - start])
2434 infoscreen_step[i - start]++;
2435 while (helpanim_info[j].element != HELPANIM_LIST_NEXT)
2441 ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep,
2443 DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep,
2444 graphic, sync_frame, USE_MASKING);
2447 DrawInfoScreen_HelpText(element, action, direction, i - start);
2452 redraw_mask |= REDRAW_FIELD;
2457 static char *getHelpText(int element, int action, int direction)
2459 char token[MAX_LINE_LEN];
2461 strcpy(token, element_info[element].token_name);
2464 strcat(token, element_action_info[action].suffix);
2466 if (direction != -1)
2467 strcat(token, element_direction_info[MV_DIR_TO_BIT(direction)].suffix);
2469 return getHashEntry(helptext_info, token);
2472 void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
2474 int font_nr = FONT_INFO_ELEMENTS;
2475 int font_width = getFontWidth(font_nr);
2476 int sx = mSX + MINI_TILEX + TILEX + MINI_TILEX;
2477 int sy = mSY + 65 + 2 * 32 + 1;
2478 int ystep = TILEY + 4;
2479 int pad_x = sx - SX;
2480 int max_chars_per_line = (SXSIZE - pad_x - MINI_TILEX) / font_width;
2481 int max_lines_per_text = 2;
2484 if (action != -1 && direction != -1) /* element.action.direction */
2485 text = getHelpText(element, action, direction);
2487 if (text == NULL && action != -1) /* element.action */
2488 text = getHelpText(element, action, -1);
2490 if (text == NULL && direction != -1) /* element.direction */
2491 text = getHelpText(element, -1, direction);
2493 if (text == NULL) /* base element */
2494 text = getHelpText(element, -1, -1);
2496 if (text == NULL) /* not found */
2497 text = "No description available";
2499 if (strlen(text) <= max_chars_per_line) /* only one line of text */
2500 sy += getFontHeight(font_nr) / 2;
2502 DrawTextBuffer(sx, sy + ypos * ystep, text, font_nr,
2503 max_chars_per_line, -1, max_lines_per_text, 0, -1,
2504 TRUE, FALSE, FALSE);
2507 void DrawInfoScreen_TitleScreen()
2512 void HandleInfoScreen_TitleScreen(int button)
2514 HandleTitleScreen(0, 0, 0, 0, button);
2517 void DrawInfoScreen_Elements()
2519 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
2521 FadeOut(REDRAW_FIELD);
2526 HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
2528 FadeIn(REDRAW_FIELD);
2533 void HandleInfoScreen_Elements(int button)
2535 static unsigned int info_delay = 0;
2536 static int num_anims;
2537 static int num_pages;
2539 int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
2542 if (button == MB_MENU_INITIALIZE)
2544 boolean new_element = TRUE;
2548 for (i = 0; helpanim_info[i].element != HELPANIM_LIST_END; i++)
2550 if (helpanim_info[i].element == HELPANIM_LIST_NEXT)
2552 else if (new_element)
2555 new_element = FALSE;
2559 num_pages = (num_anims + anims_per_page - 1) / anims_per_page;
2563 if (button == MB_MENU_LEAVE)
2565 PlaySound(SND_MENU_ITEM_SELECTING);
2567 info_mode = INFO_MODE_MAIN;
2572 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2574 if (button != MB_MENU_INITIALIZE)
2576 PlaySound(SND_MENU_ITEM_SELECTING);
2581 if (page >= num_pages)
2583 FadeSoundsAndMusic();
2585 info_mode = INFO_MODE_MAIN;
2586 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2593 FadeSetNextScreen();
2596 if (button != MB_MENU_INITIALIZE)
2597 FadeOut(REDRAW_FIELD);
2599 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, TRUE);
2601 if (button != MB_MENU_INITIALIZE)
2602 FadeIn(REDRAW_FIELD);
2606 if (DelayReached(&info_delay, GameFrameDelay))
2607 if (page < num_pages)
2608 DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
2610 PlayMenuSoundIfLoop();
2614 void DrawInfoScreen_Music()
2616 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
2619 FadeOut(REDRAW_FIELD);
2627 HandleInfoScreen_Music(MB_MENU_INITIALIZE);
2630 FadeIn(REDRAW_FIELD);
2634 void HandleInfoScreen_Music(int button)
2636 static struct MusicFileInfo *list = NULL;
2637 int ystart1 = mSY - SY + 100;
2638 int ystart2 = mSY - SY + 150;
2639 int ybottom = mSY - SY + SYSIZE - 20;
2642 if (button == MB_MENU_INITIALIZE)
2644 list = music_file_info;
2648 FadeSoundsAndMusic();
2653 DrawTextSCentered(ystart1, FONT_TEXT_1,
2654 "No music info for this level set.");
2656 DrawTextSCentered(ybottom, FONT_TEXT_4,
2657 "Press any key or button for info menu");
2663 if (button == MB_MENU_LEAVE)
2665 PlaySound(SND_MENU_ITEM_SELECTING);
2667 FadeSoundsAndMusic();
2669 info_mode = INFO_MODE_MAIN;
2674 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2678 if (button != MB_MENU_INITIALIZE)
2680 PlaySound(SND_MENU_ITEM_SELECTING);
2688 FadeSoundsAndMusic();
2690 info_mode = INFO_MODE_MAIN;
2691 DrawAndFadeInInfoScreen(REDRAW_FIELD);
2696 FadeSoundsAndMusic();
2699 if (list != music_file_info)
2700 FadeSetNextScreen();
2703 if (button != MB_MENU_INITIALIZE)
2704 FadeOut(REDRAW_FIELD);
2711 int sound = list->music;
2713 if (sound_info[sound].loop)
2714 PlaySoundLoop(sound);
2718 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Sounds:");
2722 PlayMusic(list->music);
2724 DrawTextSCentered(ystart1, FONT_TEXT_1, "The Game Background Music:");
2727 if (!strEqual(list->title, UNKNOWN_NAME))
2729 if (!strEqual(list->title_header, UNKNOWN_NAME))
2730 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->title_header);
2732 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title);
2735 if (!strEqual(list->artist, UNKNOWN_NAME))
2737 if (!strEqual(list->artist_header, UNKNOWN_NAME))
2738 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->artist_header);
2740 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "by");
2742 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->artist);
2745 if (!strEqual(list->album, UNKNOWN_NAME))
2747 if (!strEqual(list->album_header, UNKNOWN_NAME))
2748 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->album_header);
2750 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the album");
2752 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album);
2755 if (!strEqual(list->year, UNKNOWN_NAME))
2757 if (!strEqual(list->year_header, UNKNOWN_NAME))
2758 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, list->year_header);
2760 DrawTextSCentered(ystart2 + y++ * dy, FONT_TEXT_2, "from the year");
2762 DrawTextFCentered(ystart2 + y++ * dy, FONT_TEXT_3, "%s", list->year);
2765 DrawTextSCentered(ybottom, FONT_TEXT_4,
2766 "Press any key or button for next page");
2768 if (button != MB_MENU_INITIALIZE)
2769 FadeIn(REDRAW_FIELD);
2772 if (list != NULL && list->is_sound && sound_info[list->music].loop)
2773 PlaySoundLoop(list->music);
2776 static void DrawInfoScreen_CreditsScreen(int screen_nr)
2778 int ystart1 = mSY - SY + 100;
2779 int ystart2 = mSY - SY + 150;
2780 int ybottom = mSY - SY + SYSIZE - 20;
2786 DrawTextSCentered(ystart1, FONT_TEXT_1, "Credits:");
2790 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2791 "Special thanks to");
2792 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2794 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2796 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2797 "\"Boulder Dash\"");
2798 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2800 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2802 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2804 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2805 "First Star Software");
2807 else if (screen_nr == 1)
2809 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2810 "Special thanks to");
2811 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2812 "Klaus Heinz & Volker Wertich");
2813 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2815 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2816 "\"Emerald Mine\"");
2817 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2819 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2821 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2823 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2826 else if (screen_nr == 2)
2828 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2829 "Special thanks to");
2830 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2831 "Michael Stopp & Philip Jespersen");
2832 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2834 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2836 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2838 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2840 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2842 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2843 "Digital Integration");
2845 else if (screen_nr == 3)
2847 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2848 "Special thanks to");
2849 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2850 "Hiroyuki Imabayashi");
2851 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2853 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2855 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2857 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2859 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2861 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
2864 else if (screen_nr == 4)
2866 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2867 "Special thanks to");
2868 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2870 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2872 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2873 "Jürgen Bonhagen");
2874 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2875 "for the continuous creation");
2876 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2877 "of outstanding level sets");
2879 else if (screen_nr == 5)
2881 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2883 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2885 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2886 "for ideas and inspiration by");
2887 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2890 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
2892 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
2894 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
2895 "for ideas and inspiration by");
2896 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
2899 else if (screen_nr == 6)
2901 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2903 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2906 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2907 "for the code base used for the");
2908 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
2909 "native Emerald Mine engine");
2911 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2912 "for the new Emerald Mine engine");
2915 else if (screen_nr == 7)
2917 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2919 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
2921 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
2922 "for the initial DOS port");
2924 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
2926 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
2928 DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
2929 "for some additional toons");
2931 else if (screen_nr == 8)
2933 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
2934 "And not to forget:");
2935 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
2937 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
2938 "All those who contributed");
2939 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
2940 "levels to this game");
2941 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
2945 DrawTextSCentered(ybottom, FONT_TEXT_4,
2946 "Press any key or button for next page");
2949 void DrawInfoScreen_Credits()
2951 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
2953 FadeSoundsAndMusic();
2956 FadeOut(REDRAW_FIELD);
2959 HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
2962 FadeIn(REDRAW_FIELD);
2966 void HandleInfoScreen_Credits(int button)
2968 static int screen_nr = 0;
2969 int num_screens = 9;
2971 if (button == MB_MENU_INITIALIZE)
2975 // DrawInfoScreen_CreditsScreen(screen_nr);
2978 if (button == MB_MENU_LEAVE)
2980 PlaySound(SND_MENU_ITEM_SELECTING);
2982 info_mode = INFO_MODE_MAIN;
2987 else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
2989 if (button != MB_MENU_INITIALIZE)
2991 PlaySound(SND_MENU_ITEM_SELECTING);
2996 if (screen_nr >= num_screens)
2998 FadeSoundsAndMusic();
3000 info_mode = INFO_MODE_MAIN;
3001 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3008 FadeSetNextScreen();
3011 if (button != MB_MENU_INITIALIZE)
3012 FadeOut(REDRAW_FIELD);
3014 DrawInfoScreen_CreditsScreen(screen_nr);
3016 if (button != MB_MENU_INITIALIZE)
3017 FadeIn(REDRAW_FIELD);
3021 PlayMenuSoundIfLoop();
3025 void DrawInfoScreen_Program()
3027 int ystart1 = mSY - SY + 100;
3028 int ystart2 = mSY - SY + 150;
3029 int ybottom = mSY - SY + SYSIZE - 20;
3032 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
3035 FadeOut(REDRAW_FIELD);
3041 DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
3043 DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
3044 "This game is Freeware!");
3045 DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
3046 "If you like it, send e-mail to:");
3047 DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
3048 PROGRAM_EMAIL_STRING);
3050 DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
3051 "More information and levels:");
3052 DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
3053 PROGRAM_WEBSITE_STRING);
3054 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3055 "If you have created new levels,");
3056 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
3057 "send them to me to include them!");
3058 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3061 DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
3062 "or SnailMail to:");
3063 DrawTextSCentered(ystart2 + 4 * ystep + 0, FONT_TEXT_3,
3065 DrawTextSCentered(ystart2 + 4 * ystep + 20, FONT_TEXT_3,
3066 "Detmolder Strasse 189");
3067 DrawTextSCentered(ystart2 + 4 * ystep + 40, FONT_TEXT_3,
3069 DrawTextSCentered(ystart2 + 4 * ystep + 60, FONT_TEXT_3,
3071 DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
3072 "More information and levels:");
3073 DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
3074 PROGRAM_WEBSITE_STRING);
3075 DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
3076 "If you have created new levels,");
3077 DrawTextSCentered(ystart2 + 10 * ystep, FONT_TEXT_2,
3078 "send them to me to include them!");
3079 DrawTextSCentered(ystart2 + 11 * ystep, FONT_TEXT_2,
3083 DrawTextSCentered(ybottom, FONT_TEXT_4,
3084 "Press any key or button for info menu");
3087 FadeIn(REDRAW_FIELD);
3091 void HandleInfoScreen_Program(int button)
3093 if (button == MB_MENU_LEAVE)
3095 PlaySound(SND_MENU_ITEM_SELECTING);
3097 info_mode = INFO_MODE_MAIN;
3102 else if (button == MB_MENU_CHOICE)
3104 PlaySound(SND_MENU_ITEM_SELECTING);
3106 FadeSoundsAndMusic();
3109 FadeOut(REDRAW_FIELD);
3112 info_mode = INFO_MODE_MAIN;
3113 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3117 PlayMenuSoundIfLoop();
3121 void DrawInfoScreen_Version()
3123 int font_header = FONT_TEXT_3;
3124 int font_text = FONT_TEXT_2;
3125 int xstep = getFontWidth(font_text);
3126 int ystep = getFontHeight(font_text);
3127 int ystart1 = mSY - SY + 100;
3128 int ystart2 = mSY - SY + 150;
3129 int ybottom = mSY - SY + SYSIZE - 20;
3130 int xstart1 = mSX - SX + 2 * xstep;
3131 int xstart2 = mSX - SX + 18 * xstep;
3132 #if defined(TARGET_SDL)
3133 int xstart3 = mSX - SX + 28 * xstep;
3134 SDL_version sdl_version_compiled;
3135 const SDL_version *sdl_version_linked;
3136 int driver_name_len = 10;
3137 #if defined(TARGET_SDL2)
3138 SDL_version sdl_version_linked_ext;
3139 const char *driver_name = NULL;
3141 char driver_name[driver_name_len];
3145 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
3148 FadeOut(REDRAW_FIELD);
3154 DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
3156 DrawTextF(xstart1, ystart2, font_header, "Name");
3157 DrawTextF(xstart2, ystart2, font_text, PROGRAM_TITLE_STRING);
3160 DrawTextF(xstart1, ystart2, font_header, "Version");
3161 DrawTextF(xstart2, ystart2, font_text, getProgramFullVersionString());
3164 DrawTextF(xstart1, ystart2, font_header, "Platform");
3165 DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
3168 DrawTextF(xstart1, ystart2, font_header, "Target");
3169 DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
3172 DrawTextF(xstart1, ystart2, font_header, "Compile time");
3173 DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
3175 #if defined(TARGET_SDL)
3176 ystart2 += 3 * ystep;
3177 DrawTextF(xstart1, ystart2, font_header, "Library");
3178 DrawTextF(xstart2, ystart2, font_header, "compiled");
3179 DrawTextF(xstart3, ystart2, font_header, "linked");
3181 SDL_VERSION(&sdl_version_compiled);
3182 #if defined(TARGET_SDL2)
3183 SDL_GetVersion(&sdl_version_linked_ext);
3184 sdl_version_linked = &sdl_version_linked_ext;
3186 sdl_version_linked = SDL_Linked_Version();
3189 ystart2 += 2 * ystep;
3190 DrawTextF(xstart1, ystart2, font_text, "SDL");
3191 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3192 sdl_version_compiled.major,
3193 sdl_version_compiled.minor,
3194 sdl_version_compiled.patch);
3195 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3196 sdl_version_linked->major,
3197 sdl_version_linked->minor,
3198 sdl_version_linked->patch);
3200 SDL_IMAGE_VERSION(&sdl_version_compiled);
3201 sdl_version_linked = IMG_Linked_Version();
3204 DrawTextF(xstart1, ystart2, font_text, "SDL_image");
3205 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3206 sdl_version_compiled.major,
3207 sdl_version_compiled.minor,
3208 sdl_version_compiled.patch);
3209 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3210 sdl_version_linked->major,
3211 sdl_version_linked->minor,
3212 sdl_version_linked->patch);
3214 SDL_MIXER_VERSION(&sdl_version_compiled);
3215 sdl_version_linked = Mix_Linked_Version();
3218 DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
3219 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3220 sdl_version_compiled.major,
3221 sdl_version_compiled.minor,
3222 sdl_version_compiled.patch);
3223 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3224 sdl_version_linked->major,
3225 sdl_version_linked->minor,
3226 sdl_version_linked->patch);
3228 SDL_NET_VERSION(&sdl_version_compiled);
3229 sdl_version_linked = SDLNet_Linked_Version();
3232 DrawTextF(xstart1, ystart2, font_text, "SDL_net");
3233 DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
3234 sdl_version_compiled.major,
3235 sdl_version_compiled.minor,
3236 sdl_version_compiled.patch);
3237 DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
3238 sdl_version_linked->major,
3239 sdl_version_linked->minor,
3240 sdl_version_linked->patch);
3242 ystart2 += 3 * ystep;
3243 DrawTextF(xstart1, ystart2, font_header, "Driver");
3244 DrawTextF(xstart2, ystart2, font_header, "Requested");
3245 DrawTextF(xstart3, ystart2, font_header, "Used");
3247 #if defined(TARGET_SDL2)
3248 driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
3250 SDL_VideoDriverName(driver_name, driver_name_len);
3253 ystart2 += 2 * ystep;
3254 DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
3255 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
3256 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3258 #if defined(TARGET_SDL2)
3259 driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
3261 SDL_AudioDriverName(driver_name, driver_name_len);
3265 DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
3266 DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
3267 DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
3270 DrawTextSCentered(ybottom, FONT_TEXT_4,
3271 "Press any key or button for info menu");
3274 FadeIn(REDRAW_FIELD);
3278 void HandleInfoScreen_Version(int button)
3280 if (button == MB_MENU_LEAVE)
3282 PlaySound(SND_MENU_ITEM_SELECTING);
3284 info_mode = INFO_MODE_MAIN;
3289 else if (button == MB_MENU_CHOICE)
3291 PlaySound(SND_MENU_ITEM_SELECTING);
3293 FadeSoundsAndMusic();
3296 FadeOut(REDRAW_FIELD);
3299 info_mode = INFO_MODE_MAIN;
3300 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3304 PlayMenuSoundIfLoop();
3308 void DrawInfoScreen_LevelSet()
3310 struct TitleMessageInfo *tmi = &readme;
3311 char *filename = getLevelSetInfoFilename();
3313 /* if chars set to "-1", automatically determine by text and font width */
3314 if (tmi->chars == -1)
3315 tmi->chars = tmi->width / getFontWidth(tmi->font);
3317 tmi->width = tmi->chars * getFontWidth(tmi->font);
3319 /* if lines set to "-1", automatically determine by text and font height */
3320 if (tmi->lines == -1)
3321 tmi->lines = tmi->height / getFontHeight(tmi->font);
3323 tmi->height = tmi->lines * getFontHeight(tmi->font);
3325 SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
3328 FadeOut(REDRAW_FIELD);
3334 DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
3336 if (filename != NULL)
3337 DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
3338 filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
3339 tmi->autowrap, tmi->centered, tmi->parse_comments);
3341 DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
3342 "No information for this level set.");
3344 DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
3345 "Press any key or button for info menu");
3348 FadeIn(REDRAW_FIELD);
3352 void HandleInfoScreen_LevelSet(int button)
3354 if (button == MB_MENU_LEAVE)
3356 PlaySound(SND_MENU_ITEM_SELECTING);
3358 info_mode = INFO_MODE_MAIN;
3363 else if (button == MB_MENU_CHOICE)
3365 PlaySound(SND_MENU_ITEM_SELECTING);
3367 FadeSoundsAndMusic();
3370 FadeOut(REDRAW_FIELD);
3373 info_mode = INFO_MODE_MAIN;
3374 DrawAndFadeInInfoScreen(REDRAW_FIELD);
3378 PlayMenuSoundIfLoop();
3382 static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
3384 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
3386 if (info_mode == INFO_MODE_TITLE)
3387 DrawInfoScreen_TitleScreen();
3388 else if (info_mode == INFO_MODE_ELEMENTS)
3389 DrawInfoScreen_Elements();
3390 else if (info_mode == INFO_MODE_MUSIC)
3391 DrawInfoScreen_Music();
3392 else if (info_mode == INFO_MODE_CREDITS)
3393 DrawInfoScreen_Credits();
3394 else if (info_mode == INFO_MODE_PROGRAM)
3395 DrawInfoScreen_Program();
3396 else if (info_mode == INFO_MODE_VERSION)
3397 DrawInfoScreen_Version();
3398 else if (info_mode == INFO_MODE_LEVELSET)
3399 DrawInfoScreen_LevelSet();
3401 DrawInfoScreen_Main(fade_mask, do_fading);
3403 if (info_mode != INFO_MODE_MAIN &&
3404 info_mode != INFO_MODE_TITLE &&
3405 info_mode != INFO_MODE_MUSIC)
3412 void DrawAndFadeInInfoScreen(int fade_mask)
3414 DrawInfoScreenExt(fade_mask, TRUE);
3417 void DrawInfoScreen()
3419 DrawInfoScreenExt(REDRAW_FIELD, FALSE);
3422 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
3424 if (info_mode == INFO_MODE_TITLE)
3425 HandleInfoScreen_TitleScreen(button);
3426 else if (info_mode == INFO_MODE_ELEMENTS)
3427 HandleInfoScreen_Elements(button);
3428 else if (info_mode == INFO_MODE_MUSIC)
3429 HandleInfoScreen_Music(button);
3430 else if (info_mode == INFO_MODE_CREDITS)
3431 HandleInfoScreen_Credits(button);
3432 else if (info_mode == INFO_MODE_PROGRAM)
3433 HandleInfoScreen_Program(button);
3434 else if (info_mode == INFO_MODE_VERSION)
3435 HandleInfoScreen_Version(button);
3436 else if (info_mode == INFO_MODE_LEVELSET)
3437 HandleInfoScreen_LevelSet(button);
3439 HandleInfoScreen_Main(mx, my, dx, dy, button);
3447 /* ========================================================================= */
3448 /* type name functions */
3449 /* ========================================================================= */
3451 void HandleTypeName(int newxpos, Key key)
3453 static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
3454 struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
3455 struct TextPosInfo *pos = mci->pos_input;
3456 int startx = mSX + ALIGNED_TEXT_XPOS(pos);
3457 int starty = mSY + ALIGNED_TEXT_YPOS(pos);
3458 static int xpos = 0;
3459 int font_nr = pos->font;
3460 int font_active_nr = FONT_ACTIVE(font_nr);
3461 int font_width = getFontWidth(font_active_nr);
3462 char key_char = getValidConfigValueChar(getCharFromKey(key));
3463 boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
3464 boolean is_active = TRUE;
3466 DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
3470 strcpy(last_player_name, setup.player_name);
3474 else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
3476 setup.player_name[xpos] = key_char;
3477 setup.player_name[xpos + 1] = 0;
3481 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
3485 setup.player_name[xpos] = 0;
3487 else if (key == KSYM_Return && xpos > 0)
3493 game_status = GAME_MODE_MAIN;
3495 else if (key == KSYM_Escape)
3497 strcpy(setup.player_name, last_player_name);
3501 game_status = GAME_MODE_MAIN;
3506 pos->width = (strlen(setup.player_name) + 1) * font_width;
3507 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3509 DrawText(startx, starty, setup.player_name, font_active_nr);
3510 DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
3514 pos->width = strlen(setup.player_name) * font_width;
3515 startx = mSX + ALIGNED_TEXT_XPOS(pos);
3517 DrawText(startx, starty, setup.player_name, font_nr);
3522 /* ========================================================================= */
3523 /* tree menu functions */
3524 /* ========================================================================= */
3526 static void DrawChooseTree(TreeInfo **ti_ptr)
3530 FreeScreenGadgets();
3531 CreateScreenGadgets();
3533 CloseDoor(DOOR_CLOSE_2);
3536 FadeOut(REDRAW_FIELD);
3541 HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
3542 MapScreenTreeGadgets(*ti_ptr);
3545 FadeIn(REDRAW_FIELD);
3551 static void AdjustScrollbar(int id, int items_max, int items_visible,
3554 struct GadgetInfo *gi = screen_gadget[id];
3556 if (item_position > items_max - items_visible)
3557 item_position = items_max - items_visible;
3559 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3560 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3561 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3564 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
3567 AdjustScrollbar(id, numTreeInfoInGroup(ti), NUM_MENU_ENTRIES_ON_SCREEN,
3570 struct GadgetInfo *gi = screen_gadget[id];
3571 int items_max, items_visible, item_position;
3573 items_max = numTreeInfoInGroup(ti);
3574 items_visible = NUM_MENU_ENTRIES_ON_SCREEN;
3575 item_position = first_entry;
3577 if (item_position > items_max - items_visible)
3578 item_position = items_max - items_visible;
3580 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
3581 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
3582 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
3586 static void drawChooseTreeList(int first_entry, int num_page_entries,
3590 char *title_string = NULL;
3591 int yoffset_sets = MENU_TITLE1_YPOS;
3592 int yoffset_setup = 16;
3593 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
3594 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
3595 int last_game_status = game_status; /* save current game status */
3597 title_string = ti->infotext;
3599 DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
3602 /* force LEVELS font on artwork setup screen */
3603 game_status = GAME_MODE_LEVELS;
3607 /* clear tree list area, but not title or scrollbar */
3608 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3609 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3610 NUM_MENU_ENTRIES_ON_SCREEN * 32);
3612 /* clear tree list area, but not title or scrollbar */
3613 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
3614 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
3615 MAX_MENU_ENTRIES_ON_SCREEN * 32);
3618 for (i = 0; i < num_page_entries; i++)
3620 TreeInfo *node, *node_first;
3621 int entry_pos = first_entry + i;
3622 int xpos = MENU_SCREEN_START_XPOS;
3623 int ypos = MENU_SCREEN_START_YPOS + i;
3624 int startx = mSX + xpos * 32;
3625 int starty = mSY + ypos * 32;
3626 int font_nr = FONT_TEXT_1;
3627 int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
3628 int startx_text = startx + font_xoffset;
3629 int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
3630 int text_size = startx_scrollbar - startx_text;
3631 int max_buffer_len = text_size / getFontWidth(font_nr);
3632 char buffer[max_buffer_len + 1];
3634 node_first = getTreeInfoFirstGroupEntry(ti);
3635 node = getTreeInfoFromPos(node_first, entry_pos);
3637 strncpy(buffer, node->name, max_buffer_len);
3638 buffer[max_buffer_len] = '\0';
3640 DrawText(startx, starty, buffer, font_nr + node->color);
3642 if (node->parent_link)
3643 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
3644 else if (node->level_group)
3645 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
3647 initCursor(i, IMG_MENU_BUTTON);
3650 game_status = last_game_status; /* restore current game status */
3652 redraw_mask |= REDRAW_FIELD;
3655 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
3657 TreeInfo *node, *node_first;
3658 int x, last_redraw_mask = redraw_mask;
3659 int ypos = MENU_TITLE2_YPOS;
3660 int font_nr = FONT_TITLE_2;
3662 if (ti->type == TREE_TYPE_LEVEL_NR)
3663 DrawTextFCentered(ypos, font_nr, leveldir_current->name);
3665 if (ti->type != TREE_TYPE_LEVEL_DIR)
3668 node_first = getTreeInfoFirstGroupEntry(ti);
3669 node = getTreeInfoFromPos(node_first, entry_pos);
3671 DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
3674 if (node->parent_link)
3675 DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
3676 node->node_parent->name);
3677 else if (node->level_group)
3678 DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
3680 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3681 DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
3682 node->levels, (node->levels > 1 ? "levels" : "level"),
3685 if (node->parent_link)
3686 DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
3688 else if (node->level_group)
3689 DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
3691 else if (ti->type == TREE_TYPE_LEVEL_DIR)
3692 DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
3693 node->levels, node->class_desc);
3696 /* let BackToFront() redraw only what is needed */
3697 redraw_mask = last_redraw_mask | REDRAW_TILES;
3698 for (x = 0; x < SCR_FIELDX; x++)
3699 MarkTileDirty(x, 1);
3702 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
3705 TreeInfo *ti = *ti_ptr;
3707 int y = ti->cl_cursor;
3708 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
3709 int num_entries = numTreeInfoInGroup(ti);
3710 int num_page_entries;
3711 int last_game_status = game_status; /* save current game status */
3712 boolean position_set_by_scrollbar = (dx == 999);
3715 /* force LEVELS draw offset on choose level and artwork setup screen */
3716 game_status = GAME_MODE_LEVELS;
3719 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
3720 num_page_entries = num_entries;
3722 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
3724 game_status = last_game_status; /* restore current game status */
3726 if (button == MB_MENU_INITIALIZE)
3728 int num_entries = numTreeInfoInGroup(ti);
3729 int entry_pos = posTreeInfo(ti);
3731 if (ti->cl_first == -1)
3733 /* only on initialization */
3734 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3735 ti->cl_cursor = entry_pos - ti->cl_first;
3737 else if (ti->cl_cursor >= num_page_entries ||
3738 (num_entries > num_page_entries &&
3739 num_entries - ti->cl_first < num_page_entries))
3741 /* only after change of list size (by custom graphic configuration) */
3742 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
3743 ti->cl_cursor = entry_pos - ti->cl_first;
3746 if (position_set_by_scrollbar)
3749 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3752 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3753 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3754 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3758 else if (button == MB_MENU_LEAVE)
3762 PlaySound(SND_MENU_ITEM_SELECTING);
3764 if (ti->node_parent)
3766 *ti_ptr = ti->node_parent;
3767 DrawChooseTree(ti_ptr);
3769 else if (game_status == GAME_MODE_SETUP)
3771 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
3772 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
3774 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
3775 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
3776 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
3777 execSetupGraphics();
3778 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
3779 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
3780 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
3782 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
3783 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
3784 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
3791 if (game_status == GAME_MODE_LEVELNR)
3792 level_nr = atoi(level_number_current->identifier);
3794 game_status = GAME_MODE_MAIN;
3796 DrawMainMenuExt(REDRAW_FIELD, FALSE);
3802 if (mx || my) /* mouse input */
3804 int last_game_status = game_status; /* save current game status */
3807 /* force LEVELS draw offset on artwork setup screen */
3808 game_status = GAME_MODE_LEVELS;
3811 x = (mx - mSX) / 32;
3812 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
3814 game_status = last_game_status; /* restore current game status */
3816 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
3818 /* move cursor instead of scrolling when already at start/end of list */
3819 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
3821 else if (dy == +1 * SCROLL_LINE &&
3822 ti->cl_first + num_page_entries == num_entries)
3825 /* handle scrolling screen one line or page */
3826 if (ti->cl_cursor + dy < 0 ||
3827 ti->cl_cursor + dy > num_page_entries - 1)
3830 boolean redraw = FALSE;
3832 if (ABS(dy) == SCROLL_PAGE)
3833 step = num_page_entries - 1;
3835 if (dy < 0 && ti->cl_first > 0)
3837 /* scroll page/line up */
3839 ti->cl_first -= step;
3840 if (ti->cl_first < 0)
3845 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3847 /* scroll page/line down */
3849 ti->cl_first += step;
3850 if (ti->cl_first + num_page_entries > num_entries)
3851 ti->cl_first = MAX(0, num_entries - num_page_entries);
3858 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3859 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3860 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3862 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3868 if (ABS(dy) == SCROLL_PAGE)
3869 step = num_page_entries - 1;
3871 if (dy < 0 && ti->cl_first > 0)
3873 /* scroll page/line up */
3875 ti->cl_first -= step;
3876 if (ti->cl_first < 0)
3879 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3880 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3881 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3883 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3886 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
3888 /* scroll page/line down */
3890 ti->cl_first += step;
3891 if (ti->cl_first + num_page_entries > num_entries)
3892 ti->cl_first = MAX(0, num_entries - num_page_entries);
3894 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
3895 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
3896 drawChooseTreeCursor(ti->cl_cursor, TRUE);
3898 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
3906 /* handle moving cursor one line */
3907 y = ti->cl_cursor + dy;
3912 TreeInfo *node_first, *node_cursor;
3913 int entry_pos = ti->cl_first + y;
3915 node_first = getTreeInfoFirstGroupEntry(ti);
3916 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3918 if (node_cursor->node_group)
3922 PlaySound(SND_MENU_ITEM_SELECTING);
3924 node_cursor->cl_first = ti->cl_first;
3925 node_cursor->cl_cursor = ti->cl_cursor;
3926 *ti_ptr = node_cursor->node_group;
3927 DrawChooseTree(ti_ptr);
3932 else if (dx == -1 && ti->node_parent)
3936 PlaySound(SND_MENU_ITEM_SELECTING);
3938 *ti_ptr = ti->node_parent;
3939 DrawChooseTree(ti_ptr);
3944 if (!anyScrollbarGadgetActive() &&
3945 IN_VIS_FIELD(x, y) &&
3946 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
3947 y >= 0 && y < num_page_entries)
3950 printf("::: TEST/HandleChooseTree [%d, %d, %d, %d]\n", Counter(),
3951 button, mx, screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x);
3956 if (y != ti->cl_cursor)
3958 PlaySound(SND_MENU_ITEM_ACTIVATING);
3960 drawChooseTreeCursor(ti->cl_cursor, FALSE);
3961 drawChooseTreeCursor(y, TRUE);
3962 drawChooseTreeInfo(ti->cl_first + y, ti);
3969 TreeInfo *node_first, *node_cursor;
3970 int entry_pos = ti->cl_first + y;
3972 PlaySound(SND_MENU_ITEM_SELECTING);
3974 node_first = getTreeInfoFirstGroupEntry(ti);
3975 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
3977 if (node_cursor->node_group)
3981 node_cursor->cl_first = ti->cl_first;
3982 node_cursor->cl_cursor = ti->cl_cursor;
3983 *ti_ptr = node_cursor->node_group;
3984 DrawChooseTree(ti_ptr);
3986 else if (node_cursor->parent_link)
3990 *ti_ptr = node_cursor->node_parent;
3991 DrawChooseTree(ti_ptr);
3998 FadeSetEnterScreen();
4001 node_cursor->cl_first = ti->cl_first;
4002 node_cursor->cl_cursor = ti->cl_cursor;
4003 *ti_ptr = node_cursor;
4005 if (ti->type == TREE_TYPE_LEVEL_DIR)
4007 LoadLevelSetup_SeriesInfo();
4009 SaveLevelSetup_LastSeries();
4010 SaveLevelSetup_SeriesInfo();
4014 if (game_status == GAME_MODE_SETUP)
4016 if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
4017 setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
4019 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
4020 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
4021 setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
4022 execSetupGraphics();
4023 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
4024 setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
4025 setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
4027 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
4028 setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
4029 setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
4036 if (game_status == GAME_MODE_LEVELNR)
4037 level_nr = atoi(level_number_current->identifier);
4039 game_status = GAME_MODE_MAIN;
4048 void DrawChooseLevelSet()
4050 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
4052 DrawChooseTree(&leveldir_current);
4058 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
4060 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4067 void DrawChooseLevelNr()
4071 if (level_number != NULL)
4073 freeTreeInfo(level_number);
4075 level_number = NULL;
4078 for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
4080 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
4081 char identifier[32], name[32];
4084 /* temporarily load level info to get level name */
4085 LoadLevelInfoOnly(i);
4087 ti->node_top = &level_number;
4088 ti->sort_priority = 10000 + value;
4089 ti->color = (level.no_valid_file ? FC_BLUE :
4090 LevelStats_getSolved(i) ? FC_GREEN :
4091 LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
4093 sprintf(identifier, "%d", value);
4094 sprintf(name, "%03d: %s", value,
4095 (level.no_valid_file ? "(no file)" : level.name));
4097 setString(&ti->identifier, identifier);
4098 setString(&ti->name, name);
4099 setString(&ti->name_sorting, name);
4101 pushTreeInfo(&level_number, ti);
4104 /* sort level number values to start with lowest level number */
4105 sortTreeInfo(&level_number);
4107 /* set current level number to current level number */
4108 level_number_current =
4109 getTreeInfoFromIdentifier(level_number, i_to_a(level_nr));
4111 /* if that also fails, set current level number to first available level */
4112 if (level_number_current == NULL)
4113 level_number_current = level_number;
4115 SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
4118 DrawChooseTree(&level_number_current);
4120 DrawChooseTree(&leveldir_current);
4127 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
4130 HandleChooseTree(mx, my, dx, dy, button, &level_number_current);
4132 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
4140 void DrawHallOfFame(int highlight_position)
4143 FadeSoundsAndMusic();
4145 /* (this is needed when called from GameEnd() after winning a game) */
4146 KeyboardAutoRepeatOn();
4149 /* (this is needed when called from GameEnd() after winning a game) */
4150 SetDrawDeactivationMask(REDRAW_NONE);
4151 SetDrawBackgroundMask(REDRAW_FIELD);
4153 CloseDoor(DOOR_CLOSE_2);
4155 if (highlight_position < 0)
4156 LoadScore(level_nr);
4158 FadeSetEnterScreen();
4160 // printf("::: %d: %d\n", game_status, menu.enter_screen[game_status]);
4163 FadeOut(REDRAW_FIELD);
4171 HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
4174 FadeIn(REDRAW_FIELD);
4178 static void drawHallOfFameList(int first_entry, int highlight_position)
4182 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
4185 DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, "Hall Of Fame");
4186 DrawTextFCentered(MENU_TITLE2_YPOS, FONT_TITLE_2,
4187 "HighScores of Level %d", level_nr);
4189 for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
4191 int entry = first_entry + i;
4192 boolean active = (entry == highlight_position);
4193 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
4194 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
4195 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
4196 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
4197 int dx1 = 3 * getFontWidth(font_nr1);
4198 int dx2 = dx1 + getFontWidth(font_nr1);
4200 int dx3 = SXSIZE - 5 * getFontWidth(font_nr4);
4201 int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
4203 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
4205 int sy = mSY + 64 + i * 32;
4207 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
4208 DrawText(mSX + dx1, sy, ".", font_nr1);
4210 for (j = 0; j < num_dots; j++)
4211 DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
4213 DrawText(mSX + dx2, sy, ".........................", font_nr3);
4216 if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
4217 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
4219 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
4222 redraw_mask |= REDRAW_FIELD;
4225 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
4227 static int first_entry = 0;
4228 static int highlight_position = 0;
4229 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
4231 if (button == MB_MENU_INITIALIZE)
4234 highlight_position = mx;
4235 drawHallOfFameList(first_entry, highlight_position);
4240 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
4241 step = NUM_MENU_ENTRIES_ON_SCREEN - 1;
4245 if (first_entry > 0)
4247 first_entry -= step;
4248 if (first_entry < 0)
4251 drawHallOfFameList(first_entry, highlight_position);
4256 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
4258 first_entry += step;
4259 if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
4260 first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
4262 drawHallOfFameList(first_entry, highlight_position);
4265 else if (button == MB_MENU_LEAVE)
4267 PlaySound(SND_MENU_ITEM_SELECTING);
4269 FadeSound(SND_BACKGROUND_SCORES);
4271 game_status = GAME_MODE_MAIN;
4275 else if (button == MB_MENU_CHOICE)
4277 PlaySound(SND_MENU_ITEM_SELECTING);
4279 FadeSound(SND_BACKGROUND_SCORES);
4282 FadeOut(REDRAW_FIELD);
4285 game_status = GAME_MODE_MAIN;
4287 DrawAndFadeInMainMenu(REDRAW_FIELD);
4290 if (game_status == GAME_MODE_SCORES)
4291 PlayMenuSoundIfLoop();
4299 /* ========================================================================= */
4300 /* setup screen functions */
4301 /* ========================================================================= */
4303 static struct TokenInfo *setup_info;
4304 static int num_setup_info; /* number of setup entries shown on screen */
4305 static int max_setup_info; /* total number of setup entries in list */
4307 static char *screen_mode_text;
4308 static char *window_size_text;
4309 static char *scaling_type_text;
4310 static char *scroll_delay_text;
4311 static char *game_speed_text;
4312 static char *graphics_set_name;
4313 static char *sounds_set_name;
4314 static char *music_set_name;
4315 static char *volume_simple_text;
4316 static char *volume_loops_text;
4317 static char *volume_music_text;
4318 static char *touch_controls_text;
4319 static char *move_distance_text;
4320 static char *drop_distance_text;
4322 static void execSetupMain()
4324 setup_mode = SETUP_MODE_MAIN;
4329 static void execSetupGame_setGameSpeeds()
4331 if (game_speeds == NULL)
4335 for (i = 0; game_speeds_list[i].value != -1; i++)
4337 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4338 char identifier[32], name[32];
4339 int value = game_speeds_list[i].value;
4340 char *text = game_speeds_list[i].text;
4342 ti->node_top = &game_speeds;
4343 ti->sort_priority = 10000 - value;
4345 sprintf(identifier, "%d", value);
4346 sprintf(name, "%s", text);
4348 setString(&ti->identifier, identifier);
4349 setString(&ti->name, name);
4350 setString(&ti->name_sorting, name);
4351 setString(&ti->infotext, "Game Speed");
4353 pushTreeInfo(&game_speeds, ti);
4356 /* sort game speed values to start with slowest game speed */
4357 sortTreeInfo(&game_speeds);
4359 /* set current game speed to configured game speed value */
4360 game_speed_current =
4361 getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay));
4363 /* if that fails, set current game speed to reliable default value */
4364 if (game_speed_current == NULL)
4365 game_speed_current =
4366 getTreeInfoFromIdentifier(game_speeds, i_to_a(GAME_FRAME_DELAY));
4368 /* if that also fails, set current game speed to first available speed */
4369 if (game_speed_current == NULL)
4370 game_speed_current = game_speeds;
4373 setup.game_frame_delay = atoi(game_speed_current->identifier);
4375 /* needed for displaying game speed text instead of identifier */
4376 game_speed_text = game_speed_current->name;
4379 static void execSetupGame_setScrollDelays()
4381 if (scroll_delays == NULL)
4385 for (i = 0; scroll_delays_list[i].value != -1; i++)
4387 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4388 char identifier[32], name[32];
4389 int value = scroll_delays_list[i].value;
4390 char *text = scroll_delays_list[i].text;
4392 ti->node_top = &scroll_delays;
4393 ti->sort_priority = value;
4395 sprintf(identifier, "%d", value);
4396 sprintf(name, "%s", text);
4398 setString(&ti->identifier, identifier);
4399 setString(&ti->name, name);
4400 setString(&ti->name_sorting, name);
4401 setString(&ti->infotext, "Scaling Type");
4403 pushTreeInfo(&scroll_delays, ti);
4406 /* sort scaling type values to start with lowest scaling type value */
4407 sortTreeInfo(&scroll_delays);
4409 /* set current scaling type value to configured scaling type value */
4410 scroll_delay_current =
4411 getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
4413 /* if that fails, set current scaling type to reliable default value */
4414 if (scroll_delay_current == NULL)
4415 scroll_delay_current =
4416 getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
4418 /* if that also fails, set current scaling type to first available value */
4419 if (scroll_delay_current == NULL)
4420 scroll_delay_current = scroll_delays;
4423 setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
4425 /* needed for displaying scaling type text instead of identifier */
4426 scroll_delay_text = scroll_delay_current->name;
4429 static void execSetupGame()
4431 execSetupGame_setGameSpeeds();
4432 execSetupGame_setScrollDelays();
4434 setup_mode = SETUP_MODE_GAME;
4439 static void execSetupChooseGameSpeed()
4441 setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED;
4446 static void execSetupChooseScrollDelay()
4448 setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY;
4453 static void execSetupEditor()
4455 setup_mode = SETUP_MODE_EDITOR;
4460 static void execSetupGraphics_setWindowSizes(boolean update_list)
4462 if (window_sizes != NULL && update_list)
4464 freeTreeInfo(window_sizes);
4466 window_sizes = NULL;
4469 if (window_sizes == NULL)
4471 boolean current_window_size_found = FALSE;
4474 for (i = 0; window_sizes_list[i].value != -1; i++)
4476 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4477 char identifier[32], name[32];
4478 int value = window_sizes_list[i].value;
4479 char *text = window_sizes_list[i].text;
4481 ti->node_top = &window_sizes;
4482 ti->sort_priority = value;
4484 sprintf(identifier, "%d", value);
4485 sprintf(name, "%s", text);
4487 setString(&ti->identifier, identifier);
4488 setString(&ti->name, name);
4489 setString(&ti->name_sorting, name);
4490 setString(&ti->infotext, "Window Scaling");
4492 pushTreeInfo(&window_sizes, ti);
4494 if (value == setup.window_scaling_percent)
4495 current_window_size_found = TRUE;
4498 if (!current_window_size_found)
4500 // add entry for non-preset window scaling value
4502 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4503 char identifier[32], name[32];
4504 int value = setup.window_scaling_percent;
4506 ti->node_top = &window_sizes;
4507 ti->sort_priority = value;
4509 sprintf(identifier, "%d", value);
4510 sprintf(name, "%d %% (Current)", value);
4512 setString(&ti->identifier, identifier);
4513 setString(&ti->name, name);
4514 setString(&ti->name_sorting, name);
4515 setString(&ti->infotext, "Window Scaling");
4517 pushTreeInfo(&window_sizes, ti);
4520 /* sort window size values to start with lowest window size value */
4521 sortTreeInfo(&window_sizes);
4523 /* set current window size value to configured window size value */
4524 window_size_current =
4525 getTreeInfoFromIdentifier(window_sizes,
4526 i_to_a(setup.window_scaling_percent));
4528 /* if that fails, set current window size to reliable default value */
4529 if (window_size_current == NULL)
4530 window_size_current =
4531 getTreeInfoFromIdentifier(window_sizes,
4532 i_to_a(STD_WINDOW_SCALING_PERCENT));
4534 /* if that also fails, set current window size to first available value */
4535 if (window_size_current == NULL)
4536 window_size_current = window_sizes;
4539 setup.window_scaling_percent = atoi(window_size_current->identifier);
4541 /* needed for displaying window size text instead of identifier */
4542 window_size_text = window_size_current->name;
4545 static void execSetupGraphics_setScalingTypes()
4547 if (scaling_types == NULL)
4551 for (i = 0; scaling_types_list[i].value != NULL; i++)
4553 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4554 char identifier[32], name[32];
4555 char *value = scaling_types_list[i].value;
4556 char *text = scaling_types_list[i].text;
4558 ti->node_top = &scaling_types;
4559 ti->sort_priority = i;
4561 sprintf(identifier, "%s", value);
4562 sprintf(name, "%s", text);
4564 setString(&ti->identifier, identifier);
4565 setString(&ti->name, name);
4566 setString(&ti->name_sorting, name);
4567 setString(&ti->infotext, "Anti-Aliasing");
4569 pushTreeInfo(&scaling_types, ti);
4572 /* sort scaling type values to start with lowest scaling type value */
4573 sortTreeInfo(&scaling_types);
4575 /* set current scaling type value to configured scaling type value */
4576 scaling_type_current =
4577 getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality);
4579 /* if that fails, set current scaling type to reliable default value */
4580 if (scaling_type_current == NULL)
4581 scaling_type_current =
4582 getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT);
4584 /* if that also fails, set current scaling type to first available value */
4585 if (scaling_type_current == NULL)
4586 scaling_type_current = scaling_types;
4589 setup.window_scaling_quality = scaling_type_current->identifier;
4591 /* needed for displaying scaling type text instead of identifier */
4592 scaling_type_text = scaling_type_current->name;
4595 static void execSetupGraphics_setScreenModes()
4597 // if (screen_modes == NULL && video.fullscreen_available)
4598 if (screen_modes == NULL && video.fullscreen_modes != NULL)
4602 for (i = 0; video.fullscreen_modes[i].width != -1; i++)
4604 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4605 char identifier[32], name[32];
4606 int x = video.fullscreen_modes[i].width;
4607 int y = video.fullscreen_modes[i].height;
4610 get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
4612 ti->node_top = &screen_modes;
4613 ti->sort_priority = x * 10000 + y;
4615 sprintf(identifier, "%dx%d", x, y);
4616 sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
4618 setString(&ti->identifier, identifier);
4619 setString(&ti->name, name);
4620 setString(&ti->name_sorting, name);
4621 setString(&ti->infotext, "Fullscreen Mode");
4623 pushTreeInfo(&screen_modes, ti);
4626 /* sort fullscreen modes to start with lowest available screen resolution */
4627 sortTreeInfo(&screen_modes);
4629 /* set current screen mode for fullscreen mode to configured setup value */
4630 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4631 setup.fullscreen_mode);
4633 /* if that fails, set current screen mode to reliable default value */
4634 if (screen_mode_current == NULL)
4635 screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
4636 DEFAULT_FULLSCREEN_MODE);
4638 /* if that also fails, set current screen mode to first available mode */
4639 if (screen_mode_current == NULL)
4640 screen_mode_current = screen_modes;
4642 if (screen_mode_current == NULL)
4643 video.fullscreen_available = FALSE;
4646 // if (video.fullscreen_available)
4647 if (screen_mode_current != NULL)
4649 setup.fullscreen_mode = screen_mode_current->identifier;
4651 /* needed for displaying screen mode name instead of identifier */
4652 screen_mode_text = screen_mode_current->name;
4656 static void execSetupGraphics()
4658 if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
4660 // update "setup.window_scaling_percent" from list selection
4661 execSetupGraphics_setWindowSizes(FALSE);
4665 // update list selection from "setup.window_scaling_percent"
4666 execSetupGraphics_setWindowSizes(TRUE);
4669 execSetupGraphics_setScalingTypes();
4670 execSetupGraphics_setScreenModes();
4672 setup_mode = SETUP_MODE_GRAPHICS;
4676 #if defined(TARGET_SDL2)
4677 // window scaling may have changed at this point
4678 ToggleFullscreenOrChangeWindowScalingIfNeeded();
4680 // window scaling quality may have changed at this point
4681 if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
4682 SDLSetWindowScalingQuality(setup.window_scaling_quality);
4686 #if !defined(PLATFORM_ANDROID)
4687 #if defined(TARGET_SDL2)
4688 static void execSetupChooseWindowSize()
4691 if (!video.window_scaling_available)
4695 setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
4700 static void execSetupChooseScalingType()
4702 setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE;
4707 static void execSetupChooseScreenMode()
4709 if (!video.fullscreen_available)
4712 setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
4719 static void execSetupChooseVolumeSimple()
4721 setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE;
4726 static void execSetupChooseVolumeLoops()
4728 setup_mode = SETUP_MODE_CHOOSE_VOLUME_LOOPS;
4733 static void execSetupChooseVolumeMusic()
4735 setup_mode = SETUP_MODE_CHOOSE_VOLUME_MUSIC;
4740 static void execSetupSound()
4743 if (volumes_simple == NULL)
4747 for (i = 0; volumes_list[i].value != -1; i++)
4749 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4750 char identifier[32], name[32];
4751 int value = volumes_list[i].value;
4752 char *text = volumes_list[i].text;
4754 ti->node_top = &volumes_simple;
4755 ti->sort_priority = value;
4757 sprintf(identifier, "%d", value);
4758 sprintf(name, "%s", text);
4760 setString(&ti->identifier, identifier);
4761 setString(&ti->name, name);
4762 setString(&ti->name_sorting, name);
4763 setString(&ti->infotext, "Sound Volume");
4765 pushTreeInfo(&volumes_simple, ti);
4768 /* sort volume values to start with lowest volume value */
4769 sortTreeInfo(&volumes_simple);
4771 /* set current volume value to configured volume value */
4772 volume_simple_current =
4773 getTreeInfoFromIdentifier(volumes_simple,i_to_a(setup.volume_simple));
4775 /* if that fails, set current volume to reliable default value */
4776 if (volume_simple_current == NULL)
4777 volume_simple_current =
4778 getTreeInfoFromIdentifier(volumes_simple, i_to_a(100));
4780 /* if that also fails, set current volume to first available value */
4781 if (volume_simple_current == NULL)
4782 volume_simple_current = volumes_simple;
4785 if (volumes_loops == NULL)
4789 for (i = 0; volumes_list[i].value != -1; i++)
4791 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4792 char identifier[32], name[32];
4793 int value = volumes_list[i].value;
4794 char *text = volumes_list[i].text;
4796 ti->node_top = &volumes_loops;
4797 ti->sort_priority = value;
4799 sprintf(identifier, "%d", value);
4800 sprintf(name, "%s", text);
4802 setString(&ti->identifier, identifier);
4803 setString(&ti->name, name);
4804 setString(&ti->name_sorting, name);
4805 setString(&ti->infotext, "Loops Volume");
4807 pushTreeInfo(&volumes_loops, ti);
4810 /* sort volume values to start with lowest volume value */
4811 sortTreeInfo(&volumes_loops);
4813 /* set current volume value to configured volume value */
4814 volume_loops_current =
4815 getTreeInfoFromIdentifier(volumes_loops,i_to_a(setup.volume_loops));
4817 /* if that fails, set current volume to reliable default value */
4818 if (volume_loops_current == NULL)
4819 volume_loops_current =
4820 getTreeInfoFromIdentifier(volumes_loops, i_to_a(100));
4822 /* if that also fails, set current volume to first available value */
4823 if (volume_loops_current == NULL)
4824 volume_loops_current = volumes_loops;
4827 if (volumes_music == NULL)
4831 for (i = 0; volumes_list[i].value != -1; i++)
4833 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4834 char identifier[32], name[32];
4835 int value = volumes_list[i].value;
4836 char *text = volumes_list[i].text;
4838 ti->node_top = &volumes_music;
4839 ti->sort_priority = value;
4841 sprintf(identifier, "%d", value);
4842 sprintf(name, "%s", text);
4844 setString(&ti->identifier, identifier);
4845 setString(&ti->name, name);
4846 setString(&ti->name_sorting, name);
4847 setString(&ti->infotext, "Music Volume");
4849 pushTreeInfo(&volumes_music, ti);
4852 /* sort volume values to start with lowest volume value */
4853 sortTreeInfo(&volumes_music);
4855 /* set current volume value to configured volume value */
4856 volume_music_current =
4857 getTreeInfoFromIdentifier(volumes_music,i_to_a(setup.volume_music));
4859 /* if that fails, set current volume to reliable default value */
4860 if (volume_music_current == NULL)
4861 volume_music_current =
4862 getTreeInfoFromIdentifier(volumes_music, i_to_a(100));
4864 /* if that also fails, set current volume to first available value */
4865 if (volume_music_current == NULL)
4866 volume_music_current = volumes_music;
4869 setup.volume_simple = atoi(volume_simple_current->identifier);
4870 setup.volume_loops = atoi(volume_loops_current->identifier);
4871 setup.volume_music = atoi(volume_music_current->identifier);
4873 /* needed for displaying volume text instead of identifier */
4874 volume_simple_text = volume_simple_current->name;
4875 volume_loops_text = volume_loops_current->name;
4876 volume_music_text = volume_music_current->name;
4879 setup_mode = SETUP_MODE_SOUND;
4884 static void execSetupChooseTouchControls()
4886 setup_mode = SETUP_MODE_CHOOSE_TOUCH_CONTROL;
4891 static void execSetupChooseMoveDistance()
4893 setup_mode = SETUP_MODE_CHOOSE_MOVE_DISTANCE;
4898 static void execSetupChooseDropDistance()
4900 setup_mode = SETUP_MODE_CHOOSE_DROP_DISTANCE;
4905 static void execSetupTouch()
4908 if (touch_controls == NULL)
4912 for (i = 0; touch_controls_list[i].value != NULL; i++)
4914 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4915 char identifier[32], name[32];
4916 char *value = touch_controls_list[i].value;
4917 char *text = touch_controls_list[i].text;
4919 ti->node_top = &touch_controls;
4920 ti->sort_priority = i;
4922 sprintf(identifier, "%s", value);
4923 sprintf(name, "%s", text);
4925 setString(&ti->identifier, identifier);
4926 setString(&ti->name, name);
4927 setString(&ti->name_sorting, name);
4928 setString(&ti->infotext, "Control Type");
4930 pushTreeInfo(&touch_controls, ti);
4933 /* sort touch control values to start with lowest touch control value */
4934 sortTreeInfo(&touch_controls);
4936 /* set current touch control value to configured touch control value */
4937 touch_control_current =
4938 getTreeInfoFromIdentifier(touch_controls, setup.touch.control_type);
4940 /* if that fails, set current touch control to reliable default value */
4941 if (touch_control_current == NULL)
4942 touch_control_current =
4943 getTreeInfoFromIdentifier(touch_controls, TOUCH_CONTROL_DEFAULT);
4945 /* if that also fails, set current touch control to first available value */
4946 if (touch_control_current == NULL)
4947 touch_control_current = touch_controls;
4950 if (move_distances == NULL)
4954 for (i = 0; distances_list[i].value != -1; i++)
4956 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
4957 char identifier[32], name[32];
4958 int value = distances_list[i].value;
4959 char *text = distances_list[i].text;
4961 ti->node_top = &move_distances;
4962 ti->sort_priority = value;
4964 sprintf(identifier, "%d", value);
4965 sprintf(name, "%s", text);
4967 setString(&ti->identifier, identifier);
4968 setString(&ti->name, name);
4969 setString(&ti->name_sorting, name);
4970 setString(&ti->infotext, "Move Distance");
4972 pushTreeInfo(&move_distances, ti);
4975 /* sort distance values to start with lowest distance value */
4976 sortTreeInfo(&move_distances);
4978 /* set current distance value to configured distance value */
4979 move_distance_current =
4980 getTreeInfoFromIdentifier(move_distances,
4981 i_to_a(setup.touch.move_distance));
4983 /* if that fails, set current distance to reliable default value */
4984 if (move_distance_current == NULL)
4985 move_distance_current =
4986 getTreeInfoFromIdentifier(move_distances, i_to_a(1));
4988 /* if that also fails, set current distance to first available value */
4989 if (move_distance_current == NULL)
4990 move_distance_current = move_distances;
4993 if (drop_distances == NULL)
4997 for (i = 0; distances_list[i].value != -1; i++)
4999 TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
5000 char identifier[32], name[32];
5001 int value = distances_list[i].value;
5002 char *text = distances_list[i].text;
5004 ti->node_top = &drop_distances;
5005 ti->sort_priority = value;
5007 sprintf(identifier, "%d", value);
5008 sprintf(name, "%s", text);
5010 setString(&ti->identifier, identifier);
5011 setString(&ti->name, name);
5012 setString(&ti->name_sorting, name);
5013 setString(&ti->infotext, "Drop Distance");
5015 pushTreeInfo(&drop_distances, ti);
5018 /* sort distance values to start with lowest distance value */
5019 sortTreeInfo(&drop_distances);
5021 /* set current distance value to configured distance value */
5022 drop_distance_current =
5023 getTreeInfoFromIdentifier(drop_distances,
5024 i_to_a(setup.touch.drop_distance));
5026 /* if that fails, set current distance to reliable default value */
5027 if (drop_distance_current == NULL)
5028 drop_distance_current =
5029 getTreeInfoFromIdentifier(drop_distances, i_to_a(1));
5031 /* if that also fails, set current distance to first available value */
5032 if (drop_distance_current == NULL)
5033 drop_distance_current = drop_distances;
5036 setup.touch.control_type = touch_control_current->identifier;
5037 setup.touch.move_distance = atoi(move_distance_current->identifier);
5038 setup.touch.drop_distance = atoi(drop_distance_current->identifier);
5040 /* needed for displaying volume text instead of identifier */
5041 touch_controls_text = touch_control_current->name;
5042 move_distance_text = move_distance_current->name;
5043 drop_distance_text = drop_distance_current->name;
5046 setup_mode = SETUP_MODE_TOUCH;
5051 static void execSetupArtwork()
5054 printf("::: '%s', '%s', '%s'\n",
5055 artwork.gfx_current->subdir,
5056 artwork.gfx_current->fullpath,
5057 artwork.gfx_current->basepath);
5060 setup.graphics_set = artwork.gfx_current->identifier;
5061 setup.sounds_set = artwork.snd_current->identifier;
5062 setup.music_set = artwork.mus_current->identifier;
5064 /* needed if last screen (setup choice) changed graphics, sounds or music */
5065 ReloadCustomArtwork(0);
5067 /* needed for displaying artwork name instead of artwork identifier */
5068 graphics_set_name = artwork.gfx_current->name;
5069 sounds_set_name = artwork.snd_current->name;
5070 music_set_name = artwork.mus_current->name;
5072 setup_mode = SETUP_MODE_ARTWORK;
5077 static void execSetupChooseGraphics()
5079 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
5084 static void execSetupChooseSounds()
5086 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
5091 static void execSetupChooseMusic()
5093 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
5098 static void execSetupInput()
5100 setup_mode = SETUP_MODE_INPUT;
5105 static void execSetupShortcuts()
5107 setup_mode = SETUP_MODE_SHORTCUTS;
5112 static void execSetupShortcuts1()
5114 setup_mode = SETUP_MODE_SHORTCUTS_1;
5119 static void execSetupShortcuts2()
5121 setup_mode = SETUP_MODE_SHORTCUTS_2;
5126 static void execSetupShortcuts3()
5128 setup_mode = SETUP_MODE_SHORTCUTS_3;
5133 static void execSetupShortcuts4()
5135 setup_mode = SETUP_MODE_SHORTCUTS_4;
5140 static void execSetupShortcuts5()
5142 setup_mode = SETUP_MODE_SHORTCUTS_5;
5147 static void execExitSetup()
5149 game_status = GAME_MODE_MAIN;
5151 DrawMainMenuExt(REDRAW_FIELD, FALSE);
5154 static void execSaveAndExitSetup()
5160 static struct TokenInfo setup_info_main[] =
5162 { TYPE_ENTER_MENU, execSetupGame, "Game & Menu" },
5163 { TYPE_ENTER_MENU, execSetupEditor, "Editor" },
5164 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
5165 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
5166 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
5167 #if !defined(PLATFORM_ANDROID)
5168 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
5169 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
5171 { TYPE_ENTER_MENU, execSetupTouch, "Touch Controls" },
5173 { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" },
5174 { TYPE_EMPTY, NULL, "" },
5175 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
5176 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
5181 static struct TokenInfo setup_info_game[] =
5183 { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
5184 { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" },
5185 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
5186 { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" },
5187 { TYPE_SWITCH, &setup.time_limit, "Time Limit:" },
5188 { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" },
5189 { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
5190 { TYPE_STRING, &game_speed_text, "" },
5192 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
5193 { TYPE_STRING, &scroll_delay_text, "" },
5195 { TYPE_EMPTY, NULL, "" },
5196 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5201 static struct TokenInfo setup_info_editor[] =
5204 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
5205 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
5206 { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
5207 { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
5208 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
5209 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
5210 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
5211 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
5213 { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
5214 { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
5215 { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
5217 { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
5219 { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
5220 { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
5221 { TYPE_EMPTY, NULL, "" },
5223 { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
5224 { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
5225 { TYPE_EMPTY, NULL, "" },
5227 { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
5228 { TYPE_EMPTY, NULL, "" },
5229 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5234 static struct TokenInfo setup_info_graphics[] =
5236 #if !defined(PLATFORM_ANDROID)
5237 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
5238 #if defined(TARGET_SDL2)
5239 { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
5240 { TYPE_STRING, &window_size_text, "" },
5242 { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
5243 { TYPE_STRING, &scaling_type_text, "" },
5246 { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" },
5247 { TYPE_STRING, &screen_mode_text, "" },
5251 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
5254 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
5255 { TYPE_STRING, &scroll_delay_text, "" },
5258 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" },
5260 { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
5261 { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
5262 { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
5263 { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" },
5264 { TYPE_SWITCH, &setup.toons, "Show Toons:" },
5265 { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" },
5266 { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
5267 { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
5268 { TYPE_EMPTY, NULL, "" },
5269 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5274 static struct TokenInfo setup_info_sound[] =
5276 { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
5277 { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
5278 { TYPE_SWITCH, &setup.sound_music, "Music:" },
5279 { TYPE_EMPTY, NULL, "" },
5280 { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
5281 { TYPE_STRING, &volume_simple_text, "" },
5282 { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
5283 { TYPE_STRING, &volume_loops_text, "" },
5284 { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
5285 { TYPE_STRING, &volume_music_text, "" },
5286 { TYPE_EMPTY, NULL, "" },
5287 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5292 static struct TokenInfo setup_info_artwork[] =
5294 { TYPE_ENTER_LIST, execSetupChooseGraphics,"Custom Graphics:" },
5295 { TYPE_STRING, &graphics_set_name, "" },
5296 { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
5297 { TYPE_STRING, &sounds_set_name, "" },
5298 { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
5299 { TYPE_STRING, &music_set_name, "" },
5300 { TYPE_EMPTY, NULL, "" },
5303 { TYPE_YES_NO_AUTO,&setup.override_level_graphics,"Override Level Graphics:"},
5304 { TYPE_YES_NO_AUTO,&setup.override_level_sounds, "Override Level Sounds:" },
5305 { TYPE_YES_NO_AUTO,&setup.override_level_music, "Override Level Music:" },
5307 { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
5308 { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:" },
5309 { TYPE_YES_NO, &setup.override_level_music, "Override Level Music:" },
5310 { TYPE_YES_NO, &setup.auto_override_artwork, "Auto-Override Non-CE Sets:" },
5313 { TYPE_STRING, NULL, "Override Level Artwork:"},
5314 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
5315 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
5316 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
5318 { TYPE_EMPTY, NULL, "" },
5319 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5324 static struct TokenInfo setup_info_input[] =
5326 { TYPE_SWITCH, NULL, "Player:" },
5327 { TYPE_SWITCH, NULL, "Device:" },
5328 { TYPE_ENTER_MENU, NULL, "" },
5329 { TYPE_EMPTY, NULL, "" },
5330 { TYPE_EMPTY, NULL, "" },
5331 { TYPE_EMPTY, NULL, "" },
5332 { TYPE_EMPTY, NULL, "" },
5333 { TYPE_EMPTY, NULL, "" },
5334 { TYPE_EMPTY, NULL, "" },
5335 { TYPE_EMPTY, NULL, "" },
5336 { TYPE_EMPTY, NULL, "" },
5337 { TYPE_EMPTY, NULL, "" },
5338 { TYPE_EMPTY, NULL, "" },
5339 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5344 static struct TokenInfo setup_info_touch[] =
5346 { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
5347 { TYPE_STRING, &touch_controls_text, "" },
5348 { TYPE_EMPTY, NULL, "" },
5349 { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
5350 { TYPE_STRING, &move_distance_text, "" },
5351 { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
5352 { TYPE_STRING, &drop_distance_text, "" },
5353 { TYPE_EMPTY, NULL, "" },
5354 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5359 static struct TokenInfo setup_info_shortcuts[] =
5361 { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
5362 { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
5363 { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
5364 { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
5365 { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
5366 { TYPE_EMPTY, NULL, "" },
5367 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
5372 static struct TokenInfo setup_info_shortcuts_1[] =
5374 { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", },
5375 { TYPE_KEY, &setup.shortcut.save_game, "" },
5376 { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:", },
5377 { TYPE_KEY, &setup.shortcut.load_game, "" },
5378 { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:", },
5379 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
5380 { TYPE_EMPTY, NULL, "" },
5381 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
5382 { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
5383 { TYPE_EMPTY, NULL, "" },
5384 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5389 static struct TokenInfo setup_info_shortcuts_2[] =
5391 { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:", },
5392 { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
5393 { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:", },
5394 { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
5395 { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:", },
5396 { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
5397 { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:", },
5398 { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
5399 { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", },
5400 { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
5401 { TYPE_EMPTY, NULL, "" },
5402 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5407 static struct TokenInfo setup_info_shortcuts_3[] =
5409 { TYPE_KEYTEXT, NULL, "Eject Tape:", },
5410 { TYPE_KEY, &setup.shortcut.tape_eject, "" },
5411 { TYPE_KEYTEXT, NULL, "Warp / Single Step:", },
5412 { TYPE_KEY, &setup.shortcut.tape_extra, "" },
5413 { TYPE_KEYTEXT, NULL, "Stop Tape:", },
5414 { TYPE_KEY, &setup.shortcut.tape_stop, "" },
5415 { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:",},
5416 { TYPE_KEY, &setup.shortcut.tape_pause, "" },
5417 { TYPE_KEYTEXT, NULL, "Record Tape:", },
5418 { TYPE_KEY, &setup.shortcut.tape_record, "" },
5419 { TYPE_KEYTEXT, NULL, "Play Tape:", },
5420 { TYPE_KEY, &setup.shortcut.tape_play, "" },
5421 { TYPE_EMPTY, NULL, "" },
5422 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5427 static struct TokenInfo setup_info_shortcuts_4[] =
5429 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):", },
5430 { TYPE_KEY, &setup.shortcut.sound_simple, "" },
5431 { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):", },
5432 { TYPE_KEY, &setup.shortcut.sound_loops, "" },
5433 { TYPE_KEYTEXT, NULL, "Toggle Music:", },
5434 { TYPE_KEY, &setup.shortcut.sound_music, "" },
5435 { TYPE_EMPTY, NULL, "" },
5436 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5441 static struct TokenInfo setup_info_shortcuts_5[] =
5443 { TYPE_KEYTEXT, NULL, "Snap Left:", },
5444 { TYPE_KEY, &setup.shortcut.snap_left, "" },
5445 { TYPE_KEYTEXT, NULL, "Snap Right:", },
5446 { TYPE_KEY, &setup.shortcut.snap_right, "" },
5447 { TYPE_KEYTEXT, NULL, "Snap Up:", },
5448 { TYPE_KEY, &setup.shortcut.snap_up, "" },
5449 { TYPE_KEYTEXT, NULL, "Snap Down:", },
5450 { TYPE_KEY, &setup.shortcut.snap_down, "" },
5451 { TYPE_EMPTY, NULL, "" },
5452 { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
5457 static Key getSetupKey()
5459 Key key = KSYM_UNDEFINED;
5460 boolean got_key_event = FALSE;
5462 while (!got_key_event)
5464 if (PendingEvent()) /* got event */
5472 case EVENT_KEYPRESS:
5474 key = GetEventKey((KeyEvent *)&event, TRUE);
5476 /* press 'Escape' or 'Enter' to keep the existing key binding */
5477 if (key == KSYM_Escape || key == KSYM_Return)
5478 key = KSYM_UNDEFINED; /* keep old value */
5480 got_key_event = TRUE;
5484 case EVENT_KEYRELEASE:
5485 key_joystick_mapping = 0;
5489 HandleOtherEvents(&event);
5497 /* don't eat all CPU time */
5504 static int getSetupTextFont(int type)
5506 if (type & (TYPE_SWITCH |
5518 static int getSetupValueFont(int type, void *value)
5520 if (type & TYPE_KEY)
5521 return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
5522 else if (type & TYPE_STRING)
5523 return FONT_VALUE_2;
5524 else if (type & TYPE_ECS_AGA)
5525 return FONT_VALUE_1;
5526 else if (type & TYPE_BOOLEAN_STYLE)
5527 return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
5528 else if (type & TYPE_YES_NO_AUTO)
5529 return (*(int *)value == AUTO ? FONT_OPTION_ON :
5530 *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
5532 return FONT_VALUE_1;
5536 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
5538 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5539 struct TokenInfo *si = &setup_info[si_pos];
5540 boolean font_draw_xoffset_modified = FALSE;
5541 int font_draw_xoffset_old = -1;
5542 int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
5543 int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
5544 int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
5545 int xpos = menu_screen_value_xpos;
5546 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5547 int startx = mSX + xpos * 32;
5548 int starty = mSY + ypos * 32;
5549 int font_nr, font_width;
5553 int type = si->type;
5554 void *value = si->value;
5555 char *value_string = getSetupValue(type, value);
5560 if (value_string == NULL)
5563 if (type & TYPE_KEY)
5565 xpos = MENU_SCREEN_START_XPOS;
5567 if (type & TYPE_QUERY)
5568 value_string = "<press key>";
5570 else if (type & TYPE_STRING)
5572 int max_value_len = (SCR_FIELDX - 2) * 2;
5574 xpos = MENU_SCREEN_START_XPOS;
5576 if (strlen(value_string) > max_value_len)
5577 value_string[max_value_len] = '\0';
5579 else if (type & TYPE_YES_NO_AUTO)
5581 xpos = menu_screen_value_xpos - 1;
5584 startx = mSX + xpos * 32;
5585 starty = mSY + ypos * 32;
5586 font_nr = getSetupValueFont(type, value);
5587 font_width = getFontWidth(font_nr);
5589 font_height = getFontHeight(font_nr);
5593 if (menu_screen_value_xpos < 1 + MAX_MENU_TEXT_LENGTH_BIG)
5597 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5598 if (setup_mode != SETUP_MODE_INPUT)
5600 int max_menu_text_length_big = (menu_screen_value_xpos -
5601 MENU_SCREEN_START_XPOS);
5602 int max_menu_text_length_medium = max_menu_text_length_big * 2;
5603 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5604 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5605 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5606 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5607 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5608 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5609 int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
5610 boolean correct_font_draw_xoffset = FALSE;
5612 if (xpos == MENU_SCREEN_START_XPOS &&
5613 startx + font1_xoffset < text_startx + text_font_xoffset)
5614 correct_font_draw_xoffset = TRUE;
5616 if (xpos == menu_screen_value_xpos &&
5617 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5618 correct_font_draw_xoffset = TRUE;
5620 /* check if setup value would overlap with setup text when printed */
5621 /* (this can happen for extreme/wrong values for font draw offset) */
5622 if (correct_font_draw_xoffset)
5624 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5625 font_draw_xoffset_modified = TRUE;
5627 if (type & TYPE_KEY)
5628 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5629 else if (!(type & TYPE_STRING))
5630 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5631 max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
5636 DrawBackground(startx, starty, SX + SXSIZE - startx, font_height);
5638 for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
5639 DrawText(startx + i * font_width, starty, " ", font_nr);
5642 // printf("::: startx == %d\n", startx);
5644 DrawText(startx, starty, value_string, font_nr);
5646 if (font_draw_xoffset_modified)
5647 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5652 static void drawSetupValue(int pos)
5654 boolean font_draw_xoffset_modified = FALSE;
5655 int font_draw_xoffset_old = -1;
5656 int xpos = MENU_SCREEN_VALUE_XPOS;
5657 int ypos = MENU_SCREEN_START_YPOS + pos;
5658 int startx = mSX + xpos * 32;
5659 int starty = mSY + ypos * 32;
5660 int font_nr, font_width;
5664 int type = setup_info[pos].type;
5665 void *value = setup_info[pos].value;
5666 char *value_string = getSetupValue(type, value);
5671 if (value_string == NULL)
5674 if (type & TYPE_KEY)
5676 xpos = MENU_SCREEN_START_XPOS;
5678 if (type & TYPE_QUERY)
5679 value_string = "<press key>";
5681 else if (type & TYPE_STRING)
5683 int max_value_len = (SCR_FIELDX - 2) * 2;
5685 xpos = MENU_SCREEN_START_XPOS;
5687 if (strlen(value_string) > max_value_len)
5688 value_string[max_value_len] = '\0';
5690 else if (type & TYPE_YES_NO_AUTO)
5692 xpos = MENU_SCREEN_VALUE_XPOS - 1;
5695 startx = mSX + xpos * 32;
5696 starty = mSY + ypos * 32;
5697 font_nr = getSetupValueFont(type, value);
5698 font_width = getFontWidth(font_nr);
5700 font_height = getFontHeight(font_nr);
5703 /* downward compatibility correction for Juergen Bonhagen's menu settings */
5704 if (setup_mode != SETUP_MODE_INPUT)
5706 int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */
5707 int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
5708 int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset;
5709 int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
5710 int text_font_nr = getSetupTextFont(FONT_MENU_2);
5711 int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
5712 int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr);
5713 boolean correct_font_draw_xoffset = FALSE;
5715 if (xpos == MENU_SCREEN_START_XPOS &&
5716 startx + font1_xoffset < text_startx + text_font_xoffset)
5717 correct_font_draw_xoffset = TRUE;
5719 if (xpos == MENU_SCREEN_VALUE_XPOS &&
5720 startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
5721 correct_font_draw_xoffset = TRUE;
5723 /* check if setup value would overlap with setup text when printed */
5724 /* (this can happen for extreme/wrong values for font draw offset) */
5725 if (correct_font_draw_xoffset)
5727 font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
5728 font_draw_xoffset_modified = TRUE;
5730 if (type & TYPE_KEY)
5731 getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
5732 else if (!(type & TYPE_STRING))
5733 getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
5734 MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
5739 DrawBackground(startx, starty, SX + SXSIZE - startx, font_height);
5741 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
5742 DrawText(startx + i * font_width, starty, " ", font_nr);
5745 DrawText(startx, starty, value_string, font_nr);
5747 if (font_draw_xoffset_modified)
5748 getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
5753 static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
5755 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5756 struct TokenInfo *si = &setup_info[si_pos];
5758 if (si->type & TYPE_BOOLEAN_STYLE)
5760 *(boolean *)si->value ^= TRUE;
5762 else if (si->type & TYPE_YES_NO_AUTO)
5766 (*(int *)si->value == AUTO ? TRUE :
5767 *(int *)si->value == TRUE ? FALSE : AUTO) :
5768 (*(int *)si->value == TRUE ? AUTO :
5769 *(int *)si->value == AUTO ? FALSE : TRUE));
5771 else if (si->type & TYPE_KEY)
5775 si->type |= TYPE_QUERY;
5776 drawSetupValue(screen_pos, setup_info_pos_raw);
5777 si->type &= ~TYPE_QUERY;
5779 key = getSetupKey();
5780 if (key != KSYM_UNDEFINED)
5781 *(Key *)si->value = key;
5784 drawSetupValue(screen_pos, setup_info_pos_raw);
5786 // fullscreen state may have changed at this point
5787 if (si->value == &setup.fullscreen)
5788 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5793 static void changeSetupValue(int pos, int dx)
5795 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
5797 *(boolean *)setup_info[pos].value ^= TRUE;
5799 else if (setup_info[pos].type & TYPE_YES_NO_AUTO)
5801 *(int *)setup_info[pos].value =
5803 (*(int *)setup_info[pos].value == AUTO ? TRUE :
5804 *(int *)setup_info[pos].value == TRUE ? FALSE : AUTO) :
5805 (*(int *)setup_info[pos].value == TRUE ? AUTO :
5806 *(int *)setup_info[pos].value == AUTO ? FALSE : TRUE));
5808 else if (setup_info[pos].type & TYPE_KEY)
5812 setup_info[pos].type |= TYPE_QUERY;
5813 drawSetupValue(pos, -1);
5814 setup_info[pos].type &= ~TYPE_QUERY;
5816 key = getSetupKey();
5817 if (key != KSYM_UNDEFINED)
5818 *(Key *)setup_info[pos].value = key;
5821 drawSetupValue(pos, -1);
5823 // fullscreen state may have changed at this point
5824 if (setup_info[pos].value == &setup.fullscreen)
5825 ToggleFullscreenOrChangeWindowScalingIfNeeded();
5830 static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
5833 int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
5834 struct TokenInfo *si = &setup_info[si_pos];
5835 int xpos = MENU_SCREEN_START_XPOS;
5836 int ypos = MENU_SCREEN_START_YPOS + screen_pos;
5837 int font_nr = getSetupTextFont(si->type);
5839 if (setup_info == setup_info_input)
5840 font_nr = FONT_MENU_1;
5843 font_nr = FONT_ACTIVE(font_nr);
5845 DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
5847 if (si->type & ~TYPE_SKIP_ENTRY)
5848 drawCursor(screen_pos, active);
5851 static void DrawCursorAndText_Setup(int pos, boolean active)
5853 int xpos = MENU_SCREEN_START_XPOS;
5854 int ypos = MENU_SCREEN_START_YPOS + pos;
5855 int font_nr = getSetupTextFont(setup_info[pos].type);
5857 if (setup_info == setup_info_input)
5858 font_nr = FONT_MENU_1;
5861 font_nr = FONT_ACTIVE(font_nr);
5863 DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
5865 if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
5866 drawCursor(pos, active);
5870 static void drawSetupInfoList(struct TokenInfo *setup_info,
5871 int first_entry, int num_page_entries)
5875 if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
5876 num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
5878 if (num_page_entries > max_setup_info)
5879 num_page_entries = max_setup_info;
5881 if (first_entry + num_page_entries > max_setup_info)
5885 /* clear tree list area, but not title or scrollbar */
5886 DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
5887 SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
5888 NUM_MENU_ENTRIES_ON_SCREEN * 32);
5891 for (i = 0; i < num_page_entries; i++)
5893 int setup_info_pos = first_entry + i;
5894 struct TokenInfo *si = &setup_info[setup_info_pos];
5895 void *value_ptr = si->value;
5897 /* set some entries to "unchangeable" according to other variables */
5898 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
5899 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
5900 (value_ptr == &setup.sound_music && !audio.music_available) ||
5901 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
5902 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
5903 (value_ptr == &window_size_text && !video.window_scaling_available) ||
5904 (value_ptr == &scaling_type_text && !video.window_scaling_available))
5905 si->type |= TYPE_GHOSTED;
5907 if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
5908 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
5909 else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
5910 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
5911 else if (si->type & ~TYPE_SKIP_ENTRY)
5912 initCursor(i, IMG_MENU_BUTTON);
5914 DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
5916 if (si->type & TYPE_VALUE)
5917 drawSetupValue(i, setup_info_pos);
5921 static void DrawSetupScreen_Generic()
5923 boolean redraw_all = FALSE;
5924 char *title_string = NULL;
5930 FreeScreenGadgets();
5931 CreateScreenGadgets();
5934 CloseDoor(DOOR_CLOSE_2);
5936 if (redraw_mask & REDRAW_ALL)
5940 printf("::: %s\n", (redraw_mask & REDRAW_FIELD ? "REDRAW_FIELD" :
5941 redraw_mask & REDRAW_ALL ? "REDRAW_ALL" :
5942 int2str(0, redraw_mask)));
5946 /* !!! usually REDRAW_NONE => DOES NOT WORK (with fade) => CHECK THIS !!! */
5947 FadeOut(redraw_mask);
5949 FadeOut(REDRAW_FIELD);
5954 if (setup_mode == SETUP_MODE_MAIN)
5956 setup_info = setup_info_main;
5957 title_string = "Setup";
5959 else if (setup_mode == SETUP_MODE_GAME)
5961 setup_info = setup_info_game;
5962 title_string = "Setup Game";
5964 else if (setup_mode == SETUP_MODE_EDITOR)
5966 setup_info = setup_info_editor;
5967 title_string = "Setup Editor";
5969 else if (setup_mode == SETUP_MODE_GRAPHICS)
5971 setup_info = setup_info_graphics;
5972 title_string = "Setup Graphics";
5974 else if (setup_mode == SETUP_MODE_SOUND)
5976 setup_info = setup_info_sound;
5977 title_string = "Setup Sound";
5979 else if (setup_mode == SETUP_MODE_ARTWORK)
5981 setup_info = setup_info_artwork;
5982 title_string = "Custom Artwork";
5984 else if (setup_mode == SETUP_MODE_TOUCH)
5986 setup_info = setup_info_touch;
5987 title_string = "Setup Touch Ctrls";
5989 else if (setup_mode == SETUP_MODE_SHORTCUTS)
5991 setup_info = setup_info_shortcuts;
5992 title_string = "Setup Shortcuts";
5994 else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
5996 setup_info = setup_info_shortcuts_1;
5997 title_string = "Setup Shortcuts";
5999 else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
6001 setup_info = setup_info_shortcuts_2;
6002 title_string = "Setup Shortcuts";
6004 else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
6006 setup_info = setup_info_shortcuts_3;
6007 title_string = "Setup Shortcuts";
6009 else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
6011 setup_info = setup_info_shortcuts_4;
6012 title_string = "Setup Shortcuts";
6014 else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
6016 setup_info = setup_info_shortcuts_5;
6017 title_string = "Setup Shortcuts";
6020 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
6025 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
6029 for (i = 0; setup_info[i].type != 0; i++)
6033 drawSetupInfoList(setup_info, 0, NUM_MENU_ENTRIES_ON_SCREEN);
6040 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
6042 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
6045 void *value_ptr = setup_info[i].value;
6047 /* set some entries to "unchangeable" according to other variables */
6048 if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
6049 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
6050 (value_ptr == &setup.sound_music && !audio.music_available) ||
6051 (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
6052 (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
6053 (value_ptr == &window_size_text && !video.window_scaling_available) ||
6054 (value_ptr == &scaling_type_text && !video.window_scaling_available))
6055 setup_info[i].type |= TYPE_GHOSTED;
6057 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
6058 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
6059 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
6060 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
6061 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
6062 initCursor(i, IMG_MENU_BUTTON);
6064 DrawCursorAndText_Setup(i, FALSE);
6066 if (setup_info[i].type & TYPE_VALUE)
6074 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
6075 "Joysticks deactivated in setup menu");
6079 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
6083 MapScreenGadgets(max_setup_info);
6087 redraw_mask = REDRAW_ALL;
6090 FadeIn(redraw_mask);
6092 FadeIn(REDRAW_FIELD);
6097 HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
6101 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
6103 static int choice_store[MAX_SETUP_MODES];
6104 static int first_entry_store[MAX_SETUP_MODES];
6105 int choice = choice_store[setup_mode]; /* starts with 0 */
6106 int first_entry = first_entry_store[setup_mode]; /* starts with 0 */
6109 int y = choice - first_entry;
6114 boolean position_set_by_scrollbar = (dx == 999);
6116 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
6117 int num_page_entries;
6119 num_page_entries = MIN(max_setup_info, NUM_MENU_ENTRIES_ON_SCREEN);
6122 if (button == MB_MENU_INITIALIZE)
6124 /* advance to first valid menu entry */
6125 while (choice < num_setup_info &&
6126 setup_info[choice].type & TYPE_SKIP_ENTRY)
6129 choice_store[setup_mode] = choice;
6133 if (position_set_by_scrollbar)
6134 first_entry = first_entry_store[setup_mode] = dy;
6136 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
6137 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
6139 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
6143 if (choice < first_entry)
6145 choice = first_entry;
6147 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
6150 else if (choice > first_entry + num_page_entries - 1)
6152 choice = first_entry + num_page_entries - 1;
6154 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
6158 choice_store[setup_mode] = choice;
6160 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
6162 DrawCursorAndText_Setup(choice, -1, TRUE);
6167 else if (button == MB_MENU_LEAVE)
6171 PlaySound(SND_MENU_ITEM_SELECTING);
6173 for (i = 0; setup_info[i].type != 0; i++)
6175 if (setup_info[i].type & TYPE_LEAVE_MENU)
6177 void (*menu_callback_function)(void) = setup_info[i].value;
6181 menu_callback_function();
6183 break; /* absolutely needed because function changes 'setup_info'! */
6190 if (mx || my) /* mouse input */
6192 x = (mx - mSX) / 32;
6193 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
6196 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
6198 else if (dx || dy) /* keyboard input */
6201 /* move cursor instead of scrolling when already at start/end of list */
6202 if (dy == -1 * SCROLL_LINE && first_entry == 0)
6204 else if (dy == +1 * SCROLL_LINE &&
6205 first_entry + num_page_entries == max_setup_info)
6208 /* handle scrolling screen one line or page */
6210 y + dy > num_page_entries - 1)
6212 boolean redraw = FALSE;
6214 if (ABS(dy) == SCROLL_PAGE)
6215 step = num_page_entries - 1;
6217 if (dy < 0 && first_entry > 0)
6219 /* scroll page/line up */
6221 first_entry -= step;
6222 if (first_entry < 0)
6227 else if (dy > 0 && first_entry + num_page_entries < max_setup_info)
6229 /* scroll page/line down */
6231 first_entry += step;
6232 if (first_entry + num_page_entries > max_setup_info)
6233 first_entry = MAX(0, max_setup_info - num_page_entries);
6240 choice += first_entry - first_entry_store[setup_mode];
6242 if (choice < first_entry)
6244 choice = first_entry;
6246 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
6249 else if (choice > first_entry + num_page_entries - 1)
6251 choice = first_entry + num_page_entries - 1;
6253 if (setup_info[choice].type & TYPE_SKIP_ENTRY)
6257 else if (setup_info[choice].type & TYPE_SKIP_ENTRY)
6261 if (choice < first_entry ||
6262 choice > first_entry + num_page_entries - 1)
6263 first_entry += SIGN(dy);
6267 // printf("::: MARK 1: %d\n", first_entry);
6269 first_entry_store[setup_mode] = first_entry;
6270 choice_store[setup_mode] = choice;
6272 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
6274 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
6276 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
6277 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
6285 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
6287 if (setup_info[choice].type & menu_navigation_type ||
6288 setup_info[choice].type & TYPE_BOOLEAN_STYLE ||
6289 setup_info[choice].type & TYPE_YES_NO_AUTO)
6290 button = MB_MENU_CHOICE;
6300 /* jump to next non-empty menu entry (up or down) */
6302 while (first_entry + y > 0 &&
6303 first_entry + y < max_setup_info - 1 &&
6304 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
6307 while (y > 0 && y < num_setup_info - 1 &&
6308 setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
6312 if (!IN_VIS_FIELD(x, y))
6314 choice += y - y_old;
6316 if (choice < first_entry)
6317 first_entry = choice;
6318 else if (choice > first_entry + num_page_entries - 1)
6319 first_entry = choice - num_page_entries + 1;
6321 first_entry += y - y_old;
6324 if (first_entry >= 0 &&
6325 first_entry + num_page_entries <= max_setup_info)
6327 first_entry_store[setup_mode] = first_entry;
6329 if (choice < first_entry)
6330 choice = first_entry;
6331 else if (choice > first_entry + num_page_entries - 1)
6332 choice = first_entry + num_page_entries - 1;
6334 choice_store[setup_mode] = choice;
6336 drawSetupInfoList(setup_info, first_entry, NUM_MENU_ENTRIES_ON_SCREEN);
6338 DrawCursorAndText_Setup(choice - first_entry, choice, TRUE);
6340 AdjustScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, max_setup_info,
6341 NUM_MENU_ENTRIES_ON_SCREEN, first_entry);
6349 if (!anyScrollbarGadgetActive() &&
6350 IN_VIS_FIELD(x, y) &&
6351 mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
6352 y >= 0 && y < num_page_entries)
6354 if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
6358 printf("::: TEST/HandleSetupScreen_Generic [%d, %d, %d, %d]\n", Counter(),
6359 button, mx, screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x);
6365 if (first_entry + y != choice &&
6366 setup_info[first_entry + y].type & ~TYPE_SKIP_ENTRY)
6368 PlaySound(SND_MENU_ITEM_ACTIVATING);
6370 DrawCursorAndText_Setup(choice - first_entry, choice, FALSE);
6371 DrawCursorAndText_Setup(y, first_entry + y, TRUE);
6373 choice = choice_store[setup_mode] = first_entry + y;
6376 if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
6378 PlaySound(SND_MENU_ITEM_ACTIVATING);
6380 DrawCursorAndText_Setup(choice, -1, FALSE);
6381 DrawCursorAndText_Setup(y, -1, TRUE);
6383 choice = choice_store[setup_mode] = y;
6388 else if (!(setup_info[first_entry + y].type & TYPE_GHOSTED))
6390 PlaySound(SND_MENU_ITEM_SELECTING);
6392 /* when selecting key headline, execute function for key value change */
6393 if (setup_info[first_entry + y].type & TYPE_KEYTEXT &&
6394 setup_info[first_entry + y + 1].type & TYPE_KEY)
6397 /* when selecting string value, execute function for list selection */
6398 if (setup_info[first_entry + y].type & TYPE_STRING && y > 0 &&
6399 setup_info[first_entry + y - 1].type & TYPE_ENTER_LIST)
6402 if (setup_info[first_entry + y].type & TYPE_ENTER_OR_LEAVE)
6404 void (*menu_callback_function)(void) =
6405 setup_info[first_entry + y].value;
6407 FadeSetFromType(setup_info[first_entry + y].type);
6409 menu_callback_function();
6413 if (setup_info[first_entry + y].type & TYPE_VALUE)
6414 changeSetupValue(y, first_entry + y, dx);
6418 else if (!(setup_info[y].type & TYPE_GHOSTED))
6420 PlaySound(SND_MENU_ITEM_SELECTING);
6422 /* when selecting key headline, execute function for key value change */
6423 if (setup_info[y].type & TYPE_KEYTEXT &&
6424 setup_info[y + 1].type & TYPE_KEY)
6427 /* when selecting string value, execute function for list selection */
6428 if (setup_info[y].type & TYPE_STRING && y > 0 &&
6429 setup_info[y - 1].type & TYPE_ENTER_LIST)
6432 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
6434 void (*menu_callback_function)(void) = setup_info[y].value;
6436 FadeSetFromType(setup_info[y].type);
6438 menu_callback_function();
6442 if (setup_info[y].type & TYPE_VALUE)
6443 changeSetupValue(y, dx);
6450 void DrawSetupScreen_Input()
6455 FadeOut(REDRAW_FIELD);
6461 setup_info = setup_info_input;
6464 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Setup Input");
6468 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
6469 "Joysticks deactivated on this screen");
6471 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
6472 "Joysticks deactivated on this screen");
6477 for (i = 0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
6479 for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
6482 if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
6483 initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
6484 else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
6485 initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
6486 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
6487 initCursor(i, IMG_MENU_BUTTON);
6489 DrawCursorAndText_Setup(i, -1, FALSE);
6493 DeactivateJoystickForCalibration();
6498 DrawTextSCentered(SYSIZE - 20, FONT_TITLE_2,
6499 "Joysticks deactivated on this screen");
6501 DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4,
6502 "Joysticks deactivated on this screen");
6506 /* create gadgets for setup input menu screen */
6507 FreeScreenGadgets();
6508 CreateScreenGadgets();
6510 /* map gadgets for setup input menu screen */
6511 MapScreenMenuGadgets(SCREEN_MASK_INPUT);
6513 HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
6516 FadeIn(REDRAW_FIELD);
6522 static void setJoystickDeviceToNr(char *device_name, int device_nr)
6524 if (device_name == NULL)
6527 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
6530 if (strlen(device_name) > 1)
6532 char c1 = device_name[strlen(device_name) - 1];
6533 char c2 = device_name[strlen(device_name) - 2];
6535 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
6536 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
6539 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
6540 strlen(device_name));
6543 static void drawPlayerSetupInputInfo(int player_nr, boolean active)
6546 static struct SetupKeyboardInfo custom_key;
6553 { &custom_key.left, "Joystick Left" },
6554 { &custom_key.right, "Joystick Right" },
6555 { &custom_key.up, "Joystick Up" },
6556 { &custom_key.down, "Joystick Down" },
6557 { &custom_key.snap, "Button 1" },
6558 { &custom_key.drop, "Button 2" }
6560 static char *joystick_name[MAX_PLAYERS] =
6567 int text_font_nr = (active ? FONT_MENU_1_ACTIVE : FONT_MENU_1);
6571 custom_key = setup.input[player_nr].key;
6573 DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
6574 FONT_INPUT_1_ACTIVE);
6576 ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
6578 DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
6579 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
6581 if (setup.input[player_nr].use_joystick)
6583 char *device_name = setup.input[player_nr].joy.device_name;
6584 char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
6585 int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
6587 DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
6588 DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", text_font_nr);
6592 DrawText(mSX + 8 * 32, mSY + 3 * 32, "Keyboard ", FONT_VALUE_1);
6593 DrawText(mSX + 1 * 32, mSY + 4 * 32, "Customize", text_font_nr);
6596 DrawText(mSX + 32, mSY + 5 * 32, "Actual Settings:", FONT_MENU_1);
6598 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
6599 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
6600 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
6601 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
6603 DrawText(mSX + 2 * 32, mSY + 6 * 32, ":", FONT_VALUE_OLD);
6604 DrawText(mSX + 2 * 32, mSY + 7 * 32, ":", FONT_VALUE_OLD);
6605 DrawText(mSX + 2 * 32, mSY + 8 * 32, ":", FONT_VALUE_OLD);
6606 DrawText(mSX + 2 * 32, mSY + 9 * 32, ":", FONT_VALUE_OLD);
6607 DrawText(mSX + 1 * 32, mSY + 10 * 32, "Snap Field:", FONT_VALUE_OLD);
6608 DrawText(mSX + 1 * 32, mSY + 12 * 32, "Drop Element:", FONT_VALUE_OLD);
6610 for (i = 0; i < 6; i++)
6612 int ypos = 6 + i + (i > 3 ? i-3 : 0);
6614 DrawText(mSX + 3 * 32, mSY + ypos * 32,
6616 DrawText(mSX + 3 * 32, mSY + ypos * 32,
6617 (setup.input[player_nr].use_joystick ?
6619 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
6623 static int input_player_nr = 0;
6625 void HandleSetupScreen_Input_Player(int step, int direction)
6627 int old_player_nr = input_player_nr;
6630 new_player_nr = old_player_nr + step * direction;
6631 if (new_player_nr < 0)
6633 if (new_player_nr > MAX_PLAYERS - 1)
6634 new_player_nr = MAX_PLAYERS - 1;
6636 if (new_player_nr != old_player_nr)
6638 input_player_nr = new_player_nr;
6640 drawPlayerSetupInputInfo(input_player_nr, FALSE);
6644 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
6646 static int choice = 0;
6649 int pos_start = SETUPINPUT_SCREEN_POS_START;
6650 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
6651 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
6652 int pos_end = SETUPINPUT_SCREEN_POS_END;
6654 if (button == MB_MENU_INITIALIZE)
6656 drawPlayerSetupInputInfo(input_player_nr, (choice == 2));
6658 DrawCursorAndText_Setup(choice, -1, TRUE);
6662 else if (button == MB_MENU_LEAVE)
6664 setup_mode = SETUP_MODE_MAIN;
6671 if (mx || my) /* mouse input */
6673 x = (mx - mSX) / 32;
6674 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
6676 else if (dx || dy) /* keyboard input */
6678 if (dx && choice == 0)
6679 x = (dx < 0 ? 10 : 12);
6680 else if ((dx && choice == 1) ||
6681 (dx == +1 && choice == 2) ||
6682 (dx == -1 && choice == pos_end))
6683 button = MB_MENU_CHOICE;
6687 if (y >= pos_empty1 && y <= pos_empty2)
6688 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
6691 if (y == 0 && dx != 0 && button)
6693 HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
6695 else if (IN_VIS_FIELD(x, y) &&
6696 y >= pos_start && y <= pos_end &&
6697 !(y >= pos_empty1 && y <= pos_empty2))
6703 DrawCursorAndText_Setup(choice, -1, FALSE);
6704 DrawCursorAndText_Setup(y, -1, TRUE);
6706 drawPlayerSetupInputInfo(input_player_nr, (y == 2));
6715 char *device_name = setup.input[input_player_nr].joy.device_name;
6717 if (!setup.input[input_player_nr].use_joystick)
6719 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
6721 setJoystickDeviceToNr(device_name, new_device_nr);
6722 setup.input[input_player_nr].use_joystick = TRUE;
6726 int device_nr = getJoystickNrFromDeviceName(device_name);
6727 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
6729 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
6730 setup.input[input_player_nr].use_joystick = FALSE;
6732 setJoystickDeviceToNr(device_name, new_device_nr);
6735 drawPlayerSetupInputInfo(input_player_nr, FALSE);
6739 if (setup.input[input_player_nr].use_joystick)
6742 CalibrateJoystick(input_player_nr);
6745 CustomizeKeyboard(input_player_nr);
6747 else if (y == pos_end)
6753 setup_mode = SETUP_MODE_MAIN;
6760 void CustomizeKeyboard(int player_nr)
6764 boolean finished = FALSE;
6765 static struct SetupKeyboardInfo custom_key;
6770 } customize_step[] =
6772 { &custom_key.left, "Move Left" },
6773 { &custom_key.right, "Move Right" },
6774 { &custom_key.up, "Move Up" },
6775 { &custom_key.down, "Move Down" },
6776 { &custom_key.snap, "Snap Field" },
6777 { &custom_key.drop, "Drop Element" }
6780 /* read existing key bindings from player setup */
6781 custom_key = setup.input[player_nr].key;
6784 FadeOut(REDRAW_FIELD);
6788 DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input");
6796 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6797 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6798 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6799 "Key:", FONT_INPUT_1_ACTIVE);
6800 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6801 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
6804 FadeIn(REDRAW_FIELD);
6811 if (PendingEvent()) /* got event */
6819 case EVENT_KEYPRESS:
6821 Key key = GetEventKey((KeyEvent *)&event, FALSE);
6823 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
6825 if (key == KSYM_Escape)
6826 FadeSkipNextFadeIn();
6832 /* all keys configured -- wait for "Escape" or "Return" key */
6836 /* press 'Enter' to keep the existing key binding */
6837 if (key == KSYM_Return)
6838 key = *customize_step[step_nr].key;
6840 /* check if key already used */
6841 for (i = 0; i < step_nr; i++)
6842 if (*customize_step[i].key == key)
6847 /* got new key binding */
6848 *customize_step[step_nr].key = key;
6849 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6851 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6852 getKeyNameFromKey(key), FONT_VALUE_1);
6855 /* un-highlight last query */
6856 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1)) * 32,
6857 customize_step[step_nr - 1].text, FONT_MENU_1);
6858 DrawText(mSX, mSY + (2 + 2 * (step_nr - 1) + 1) * 32,
6859 "Key:", FONT_MENU_1);
6861 /* press 'Enter' to leave */
6864 DrawText(mSX + 16, mSY + 15 * 32 + 16,
6865 "Press Enter", FONT_TITLE_1);
6869 /* query next key binding */
6870 DrawText(mSX, mSY + (2 + 2 * step_nr) * 32,
6871 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
6872 DrawText(mSX, mSY + (2 + 2 * step_nr + 1) * 32,
6873 "Key:", FONT_INPUT_1_ACTIVE);
6874 DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32,
6875 getKeyNameFromKey(*customize_step[step_nr].key),
6880 case EVENT_KEYRELEASE:
6881 key_joystick_mapping = 0;
6885 HandleOtherEvents(&event);
6893 /* don't eat all CPU time */
6897 /* write new key bindings back to player setup */
6898 setup.input[player_nr].key = custom_key;
6901 DrawSetupScreen_Input();
6904 static boolean CalibrateJoystickMain(int player_nr)
6906 int new_joystick_xleft = JOYSTICK_XMIDDLE;
6907 int new_joystick_xright = JOYSTICK_XMIDDLE;
6908 int new_joystick_yupper = JOYSTICK_YMIDDLE;
6909 int new_joystick_ylower = JOYSTICK_YMIDDLE;
6910 int new_joystick_xmiddle, new_joystick_ymiddle;
6912 int joystick_fd = joystick.fd[player_nr];
6913 int x, y, last_x, last_y, xpos = 8, ypos = 3;
6914 boolean check[3][3];
6915 int check_remaining = 3 * 3;
6920 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
6923 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
6927 FadeOut(REDRAW_FIELD);
6931 for (y = 0; y < 3; y++)
6933 for (x = 0; x < 3; x++)
6935 DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
6936 check[x][y] = FALSE;
6940 DrawTextSCentered(mSY - SY + 6 * 32, FONT_TITLE_1, "Rotate joystick");
6941 DrawTextSCentered(mSY - SY + 7 * 32, FONT_TITLE_1, "in all directions");
6942 DrawTextSCentered(mSY - SY + 9 * 32, FONT_TITLE_1, "if all balls");
6943 DrawTextSCentered(mSY - SY + 10 * 32, FONT_TITLE_1, "are marked,");
6944 DrawTextSCentered(mSY - SY + 11 * 32, FONT_TITLE_1, "center joystick");
6945 DrawTextSCentered(mSY - SY + 12 * 32, FONT_TITLE_1, "and");
6946 DrawTextSCentered(mSY - SY + 13 * 32, FONT_TITLE_1, "press any button!");
6948 joy_value = Joystick(player_nr);
6949 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
6950 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
6952 /* eventually uncalibrated center position (joystick could be uncentered) */
6953 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
6956 new_joystick_xmiddle = joy_x;
6957 new_joystick_ymiddle = joy_y;
6959 DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
6961 FadeIn(REDRAW_FIELD);
6963 while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
6968 if (PendingEvent()) /* got event */
6976 case EVENT_KEYPRESS:
6977 switch (GetEventKey((KeyEvent *)&event, TRUE))
6980 if (check_remaining == 0)
6985 FadeSkipNextFadeIn();
6994 case EVENT_KEYRELEASE:
6995 key_joystick_mapping = 0;
6999 HandleOtherEvents(&event);
7004 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
7007 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
7008 new_joystick_xright = MAX(new_joystick_xright, joy_x);
7009 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
7010 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
7012 setup.input[player_nr].joy.xleft = new_joystick_xleft;
7013 setup.input[player_nr].joy.yupper = new_joystick_yupper;
7014 setup.input[player_nr].joy.xright = new_joystick_xright;
7015 setup.input[player_nr].joy.ylower = new_joystick_ylower;
7016 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
7017 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
7019 CheckJoystickData();
7021 joy_value = Joystick(player_nr);
7023 if (joy_value & JOY_BUTTON && check_remaining == 0)
7026 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
7027 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
7029 if (x != last_x || y != last_y)
7031 DrawFixedGraphic(xpos + last_x, ypos + last_y,
7032 IMG_MENU_CALIBRATE_YELLOW, 0);
7033 DrawFixedGraphic(xpos + x, ypos + y,
7034 IMG_MENU_CALIBRATE_RED, 0);
7039 if (check_remaining > 0 && !check[x+1][y+1])
7041 check[x+1][y+1] = TRUE;
7047 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
7048 setup.input[player_nr].joy.xleft,
7049 setup.input[player_nr].joy.xmiddle,
7050 setup.input[player_nr].joy.xright);
7051 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
7052 setup.input[player_nr].joy.yupper,
7053 setup.input[player_nr].joy.ymiddle,
7054 setup.input[player_nr].joy.ylower);
7063 /* don't eat all CPU time */
7067 /* calibrated center position (joystick should now be centered) */
7068 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
7071 new_joystick_xmiddle = joy_x;
7072 new_joystick_ymiddle = joy_y;
7077 DrawSetupScreen_Input();
7080 /* wait until the last pressed button was released */
7081 while (Joystick(player_nr) & JOY_BUTTON)
7083 if (PendingEvent()) /* got event */
7088 HandleOtherEvents(&event);
7097 void CalibrateJoystick(int player_nr)
7099 if (!CalibrateJoystickMain(player_nr))
7101 char *device_name = setup.input[player_nr].joy.device_name;
7102 int nr = getJoystickNrFromDeviceName(device_name) + 1;
7103 int xpos = mSX - SX;
7104 int ypos = mSY - SY;
7108 DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, " JOYSTICK %d ", nr);
7109 DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
7112 Delay(2000); /* show error message for a short time */
7118 DrawSetupScreen_Input();
7122 void DrawSetupScreen()
7124 DeactivateJoystick();
7126 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
7128 if (setup_mode == SETUP_MODE_INPUT)
7129 DrawSetupScreen_Input();
7130 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
7131 DrawChooseTree(&game_speed_current);
7132 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
7133 DrawChooseTree(&scroll_delay_current);
7134 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
7135 DrawChooseTree(&screen_mode_current);
7136 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7137 DrawChooseTree(&window_size_current);
7138 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
7139 DrawChooseTree(&scaling_type_current);
7140 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
7141 DrawChooseTree(&artwork.gfx_current);
7142 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
7143 DrawChooseTree(&artwork.snd_current);
7144 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
7145 DrawChooseTree(&artwork.mus_current);
7146 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
7147 DrawChooseTree(&volume_simple_current);
7148 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
7149 DrawChooseTree(&volume_loops_current);
7150 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
7151 DrawChooseTree(&volume_music_current);
7152 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
7153 DrawChooseTree(&touch_control_current);
7154 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
7155 DrawChooseTree(&move_distance_current);
7156 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
7157 DrawChooseTree(&drop_distance_current);
7159 DrawSetupScreen_Generic();
7165 void RedrawSetupScreenAfterFullscreenToggle()
7168 if (setup_mode == SETUP_MODE_GRAPHICS ||
7169 setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7171 // update list selection from "setup.window_scaling_percent"
7172 execSetupGraphics_setWindowSizes(TRUE);
7177 if (setup_mode == SETUP_MODE_GRAPHICS)
7182 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
7184 if (setup_mode == SETUP_MODE_INPUT)
7185 HandleSetupScreen_Input(mx, my, dx, dy, button);
7186 else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
7187 HandleChooseTree(mx, my, dx, dy, button, &game_speed_current);
7188 else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY)
7189 HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
7190 else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
7191 HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
7192 else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
7193 HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
7194 else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
7195 HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
7196 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
7197 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
7198 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
7199 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
7200 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
7201 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
7202 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE)
7203 HandleChooseTree(mx, my, dx, dy, button, &volume_simple_current);
7204 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS)
7205 HandleChooseTree(mx, my, dx, dy, button, &volume_loops_current);
7206 else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
7207 HandleChooseTree(mx, my, dx, dy, button, &volume_music_current);
7208 else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL)
7209 HandleChooseTree(mx, my, dx, dy, button, &touch_control_current);
7210 else if (setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE)
7211 HandleChooseTree(mx, my, dx, dy, button, &move_distance_current);
7212 else if (setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
7213 HandleChooseTree(mx, my, dx, dy, button, &drop_distance_current);
7215 HandleSetupScreen_Generic(mx, my, dx, dy, button);
7222 void HandleGameActions()
7224 if (game_status != GAME_MODE_PLAYING)
7227 GameActions(); /* main game loop */
7229 if (tape.auto_play && !tape.playing)
7230 AutoPlayTape(); /* continue automatically playing next tape */
7234 /* ---------- new screen button stuff -------------------------------------- */
7236 static void getScreenMenuButtonPos(int *x, int *y, int gadget_id)
7241 case SCREEN_CTRL_ID_PREV_LEVEL:
7242 *x = mSX + GDI_ACTIVE_POS(menu.main.button.prev_level.x);
7243 *y = mSY + GDI_ACTIVE_POS(menu.main.button.prev_level.y);
7246 case SCREEN_CTRL_ID_NEXT_LEVEL:
7247 *x = mSX + GDI_ACTIVE_POS(menu.main.button.next_level.x);
7248 *y = mSY + GDI_ACTIVE_POS(menu.main.button.next_level.y);
7251 case SCREEN_CTRL_ID_PREV_LEVEL:
7252 *x = mSX + TILEX * getPrevlevelButtonPos();
7253 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
7256 case SCREEN_CTRL_ID_NEXT_LEVEL:
7257 *x = mSX + TILEX * getNextLevelButtonPos();
7258 *y = mSY + TILEY * (MENU_SCREEN_START_YPOS + 1);
7262 case SCREEN_CTRL_ID_PREV_PLAYER:
7263 *x = mSX + TILEX * 10;
7264 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
7267 case SCREEN_CTRL_ID_NEXT_PLAYER:
7268 *x = mSX + TILEX * 12;
7269 *y = mSY + TILEY * MENU_SCREEN_START_YPOS;
7273 Error(ERR_EXIT, "unknown gadget ID %d", gadget_id);
7279 int gfx_unpressed, gfx_pressed;
7280 void (*get_gadget_position)(int *, int *, int);
7284 } menubutton_info[NUM_SCREEN_MENUBUTTONS] =
7287 IMG_MENU_BUTTON_PREV_LEVEL, IMG_MENU_BUTTON_PREV_LEVEL_ACTIVE,
7288 getScreenMenuButtonPos,
7289 SCREEN_CTRL_ID_PREV_LEVEL,
7294 IMG_MENU_BUTTON_NEXT_LEVEL, IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE,
7295 getScreenMenuButtonPos,
7296 SCREEN_CTRL_ID_NEXT_LEVEL,
7301 IMG_MENU_BUTTON_LEFT, IMG_MENU_BUTTON_LEFT_ACTIVE,
7302 getScreenMenuButtonPos,
7303 SCREEN_CTRL_ID_PREV_PLAYER,
7308 IMG_MENU_BUTTON_RIGHT, IMG_MENU_BUTTON_RIGHT_ACTIVE,
7309 getScreenMenuButtonPos,
7310 SCREEN_CTRL_ID_NEXT_PLAYER,
7318 int gfx_unpressed, gfx_pressed;
7322 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
7325 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
7327 -1, -1, /* these values are not constant, but can change at runtime */
7329 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
7331 SCREEN_CTRL_ID_SCROLL_UP,
7335 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
7337 -1, -1, /* these values are not constant, but can change at runtime */
7339 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
7341 SCREEN_CTRL_ID_SCROLL_DOWN,
7348 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
7349 Bitmap **gfx_unpressed, **gfx_pressed;
7351 int gfx_unpressed, gfx_pressed;
7358 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
7361 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
7362 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
7364 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
7367 -1, -1, /* these values are not constant, but can change at runtime */
7368 -1, -1, /* these values are not constant, but can change at runtime */
7370 SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
7371 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
7373 GD_TYPE_SCROLLBAR_VERTICAL,
7374 SCREEN_CTRL_ID_SCROLL_VERTICAL,
7375 "scroll level series vertically"
7379 static void CreateScreenMenubuttons()
7381 struct GadgetInfo *gi;
7382 unsigned int event_mask;
7385 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
7387 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7388 int gfx_unpressed, gfx_pressed;
7389 int x, y, width, height;
7390 int gd_x1, gd_x2, gd_y1, gd_y2;
7391 int id = menubutton_info[i].gadget_id;
7393 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7395 menubutton_info[i].get_gadget_position(&x, &y, id);
7397 width = SC_MENUBUTTON_XSIZE;
7398 height = SC_MENUBUTTON_YSIZE;
7400 gfx_unpressed = menubutton_info[i].gfx_unpressed;
7401 gfx_pressed = menubutton_info[i].gfx_pressed;
7402 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7403 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7404 gd_x1 = graphic_info[gfx_unpressed].src_x;
7405 gd_y1 = graphic_info[gfx_unpressed].src_y;
7406 gd_x2 = graphic_info[gfx_pressed].src_x;
7407 gd_y2 = graphic_info[gfx_pressed].src_y;
7409 gi = CreateGadget(GDI_CUSTOM_ID, id,
7410 GDI_CUSTOM_TYPE_ID, i,
7411 GDI_INFO_TEXT, menubutton_info[i].infotext,
7416 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7417 GDI_STATE, GD_BUTTON_UNPRESSED,
7418 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7419 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7420 GDI_DIRECT_DRAW, FALSE,
7421 GDI_EVENT_MASK, event_mask,
7422 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7426 Error(ERR_EXIT, "cannot create gadget");
7428 screen_gadget[id] = gi;
7432 static void CreateScreenScrollbuttons()
7434 struct GadgetInfo *gi;
7435 unsigned int event_mask;
7438 /* these values are not constant, but can change at runtime */
7439 scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
7440 scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
7441 scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
7442 scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
7444 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7446 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7447 int gfx_unpressed, gfx_pressed;
7448 int x, y, width, height;
7449 int gd_x1, gd_x2, gd_y1, gd_y2;
7450 int id = scrollbutton_info[i].gadget_id;
7452 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
7454 x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset;
7455 y = mSY + scrollbutton_info[i].y;
7456 width = SC_SCROLLBUTTON_XSIZE;
7457 height = SC_SCROLLBUTTON_YSIZE;
7459 if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
7460 y = mSY + (SC_SCROLL_VERTICAL_YPOS +
7461 (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
7463 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
7464 gfx_pressed = scrollbutton_info[i].gfx_pressed;
7465 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7466 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7467 gd_x1 = graphic_info[gfx_unpressed].src_x;
7468 gd_y1 = graphic_info[gfx_unpressed].src_y;
7469 gd_x2 = graphic_info[gfx_pressed].src_x;
7470 gd_y2 = graphic_info[gfx_pressed].src_y;
7472 gi = CreateGadget(GDI_CUSTOM_ID, id,
7473 GDI_CUSTOM_TYPE_ID, i,
7474 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
7479 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
7480 GDI_STATE, GD_BUTTON_UNPRESSED,
7481 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7482 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7483 GDI_DIRECT_DRAW, FALSE,
7484 GDI_EVENT_MASK, event_mask,
7485 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7489 Error(ERR_EXIT, "cannot create gadget");
7491 screen_gadget[id] = gi;
7495 static void CreateScreenScrollbars()
7499 /* these values are not constant, but can change at runtime */
7500 scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
7501 scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
7502 scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE;
7503 scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
7505 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7507 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
7508 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
7509 int gfx_unpressed, gfx_pressed;
7511 int x, y, width, height;
7512 int gd_x1, gd_x2, gd_y1, gd_y2;
7513 struct GadgetInfo *gi;
7514 int items_max, items_visible, item_position;
7515 unsigned int event_mask;
7516 int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
7517 int id = scrollbar_info[i].gadget_id;
7519 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
7521 x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset;
7522 y = mSY + scrollbar_info[i].y;
7523 width = scrollbar_info[i].width;
7524 height = scrollbar_info[i].height;
7526 if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
7527 height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
7529 items_max = num_page_entries;
7530 items_visible = num_page_entries;
7533 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
7534 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
7535 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
7541 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
7542 gfx_pressed = scrollbar_info[i].gfx_pressed;
7543 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
7544 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
7545 gd_x1 = graphic_info[gfx_unpressed].src_x;
7546 gd_y1 = graphic_info[gfx_unpressed].src_y;
7547 gd_x2 = graphic_info[gfx_pressed].src_x;
7548 gd_y2 = graphic_info[gfx_pressed].src_y;
7551 gi = CreateGadget(GDI_CUSTOM_ID, id,
7552 GDI_CUSTOM_TYPE_ID, i,
7553 GDI_INFO_TEXT, scrollbar_info[i].infotext,
7558 GDI_TYPE, scrollbar_info[i].type,
7559 GDI_SCROLLBAR_ITEMS_MAX, items_max,
7560 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
7561 GDI_SCROLLBAR_ITEM_POSITION, item_position,
7563 GDI_WHEEL_AREA_X, SX,
7564 GDI_WHEEL_AREA_Y, SY,
7565 GDI_WHEEL_AREA_WIDTH, SXSIZE,
7566 GDI_WHEEL_AREA_HEIGHT, SYSIZE,
7568 GDI_WHEEL_AREA_X, 0,
7569 GDI_WHEEL_AREA_Y, 0,
7570 GDI_WHEEL_AREA_WIDTH, WIN_XSIZE,
7571 GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE,
7573 GDI_STATE, GD_BUTTON_UNPRESSED,
7574 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
7575 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
7576 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
7577 GDI_DIRECT_DRAW, FALSE,
7578 GDI_EVENT_MASK, event_mask,
7579 GDI_CALLBACK_ACTION, HandleScreenGadgets,
7583 Error(ERR_EXIT, "cannot create gadget");
7585 screen_gadget[id] = gi;
7589 void CreateScreenGadgets()
7591 int last_game_status = game_status; /* save current game status */
7593 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
7596 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
7598 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
7600 /* copy pointers to clip mask and GC */
7601 scrollbar_bitmap[i]->clip_mask =
7602 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
7603 scrollbar_bitmap[i]->stored_clip_gc =
7604 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
7606 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
7607 scrollbar_bitmap[i],
7608 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
7609 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
7610 TILEX, TILEY, 0, 0);
7614 CreateScreenMenubuttons();
7617 /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */
7618 game_status = GAME_MODE_LEVELS;
7621 CreateScreenScrollbuttons();
7622 CreateScreenScrollbars();
7624 game_status = last_game_status; /* restore current game status */
7627 void FreeScreenGadgets()
7631 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
7632 for (i = 0; i < NUM_SCROLLBAR_BITMAPS; i++)
7634 /* prevent freeing clip mask and GC twice */
7635 scrollbar_bitmap[i]->clip_mask = None;
7636 scrollbar_bitmap[i]->stored_clip_gc = None;
7638 FreeBitmap(scrollbar_bitmap[i]);
7642 for (i = 0; i < NUM_SCREEN_GADGETS; i++)
7643 FreeGadget(screen_gadget[i]);
7646 void MapScreenMenuGadgets(int screen_mask)
7650 for (i = 0; i < NUM_SCREEN_MENUBUTTONS; i++)
7651 if (screen_mask & menubutton_info[i].screen_mask)
7652 MapGadget(screen_gadget[menubutton_info[i].gadget_id]);
7655 void MapScreenGadgets(int num_entries)
7659 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
7662 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7663 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
7665 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7666 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
7669 void MapScreenTreeGadgets(TreeInfo *ti)
7672 MapScreenGadgets(numTreeInfoInGroup(ti));
7674 int num_entries = numTreeInfoInGroup(ti);
7677 if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
7680 for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
7681 MapGadget(screen_gadget[scrollbutton_info[i].gadget_id]);
7683 for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
7684 MapGadget(screen_gadget[scrollbar_info[i].gadget_id]);
7688 static void HandleScreenGadgets(struct GadgetInfo *gi)
7690 int id = gi->custom_id;
7691 int button = gi->event.button;
7692 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
7696 case SCREEN_CTRL_ID_PREV_LEVEL:
7697 HandleMainMenu_SelectLevel(step, -1);
7700 case SCREEN_CTRL_ID_NEXT_LEVEL:
7701 HandleMainMenu_SelectLevel(step, +1);
7704 case SCREEN_CTRL_ID_PREV_PLAYER:
7705 HandleSetupScreen_Input_Player(step, -1);
7708 case SCREEN_CTRL_ID_NEXT_PLAYER:
7709 HandleSetupScreen_Input_Player(step, +1);
7712 case SCREEN_CTRL_ID_SCROLL_UP:
7713 if (game_status == GAME_MODE_LEVELS)
7714 HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7715 else if (game_status == GAME_MODE_LEVELNR)
7716 HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7717 else if (game_status == GAME_MODE_SETUP)
7718 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
7721 case SCREEN_CTRL_ID_SCROLL_DOWN:
7722 if (game_status == GAME_MODE_LEVELS)
7723 HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7724 else if (game_status == GAME_MODE_LEVELNR)
7725 HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7726 else if (game_status == GAME_MODE_SETUP)
7727 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
7730 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
7731 if (game_status == GAME_MODE_LEVELS)
7732 HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
7733 else if (game_status == GAME_MODE_LEVELNR)
7734 HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE);
7735 else if (game_status == GAME_MODE_SETUP)
7736 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);