1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
27 /* screens in the setup menu */
28 #define SETUP_MODE_MAIN 0
29 #define SETUP_MODE_GAME 1
30 #define SETUP_MODE_INPUT 2
31 #define SETUP_MODE_SHORTCUT 3
32 #define SETUP_MODE_GRAPHICS 4
33 #define SETUP_MODE_SOUND 5
34 #define SETUP_MODE_ARTWORK 6
35 #define SETUP_MODE_CHOOSE_GRAPHICS 7
36 #define SETUP_MODE_CHOOSE_SOUNDS 8
37 #define SETUP_MODE_CHOOSE_MUSIC 9
39 #define MAX_SETUP_MODES 10
41 /* for input setup functions */
42 #define SETUPINPUT_SCREEN_POS_START 0
43 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
44 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
45 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
47 /* for various menu stuff */
48 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - 2)
49 #define MENU_SCREEN_START_YPOS 2
50 #define MENU_SCREEN_VALUE_XPOS 14
52 /* buttons and scrollbars identifiers */
53 #define SCREEN_CTRL_ID_SCROLL_UP 0
54 #define SCREEN_CTRL_ID_SCROLL_DOWN 1
55 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 2
57 #define NUM_SCREEN_SCROLLBUTTONS 2
58 #define NUM_SCREEN_SCROLLBARS 1
59 #define NUM_SCREEN_GADGETS 3
61 /* forward declarations of internal functions */
62 static void HandleScreenGadgets(struct GadgetInfo *);
63 static void HandleSetupScreen_Generic(int, int, int, int, int);
64 static void HandleSetupScreen_Input(int, int, int, int, int);
65 static void CustomizeKeyboard(int);
66 static void CalibrateJoystick(int);
67 static void execSetupArtwork(void);
68 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
70 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
71 static int setup_mode = SETUP_MODE_MAIN;
73 static void drawCursorExt(int pos, int color, int graphic)
75 static int cursor_array[SCR_FIELDY];
78 cursor_array[pos] = graphic;
80 graphic = cursor_array[pos];
83 graphic = (graphic == IMG_ARROW_BLUE_LEFT ? IMG_ARROW_RED_LEFT :
84 graphic == IMG_ARROW_BLUE_RIGHT ? IMG_ARROW_RED_RIGHT :
87 DrawGraphic(0, MENU_SCREEN_START_YPOS + pos, graphic, 0);
90 static void initCursor(int pos, int graphic)
92 drawCursorExt(pos, FC_BLUE, graphic);
95 static void drawCursor(int pos, int color)
97 drawCursorExt(pos, color, 0);
102 int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
104 DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
105 DrawTextFCentered(46, FC_RED, WINDOW_SUBTITLE_STRING);
108 static void ToggleFullscreenIfNeeded()
110 if (setup.fullscreen != video.fullscreen_enabled)
112 /* save old door content */
113 BlitBitmap(backbuffer, bitmap_db_door,
114 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
116 /* toggle fullscreen */
117 ChangeVideoModeIfNeeded(setup.fullscreen);
118 setup.fullscreen = video.fullscreen_enabled;
120 /* redraw background to newly created backbuffer */
121 BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, backbuffer,
122 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
124 /* restore old door content */
125 BlitBitmap(bitmap_db_door, backbuffer,
126 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
128 redraw_mask = REDRAW_ALL;
134 static LevelDirTree *leveldir_last_valid = NULL;
136 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
140 KeyboardAutoRepeatOn();
142 SetDrawDeactivationMask(REDRAW_NONE);
143 audio.sound_deactivated = FALSE;
145 /* needed if last screen was the playing screen, invoked from level editor */
146 if (level_editor_test_game)
148 game_status = LEVELED;
153 /* needed if last screen was the editor screen */
154 UndrawSpecialEditorDoor();
156 /* needed if last screen was the setup screen and fullscreen state changed */
157 ToggleFullscreenIfNeeded();
159 /* needed if last screen (level choice) changed graphics, sounds or music */
160 ReloadCustomArtwork();
163 SetDrawtoField(DRAW_BACKBUFFER);
166 /* map gadgets for main menu screen */
169 /* leveldir_current may be invalid (level group, parent link) */
170 if (!validLevelSeries(leveldir_current))
171 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
173 /* store valid level series information */
174 leveldir_last_valid = leveldir_current;
176 /* level_nr may have been set to value over handicap with level editor */
177 if (setup.handicap && level_nr > leveldir_current->handicap_level)
178 level_nr = leveldir_current->handicap_level;
185 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
186 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
187 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
188 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
189 (leveldir_current->readonly ? FC_RED : FC_YELLOW));
190 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
191 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
192 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
193 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
194 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
195 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
197 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
199 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
200 leveldir_current->first_level,
201 leveldir_current->last_level);
203 if (leveldir_current->readonly)
205 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
206 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
210 initCursor(i, (i == 1 || i == 6 ? IMG_ARROW_BLUE_RIGHT : IMG_BALL_BLUE));
212 DrawGraphic(10, 3, IMG_ARROW_BLUE_LEFT, 0);
213 DrawGraphic(14, 3, IMG_ARROW_BLUE_RIGHT, 0);
215 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
218 if (leveldir_current->name)
220 int len = strlen(leveldir_current->name);
221 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
222 int lypos = SY + 352;
224 DrawText(lxpos, lypos, leveldir_current->name, FS_SMALL, FC_SPECIAL2);
229 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
232 if (TAPE_IS_EMPTY(tape))
234 DrawCompleteVideoDisplay();
236 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
238 if (options.autoplay_leveldir)
246 static void gotoTopLevelDir()
248 /* move upwards to top level directory */
249 while (leveldir_current->node_parent)
251 /* write a "path" into level tree for easy navigation to last level */
252 if (leveldir_current->node_parent->node_group->cl_first == -1)
254 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
255 int leveldir_pos = posTreeInfo(leveldir_current);
256 int num_page_entries;
257 int cl_first, cl_cursor;
259 if (num_leveldirs <= MAX_MENU_ENTRIES_ON_SCREEN)
260 num_page_entries = num_leveldirs;
262 num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
264 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
265 cl_cursor = leveldir_pos - cl_first;
267 leveldir_current->node_parent->node_group->cl_first = cl_first;
268 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
271 leveldir_current = leveldir_current->node_parent;
275 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
277 static int choice = 0;
281 if (button == MB_MENU_INITIALIZE)
283 drawCursor(choice, FC_RED);
287 if (mx || my) /* mouse input */
290 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
292 else if (dx || dy) /* keyboard input */
294 if (dx && choice == 1)
295 x = (dx < 0 ? 10 : 14);
300 if (y == 1 && ((x == 10 && level_nr > leveldir_current->first_level) ||
301 (x == 14 && level_nr < leveldir_current->last_level)) &&
304 static unsigned long level_delay = 0;
305 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
306 int new_level_nr, old_level_nr = level_nr;
307 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
309 new_level_nr = level_nr + (x == 10 ? -step : +step);
310 if (new_level_nr < leveldir_current->first_level)
311 new_level_nr = leveldir_current->first_level;
312 if (new_level_nr > leveldir_current->last_level)
313 new_level_nr = leveldir_current->last_level;
315 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
316 new_level_nr = leveldir_current->handicap_level;
318 if (old_level_nr == new_level_nr ||
319 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
322 level_nr = new_level_nr;
324 DrawTextExt(drawto, SX + 11 * 32, SY + 3 * 32,
325 int2str(level_nr, 3), FS_BIG, font_color);
326 DrawTextExt(window, SX + 11 * 32, SY + 3 * 32,
327 int2str(level_nr, 3), FS_BIG, font_color);
330 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
334 DrawCompleteVideoDisplay();
336 /* needed because DrawMicroLevel() takes some time */
339 DelayReached(&level_delay, 0); /* reset delay counter */
341 else if (x == 0 && y >= 0 && y <= 7)
347 drawCursor(y, FC_RED);
348 drawCursor(choice, FC_BLUE);
356 game_status = TYPENAME;
357 HandleTypeName(strlen(setup.player_name), 0);
363 game_status = CHOOSELEVEL;
364 SaveLevelSetup_LastSeries();
365 SaveLevelSetup_SeriesInfo();
374 game_status = HALLOFFAME;
379 if (leveldir_current->readonly &&
380 strcmp(setup.player_name, "Artsoft") != 0)
381 Request("This level is read only !", REQ_CONFIRM);
382 game_status = LEVELED;
387 game_status = HELPSCREEN;
392 if (setup.autorecord)
393 TapeStartRecording();
395 #if defined(PLATFORM_UNIX)
397 SendToServer_StartPlaying();
401 game_status = PLAYING;
409 setup_mode = SETUP_MODE_MAIN;
414 SaveLevelSetup_LastSeries();
415 SaveLevelSetup_SeriesInfo();
416 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
417 game_status = EXITGAME;
426 if (game_status == MAINMENU)
428 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
434 #define MAX_HELPSCREEN_ELS 10
438 static long helpscreen_state;
439 static int helpscreen_step[MAX_HELPSCREEN_ELS];
440 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
442 static int OLD_helpscreen_action[] =
444 GFX_SPIELER1_DOWN,4,2,
446 GFX_SPIELER1_LEFT,4,2,
447 GFX_SPIELER1_RIGHT,4,2,
448 GFX_SPIELER1_PUSH_LEFT,4,2,
449 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
450 GFX_ERDREICH,1,100, HA_NEXT,
451 GFX_LEERRAUM,1,100, HA_NEXT,
452 GFX_MORAST_LEER,1,100, HA_NEXT,
453 GFX_BETON,1,100, HA_NEXT,
454 GFX_MAUERWERK,1,100, HA_NEXT,
455 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
456 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
457 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
458 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
459 GFX_UNSICHTBAR,1,100, HA_NEXT,
460 GFX_FELSBODEN,1,100, HA_NEXT,
461 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
462 GFX_EDELSTEIN,2,5, HA_NEXT,
463 GFX_DIAMANT,2,5, HA_NEXT,
464 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
465 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
466 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
467 GFX_FELSBROCKEN,4,5, HA_NEXT,
468 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
469 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
470 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
471 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
472 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
473 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
474 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
475 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
476 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
477 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
478 GFX_GEBLUBBER,4,4, HA_NEXT,
479 GFX_SCHLUESSEL1,4,25, HA_NEXT,
480 GFX_PFORTE1,4,25, HA_NEXT,
481 GFX_PFORTE1X,4,25, HA_NEXT,
482 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
483 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
484 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
485 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
486 GFX_LEERRAUM,1,10, HA_NEXT,
487 GFX_DYNABOMB_NR,1,100, HA_NEXT,
488 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
489 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
490 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
491 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
492 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
493 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
494 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
495 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
496 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
497 GFX_BUTTERFLY,2,2, HA_NEXT,
498 GFX_FIREFLY,2,2, HA_NEXT,
499 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
500 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
501 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
502 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
503 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
504 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
505 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
506 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
507 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
508 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
512 GFX_MOLE_RIGHT,4,2, HA_NEXT,
513 GFX_PINGUIN_DOWN,4,2,
515 GFX_PINGUIN_LEFT,4,2,
516 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
517 GFX_SCHWEIN_DOWN,4,2,
519 GFX_SCHWEIN_LEFT,4,2,
520 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
524 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
525 GFX_SONDE_START,8,1, HA_NEXT,
526 GFX_ABLENK,4,1, HA_NEXT,
527 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
528 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
529 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
530 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
531 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
532 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
533 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
534 GFX_DIAMANT,1,10, HA_NEXT,
535 GFX_LIFE,1,100, HA_NEXT,
536 GFX_LIFE_ASYNC,1,100, HA_NEXT,
537 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
538 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
539 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
540 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
541 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
542 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
543 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
544 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
545 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
546 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
547 GFX_SPEED_PILL,1,100, HA_NEXT,
552 static int helpscreen_action[] =
554 IMG_PLAYER1_DOWN_MOVING, 16,
555 IMG_PLAYER1_UP_MOVING, 16,
556 IMG_PLAYER1_LEFT_MOVING, 16,
557 IMG_PLAYER1_RIGHT_MOVING, 16,
558 IMG_PLAYER1_LEFT_PUSHING, 16,
559 IMG_PLAYER1_RIGHT_PUSHING, 16, HA_NEXT,
561 IMG_SAND, -1, HA_NEXT,
563 IMG_EMPTY_SPACE, -1, HA_NEXT,
565 IMG_QUICKSAND_EMPTY, -1, HA_NEXT,
567 IMG_STEELWALL, -1, HA_NEXT,
569 IMG_WALL, -1, HA_NEXT,
571 IMG_WALL_GROWING_ACTIVE_LEFT, 20,
574 IMG_WALL_GROWING_ACTIVE_RIGHT, 20,
577 IMG_WALL_GROWING_ACTIVE_UP, 20,
580 IMG_WALL_GROWING_ACTIVE_DOWN, 20,
582 IMG_EMPTY_SPACE, 20, HA_NEXT,
584 IMG_INVISIBLE_WALL, -1, HA_NEXT,
586 IMG_WALL_CRUMBLED, -1, HA_NEXT,
588 IMG_INFO_FONT_EM_1, 160,
589 IMG_INFO_FONT_EM_2, 160,
590 IMG_INFO_FONT_EM_3, 160,
591 IMG_INFO_FONT_EM_4, 160,
592 IMG_INFO_FONT_EM_5, 40, HA_NEXT,
594 IMG_EMERALD, -1, HA_NEXT,
596 IMG_DIAMOND, -1, HA_NEXT,
598 IMG_BD_DIAMOND, -1, HA_NEXT,
600 IMG_EMERALD_YELLOW, 50,
602 IMG_EMERALD_PURPLE, 50, HA_NEXT,
604 IMG_BD_ROCK, -1, HA_NEXT,
608 IMG_EMPTY_SPACE, 10, HA_NEXT,
612 IMG_EMERALD, 20, HA_NEXT,
614 IMG_WALL_EMERALD, 100,
616 IMG_EMERALD, 20, HA_NEXT,
618 IMG_WALL_DIAMOND, 100,
620 IMG_DIAMOND, 20, HA_NEXT,
622 IMG_WALL_BD_DIAMOND, 100,
624 IMG_BD_DIAMOND, 20, HA_NEXT,
626 IMG_WALL_EMERALD_YELLOW, 100,
628 IMG_EMERALD_YELLOW, 20,
629 IMG_WALL_EMERALD_RED, 100,
632 IMG_WALL_EMERALD_PURPLE, 100,
634 IMG_EMERALD_PURPLE, 20, HA_NEXT,
636 IMG_ACID, -1, HA_NEXT,
641 IMG_KEY4, 50, HA_NEXT,
646 IMG_GATE4, 50, HA_NEXT,
651 IMG_GATE4_GRAY, 50, HA_NEXT,
653 IMG_DYNAMITE, -1, HA_NEXT,
655 IMG_DYNAMITE_ACTIVE, 96,
657 IMG_EMPTY_SPACE, 20, HA_NEXT,
659 IMG_DYNABOMB_ACTIVE, 100,
661 IMG_EMPTY_SPACE, 20, HA_NEXT,
663 IMG_DYNABOMB_NR, -1, HA_NEXT,
665 IMG_DYNABOMB_SZ, -1, HA_NEXT,
667 IMG_SPACESHIP_RIGHT, 16,
668 IMG_SPACESHIP_UP, 16,
669 IMG_SPACESHIP_LEFT, 16,
670 IMG_SPACESHIP_DOWN, 16, HA_NEXT,
675 IMG_BUG_DOWN, 16, HA_NEXT,
677 IMG_BD_BUTTERFLY, -1, HA_NEXT,
679 IMG_BD_FIREFLY, -1, HA_NEXT,
681 IMG_PACMAN_RIGHT, 16,
684 IMG_PACMAN_DOWN, 16, HA_NEXT,
686 IMG_YAMYAM, -1, HA_NEXT,
688 IMG_DARK_YAMYAM, -1, HA_NEXT,
690 IMG_ROBOT, -1, HA_NEXT,
692 IMG_MOLE_RIGHT_MOVING, 16,
693 IMG_MOLE_UP_MOVING, 16,
694 IMG_MOLE_LEFT_MOVING, 16,
695 IMG_MOLE_DOWN_MOVING, 16, HA_NEXT,
697 IMG_PENGUIN_RIGHT_MOVING, 16,
698 IMG_PENGUIN_UP_MOVING, 16,
699 IMG_PENGUIN_LEFT_MOVING, 16,
700 IMG_PENGUIN_DOWN_MOVING, 16, HA_NEXT,
702 IMG_PIG_RIGHT_MOVING, 16,
703 IMG_PIG_UP_MOVING, 16,
704 IMG_PIG_LEFT_MOVING, 16,
705 IMG_PIG_DOWN_MOVING, 16, HA_NEXT,
707 IMG_DRAGON_RIGHT_MOVING, 16,
708 IMG_DRAGON_UP_MOVING, 16,
709 IMG_DRAGON_LEFT_MOVING, 16,
710 IMG_DRAGON_DOWN_MOVING, 16, HA_NEXT,
712 IMG_SATELLITE, -1, HA_NEXT,
715 IMG_ROBOT_WHEEL_ACTIVE, 100, HA_NEXT,
718 IMG_LAMP_ACTIVE, 50, HA_NEXT,
720 IMG_TIME_ORB_FULL, 50,
721 IMG_TIME_ORB_EMPTY, 50, HA_NEXT,
724 IMG_AMOEBA_CREATING, 6,
725 IMG_AMOEBA_WET, 20, HA_NEXT,
727 IMG_AMOEBA_DEAD, -1, HA_NEXT,
729 IMG_AMOEBA_WET, -1, HA_NEXT,
732 IMG_AMOEBA_CREATING, 6, HA_NEXT,
737 IMG_DIAMOND, 20, HA_NEXT,
739 IMG_GAMEOFLIFE, -1, HA_NEXT,
741 IMG_BIOMAZE, -1, HA_NEXT,
743 IMG_MAGIC_WALL_ACTIVE, -1, HA_NEXT,
745 IMG_BD_MAGIC_WALL_ACTIVE, -1, HA_NEXT,
747 IMG_EXIT_CLOSED, 200,
748 IMG_EXIT_OPENING, 16,
749 IMG_EXIT_OPEN, 100, HA_NEXT,
751 IMG_EXIT_OPEN, -1, HA_NEXT,
753 IMG_SOKOBAN_OBJECT, -1, HA_NEXT,
755 IMG_SOKOBAN_FIELD_EMPTY, -1, HA_NEXT,
757 IMG_SOKOBAN_FIELD_FULL, -1, HA_NEXT,
759 IMG_SPEED_PILL, -1, HA_NEXT,
763 static char *helpscreen_eltext[][2] =
765 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
766 {"Normal sand:", "You can dig through it"},
767 {"Empty field:", "You can walk through it"},
768 {"Quicksand: You cannot pass it,", "but rocks can fall through it"},
769 {"Massive Wall:", "Nothing can go through it"},
770 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
771 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
772 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
773 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
774 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
775 {"Emerald: You must collect enough of","them to finish a level"},
776 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
777 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
778 {"Colorful Gems:", "Seem to behave like Emeralds"},
779 {"Rock: Smashes several things;", "Can be moved by the player"},
780 {"Bomb: You can move it, but be", "careful when dropping it"},
781 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
782 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
783 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
784 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
785 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
786 {"Acid: Things that fall in are gone", "forever (including our hero)"},
787 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
788 {"Door: Can be opened by the key", "with the same color"},
789 {"Door: You have to find out the", "right color of the key for it"},
790 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
791 {"Dynamite: This one explodes after", "a few seconds"},
792 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
793 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
794 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
795 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
796 {"Bug: Moves at the right side", "of walls; don't touch it!"},
797 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
798 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
799 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
800 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
801 {"Cruncher (BD style):", "Eats almost everything"},
802 {"Robot: Tries to kill the player", ""},
803 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
804 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
805 {"The Pig: Harmless, but eats all", "gems it can get"},
806 {"The Dragon: Breathes fire,", "especially to some monsters"},
807 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
808 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
809 {"Light Bulb: All of them must be", "switched on to finish a level"},
810 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
811 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
812 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
813 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
814 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
815 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
816 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
817 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
818 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
819 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
820 {"Exit door: Opens if you have enough","emeralds to finish the level"},
821 {"Open exit door: Enter here to leave","the level and exit the actual game"},
822 {"Sokoban element: Object which must", "be pushed to an empty field"},
823 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
824 {"Sokoban element: Field with object", "which can be pushed away"},
825 {"Speed pill: Lets the player run", "twice as fast as normally"},
827 static int num_helpscreen_els = sizeof(helpscreen_eltext) / (2*sizeof(char *));
829 static char *helpscreen_music[][3] =
831 { "Alchemy", "Ian Boddy", "Drive" },
832 { "The Chase", "Propaganda", "A Secret Wish" },
833 { "Network 23", "Tangerine Dream", "Exit" },
834 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
835 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
836 { "Voyager", "The Alan Parsons Project","Pyramid" },
837 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
839 static int num_helpscreen_music = 7;
840 static int helpscreen_musicpos;
843 void OLD_DrawHelpScreenElAction(int start)
847 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
849 while(helpscreen_action[j] != HA_END)
851 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
853 else if (i<start || helpscreen_delay[i-start])
855 if (i>=start && helpscreen_delay[i-start])
856 helpscreen_delay[i-start]--;
858 while(helpscreen_action[j] != HA_NEXT)
865 j += 3*helpscreen_step[i-start];
866 graphic = helpscreen_action[j++];
868 if (helpscreen_frame[i-start])
870 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
871 helpscreen_frame[i-start]--;
876 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
879 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
881 if (helpscreen_action[j] == HA_NEXT)
883 if (!helpscreen_frame[i-start])
884 helpscreen_step[i-start] = 0;
888 if (!helpscreen_frame[i-start])
889 helpscreen_step[i-start]++;
890 while(helpscreen_action[j] != HA_NEXT)
895 DrawOldGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
907 void DrawHelpScreenElAction(int start)
910 int xstart = SX + 16;
911 int ystart = SY + 64 + 2 * 32;
912 int ystep = TILEY + 4;
918 while (helpscreen_action[j] != HA_END)
920 if (i >= start + MAX_HELPSCREEN_ELS || i >= num_helpscreen_els)
924 while (helpscreen_action[j] != HA_NEXT)
933 j += 2 * helpscreen_step[i-start];
934 graphic = helpscreen_action[j++];
935 frame_count = helpscreen_action[j++];
936 if (frame_count == -1)
937 frame_count = 1000000;
939 if (helpscreen_frame[i-start] == 0)
942 helpscreen_frame[i-start] = frame_count - 1;
946 sync_frame = frame_count - helpscreen_frame[i-start];
947 helpscreen_frame[i-start]--;
950 if (helpscreen_action[j] == HA_NEXT)
952 if (!helpscreen_frame[i-start])
953 helpscreen_step[i-start] = 0;
957 if (!helpscreen_frame[i-start])
958 helpscreen_step[i-start]++;
959 while(helpscreen_action[j] != HA_NEXT)
964 frame = getGraphicAnimationFrame(graphic, sync_frame);
966 DrawGraphicExt(drawto, xstart, ystart + (i-start) * ystep,
981 void DrawHelpScreenElText(int start)
984 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
985 int ybottom = SYSIZE - 20;
990 DrawTextFCentered(100, FC_GREEN, "The game elements:");
992 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
995 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
996 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
997 DrawText(xstart, ystart + (i - start) * ystep + 16,
998 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
1001 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
1004 void DrawHelpScreenMusicText(int num)
1006 int ystart = 150, ystep = 30;
1007 int ybottom = SYSIZE - 20;
1013 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
1015 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
1017 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
1018 helpscreen_music[num][0]);
1019 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
1021 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
1022 "%s", helpscreen_music[num][1]);
1023 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
1025 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
1026 helpscreen_music[num][2]);
1028 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
1031 PlaySoundLoop(background_loop[num]);
1035 void DrawHelpScreenCreditsText()
1037 int ystart = 150, ystep = 30;
1038 int ybottom = SYSIZE - 20;
1044 DrawTextFCentered(100, FC_GREEN,
1046 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
1047 "DOS port of the game:");
1048 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
1050 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
1051 "Additional toons:");
1052 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
1054 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
1055 "...and many thanks to all contributors");
1056 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
1059 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
1062 void DrawHelpScreenContactText()
1064 int ystart = 150, ystep = 30;
1065 int ybottom = SYSIZE - 20;
1070 DrawTextFCentered(100, FC_GREEN, "Program information:");
1072 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
1073 "This game is Freeware!");
1074 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
1075 "If you like it, send e-mail to:");
1076 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
1077 "info@artsoft.org");
1078 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
1079 "or SnailMail to:");
1080 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
1082 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
1083 "Detmolder Strasse 189");
1084 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
1086 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
1089 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
1090 "If you have created new levels,");
1091 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
1092 "send them to me to include them!");
1093 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
1096 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
1099 void DrawHelpScreen()
1104 CloseDoor(DOOR_CLOSE_2);
1106 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
1107 helpscreen_step[i] = helpscreen_frame[i] = 0;
1108 helpscreen_musicpos = 0;
1109 helpscreen_state = 0;
1110 DrawHelpScreenElText(0);
1111 DrawHelpScreenElAction(0);
1115 PlaySoundLoop(SND_MENU_INFO_SCREEN);
1118 void HandleHelpScreen(int button)
1120 static unsigned long hs_delay = 0;
1121 int num_helpscreen_els_pages =
1122 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
1123 int button_released = !button;
1126 if (button_released)
1128 if (helpscreen_state < num_helpscreen_els_pages - 1)
1130 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
1131 helpscreen_step[i] = helpscreen_frame[i] = 0;
1135 DrawHelpScreenElText(helpscreen_state * MAX_HELPSCREEN_ELS);
1136 DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS);
1138 else if (helpscreen_state <
1139 num_helpscreen_els_pages + num_helpscreen_music - 1)
1142 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
1144 else if (helpscreen_state ==
1145 num_helpscreen_els_pages + num_helpscreen_music - 1)
1148 DrawHelpScreenCreditsText();
1150 else if (helpscreen_state ==
1151 num_helpscreen_els_pages + num_helpscreen_music)
1154 DrawHelpScreenContactText();
1160 game_status = MAINMENU;
1165 if (DelayReached(&hs_delay, GAME_FRAME_DELAY))
1167 if (helpscreen_state < num_helpscreen_els_pages)
1168 DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS);
1171 /* !!! workaround for playing "music" that is really a sound loop (and
1172 must therefore periodically be reactivated with the current sound
1174 PlaySoundLoop(SND_MENU_INFO_SCREEN);
1182 void HandleTypeName(int newxpos, Key key)
1184 static int xpos = 0, ypos = 2;
1189 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
1190 DrawGraphic(xpos + 6, ypos, IMG_BALL_RED, 0);
1194 if (((key >= KSYM_A && key <= KSYM_Z) ||
1195 (key >= KSYM_a && key <= KSYM_z)) &&
1196 xpos < MAX_PLAYER_NAME_LEN)
1200 if (key >= KSYM_A && key <= KSYM_Z)
1201 ascii = 'A' + (char)(key - KSYM_A);
1203 ascii = 'a' + (char)(key - KSYM_a);
1205 setup.player_name[xpos] = ascii;
1206 setup.player_name[xpos + 1] = 0;
1208 DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
1209 setup.player_name, FS_BIG, FC_YELLOW);
1210 DrawTextExt(window, SX + 6*32, SY + ypos*32,
1211 setup.player_name, FS_BIG, FC_YELLOW);
1212 DrawGraphic(xpos + 6, ypos, IMG_BALL_RED, 0);
1214 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
1217 setup.player_name[xpos] = 0;
1218 DrawGraphic(xpos + 6, ypos, IMG_BALL_RED, 0);
1219 DrawGraphic(xpos + 7, ypos, IMG_EMPTY, 0);
1221 else if (key == KSYM_Return && xpos > 0)
1223 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
1224 DrawGraphic(xpos + 6, ypos, IMG_EMPTY, 0);
1227 game_status = MAINMENU;
1233 static void DrawChooseTree(TreeInfo **ti_ptr)
1236 CloseDoor(DOOR_CLOSE_2);
1239 HandleChooseTree(0,0, 0,0, MB_MENU_INITIALIZE, ti_ptr);
1240 MapChooseTreeGadgets(*ti_ptr);
1246 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
1248 struct GadgetInfo *gi = screen_gadget[id];
1249 int items_max, items_visible, item_position;
1251 items_max = numTreeInfoInGroup(ti);
1252 items_visible = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1253 item_position = first_entry;
1255 if (item_position > items_max - items_visible)
1256 item_position = items_max - items_visible;
1258 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
1259 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
1262 static void drawChooseTreeList(int first_entry, int num_page_entries,
1266 char buffer[SCR_FIELDX * 2];
1267 int max_buffer_len = (SCR_FIELDX - 2) * 2;
1268 int num_entries = numTreeInfoInGroup(ti);
1269 char *title_string = NULL;
1270 int offset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : 16);
1272 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
1273 redraw_mask |= REDRAW_FIELD;
1276 (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Directories" :
1277 ti->type == TREE_TYPE_GRAPHICS_DIR ? "Custom Graphics" :
1278 ti->type == TREE_TYPE_SOUNDS_DIR ? "Custom Sounds" :
1279 ti->type == TREE_TYPE_MUSIC_DIR ? "Custom Music" : "");
1281 DrawText(SX + offset, SY + offset, title_string, FS_BIG,
1282 (ti->type == TREE_TYPE_LEVEL_DIR ? FC_GREEN : FC_YELLOW));
1284 for(i=0; i<num_page_entries; i++)
1286 TreeInfo *node, *node_first;
1287 int entry_pos = first_entry + i;
1288 int ypos = MENU_SCREEN_START_YPOS + i;
1290 node_first = getTreeInfoFirstGroupEntry(ti);
1291 node = getTreeInfoFromPos(node_first, entry_pos);
1293 strncpy(buffer, node->name , max_buffer_len);
1294 buffer[max_buffer_len] = '\0';
1296 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
1298 if (node->parent_link)
1299 initCursor(i, IMG_ARROW_BLUE_LEFT);
1300 else if (node->level_group)
1301 initCursor(i, IMG_ARROW_BLUE_RIGHT);
1303 initCursor(i, IMG_BALL_BLUE);
1306 if (first_entry > 0)
1307 DrawGraphic(0, 1, IMG_ARROW_BLUE_UP, 0);
1309 if (first_entry + num_page_entries < num_entries)
1310 DrawGraphic(0, MAX_MENU_ENTRIES_ON_SCREEN + 1, IMG_ARROW_BLUE_DOWN, 0);
1313 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
1315 TreeInfo *node, *node_first;
1316 int x, last_redraw_mask = redraw_mask;
1318 if (ti->type != TREE_TYPE_LEVEL_DIR)
1321 node_first = getTreeInfoFirstGroupEntry(ti);
1322 node = getTreeInfoFromPos(node_first, entry_pos);
1324 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
1326 if (node->parent_link)
1327 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
1328 else if (node->level_group)
1329 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
1330 else if (ti->type == TREE_TYPE_LEVEL_DIR)
1331 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
1332 node->levels, node->class_desc);
1334 /* let BackToFront() redraw only what is needed */
1335 redraw_mask = last_redraw_mask | REDRAW_TILES;
1336 for (x=0; x<SCR_FIELDX; x++)
1337 MarkTileDirty(x, 1);
1340 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
1343 static unsigned long choose_delay = 0;
1344 TreeInfo *ti = *ti_ptr;
1346 int y = ti->cl_cursor;
1347 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1348 int num_entries = numTreeInfoInGroup(ti);
1349 int num_page_entries;
1351 if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
1352 num_page_entries = num_entries;
1354 num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1356 if (button == MB_MENU_INITIALIZE)
1358 int entry_pos = posTreeInfo(ti);
1360 if (ti->cl_first == -1)
1362 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
1364 entry_pos - ti->cl_first;
1367 if (dx == 999) /* first entry is set by scrollbar position */
1370 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1373 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1374 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1375 drawCursor(ti->cl_cursor, FC_RED);
1378 else if (button == MB_MENU_LEAVE)
1380 if (ti->node_parent)
1382 *ti_ptr = ti->node_parent;
1383 DrawChooseTree(ti_ptr);
1385 else if (game_status == SETUP)
1391 game_status = MAINMENU;
1398 if (mx || my) /* mouse input */
1401 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
1403 else if (dx || dy) /* keyboard input */
1406 y = ti->cl_cursor + dy;
1408 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1411 step = num_page_entries - 1;
1412 y = (dy < 0 ? -1 : num_page_entries);
1416 if (x == 0 && y == -1)
1418 if (ti->cl_first > 0 &&
1419 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1421 ti->cl_first -= step;
1422 if (ti->cl_first < 0)
1425 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1426 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1427 drawCursor(ti->cl_cursor, FC_RED);
1428 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1433 else if (x == 0 && y > num_page_entries - 1)
1435 if (ti->cl_first + num_page_entries < num_entries &&
1436 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1438 ti->cl_first += step;
1439 if (ti->cl_first + num_page_entries > num_entries)
1440 ti->cl_first = MAX(0, num_entries - num_page_entries);
1442 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1443 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1444 drawCursor(ti->cl_cursor, FC_RED);
1445 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1453 TreeInfo *node_first, *node_cursor;
1454 int entry_pos = ti->cl_first + y;
1456 node_first = getTreeInfoFirstGroupEntry(ti);
1457 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
1459 if (node_cursor->node_group)
1461 node_cursor->cl_first = ti->cl_first;
1462 node_cursor->cl_cursor = ti->cl_cursor;
1463 *ti_ptr = node_cursor->node_group;
1464 DrawChooseTree(ti_ptr);
1468 else if (dx == -1 && ti->node_parent)
1470 *ti_ptr = ti->node_parent;
1471 DrawChooseTree(ti_ptr);
1475 if (x == 0 && y >= 0 && y < num_page_entries)
1479 if (y != ti->cl_cursor)
1481 drawCursor(y, FC_RED);
1482 drawCursor(ti->cl_cursor, FC_BLUE);
1483 drawChooseTreeInfo(ti->cl_first + y, ti);
1489 TreeInfo *node_first, *node_cursor;
1490 int entry_pos = ti->cl_first + y;
1492 node_first = getTreeInfoFirstGroupEntry(ti);
1493 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
1495 if (node_cursor->node_group)
1497 node_cursor->cl_first = ti->cl_first;
1498 node_cursor->cl_cursor = ti->cl_cursor;
1499 *ti_ptr = node_cursor->node_group;
1500 DrawChooseTree(ti_ptr);
1502 else if (node_cursor->parent_link)
1504 *ti_ptr = node_cursor->node_parent;
1505 DrawChooseTree(ti_ptr);
1509 node_cursor->cl_first = ti->cl_first;
1510 node_cursor->cl_cursor = ti->cl_cursor;
1511 *ti_ptr = node_cursor;
1513 if (ti->type == TREE_TYPE_LEVEL_DIR)
1515 LoadLevelSetup_SeriesInfo();
1517 SaveLevelSetup_LastSeries();
1518 SaveLevelSetup_SeriesInfo();
1522 if (game_status == SETUP)
1528 game_status = MAINMENU;
1537 if (game_status == CHOOSELEVEL || game_status == SETUP)
1541 void DrawChooseLevel()
1543 DrawChooseTree(&leveldir_current);
1546 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
1548 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
1551 void DrawHallOfFame(int highlight_position)
1555 CloseDoor(DOOR_CLOSE_2);
1557 if (highlight_position < 0)
1558 LoadScore(level_nr);
1562 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1563 PlaySound(SND_MENU_HALL_OF_FAME);
1566 static void drawHallOfFameList(int first_entry, int highlight_position)
1571 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1572 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1574 for(i=0; i<MAX_MENU_ENTRIES_ON_SCREEN; i++)
1576 int entry = first_entry + i;
1577 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1580 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1581 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1582 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1583 int2str(highscore[i].Score, 5), FS_BIG, color);
1585 DrawText(SX, SY + 64 + i * 32, "..................................",
1586 FS_MEDIUM, FC_YELLOW);
1587 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1588 FS_MEDIUM, FC_YELLOW);
1589 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1590 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1591 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1596 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1598 static int first_entry = 0;
1599 static int highlight_position = 0;
1600 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1601 int button_released = !button;
1603 if (button == MB_MENU_INITIALIZE)
1606 highlight_position = mx;
1607 drawHallOfFameList(first_entry, highlight_position);
1611 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1612 step = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1616 if (first_entry > 0)
1618 first_entry -= step;
1619 if (first_entry < 0)
1622 drawHallOfFameList(first_entry, highlight_position);
1628 if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1630 first_entry += step;
1631 if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1632 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN);
1634 drawHallOfFameList(first_entry, highlight_position);
1639 if (button_released)
1641 FadeSound(SND_MENU_HALL_OF_FAME);
1642 game_status = MAINMENU;
1648 if (game_status == HALLOFFAME)
1653 /* ========================================================================= */
1654 /* setup screen functions */
1655 /* ========================================================================= */
1657 static struct TokenInfo *setup_info;
1658 static int num_setup_info;
1660 static char *graphics_set_name;
1661 static char *sounds_set_name;
1662 static char *music_set_name;
1664 static void execSetupMain()
1666 setup_mode = SETUP_MODE_MAIN;
1670 static void execSetupGame()
1672 setup_mode = SETUP_MODE_GAME;
1676 static void execSetupGraphics()
1678 setup_mode = SETUP_MODE_GRAPHICS;
1682 static void execSetupSound()
1684 setup_mode = SETUP_MODE_SOUND;
1688 static void execSetupArtwork()
1690 /* needed if last screen (setup choice) changed graphics, sounds or music */
1691 ReloadCustomArtwork();
1693 setup.graphics_set = artwork.gfx_current->identifier;
1694 setup.sounds_set = artwork.snd_current->identifier;
1695 setup.music_set = artwork.mus_current->identifier;
1697 /* needed for displaying artwork name instead of artwork identifier */
1698 graphics_set_name = artwork.gfx_current->name;
1699 sounds_set_name = artwork.snd_current->name;
1700 music_set_name = artwork.mus_current->name;
1702 setup_mode = SETUP_MODE_ARTWORK;
1706 static void execSetupChooseGraphics()
1708 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
1712 static void execSetupChooseSounds()
1714 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
1718 static void execSetupChooseMusic()
1720 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
1724 static void execSetupInput()
1726 setup_mode = SETUP_MODE_INPUT;
1730 static void execSetupShortcut()
1732 setup_mode = SETUP_MODE_SHORTCUT;
1736 static void execExitSetup()
1738 game_status = MAINMENU;
1742 static void execSaveAndExitSetup()
1748 static struct TokenInfo setup_info_main[] =
1750 { TYPE_ENTER_MENU, execSetupGame, "Game Settings" },
1751 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
1752 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
1753 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
1754 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
1755 { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" },
1756 { TYPE_EMPTY, NULL, "" },
1757 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
1758 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and exit" },
1762 static struct TokenInfo setup_info_game[] =
1764 { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" },
1765 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
1766 { TYPE_SWITCH, &setup.time_limit, "Timelimit:" },
1767 { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" },
1768 { TYPE_EMPTY, NULL, "" },
1769 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1773 static struct TokenInfo setup_info_graphics[] =
1775 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
1776 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
1777 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" },
1779 { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" },
1780 { TYPE_SWITCH, &setup.fading, "Fading:" },
1782 { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" },
1783 { TYPE_SWITCH, &setup.toons, "Toons:" },
1784 { TYPE_EMPTY, NULL, "" },
1785 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1789 static struct TokenInfo setup_info_sound[] =
1791 { TYPE_SWITCH, &setup.sound, "Sound:", },
1792 { TYPE_EMPTY, NULL, "" },
1793 { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" },
1794 { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" },
1795 { TYPE_SWITCH, &setup.sound_music, "Game Music:" },
1796 { TYPE_EMPTY, NULL, "" },
1797 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1801 static struct TokenInfo setup_info_artwork[] =
1803 { TYPE_ENTER_MENU, execSetupChooseGraphics,"Custom Graphics" },
1804 { TYPE_STRING, &graphics_set_name, "" },
1805 { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" },
1806 { TYPE_STRING, &sounds_set_name, "" },
1807 { TYPE_ENTER_MENU, execSetupChooseMusic, "Custom Music" },
1808 { TYPE_STRING, &music_set_name, "" },
1809 { TYPE_EMPTY, NULL, "" },
1810 { TYPE_STRING, NULL, "Override Level Artwork:"},
1811 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
1812 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
1813 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
1814 { TYPE_EMPTY, NULL, "" },
1815 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1819 static struct TokenInfo setup_info_shortcut[] =
1821 { TYPE_KEYTEXT, NULL, "Quick Save Game:", },
1822 { TYPE_KEY, &setup.shortcut.save_game, "" },
1823 { TYPE_KEYTEXT, NULL, "Quick Load Game:", },
1824 { TYPE_KEY, &setup.shortcut.load_game, "" },
1825 { TYPE_KEYTEXT, NULL, "Toggle Pause:", },
1826 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
1827 { TYPE_EMPTY, NULL, "" },
1828 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on Esc:" },
1829 { TYPE_EMPTY, NULL, "" },
1830 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1834 static Key getSetupKey()
1836 Key key = KSYM_UNDEFINED;
1837 boolean got_key_event = FALSE;
1839 while (!got_key_event)
1841 if (PendingEvent()) /* got event */
1849 case EVENT_KEYPRESS:
1851 key = GetEventKey((KeyEvent *)&event, TRUE);
1853 /* press 'Escape' or 'Enter' to keep the existing key binding */
1854 if (key == KSYM_Escape || key == KSYM_Return)
1855 key = KSYM_UNDEFINED; /* keep old value */
1857 got_key_event = TRUE;
1861 case EVENT_KEYRELEASE:
1862 key_joystick_mapping = 0;
1866 HandleOtherEvents(&event);
1874 /* don't eat all CPU time */
1881 static void drawSetupValue(int pos)
1883 int xpos = MENU_SCREEN_VALUE_XPOS;
1884 int ypos = MENU_SCREEN_START_YPOS + pos;
1885 int font_size = FS_BIG;
1886 int font_color = FC_YELLOW;
1887 char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED,
1888 setup_info[pos].value);
1890 if (value_string == NULL)
1893 if (setup_info[pos].type & TYPE_KEY)
1897 if (setup_info[pos].type & TYPE_QUERY)
1899 value_string = "<press key>";
1900 font_color = FC_RED;
1903 else if (setup_info[pos].type & TYPE_STRING)
1905 int max_value_len = (SCR_FIELDX - 2) * 2;
1908 font_size = FS_MEDIUM;
1910 if (strlen(value_string) > max_value_len)
1911 value_string[max_value_len] = '\0';
1913 else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE &&
1914 !*(boolean *)(setup_info[pos].value))
1915 font_color = FC_BLUE;
1917 DrawText(SX + xpos * 32, SY + ypos * 32,
1918 (xpos == 3 ? " " : " "), FS_BIG, FC_YELLOW);
1919 DrawText(SX + xpos * 32, SY + ypos * 32, value_string, font_size,font_color);
1922 static void changeSetupValue(int pos)
1924 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
1926 *(boolean *)setup_info[pos].value ^= TRUE;
1928 else if (setup_info[pos].type & TYPE_KEY)
1932 setup_info[pos].type |= TYPE_QUERY;
1933 drawSetupValue(pos);
1934 setup_info[pos].type &= ~TYPE_QUERY;
1936 key = getSetupKey();
1937 if (key != KSYM_UNDEFINED)
1938 *(Key *)setup_info[pos].value = key;
1941 drawSetupValue(pos);
1944 static void DrawSetupScreen_Generic()
1946 char *title_string = NULL;
1950 CloseDoor(DOOR_CLOSE_2);
1953 if (setup_mode == SETUP_MODE_MAIN)
1955 setup_info = setup_info_main;
1956 title_string = "Setup";
1958 else if (setup_mode == SETUP_MODE_GAME)
1960 setup_info = setup_info_game;
1961 title_string = "Setup Game";
1963 else if (setup_mode == SETUP_MODE_GRAPHICS)
1965 setup_info = setup_info_graphics;
1966 title_string = "Setup Graphics";
1968 else if (setup_mode == SETUP_MODE_SOUND)
1970 setup_info = setup_info_sound;
1971 title_string = "Setup Sound";
1973 else if (setup_mode == SETUP_MODE_ARTWORK)
1975 setup_info = setup_info_artwork;
1976 title_string = "Custom Artwork";
1978 else if (setup_mode == SETUP_MODE_SHORTCUT)
1980 setup_info = setup_info_shortcut;
1981 title_string = "Setup Shortcuts";
1984 DrawText(SX + 16, SY + 16, title_string, FS_BIG, FC_YELLOW);
1987 for(i=0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1989 void *value_ptr = setup_info[i].value;
1990 int ypos = MENU_SCREEN_START_YPOS + i;
1991 int font_size = FS_BIG;
1993 /* set some entries to "unchangeable" according to other variables */
1994 if ((value_ptr == &setup.sound && !audio.sound_available) ||
1995 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
1996 (value_ptr == &setup.sound_music && !audio.music_available) ||
1997 (value_ptr == &setup.fullscreen && !video.fullscreen_available))
1998 setup_info[i].type |= TYPE_GHOSTED;
2000 if (setup_info[i].type & TYPE_STRING)
2001 font_size = FS_MEDIUM;
2003 DrawText(SX + 32, SY + ypos * 32, setup_info[i].text, font_size, FC_GREEN);
2005 if (setup_info[i].type & TYPE_ENTER_MENU)
2006 initCursor(i, IMG_ARROW_BLUE_RIGHT);
2007 else if (setup_info[i].type & TYPE_LEAVE_MENU)
2008 initCursor(i, IMG_ARROW_BLUE_LEFT);
2009 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
2010 initCursor(i, IMG_BALL_BLUE);
2012 if (setup_info[i].type & TYPE_VALUE)
2020 HandleSetupScreen_Generic(0,0,0,0,MB_MENU_INITIALIZE);
2023 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
2025 static int choice_store[MAX_SETUP_MODES];
2026 int choice = choice_store[setup_mode];
2030 if (button == MB_MENU_INITIALIZE)
2032 drawCursor(choice, FC_RED);
2035 else if (button == MB_MENU_LEAVE)
2037 for (y=0; y<num_setup_info; y++)
2039 if (setup_info[y].type & TYPE_LEAVE_MENU)
2041 void (*menu_callback_function)(void) = setup_info[y].value;
2043 menu_callback_function();
2044 break; /* absolutely needed because function changes 'setup_info'! */
2051 if (mx || my) /* mouse input */
2054 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
2056 else if (dx || dy) /* keyboard input */
2060 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU);
2062 if ((setup_info[choice].type & menu_navigation_type) ||
2063 (setup_info[choice].type & TYPE_BOOLEAN_STYLE))
2064 button = MB_MENU_CHOICE;
2069 /* jump to next non-empty menu entry (up or down) */
2070 while (y > 0 && y < num_setup_info - 1 &&
2071 (setup_info[y].type & TYPE_SKIP_ENTRY))
2075 if (x == 0 && y >= 0 && y < num_setup_info &&
2076 (setup_info[y].type & ~TYPE_SKIP_ENTRY))
2082 drawCursor(y, FC_RED);
2083 drawCursor(choice, FC_BLUE);
2084 choice = choice_store[setup_mode] = y;
2087 else if (!(setup_info[y].type & TYPE_GHOSTED))
2089 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
2091 void (*menu_callback_function)(void) = setup_info[choice].value;
2093 menu_callback_function();
2097 if ((setup_info[y].type & TYPE_KEYTEXT) &&
2098 (setup_info[y + 1].type & TYPE_KEY))
2101 if (setup_info[y].type & TYPE_VALUE)
2102 changeSetupValue(y);
2109 if (game_status == SETUP)
2113 void DrawSetupScreen_Input()
2116 DrawText(SX+16, SY+16, "Setup Input", FS_BIG, FC_YELLOW);
2118 initCursor(0, IMG_BALL_BLUE);
2119 initCursor(1, IMG_BALL_BLUE);
2120 initCursor(2, IMG_ARROW_BLUE_RIGHT);
2121 initCursor(13, IMG_ARROW_BLUE_LEFT);
2123 DrawGraphic(10, MENU_SCREEN_START_YPOS, IMG_ARROW_BLUE_LEFT, 0);
2124 DrawGraphic(12, MENU_SCREEN_START_YPOS, IMG_ARROW_BLUE_RIGHT, 0);
2126 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
2127 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
2128 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
2131 DeactivateJoystickForCalibration();
2132 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
2133 "Joysticks deactivated on this screen");
2136 HandleSetupScreen_Input(0,0, 0,0, MB_MENU_INITIALIZE);
2141 static void setJoystickDeviceToNr(char *device_name, int device_nr)
2143 if (device_name == NULL)
2146 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
2149 if (strlen(device_name) > 1)
2151 char c1 = device_name[strlen(device_name) - 1];
2152 char c2 = device_name[strlen(device_name) - 2];
2154 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
2155 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
2158 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
2159 strlen(device_name));
2162 static void drawPlayerSetupInputInfo(int player_nr)
2165 static struct SetupKeyboardInfo custom_key;
2172 { &custom_key.left, "Joystick Left" },
2173 { &custom_key.right, "Joystick Right" },
2174 { &custom_key.up, "Joystick Up" },
2175 { &custom_key.down, "Joystick Down" },
2176 { &custom_key.snap, "Button 1" },
2177 { &custom_key.bomb, "Button 2" }
2179 static char *joystick_name[MAX_PLAYERS] =
2187 custom_key = setup.input[player_nr].key;
2189 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
2190 DrawGraphic(8, 2, PLAYER_NR_GFX(IMG_PLAYER1, player_nr), 0);
2192 if (setup.input[player_nr].use_joystick)
2194 char *device_name = setup.input[player_nr].joy.device_name;
2196 DrawText(SX+8*32, SY+3*32,
2197 joystick_name[getJoystickNrFromDeviceName(device_name)],
2199 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
2203 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
2204 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
2207 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
2208 DrawGraphic(1, 6, IMG_ARROW_BLUE_LEFT, 0);
2209 DrawGraphic(1, 7, IMG_ARROW_BLUE_RIGHT, 0);
2210 DrawGraphic(1, 8, IMG_ARROW_BLUE_UP, 0);
2211 DrawGraphic(1, 9, IMG_ARROW_BLUE_DOWN, 0);
2212 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
2213 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
2214 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
2215 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
2216 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
2217 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
2221 int ypos = 6 + i + (i > 3 ? i-3 : 0);
2223 DrawText(SX + 3*32, SY + ypos*32,
2224 " ", FS_BIG, FC_YELLOW);
2225 DrawText(SX + 3*32, SY + ypos*32,
2226 (setup.input[player_nr].use_joystick ?
2228 getKeyNameFromKey(*custom[i].key)),
2233 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
2235 static int choice = 0;
2236 static int player_nr = 0;
2239 int pos_start = SETUPINPUT_SCREEN_POS_START;
2240 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
2241 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
2242 int pos_end = SETUPINPUT_SCREEN_POS_END;
2244 if (button == MB_MENU_INITIALIZE)
2246 drawPlayerSetupInputInfo(player_nr);
2247 drawCursor(choice, FC_RED);
2250 else if (button == MB_MENU_LEAVE)
2252 setup_mode = SETUP_MODE_MAIN;
2257 if (mx || my) /* mouse input */
2260 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
2262 else if (dx || dy) /* keyboard input */
2264 if (dx && choice == 0)
2265 x = (dx < 0 ? 10 : 12);
2266 else if ((dx && choice == 1) ||
2267 (dx == +1 && choice == 2) ||
2268 (dx == -1 && choice == pos_end))
2269 button = MB_MENU_CHOICE;
2273 if (y >= pos_empty1 && y <= pos_empty2)
2274 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
2277 if (y == 0 && ((x == 0 && !button) || ((x == 10 || x == 12) && button)))
2279 static unsigned long delay = 0;
2281 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
2284 player_nr = (player_nr + (x == 10 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
2286 drawPlayerSetupInputInfo(player_nr);
2288 else if (x == 0 && y >= pos_start && y <= pos_end &&
2289 !(y >= pos_empty1 && y <= pos_empty2))
2295 drawCursor(y, FC_RED);
2296 drawCursor(choice, FC_BLUE);
2304 char *device_name = setup.input[player_nr].joy.device_name;
2306 if (!setup.input[player_nr].use_joystick)
2308 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
2310 setJoystickDeviceToNr(device_name, new_device_nr);
2311 setup.input[player_nr].use_joystick = TRUE;
2315 int device_nr = getJoystickNrFromDeviceName(device_name);
2316 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
2318 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
2319 setup.input[player_nr].use_joystick = FALSE;
2321 setJoystickDeviceToNr(device_name, new_device_nr);
2324 drawPlayerSetupInputInfo(player_nr);
2328 if (setup.input[player_nr].use_joystick)
2331 CalibrateJoystick(player_nr);
2334 CustomizeKeyboard(player_nr);
2336 else if (y == pos_end)
2340 setup_mode = SETUP_MODE_MAIN;
2350 if (game_status == SETUP)
2354 void CustomizeKeyboard(int player_nr)
2358 boolean finished = FALSE;
2359 static struct SetupKeyboardInfo custom_key;
2364 } customize_step[] =
2366 { &custom_key.left, "Move Left" },
2367 { &custom_key.right, "Move Right" },
2368 { &custom_key.up, "Move Up" },
2369 { &custom_key.down, "Move Down" },
2370 { &custom_key.snap, "Snap Field" },
2371 { &custom_key.bomb, "Place Bomb" }
2374 /* read existing key bindings from player setup */
2375 custom_key = setup.input[player_nr].key;
2378 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
2384 DrawText(SX, SY + (2+2*step_nr)*32,
2385 customize_step[step_nr].text, FS_BIG, FC_RED);
2386 DrawText(SX, SY + (2+2*step_nr+1)*32,
2387 "Key:", FS_BIG, FC_RED);
2388 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
2389 getKeyNameFromKey(*customize_step[step_nr].key),
2394 if (PendingEvent()) /* got event */
2402 case EVENT_KEYPRESS:
2404 Key key = GetEventKey((KeyEvent *)&event, FALSE);
2406 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
2412 /* all keys configured -- wait for "Escape" or "Return" key */
2416 /* press 'Enter' to keep the existing key binding */
2417 if (key == KSYM_Return)
2418 key = *customize_step[step_nr].key;
2420 /* check if key already used */
2421 for (i=0; i<step_nr; i++)
2422 if (*customize_step[i].key == key)
2427 /* got new key binding */
2428 *customize_step[step_nr].key = key;
2429 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
2430 " ", FS_BIG, FC_YELLOW);
2431 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
2432 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
2435 /* un-highlight last query */
2436 DrawText(SX, SY+(2+2*(step_nr-1))*32,
2437 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
2438 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
2439 "Key:", FS_BIG, FC_GREEN);
2441 /* press 'Enter' to leave */
2444 DrawText(SX + 16, SY + 15*32+16,
2445 "Press Enter", FS_BIG, FC_YELLOW);
2449 /* query next key binding */
2450 DrawText(SX, SY+(2+2*step_nr)*32,
2451 customize_step[step_nr].text, FS_BIG, FC_RED);
2452 DrawText(SX, SY+(2+2*step_nr+1)*32,
2453 "Key:", FS_BIG, FC_RED);
2454 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
2455 getKeyNameFromKey(*customize_step[step_nr].key),
2460 case EVENT_KEYRELEASE:
2461 key_joystick_mapping = 0;
2465 HandleOtherEvents(&event);
2473 /* don't eat all CPU time */
2477 /* write new key bindings back to player setup */
2478 setup.input[player_nr].key = custom_key;
2481 DrawSetupScreen_Input();
2484 static boolean CalibrateJoystickMain(int player_nr)
2486 int new_joystick_xleft = JOYSTICK_XMIDDLE;
2487 int new_joystick_xright = JOYSTICK_XMIDDLE;
2488 int new_joystick_yupper = JOYSTICK_YMIDDLE;
2489 int new_joystick_ylower = JOYSTICK_YMIDDLE;
2490 int new_joystick_xmiddle, new_joystick_ymiddle;
2492 int joystick_fd = joystick.fd[player_nr];
2493 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2494 boolean check[3][3];
2495 int check_remaining = 3 * 3;
2500 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
2503 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
2512 check[x][y] = FALSE;
2513 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_BALL_BLUE, 0);
2517 DrawText(SX, SY + 6 * 32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2518 DrawText(SX, SY + 7 * 32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2519 DrawText(SX + 16, SY + 9 * 32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2520 DrawText(SX, SY + 10 * 32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2521 DrawText(SX, SY + 11 * 32, " CENTER JOYSTICK ", FS_BIG, FC_YELLOW);
2522 DrawText(SX, SY + 12 * 32, " AND ", FS_BIG, FC_YELLOW);
2523 DrawText(SX, SY + 13 * 32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2525 joy_value = Joystick(player_nr);
2526 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2527 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2529 /* eventually uncalibrated center position (joystick could be uncentered) */
2530 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2533 new_joystick_xmiddle = joy_x;
2534 new_joystick_ymiddle = joy_y;
2536 DrawGraphic(xpos + last_x, ypos + last_y, IMG_BALL_RED, 0);
2539 while(Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
2544 if (PendingEvent()) /* got event */
2552 case EVENT_KEYPRESS:
2553 switch(GetEventKey((KeyEvent *)&event, TRUE))
2556 if (check_remaining == 0)
2569 case EVENT_KEYRELEASE:
2570 key_joystick_mapping = 0;
2574 HandleOtherEvents(&event);
2579 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2582 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
2583 new_joystick_xright = MAX(new_joystick_xright, joy_x);
2584 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
2585 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
2587 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2588 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2589 setup.input[player_nr].joy.xright = new_joystick_xright;
2590 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2591 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2592 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2594 CheckJoystickData();
2596 joy_value = Joystick(player_nr);
2598 if (joy_value & JOY_BUTTON && check_remaining == 0)
2601 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2602 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2604 if (x != last_x || y != last_y)
2606 DrawGraphic(xpos + last_x, ypos + last_y, IMG_BALL_YELLOW, 0);
2607 DrawGraphic(xpos + x, ypos + y, IMG_BALL_RED, 0);
2612 if (check_remaining > 0 && !check[x+1][y+1])
2614 check[x+1][y+1] = TRUE;
2620 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2621 setup.input[player_nr].joy.xleft,
2622 setup.input[player_nr].joy.xmiddle,
2623 setup.input[player_nr].joy.xright);
2624 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2625 setup.input[player_nr].joy.yupper,
2626 setup.input[player_nr].joy.ymiddle,
2627 setup.input[player_nr].joy.ylower);
2636 /* don't eat all CPU time */
2640 /* calibrated center position (joystick should now be centered) */
2641 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2644 new_joystick_xmiddle = joy_x;
2645 new_joystick_ymiddle = joy_y;
2649 DrawSetupScreen_Input();
2651 /* wait until the last pressed button was released */
2652 while (Joystick(player_nr) & JOY_BUTTON)
2654 if (PendingEvent()) /* got event */
2659 HandleOtherEvents(&event);
2668 void CalibrateJoystick(int player_nr)
2670 if (!CalibrateJoystickMain(player_nr))
2674 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2675 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2677 Delay(2000); /* show error message for two seconds */
2681 void DrawSetupScreen()
2683 DeactivateJoystick();
2685 if (setup_mode == SETUP_MODE_INPUT)
2686 DrawSetupScreen_Input();
2687 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
2688 DrawChooseTree(&artwork.gfx_current);
2689 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
2690 DrawChooseTree(&artwork.snd_current);
2691 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
2692 DrawChooseTree(&artwork.mus_current);
2694 DrawSetupScreen_Generic();
2697 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
2699 if (setup_mode == SETUP_MODE_INPUT)
2700 HandleSetupScreen_Input(mx, my, dx, dy, button);
2701 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
2702 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
2703 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
2704 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
2705 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
2706 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
2708 HandleSetupScreen_Generic(mx, my, dx, dy, button);
2711 void HandleGameActions()
2713 if (game_status != PLAYING)
2716 if (local_player->LevelSolved)
2719 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2727 /* ---------- new screen button stuff -------------------------------------- */
2729 /* graphic position and size values for buttons and scrollbars */
2730 #define SC_SCROLLBUTTON_XSIZE 32
2731 #define SC_SCROLLBUTTON_YSIZE 32
2733 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2734 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2735 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2736 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2737 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2738 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2739 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2740 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2742 #define SC_BORDER_SIZE 14
2746 int gfx_unpressed, gfx_pressed;
2750 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2753 IMG_ARROW_BLUE_UP, IMG_ARROW_RED_UP,
2754 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2755 SCREEN_CTRL_ID_SCROLL_UP,
2759 IMG_ARROW_BLUE_DOWN, IMG_ARROW_RED_DOWN,
2760 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2761 SCREEN_CTRL_ID_SCROLL_DOWN,
2768 int gfx_unpressed, gfx_pressed;
2774 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2777 IMG_SCROLLBAR_BLUE, IMG_SCROLLBAR_RED,
2778 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2779 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2780 GD_TYPE_SCROLLBAR_VERTICAL,
2781 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2782 "scroll level series vertically"
2786 static void CreateScreenScrollbuttons()
2788 struct GadgetInfo *gi;
2789 unsigned long event_mask;
2792 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2794 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
2795 int gfx_unpressed, gfx_pressed;
2796 int x, y, width, height;
2797 int gd_x1, gd_x2, gd_y1, gd_y2;
2798 int id = scrollbutton_info[i].gadget_id;
2800 x = scrollbutton_info[i].x;
2801 y = scrollbutton_info[i].y;
2803 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2807 width = SC_SCROLLBUTTON_XSIZE;
2808 height = SC_SCROLLBUTTON_YSIZE;
2810 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
2811 gfx_pressed = scrollbutton_info[i].gfx_pressed;
2812 gd_bitmap_unpressed = new_graphic_info[gfx_unpressed].bitmap;
2813 gd_bitmap_pressed = new_graphic_info[gfx_pressed].bitmap;
2814 gd_x1 = new_graphic_info[gfx_unpressed].src_x;
2815 gd_y1 = new_graphic_info[gfx_unpressed].src_y;
2816 gd_x2 = new_graphic_info[gfx_pressed].src_x;
2817 gd_y2 = new_graphic_info[gfx_pressed].src_y;
2819 gi = CreateGadget(GDI_CUSTOM_ID, id,
2820 GDI_CUSTOM_TYPE_ID, i,
2821 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2826 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2827 GDI_STATE, GD_BUTTON_UNPRESSED,
2828 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
2829 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
2830 GDI_EVENT_MASK, event_mask,
2831 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2835 Error(ERR_EXIT, "cannot create gadget");
2837 screen_gadget[id] = gi;
2841 static void CreateScreenScrollbars()
2845 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2847 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
2848 int gfx_unpressed, gfx_pressed;
2849 int gd_x1, gd_x2, gd_y1, gd_y2;
2850 struct GadgetInfo *gi;
2851 int items_max, items_visible, item_position;
2852 unsigned long event_mask;
2853 int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
2854 int id = scrollbar_info[i].gadget_id;
2856 items_max = num_page_entries;
2857 items_visible = num_page_entries;
2860 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2862 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
2863 gfx_pressed = scrollbar_info[i].gfx_pressed;
2864 gd_bitmap_unpressed = new_graphic_info[gfx_unpressed].bitmap;
2865 gd_bitmap_pressed = new_graphic_info[gfx_pressed].bitmap;
2866 gd_x1 = new_graphic_info[gfx_unpressed].src_x;
2867 gd_y1 = new_graphic_info[gfx_unpressed].src_y;
2868 gd_x2 = new_graphic_info[gfx_pressed].src_x;
2869 gd_y2 = new_graphic_info[gfx_pressed].src_y;
2871 gi = CreateGadget(GDI_CUSTOM_ID, id,
2872 GDI_CUSTOM_TYPE_ID, i,
2873 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2874 GDI_X, scrollbar_info[i].x,
2875 GDI_Y, scrollbar_info[i].y,
2876 GDI_WIDTH, scrollbar_info[i].width,
2877 GDI_HEIGHT, scrollbar_info[i].height,
2878 GDI_TYPE, scrollbar_info[i].type,
2879 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2880 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2881 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2882 GDI_STATE, GD_BUTTON_UNPRESSED,
2883 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
2884 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
2885 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2886 GDI_EVENT_MASK, event_mask,
2887 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2891 Error(ERR_EXIT, "cannot create gadget");
2893 screen_gadget[id] = gi;
2897 void CreateScreenGadgets()
2899 CreateScreenScrollbuttons();
2900 CreateScreenScrollbars();
2903 void MapChooseTreeGadgets(TreeInfo *ti)
2905 int num_entries = numTreeInfoInGroup(ti);
2908 if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
2911 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2912 MapGadget(screen_gadget[i]);
2915 void UnmapChooseTreeGadgets()
2919 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2920 UnmapGadget(screen_gadget[i]);
2923 static void HandleScreenGadgets(struct GadgetInfo *gi)
2925 int id = gi->custom_id;
2927 if (game_status != CHOOSELEVEL && game_status != SETUP)
2932 case SCREEN_CTRL_ID_SCROLL_UP:
2933 if (game_status == CHOOSELEVEL)
2934 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2935 else if (game_status == SETUP)
2936 HandleSetupScreen(SX,SY + 32, 0,0, MB_MENU_MARK);
2939 case SCREEN_CTRL_ID_SCROLL_DOWN:
2940 if (game_status == CHOOSELEVEL)
2941 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2942 else if (game_status == SETUP)
2943 HandleSetupScreen(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2946 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2947 if (game_status == CHOOSELEVEL)
2948 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
2949 else if (game_status == SETUP)
2950 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);