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);
243 static void gotoTopLevelDir()
245 /* move upwards to top level directory */
246 while (leveldir_current->node_parent)
248 /* write a "path" into level tree for easy navigation to last level */
249 if (leveldir_current->node_parent->node_group->cl_first == -1)
251 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
252 int leveldir_pos = posTreeInfo(leveldir_current);
253 int num_page_entries;
254 int cl_first, cl_cursor;
256 if (num_leveldirs <= MAX_MENU_ENTRIES_ON_SCREEN)
257 num_page_entries = num_leveldirs;
259 num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
261 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
262 cl_cursor = leveldir_pos - cl_first;
264 leveldir_current->node_parent->node_group->cl_first = cl_first;
265 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
268 leveldir_current = leveldir_current->node_parent;
272 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
274 static int choice = 0;
278 if (button == MB_MENU_INITIALIZE)
280 drawCursor(choice, FC_RED);
284 if (mx || my) /* mouse input */
287 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
289 else if (dx || dy) /* keyboard input */
291 if (dx && choice == 1)
292 x = (dx < 0 ? 10 : 14);
297 if (y == 1 && ((x == 10 && level_nr > leveldir_current->first_level) ||
298 (x == 14 && level_nr < leveldir_current->last_level)) &&
301 static unsigned long level_delay = 0;
302 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
303 int new_level_nr, old_level_nr = level_nr;
304 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
306 new_level_nr = level_nr + (x == 10 ? -step : +step);
307 if (new_level_nr < leveldir_current->first_level)
308 new_level_nr = leveldir_current->first_level;
309 if (new_level_nr > leveldir_current->last_level)
310 new_level_nr = leveldir_current->last_level;
312 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
313 new_level_nr = leveldir_current->handicap_level;
315 if (old_level_nr == new_level_nr ||
316 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
319 level_nr = new_level_nr;
321 DrawTextExt(drawto, SX + 11 * 32, SY + 3 * 32,
322 int2str(level_nr, 3), FS_BIG, font_color);
323 DrawTextExt(window, SX + 11 * 32, SY + 3 * 32,
324 int2str(level_nr, 3), FS_BIG, font_color);
327 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
331 DrawCompleteVideoDisplay();
333 /* needed because DrawMicroLevel() takes some time */
336 DelayReached(&level_delay, 0); /* reset delay counter */
338 else if (x == 0 && y >= 0 && y <= 7)
344 drawCursor(y, FC_RED);
345 drawCursor(choice, FC_BLUE);
353 game_status = TYPENAME;
354 HandleTypeName(strlen(setup.player_name), 0);
360 game_status = CHOOSELEVEL;
361 SaveLevelSetup_LastSeries();
362 SaveLevelSetup_SeriesInfo();
371 game_status = HALLOFFAME;
376 if (leveldir_current->readonly &&
377 strcmp(setup.player_name, "Artsoft") != 0)
378 Request("This level is read only !", REQ_CONFIRM);
379 game_status = LEVELED;
384 game_status = HELPSCREEN;
389 if (setup.autorecord)
390 TapeStartRecording();
392 #if defined(PLATFORM_UNIX)
394 SendToServer_StartPlaying();
398 game_status = PLAYING;
406 setup_mode = SETUP_MODE_MAIN;
411 SaveLevelSetup_LastSeries();
412 SaveLevelSetup_SeriesInfo();
413 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
414 game_status = EXITGAME;
423 if (game_status == MAINMENU)
425 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
431 #define MAX_HELPSCREEN_ELS 10
435 static long helpscreen_state;
436 static int helpscreen_step[MAX_HELPSCREEN_ELS];
437 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
439 static int OLD_helpscreen_action[] =
441 GFX_SPIELER1_DOWN,4,2,
443 GFX_SPIELER1_LEFT,4,2,
444 GFX_SPIELER1_RIGHT,4,2,
445 GFX_SPIELER1_PUSH_LEFT,4,2,
446 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
447 GFX_ERDREICH,1,100, HA_NEXT,
448 GFX_LEERRAUM,1,100, HA_NEXT,
449 GFX_MORAST_LEER,1,100, HA_NEXT,
450 GFX_BETON,1,100, HA_NEXT,
451 GFX_MAUERWERK,1,100, HA_NEXT,
452 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
453 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
454 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
455 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
456 GFX_UNSICHTBAR,1,100, HA_NEXT,
457 GFX_FELSBODEN,1,100, HA_NEXT,
458 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
459 GFX_EDELSTEIN,2,5, HA_NEXT,
460 GFX_DIAMANT,2,5, HA_NEXT,
461 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
462 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
463 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
464 GFX_FELSBROCKEN,4,5, HA_NEXT,
465 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
466 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
467 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
468 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
469 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
470 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
471 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
472 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
473 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
474 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
475 GFX_GEBLUBBER,4,4, HA_NEXT,
476 GFX_SCHLUESSEL1,4,25, HA_NEXT,
477 GFX_PFORTE1,4,25, HA_NEXT,
478 GFX_PFORTE1X,4,25, HA_NEXT,
479 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
480 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
481 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
482 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
483 GFX_LEERRAUM,1,10, HA_NEXT,
484 GFX_DYNABOMB_NR,1,100, HA_NEXT,
485 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
486 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
487 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
488 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
489 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
490 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
491 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
492 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
493 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
494 GFX_BUTTERFLY,2,2, HA_NEXT,
495 GFX_FIREFLY,2,2, HA_NEXT,
496 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
497 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
498 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
499 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
500 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
501 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
502 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
503 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
504 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
505 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
509 GFX_MOLE_RIGHT,4,2, HA_NEXT,
510 GFX_PINGUIN_DOWN,4,2,
512 GFX_PINGUIN_LEFT,4,2,
513 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
514 GFX_SCHWEIN_DOWN,4,2,
516 GFX_SCHWEIN_LEFT,4,2,
517 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
521 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
522 GFX_SONDE_START,8,1, HA_NEXT,
523 GFX_ABLENK,4,1, HA_NEXT,
524 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
525 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
526 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
527 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
528 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
529 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
530 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
531 GFX_DIAMANT,1,10, HA_NEXT,
532 GFX_LIFE,1,100, HA_NEXT,
533 GFX_LIFE_ASYNC,1,100, HA_NEXT,
534 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
535 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
536 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
537 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
538 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
539 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
540 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
541 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
542 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
543 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
544 GFX_SPEED_PILL,1,100, HA_NEXT,
549 static int helpscreen_action[] =
551 IMG_PLAYER1_DOWN_MOVING, 16,
552 IMG_PLAYER1_UP_MOVING, 16,
553 IMG_PLAYER1_LEFT_MOVING, 16,
554 IMG_PLAYER1_RIGHT_MOVING, 16,
555 IMG_PLAYER1_LEFT_PUSHING, 16,
556 IMG_PLAYER1_RIGHT_PUSHING, 16, HA_NEXT,
558 IMG_SAND, -1, HA_NEXT,
560 IMG_EMPTY_SPACE, -1, HA_NEXT,
562 IMG_QUICKSAND_EMPTY, -1, HA_NEXT,
564 IMG_STEELWALL, -1, HA_NEXT,
566 IMG_WALL, -1, HA_NEXT,
568 IMG_WALL_GROWING_ACTIVE_LEFT, 20,
571 IMG_WALL_GROWING_ACTIVE_RIGHT, 20,
574 IMG_WALL_GROWING_ACTIVE_UP, 20,
577 IMG_WALL_GROWING_ACTIVE_DOWN, 20,
579 IMG_EMPTY_SPACE, 20, HA_NEXT,
581 IMG_INVISIBLE_WALL, -1, HA_NEXT,
583 IMG_WALL_CRUMBLED, -1, HA_NEXT,
585 IMG_INFO_FONT_EM_1, 160,
586 IMG_INFO_FONT_EM_2, 160,
587 IMG_INFO_FONT_EM_3, 160,
588 IMG_INFO_FONT_EM_4, 160,
589 IMG_INFO_FONT_EM_5, 40, HA_NEXT,
591 IMG_EMERALD, -1, HA_NEXT,
593 IMG_DIAMOND, -1, HA_NEXT,
595 IMG_BD_DIAMOND, -1, HA_NEXT,
597 IMG_EMERALD_YELLOW, 50,
599 IMG_EMERALD_PURPLE, 50, HA_NEXT,
601 IMG_BD_ROCK, -1, HA_NEXT,
605 IMG_EMPTY_SPACE, 10, HA_NEXT,
609 IMG_EMERALD, 20, HA_NEXT,
611 IMG_WALL_EMERALD, 100,
613 IMG_EMERALD, 20, HA_NEXT,
615 IMG_WALL_DIAMOND, 100,
617 IMG_DIAMOND, 20, HA_NEXT,
619 IMG_WALL_BD_DIAMOND, 100,
621 IMG_BD_DIAMOND, 20, HA_NEXT,
623 IMG_WALL_EMERALD_YELLOW, 100,
625 IMG_EMERALD_YELLOW, 20,
626 IMG_WALL_EMERALD_RED, 100,
629 IMG_WALL_EMERALD_PURPLE, 100,
631 IMG_EMERALD_PURPLE, 20, HA_NEXT,
633 IMG_ACID, -1, HA_NEXT,
638 IMG_KEY4, 50, HA_NEXT,
643 IMG_GATE4, 50, HA_NEXT,
648 IMG_GATE4_GRAY, 50, HA_NEXT,
650 IMG_DYNAMITE, -1, HA_NEXT,
652 IMG_DYNAMITE_ACTIVE, 96,
654 IMG_EMPTY_SPACE, 20, HA_NEXT,
656 IMG_DYNABOMB_ACTIVE, 100,
658 IMG_EMPTY_SPACE, 20, HA_NEXT,
660 IMG_DYNABOMB_NR, -1, HA_NEXT,
662 IMG_DYNABOMB_SZ, -1, HA_NEXT,
664 IMG_SPACESHIP_RIGHT, 16,
665 IMG_SPACESHIP_UP, 16,
666 IMG_SPACESHIP_LEFT, 16,
667 IMG_SPACESHIP_DOWN, 16, HA_NEXT,
672 IMG_BUG_DOWN, 16, HA_NEXT,
674 IMG_BD_BUTTERFLY, -1, HA_NEXT,
676 IMG_BD_FIREFLY, -1, HA_NEXT,
678 IMG_PACMAN_RIGHT, 16,
681 IMG_PACMAN_DOWN, 16, HA_NEXT,
683 IMG_YAMYAM, -1, HA_NEXT,
685 IMG_DARK_YAMYAM, -1, HA_NEXT,
687 IMG_ROBOT, -1, HA_NEXT,
689 IMG_MOLE_RIGHT_MOVING, 16,
690 IMG_MOLE_UP_MOVING, 16,
691 IMG_MOLE_LEFT_MOVING, 16,
692 IMG_MOLE_DOWN_MOVING, 16, HA_NEXT,
694 IMG_PENGUIN_RIGHT_MOVING, 16,
695 IMG_PENGUIN_UP_MOVING, 16,
696 IMG_PENGUIN_LEFT_MOVING, 16,
697 IMG_PENGUIN_DOWN_MOVING, 16, HA_NEXT,
699 IMG_PIG_RIGHT_MOVING, 16,
700 IMG_PIG_UP_MOVING, 16,
701 IMG_PIG_LEFT_MOVING, 16,
702 IMG_PIG_DOWN_MOVING, 16, HA_NEXT,
704 IMG_DRAGON_RIGHT_MOVING, 16,
705 IMG_DRAGON_UP_MOVING, 16,
706 IMG_DRAGON_LEFT_MOVING, 16,
707 IMG_DRAGON_DOWN_MOVING, 16, HA_NEXT,
709 IMG_SATELLITE, -1, HA_NEXT,
712 IMG_ROBOT_WHEEL_ACTIVE, 100, HA_NEXT,
715 IMG_LAMP_ACTIVE, 50, HA_NEXT,
717 IMG_TIME_ORB_FULL, 50,
718 IMG_TIME_ORB_EMPTY, 50, HA_NEXT,
721 IMG_AMOEBA_CREATING, 6,
722 IMG_AMOEBA_WET, 20, HA_NEXT,
724 IMG_AMOEBA_DEAD, -1, HA_NEXT,
726 IMG_AMOEBA_WET, -1, HA_NEXT,
729 IMG_AMOEBA_CREATING, 6, HA_NEXT,
734 IMG_DIAMOND, 20, HA_NEXT,
736 IMG_GAMEOFLIFE, -1, HA_NEXT,
738 IMG_BIOMAZE, -1, HA_NEXT,
740 IMG_MAGIC_WALL_ACTIVE, -1, HA_NEXT,
742 IMG_BD_MAGIC_WALL_ACTIVE, -1, HA_NEXT,
744 IMG_EXIT_CLOSED, 200,
745 IMG_EXIT_OPENING, 16,
746 IMG_EXIT_OPEN, 100, HA_NEXT,
748 IMG_EXIT_OPEN, -1, HA_NEXT,
750 IMG_SOKOBAN_OBJECT, -1, HA_NEXT,
752 IMG_SOKOBAN_FIELD_EMPTY, -1, HA_NEXT,
754 IMG_SOKOBAN_FIELD_FULL, -1, HA_NEXT,
756 IMG_SPEED_PILL, -1, HA_NEXT,
760 static char *helpscreen_eltext[][2] =
762 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
763 {"Normal sand:", "You can dig through it"},
764 {"Empty field:", "You can walk through it"},
765 {"Quicksand: You cannot pass it,", "but rocks can fall through it"},
766 {"Massive Wall:", "Nothing can go through it"},
767 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
768 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
769 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
770 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
771 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
772 {"Emerald: You must collect enough of","them to finish a level"},
773 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
774 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
775 {"Colorful Gems:", "Seem to behave like Emeralds"},
776 {"Rock: Smashes several things;", "Can be moved by the player"},
777 {"Bomb: You can move it, but be", "careful when dropping it"},
778 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
779 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
780 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
781 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
782 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
783 {"Acid: Things that fall in are gone", "forever (including our hero)"},
784 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
785 {"Door: Can be opened by the key", "with the same color"},
786 {"Door: You have to find out the", "right color of the key for it"},
787 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
788 {"Dynamite: This one explodes after", "a few seconds"},
789 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
790 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
791 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
792 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
793 {"Bug: Moves at the right side", "of walls; don't touch it!"},
794 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
795 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
796 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
797 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
798 {"Cruncher (BD style):", "Eats almost everything"},
799 {"Robot: Tries to kill the player", ""},
800 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
801 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
802 {"The Pig: Harmless, but eats all", "gems it can get"},
803 {"The Dragon: Breathes fire,", "especially to some monsters"},
804 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
805 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
806 {"Light Bulb: All of them must be", "switched on to finish a level"},
807 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
808 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
809 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
810 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
811 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
812 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
813 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
814 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
815 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
816 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
817 {"Exit door: Opens if you have enough","emeralds to finish the level"},
818 {"Open exit door: Enter here to leave","the level and exit the actual game"},
819 {"Sokoban element: Object which must", "be pushed to an empty field"},
820 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
821 {"Sokoban element: Field with object", "which can be pushed away"},
822 {"Speed pill: Lets the player run", "twice as fast as normally"},
824 static int num_helpscreen_els = sizeof(helpscreen_eltext) / (2*sizeof(char *));
826 static char *helpscreen_music[][3] =
828 { "Alchemy", "Ian Boddy", "Drive" },
829 { "The Chase", "Propaganda", "A Secret Wish" },
830 { "Network 23", "Tangerine Dream", "Exit" },
831 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
832 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
833 { "Voyager", "The Alan Parsons Project","Pyramid" },
834 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
836 static int num_helpscreen_music = 7;
837 static int helpscreen_musicpos;
840 void OLD_DrawHelpScreenElAction(int start)
844 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
846 while(helpscreen_action[j] != HA_END)
848 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
850 else if (i<start || helpscreen_delay[i-start])
852 if (i>=start && helpscreen_delay[i-start])
853 helpscreen_delay[i-start]--;
855 while(helpscreen_action[j] != HA_NEXT)
862 j += 3*helpscreen_step[i-start];
863 graphic = helpscreen_action[j++];
865 if (helpscreen_frame[i-start])
867 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
868 helpscreen_frame[i-start]--;
873 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
876 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
878 if (helpscreen_action[j] == HA_NEXT)
880 if (!helpscreen_frame[i-start])
881 helpscreen_step[i-start] = 0;
885 if (!helpscreen_frame[i-start])
886 helpscreen_step[i-start]++;
887 while(helpscreen_action[j] != HA_NEXT)
892 DrawOldGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
904 void DrawHelpScreenElAction(int start)
907 int xstart = SX + 16;
908 int ystart = SY + 64 + 2 * 32;
909 int ystep = TILEY + 4;
915 while (helpscreen_action[j] != HA_END)
917 if (i >= start + MAX_HELPSCREEN_ELS || i >= num_helpscreen_els)
921 while (helpscreen_action[j] != HA_NEXT)
930 j += 2 * helpscreen_step[i-start];
931 graphic = helpscreen_action[j++];
932 frame_count = helpscreen_action[j++];
933 if (frame_count == -1)
934 frame_count = 1000000;
936 if (helpscreen_frame[i-start] == 0)
939 helpscreen_frame[i-start] = frame_count - 1;
943 sync_frame = frame_count - helpscreen_frame[i-start];
944 helpscreen_frame[i-start]--;
947 if (helpscreen_action[j] == HA_NEXT)
949 if (!helpscreen_frame[i-start])
950 helpscreen_step[i-start] = 0;
954 if (!helpscreen_frame[i-start])
955 helpscreen_step[i-start]++;
956 while(helpscreen_action[j] != HA_NEXT)
961 frame = getGraphicAnimationFrame(graphic, sync_frame);
963 DrawGraphicExt(drawto, xstart, ystart + (i-start) * ystep,
978 void DrawHelpScreenElText(int start)
981 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
982 int ybottom = SYSIZE - 20;
987 DrawTextFCentered(100, FC_GREEN, "The game elements:");
989 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
992 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
993 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
994 DrawText(xstart, ystart + (i - start) * ystep + 16,
995 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
998 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
1001 void DrawHelpScreenMusicText(int num)
1003 int ystart = 150, ystep = 30;
1004 int ybottom = SYSIZE - 20;
1010 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
1012 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
1014 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
1015 helpscreen_music[num][0]);
1016 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
1018 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
1019 "%s", helpscreen_music[num][1]);
1020 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
1022 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
1023 helpscreen_music[num][2]);
1025 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
1028 PlaySoundLoop(background_loop[num]);
1032 void DrawHelpScreenCreditsText()
1034 int ystart = 150, ystep = 30;
1035 int ybottom = SYSIZE - 20;
1041 DrawTextFCentered(100, FC_GREEN,
1043 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
1044 "DOS port of the game:");
1045 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
1047 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
1048 "Additional toons:");
1049 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
1051 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
1052 "...and many thanks to all contributors");
1053 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
1056 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
1059 void DrawHelpScreenContactText()
1061 int ystart = 150, ystep = 30;
1062 int ybottom = SYSIZE - 20;
1067 DrawTextFCentered(100, FC_GREEN, "Program information:");
1069 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
1070 "This game is Freeware!");
1071 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
1072 "If you like it, send e-mail to:");
1073 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
1074 "info@artsoft.org");
1075 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
1076 "or SnailMail to:");
1077 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
1079 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
1080 "Detmolder Strasse 189");
1081 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
1083 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
1086 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
1087 "If you have created new levels,");
1088 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
1089 "send them to me to include them!");
1090 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
1093 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
1096 void DrawHelpScreen()
1101 CloseDoor(DOOR_CLOSE_2);
1103 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
1104 helpscreen_step[i] = helpscreen_frame[i] = 0;
1105 helpscreen_musicpos = 0;
1106 helpscreen_state = 0;
1107 DrawHelpScreenElText(0);
1108 DrawHelpScreenElAction(0);
1112 PlaySoundLoop(SND_MENU_INFO_SCREEN);
1115 void HandleHelpScreen(int button)
1117 static unsigned long hs_delay = 0;
1118 int num_helpscreen_els_pages =
1119 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
1120 int button_released = !button;
1123 if (button_released)
1125 if (helpscreen_state < num_helpscreen_els_pages - 1)
1127 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
1128 helpscreen_step[i] = helpscreen_frame[i] = 0;
1132 DrawHelpScreenElText(helpscreen_state * MAX_HELPSCREEN_ELS);
1133 DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS);
1135 else if (helpscreen_state <
1136 num_helpscreen_els_pages + num_helpscreen_music - 1)
1139 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
1141 else if (helpscreen_state ==
1142 num_helpscreen_els_pages + num_helpscreen_music - 1)
1145 DrawHelpScreenCreditsText();
1147 else if (helpscreen_state ==
1148 num_helpscreen_els_pages + num_helpscreen_music)
1151 DrawHelpScreenContactText();
1157 game_status = MAINMENU;
1162 if (DelayReached(&hs_delay, GAME_FRAME_DELAY))
1164 if (helpscreen_state < num_helpscreen_els_pages)
1165 DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS);
1168 /* !!! workaround for playing "music" that is really a sound loop (and
1169 must therefore periodically be reactivated with the current sound
1171 PlaySoundLoop(SND_MENU_INFO_SCREEN);
1179 void HandleTypeName(int newxpos, Key key)
1181 static int xpos = 0, ypos = 2;
1186 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
1187 DrawGraphic(xpos + 6, ypos, IMG_BALL_RED, 0);
1191 if (((key >= KSYM_A && key <= KSYM_Z) ||
1192 (key >= KSYM_a && key <= KSYM_z)) &&
1193 xpos < MAX_PLAYER_NAME_LEN)
1197 if (key >= KSYM_A && key <= KSYM_Z)
1198 ascii = 'A' + (char)(key - KSYM_A);
1200 ascii = 'a' + (char)(key - KSYM_a);
1202 setup.player_name[xpos] = ascii;
1203 setup.player_name[xpos + 1] = 0;
1205 DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
1206 setup.player_name, FS_BIG, FC_YELLOW);
1207 DrawTextExt(window, SX + 6*32, SY + ypos*32,
1208 setup.player_name, FS_BIG, FC_YELLOW);
1209 DrawGraphic(xpos + 6, ypos, IMG_BALL_RED, 0);
1211 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
1214 setup.player_name[xpos] = 0;
1215 DrawGraphic(xpos + 6, ypos, IMG_BALL_RED, 0);
1216 DrawGraphic(xpos + 7, ypos, IMG_EMPTY, 0);
1218 else if (key == KSYM_Return && xpos > 0)
1220 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
1221 DrawGraphic(xpos + 6, ypos, IMG_EMPTY, 0);
1224 game_status = MAINMENU;
1230 static void DrawChooseTree(TreeInfo **ti_ptr)
1233 CloseDoor(DOOR_CLOSE_2);
1236 HandleChooseTree(0,0, 0,0, MB_MENU_INITIALIZE, ti_ptr);
1237 MapChooseTreeGadgets(*ti_ptr);
1243 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
1245 struct GadgetInfo *gi = screen_gadget[id];
1246 int items_max, items_visible, item_position;
1248 items_max = numTreeInfoInGroup(ti);
1249 items_visible = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1250 item_position = first_entry;
1252 if (item_position > items_max - items_visible)
1253 item_position = items_max - items_visible;
1255 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
1256 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
1259 static void drawChooseTreeList(int first_entry, int num_page_entries,
1263 char buffer[SCR_FIELDX * 2];
1264 int max_buffer_len = (SCR_FIELDX - 2) * 2;
1265 int num_entries = numTreeInfoInGroup(ti);
1266 char *title_string = NULL;
1267 int offset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : 16);
1269 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
1270 redraw_mask |= REDRAW_FIELD;
1273 (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Directories" :
1274 ti->type == TREE_TYPE_GRAPHICS_DIR ? "Custom Graphics" :
1275 ti->type == TREE_TYPE_SOUNDS_DIR ? "Custom Sounds" :
1276 ti->type == TREE_TYPE_MUSIC_DIR ? "Custom Music" : "");
1278 DrawText(SX + offset, SY + offset, title_string, FS_BIG,
1279 (ti->type == TREE_TYPE_LEVEL_DIR ? FC_GREEN : FC_YELLOW));
1281 for(i=0; i<num_page_entries; i++)
1283 TreeInfo *node, *node_first;
1284 int entry_pos = first_entry + i;
1285 int ypos = MENU_SCREEN_START_YPOS + i;
1287 node_first = getTreeInfoFirstGroupEntry(ti);
1288 node = getTreeInfoFromPos(node_first, entry_pos);
1290 strncpy(buffer, node->name , max_buffer_len);
1291 buffer[max_buffer_len] = '\0';
1293 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
1295 if (node->parent_link)
1296 initCursor(i, IMG_ARROW_BLUE_LEFT);
1297 else if (node->level_group)
1298 initCursor(i, IMG_ARROW_BLUE_RIGHT);
1300 initCursor(i, IMG_BALL_BLUE);
1303 if (first_entry > 0)
1304 DrawGraphic(0, 1, IMG_ARROW_BLUE_UP, 0);
1306 if (first_entry + num_page_entries < num_entries)
1307 DrawGraphic(0, MAX_MENU_ENTRIES_ON_SCREEN + 1, IMG_ARROW_BLUE_DOWN, 0);
1310 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
1312 TreeInfo *node, *node_first;
1313 int x, last_redraw_mask = redraw_mask;
1315 if (ti->type != TREE_TYPE_LEVEL_DIR)
1318 node_first = getTreeInfoFirstGroupEntry(ti);
1319 node = getTreeInfoFromPos(node_first, entry_pos);
1321 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
1323 if (node->parent_link)
1324 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
1325 else if (node->level_group)
1326 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
1327 else if (ti->type == TREE_TYPE_LEVEL_DIR)
1328 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
1329 node->levels, node->class_desc);
1331 /* let BackToFront() redraw only what is needed */
1332 redraw_mask = last_redraw_mask | REDRAW_TILES;
1333 for (x=0; x<SCR_FIELDX; x++)
1334 MarkTileDirty(x, 1);
1337 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
1340 static unsigned long choose_delay = 0;
1341 TreeInfo *ti = *ti_ptr;
1343 int y = ti->cl_cursor;
1344 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1345 int num_entries = numTreeInfoInGroup(ti);
1346 int num_page_entries;
1348 if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
1349 num_page_entries = num_entries;
1351 num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1353 if (button == MB_MENU_INITIALIZE)
1355 int entry_pos = posTreeInfo(ti);
1357 if (ti->cl_first == -1)
1359 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
1361 entry_pos - ti->cl_first;
1364 if (dx == 999) /* first entry is set by scrollbar position */
1367 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1370 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1371 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1372 drawCursor(ti->cl_cursor, FC_RED);
1375 else if (button == MB_MENU_LEAVE)
1377 if (ti->node_parent)
1379 *ti_ptr = ti->node_parent;
1380 DrawChooseTree(ti_ptr);
1382 else if (game_status == SETUP)
1388 game_status = MAINMENU;
1395 if (mx || my) /* mouse input */
1398 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
1400 else if (dx || dy) /* keyboard input */
1403 y = ti->cl_cursor + dy;
1405 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1408 step = num_page_entries - 1;
1409 y = (dy < 0 ? -1 : num_page_entries);
1413 if (x == 0 && y == -1)
1415 if (ti->cl_first > 0 &&
1416 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1418 ti->cl_first -= step;
1419 if (ti->cl_first < 0)
1422 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1423 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1424 drawCursor(ti->cl_cursor, FC_RED);
1425 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1430 else if (x == 0 && y > num_page_entries - 1)
1432 if (ti->cl_first + num_page_entries < num_entries &&
1433 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1435 ti->cl_first += step;
1436 if (ti->cl_first + num_page_entries > num_entries)
1437 ti->cl_first = MAX(0, num_entries - num_page_entries);
1439 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1440 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1441 drawCursor(ti->cl_cursor, FC_RED);
1442 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1450 TreeInfo *node_first, *node_cursor;
1451 int entry_pos = ti->cl_first + y;
1453 node_first = getTreeInfoFirstGroupEntry(ti);
1454 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
1456 if (node_cursor->node_group)
1458 node_cursor->cl_first = ti->cl_first;
1459 node_cursor->cl_cursor = ti->cl_cursor;
1460 *ti_ptr = node_cursor->node_group;
1461 DrawChooseTree(ti_ptr);
1465 else if (dx == -1 && ti->node_parent)
1467 *ti_ptr = ti->node_parent;
1468 DrawChooseTree(ti_ptr);
1472 if (x == 0 && y >= 0 && y < num_page_entries)
1476 if (y != ti->cl_cursor)
1478 drawCursor(y, FC_RED);
1479 drawCursor(ti->cl_cursor, FC_BLUE);
1480 drawChooseTreeInfo(ti->cl_first + y, ti);
1486 TreeInfo *node_first, *node_cursor;
1487 int entry_pos = ti->cl_first + y;
1489 node_first = getTreeInfoFirstGroupEntry(ti);
1490 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
1492 if (node_cursor->node_group)
1494 node_cursor->cl_first = ti->cl_first;
1495 node_cursor->cl_cursor = ti->cl_cursor;
1496 *ti_ptr = node_cursor->node_group;
1497 DrawChooseTree(ti_ptr);
1499 else if (node_cursor->parent_link)
1501 *ti_ptr = node_cursor->node_parent;
1502 DrawChooseTree(ti_ptr);
1506 node_cursor->cl_first = ti->cl_first;
1507 node_cursor->cl_cursor = ti->cl_cursor;
1508 *ti_ptr = node_cursor;
1510 if (ti->type == TREE_TYPE_LEVEL_DIR)
1512 LoadLevelSetup_SeriesInfo();
1514 SaveLevelSetup_LastSeries();
1515 SaveLevelSetup_SeriesInfo();
1519 if (game_status == SETUP)
1525 game_status = MAINMENU;
1534 if (game_status == CHOOSELEVEL || game_status == SETUP)
1538 void DrawChooseLevel()
1540 DrawChooseTree(&leveldir_current);
1543 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
1545 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
1548 void DrawHallOfFame(int highlight_position)
1552 CloseDoor(DOOR_CLOSE_2);
1554 if (highlight_position < 0)
1555 LoadScore(level_nr);
1559 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1560 PlaySound(SND_MENU_HALL_OF_FAME);
1563 static void drawHallOfFameList(int first_entry, int highlight_position)
1568 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1569 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1571 for(i=0; i<MAX_MENU_ENTRIES_ON_SCREEN; i++)
1573 int entry = first_entry + i;
1574 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1577 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1578 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1579 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1580 int2str(highscore[i].Score, 5), FS_BIG, color);
1582 DrawText(SX, SY + 64 + i * 32, "..................................",
1583 FS_MEDIUM, FC_YELLOW);
1584 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1585 FS_MEDIUM, FC_YELLOW);
1586 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1587 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1588 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1593 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1595 static int first_entry = 0;
1596 static int highlight_position = 0;
1597 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1598 int button_released = !button;
1600 if (button == MB_MENU_INITIALIZE)
1603 highlight_position = mx;
1604 drawHallOfFameList(first_entry, highlight_position);
1608 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1609 step = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1613 if (first_entry > 0)
1615 first_entry -= step;
1616 if (first_entry < 0)
1619 drawHallOfFameList(first_entry, highlight_position);
1625 if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1627 first_entry += step;
1628 if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1629 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN);
1631 drawHallOfFameList(first_entry, highlight_position);
1636 if (button_released)
1638 FadeSound(SND_MENU_HALL_OF_FAME);
1639 game_status = MAINMENU;
1645 if (game_status == HALLOFFAME)
1650 /* ========================================================================= */
1651 /* setup screen functions */
1652 /* ========================================================================= */
1654 static struct TokenInfo *setup_info;
1655 static int num_setup_info;
1657 static char *graphics_set_name;
1658 static char *sounds_set_name;
1659 static char *music_set_name;
1661 static void execSetupMain()
1663 setup_mode = SETUP_MODE_MAIN;
1667 static void execSetupGame()
1669 setup_mode = SETUP_MODE_GAME;
1673 static void execSetupGraphics()
1675 setup_mode = SETUP_MODE_GRAPHICS;
1679 static void execSetupSound()
1681 setup_mode = SETUP_MODE_SOUND;
1685 static void execSetupArtwork()
1687 /* needed if last screen (setup choice) changed graphics, sounds or music */
1688 ReloadCustomArtwork();
1690 setup.graphics_set = artwork.gfx_current->identifier;
1691 setup.sounds_set = artwork.snd_current->identifier;
1692 setup.music_set = artwork.mus_current->identifier;
1694 /* needed for displaying artwork name instead of artwork identifier */
1695 graphics_set_name = artwork.gfx_current->name;
1696 sounds_set_name = artwork.snd_current->name;
1697 music_set_name = artwork.mus_current->name;
1699 setup_mode = SETUP_MODE_ARTWORK;
1703 static void execSetupChooseGraphics()
1705 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
1709 static void execSetupChooseSounds()
1711 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
1715 static void execSetupChooseMusic()
1717 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
1721 static void execSetupInput()
1723 setup_mode = SETUP_MODE_INPUT;
1727 static void execSetupShortcut()
1729 setup_mode = SETUP_MODE_SHORTCUT;
1733 static void execExitSetup()
1735 game_status = MAINMENU;
1739 static void execSaveAndExitSetup()
1745 static struct TokenInfo setup_info_main[] =
1747 { TYPE_ENTER_MENU, execSetupGame, "Game Settings" },
1748 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
1749 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
1750 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
1751 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
1752 { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" },
1753 { TYPE_EMPTY, NULL, "" },
1754 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
1755 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and exit" },
1759 static struct TokenInfo setup_info_game[] =
1761 { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" },
1762 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
1763 { TYPE_SWITCH, &setup.time_limit, "Timelimit:" },
1764 { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" },
1765 { TYPE_EMPTY, NULL, "" },
1766 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1770 static struct TokenInfo setup_info_graphics[] =
1772 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
1773 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
1774 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" },
1776 { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" },
1777 { TYPE_SWITCH, &setup.fading, "Fading:" },
1779 { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" },
1780 { TYPE_SWITCH, &setup.toons, "Toons:" },
1781 { TYPE_EMPTY, NULL, "" },
1782 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1786 static struct TokenInfo setup_info_sound[] =
1788 { TYPE_SWITCH, &setup.sound, "Sound:", },
1789 { TYPE_EMPTY, NULL, "" },
1790 { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" },
1791 { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" },
1792 { TYPE_SWITCH, &setup.sound_music, "Game Music:" },
1793 { TYPE_EMPTY, NULL, "" },
1794 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1798 static struct TokenInfo setup_info_artwork[] =
1800 { TYPE_ENTER_MENU, execSetupChooseGraphics,"Custom Graphics" },
1801 { TYPE_STRING, &graphics_set_name, "" },
1802 { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" },
1803 { TYPE_STRING, &sounds_set_name, "" },
1804 { TYPE_ENTER_MENU, execSetupChooseMusic, "Custom Music" },
1805 { TYPE_STRING, &music_set_name, "" },
1806 { TYPE_EMPTY, NULL, "" },
1807 { TYPE_STRING, NULL, "Override Level Artwork:"},
1808 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
1809 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
1810 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
1811 { TYPE_EMPTY, NULL, "" },
1812 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1816 static struct TokenInfo setup_info_shortcut[] =
1818 { TYPE_KEYTEXT, NULL, "Quick Save Game:", },
1819 { TYPE_KEY, &setup.shortcut.save_game, "" },
1820 { TYPE_KEYTEXT, NULL, "Quick Load Game:", },
1821 { TYPE_KEY, &setup.shortcut.load_game, "" },
1822 { TYPE_KEYTEXT, NULL, "Toggle Pause:", },
1823 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
1824 { TYPE_EMPTY, NULL, "" },
1825 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on Esc:" },
1826 { TYPE_EMPTY, NULL, "" },
1827 { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
1831 static Key getSetupKey()
1833 Key key = KSYM_UNDEFINED;
1834 boolean got_key_event = FALSE;
1836 while (!got_key_event)
1838 if (PendingEvent()) /* got event */
1846 case EVENT_KEYPRESS:
1848 key = GetEventKey((KeyEvent *)&event, TRUE);
1850 /* press 'Escape' or 'Enter' to keep the existing key binding */
1851 if (key == KSYM_Escape || key == KSYM_Return)
1852 key = KSYM_UNDEFINED; /* keep old value */
1854 got_key_event = TRUE;
1858 case EVENT_KEYRELEASE:
1859 key_joystick_mapping = 0;
1863 HandleOtherEvents(&event);
1871 /* don't eat all CPU time */
1878 static void drawSetupValue(int pos)
1880 int xpos = MENU_SCREEN_VALUE_XPOS;
1881 int ypos = MENU_SCREEN_START_YPOS + pos;
1882 int font_size = FS_BIG;
1883 int font_color = FC_YELLOW;
1884 char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED,
1885 setup_info[pos].value);
1887 if (value_string == NULL)
1890 if (setup_info[pos].type & TYPE_KEY)
1894 if (setup_info[pos].type & TYPE_QUERY)
1896 value_string = "<press key>";
1897 font_color = FC_RED;
1900 else if (setup_info[pos].type & TYPE_STRING)
1902 int max_value_len = (SCR_FIELDX - 2) * 2;
1905 font_size = FS_MEDIUM;
1907 if (strlen(value_string) > max_value_len)
1908 value_string[max_value_len] = '\0';
1910 else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE &&
1911 !*(boolean *)(setup_info[pos].value))
1912 font_color = FC_BLUE;
1914 DrawText(SX + xpos * 32, SY + ypos * 32,
1915 (xpos == 3 ? " " : " "), FS_BIG, FC_YELLOW);
1916 DrawText(SX + xpos * 32, SY + ypos * 32, value_string, font_size,font_color);
1919 static void changeSetupValue(int pos)
1921 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
1923 *(boolean *)setup_info[pos].value ^= TRUE;
1925 else if (setup_info[pos].type & TYPE_KEY)
1929 setup_info[pos].type |= TYPE_QUERY;
1930 drawSetupValue(pos);
1931 setup_info[pos].type &= ~TYPE_QUERY;
1933 key = getSetupKey();
1934 if (key != KSYM_UNDEFINED)
1935 *(Key *)setup_info[pos].value = key;
1938 drawSetupValue(pos);
1941 static void DrawSetupScreen_Generic()
1943 char *title_string = NULL;
1947 CloseDoor(DOOR_CLOSE_2);
1950 if (setup_mode == SETUP_MODE_MAIN)
1952 setup_info = setup_info_main;
1953 title_string = "Setup";
1955 else if (setup_mode == SETUP_MODE_GAME)
1957 setup_info = setup_info_game;
1958 title_string = "Setup Game";
1960 else if (setup_mode == SETUP_MODE_GRAPHICS)
1962 setup_info = setup_info_graphics;
1963 title_string = "Setup Graphics";
1965 else if (setup_mode == SETUP_MODE_SOUND)
1967 setup_info = setup_info_sound;
1968 title_string = "Setup Sound";
1970 else if (setup_mode == SETUP_MODE_ARTWORK)
1972 setup_info = setup_info_artwork;
1973 title_string = "Custom Artwork";
1975 else if (setup_mode == SETUP_MODE_SHORTCUT)
1977 setup_info = setup_info_shortcut;
1978 title_string = "Setup Shortcuts";
1981 DrawText(SX + 16, SY + 16, title_string, FS_BIG, FC_YELLOW);
1984 for(i=0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1986 void *value_ptr = setup_info[i].value;
1987 int ypos = MENU_SCREEN_START_YPOS + i;
1988 int font_size = FS_BIG;
1990 /* set some entries to "unchangeable" according to other variables */
1991 if ((value_ptr == &setup.sound && !audio.sound_available) ||
1992 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
1993 (value_ptr == &setup.sound_music && !audio.music_available) ||
1994 (value_ptr == &setup.fullscreen && !video.fullscreen_available))
1995 setup_info[i].type |= TYPE_GHOSTED;
1997 if (setup_info[i].type & TYPE_STRING)
1998 font_size = FS_MEDIUM;
2000 DrawText(SX + 32, SY + ypos * 32, setup_info[i].text, font_size, FC_GREEN);
2002 if (setup_info[i].type & TYPE_ENTER_MENU)
2003 initCursor(i, IMG_ARROW_BLUE_RIGHT);
2004 else if (setup_info[i].type & TYPE_LEAVE_MENU)
2005 initCursor(i, IMG_ARROW_BLUE_LEFT);
2006 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
2007 initCursor(i, IMG_BALL_BLUE);
2009 if (setup_info[i].type & TYPE_VALUE)
2017 HandleSetupScreen_Generic(0,0,0,0,MB_MENU_INITIALIZE);
2020 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
2022 static int choice_store[MAX_SETUP_MODES];
2023 int choice = choice_store[setup_mode];
2027 if (button == MB_MENU_INITIALIZE)
2029 drawCursor(choice, FC_RED);
2032 else if (button == MB_MENU_LEAVE)
2034 for (y=0; y<num_setup_info; y++)
2036 if (setup_info[y].type & TYPE_LEAVE_MENU)
2038 void (*menu_callback_function)(void) = setup_info[y].value;
2040 menu_callback_function();
2041 break; /* absolutely needed because function changes 'setup_info'! */
2048 if (mx || my) /* mouse input */
2051 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
2053 else if (dx || dy) /* keyboard input */
2057 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU);
2059 if ((setup_info[choice].type & menu_navigation_type) ||
2060 (setup_info[choice].type & TYPE_BOOLEAN_STYLE))
2061 button = MB_MENU_CHOICE;
2066 /* jump to next non-empty menu entry (up or down) */
2067 while (y > 0 && y < num_setup_info - 1 &&
2068 (setup_info[y].type & TYPE_SKIP_ENTRY))
2072 if (x == 0 && y >= 0 && y < num_setup_info &&
2073 (setup_info[y].type & ~TYPE_SKIP_ENTRY))
2079 drawCursor(y, FC_RED);
2080 drawCursor(choice, FC_BLUE);
2081 choice = choice_store[setup_mode] = y;
2084 else if (!(setup_info[y].type & TYPE_GHOSTED))
2086 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
2088 void (*menu_callback_function)(void) = setup_info[choice].value;
2090 menu_callback_function();
2094 if ((setup_info[y].type & TYPE_KEYTEXT) &&
2095 (setup_info[y + 1].type & TYPE_KEY))
2098 if (setup_info[y].type & TYPE_VALUE)
2099 changeSetupValue(y);
2106 if (game_status == SETUP)
2110 void DrawSetupScreen_Input()
2113 DrawText(SX+16, SY+16, "Setup Input", FS_BIG, FC_YELLOW);
2115 initCursor(0, IMG_BALL_BLUE);
2116 initCursor(1, IMG_BALL_BLUE);
2117 initCursor(2, IMG_ARROW_BLUE_RIGHT);
2118 initCursor(13, IMG_ARROW_BLUE_LEFT);
2120 DrawGraphic(10, MENU_SCREEN_START_YPOS, IMG_ARROW_BLUE_LEFT, 0);
2121 DrawGraphic(12, MENU_SCREEN_START_YPOS, IMG_ARROW_BLUE_RIGHT, 0);
2123 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
2124 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
2125 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
2128 DeactivateJoystickForCalibration();
2129 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
2130 "Joysticks deactivated on this screen");
2133 HandleSetupScreen_Input(0,0, 0,0, MB_MENU_INITIALIZE);
2138 static void setJoystickDeviceToNr(char *device_name, int device_nr)
2140 if (device_name == NULL)
2143 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
2146 if (strlen(device_name) > 1)
2148 char c1 = device_name[strlen(device_name) - 1];
2149 char c2 = device_name[strlen(device_name) - 2];
2151 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
2152 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
2155 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
2156 strlen(device_name));
2159 static void drawPlayerSetupInputInfo(int player_nr)
2162 static struct SetupKeyboardInfo custom_key;
2169 { &custom_key.left, "Joystick Left" },
2170 { &custom_key.right, "Joystick Right" },
2171 { &custom_key.up, "Joystick Up" },
2172 { &custom_key.down, "Joystick Down" },
2173 { &custom_key.snap, "Button 1" },
2174 { &custom_key.bomb, "Button 2" }
2176 static char *joystick_name[MAX_PLAYERS] =
2184 custom_key = setup.input[player_nr].key;
2186 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
2187 DrawGraphic(8, 2, PLAYER_NR_GFX(IMG_PLAYER1, player_nr), 0);
2189 if (setup.input[player_nr].use_joystick)
2191 char *device_name = setup.input[player_nr].joy.device_name;
2193 DrawText(SX+8*32, SY+3*32,
2194 joystick_name[getJoystickNrFromDeviceName(device_name)],
2196 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
2200 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
2201 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
2204 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
2205 DrawGraphic(1, 6, IMG_ARROW_BLUE_LEFT, 0);
2206 DrawGraphic(1, 7, IMG_ARROW_BLUE_RIGHT, 0);
2207 DrawGraphic(1, 8, IMG_ARROW_BLUE_UP, 0);
2208 DrawGraphic(1, 9, IMG_ARROW_BLUE_DOWN, 0);
2209 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
2210 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
2211 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
2212 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
2213 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
2214 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
2218 int ypos = 6 + i + (i > 3 ? i-3 : 0);
2220 DrawText(SX + 3*32, SY + ypos*32,
2221 " ", FS_BIG, FC_YELLOW);
2222 DrawText(SX + 3*32, SY + ypos*32,
2223 (setup.input[player_nr].use_joystick ?
2225 getKeyNameFromKey(*custom[i].key)),
2230 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
2232 static int choice = 0;
2233 static int player_nr = 0;
2236 int pos_start = SETUPINPUT_SCREEN_POS_START;
2237 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
2238 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
2239 int pos_end = SETUPINPUT_SCREEN_POS_END;
2241 if (button == MB_MENU_INITIALIZE)
2243 drawPlayerSetupInputInfo(player_nr);
2244 drawCursor(choice, FC_RED);
2247 else if (button == MB_MENU_LEAVE)
2249 setup_mode = SETUP_MODE_MAIN;
2254 if (mx || my) /* mouse input */
2257 y = (my - SY) / 32 - MENU_SCREEN_START_YPOS;
2259 else if (dx || dy) /* keyboard input */
2261 if (dx && choice == 0)
2262 x = (dx < 0 ? 10 : 12);
2263 else if ((dx && choice == 1) ||
2264 (dx == +1 && choice == 2) ||
2265 (dx == -1 && choice == pos_end))
2266 button = MB_MENU_CHOICE;
2270 if (y >= pos_empty1 && y <= pos_empty2)
2271 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
2274 if (y == 0 && ((x == 0 && !button) || ((x == 10 || x == 12) && button)))
2276 static unsigned long delay = 0;
2278 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
2281 player_nr = (player_nr + (x == 10 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
2283 drawPlayerSetupInputInfo(player_nr);
2285 else if (x == 0 && y >= pos_start && y <= pos_end &&
2286 !(y >= pos_empty1 && y <= pos_empty2))
2292 drawCursor(y, FC_RED);
2293 drawCursor(choice, FC_BLUE);
2301 char *device_name = setup.input[player_nr].joy.device_name;
2303 if (!setup.input[player_nr].use_joystick)
2305 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
2307 setJoystickDeviceToNr(device_name, new_device_nr);
2308 setup.input[player_nr].use_joystick = TRUE;
2312 int device_nr = getJoystickNrFromDeviceName(device_name);
2313 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
2315 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
2316 setup.input[player_nr].use_joystick = FALSE;
2318 setJoystickDeviceToNr(device_name, new_device_nr);
2321 drawPlayerSetupInputInfo(player_nr);
2325 if (setup.input[player_nr].use_joystick)
2328 CalibrateJoystick(player_nr);
2331 CustomizeKeyboard(player_nr);
2333 else if (y == pos_end)
2337 setup_mode = SETUP_MODE_MAIN;
2347 if (game_status == SETUP)
2351 void CustomizeKeyboard(int player_nr)
2355 boolean finished = FALSE;
2356 static struct SetupKeyboardInfo custom_key;
2361 } customize_step[] =
2363 { &custom_key.left, "Move Left" },
2364 { &custom_key.right, "Move Right" },
2365 { &custom_key.up, "Move Up" },
2366 { &custom_key.down, "Move Down" },
2367 { &custom_key.snap, "Snap Field" },
2368 { &custom_key.bomb, "Place Bomb" }
2371 /* read existing key bindings from player setup */
2372 custom_key = setup.input[player_nr].key;
2375 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
2381 DrawText(SX, SY + (2+2*step_nr)*32,
2382 customize_step[step_nr].text, FS_BIG, FC_RED);
2383 DrawText(SX, SY + (2+2*step_nr+1)*32,
2384 "Key:", FS_BIG, FC_RED);
2385 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
2386 getKeyNameFromKey(*customize_step[step_nr].key),
2391 if (PendingEvent()) /* got event */
2399 case EVENT_KEYPRESS:
2401 Key key = GetEventKey((KeyEvent *)&event, FALSE);
2403 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
2409 /* all keys configured -- wait for "Escape" or "Return" key */
2413 /* press 'Enter' to keep the existing key binding */
2414 if (key == KSYM_Return)
2415 key = *customize_step[step_nr].key;
2417 /* check if key already used */
2418 for (i=0; i<step_nr; i++)
2419 if (*customize_step[i].key == key)
2424 /* got new key binding */
2425 *customize_step[step_nr].key = key;
2426 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
2427 " ", FS_BIG, FC_YELLOW);
2428 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
2429 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
2432 /* un-highlight last query */
2433 DrawText(SX, SY+(2+2*(step_nr-1))*32,
2434 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
2435 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
2436 "Key:", FS_BIG, FC_GREEN);
2438 /* press 'Enter' to leave */
2441 DrawText(SX + 16, SY + 15*32+16,
2442 "Press Enter", FS_BIG, FC_YELLOW);
2446 /* query next key binding */
2447 DrawText(SX, SY+(2+2*step_nr)*32,
2448 customize_step[step_nr].text, FS_BIG, FC_RED);
2449 DrawText(SX, SY+(2+2*step_nr+1)*32,
2450 "Key:", FS_BIG, FC_RED);
2451 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
2452 getKeyNameFromKey(*customize_step[step_nr].key),
2457 case EVENT_KEYRELEASE:
2458 key_joystick_mapping = 0;
2462 HandleOtherEvents(&event);
2470 /* don't eat all CPU time */
2474 /* write new key bindings back to player setup */
2475 setup.input[player_nr].key = custom_key;
2478 DrawSetupScreen_Input();
2481 static boolean CalibrateJoystickMain(int player_nr)
2483 int new_joystick_xleft = JOYSTICK_XMIDDLE;
2484 int new_joystick_xright = JOYSTICK_XMIDDLE;
2485 int new_joystick_yupper = JOYSTICK_YMIDDLE;
2486 int new_joystick_ylower = JOYSTICK_YMIDDLE;
2487 int new_joystick_xmiddle, new_joystick_ymiddle;
2489 int joystick_fd = joystick.fd[player_nr];
2490 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2491 boolean check[3][3];
2492 int check_remaining = 3 * 3;
2497 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
2500 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
2509 check[x][y] = FALSE;
2510 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_BALL_BLUE, 0);
2514 DrawText(SX, SY + 6 * 32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2515 DrawText(SX, SY + 7 * 32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2516 DrawText(SX + 16, SY + 9 * 32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2517 DrawText(SX, SY + 10 * 32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2518 DrawText(SX, SY + 11 * 32, " CENTER JOYSTICK ", FS_BIG, FC_YELLOW);
2519 DrawText(SX, SY + 12 * 32, " AND ", FS_BIG, FC_YELLOW);
2520 DrawText(SX, SY + 13 * 32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2522 joy_value = Joystick(player_nr);
2523 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2524 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2526 /* eventually uncalibrated center position (joystick could be uncentered) */
2527 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2530 new_joystick_xmiddle = joy_x;
2531 new_joystick_ymiddle = joy_y;
2533 DrawGraphic(xpos + last_x, ypos + last_y, IMG_BALL_RED, 0);
2536 while(Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
2541 if (PendingEvent()) /* got event */
2549 case EVENT_KEYPRESS:
2550 switch(GetEventKey((KeyEvent *)&event, TRUE))
2553 if (check_remaining == 0)
2566 case EVENT_KEYRELEASE:
2567 key_joystick_mapping = 0;
2571 HandleOtherEvents(&event);
2576 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2579 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
2580 new_joystick_xright = MAX(new_joystick_xright, joy_x);
2581 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
2582 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
2584 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2585 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2586 setup.input[player_nr].joy.xright = new_joystick_xright;
2587 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2588 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2589 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2591 CheckJoystickData();
2593 joy_value = Joystick(player_nr);
2595 if (joy_value & JOY_BUTTON && check_remaining == 0)
2598 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2599 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2601 if (x != last_x || y != last_y)
2603 DrawGraphic(xpos + last_x, ypos + last_y, IMG_BALL_YELLOW, 0);
2604 DrawGraphic(xpos + x, ypos + y, IMG_BALL_RED, 0);
2609 if (check_remaining > 0 && !check[x+1][y+1])
2611 check[x+1][y+1] = TRUE;
2617 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2618 setup.input[player_nr].joy.xleft,
2619 setup.input[player_nr].joy.xmiddle,
2620 setup.input[player_nr].joy.xright);
2621 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2622 setup.input[player_nr].joy.yupper,
2623 setup.input[player_nr].joy.ymiddle,
2624 setup.input[player_nr].joy.ylower);
2633 /* don't eat all CPU time */
2637 /* calibrated center position (joystick should now be centered) */
2638 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2641 new_joystick_xmiddle = joy_x;
2642 new_joystick_ymiddle = joy_y;
2646 DrawSetupScreen_Input();
2648 /* wait until the last pressed button was released */
2649 while (Joystick(player_nr) & JOY_BUTTON)
2651 if (PendingEvent()) /* got event */
2656 HandleOtherEvents(&event);
2665 void CalibrateJoystick(int player_nr)
2667 if (!CalibrateJoystickMain(player_nr))
2671 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2672 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2674 Delay(2000); /* show error message for two seconds */
2678 void DrawSetupScreen()
2680 DeactivateJoystick();
2682 if (setup_mode == SETUP_MODE_INPUT)
2683 DrawSetupScreen_Input();
2684 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
2685 DrawChooseTree(&artwork.gfx_current);
2686 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
2687 DrawChooseTree(&artwork.snd_current);
2688 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
2689 DrawChooseTree(&artwork.mus_current);
2691 DrawSetupScreen_Generic();
2694 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
2696 if (setup_mode == SETUP_MODE_INPUT)
2697 HandleSetupScreen_Input(mx, my, dx, dy, button);
2698 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
2699 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
2700 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
2701 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
2702 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
2703 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
2705 HandleSetupScreen_Generic(mx, my, dx, dy, button);
2708 void HandleGameActions()
2710 if (game_status != PLAYING)
2713 if (local_player->LevelSolved)
2716 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2724 /* ---------- new screen button stuff -------------------------------------- */
2726 /* graphic position and size values for buttons and scrollbars */
2727 #define SC_SCROLLBUTTON_XSIZE 32
2728 #define SC_SCROLLBUTTON_YSIZE 32
2730 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2731 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2732 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2733 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2734 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2735 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2736 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2737 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2739 #define SC_BORDER_SIZE 14
2743 int gfx_unpressed, gfx_pressed;
2747 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2750 IMG_ARROW_BLUE_UP, IMG_ARROW_RED_UP,
2751 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2752 SCREEN_CTRL_ID_SCROLL_UP,
2756 IMG_ARROW_BLUE_DOWN, IMG_ARROW_RED_DOWN,
2757 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2758 SCREEN_CTRL_ID_SCROLL_DOWN,
2765 int gfx_unpressed, gfx_pressed;
2771 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2774 IMG_SCROLLBAR_BLUE, IMG_SCROLLBAR_RED,
2775 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2776 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2777 GD_TYPE_SCROLLBAR_VERTICAL,
2778 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2779 "scroll level series vertically"
2783 static void CreateScreenScrollbuttons()
2785 struct GadgetInfo *gi;
2786 unsigned long event_mask;
2789 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2791 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
2792 int gfx_unpressed, gfx_pressed;
2793 int x, y, width, height;
2794 int gd_x1, gd_x2, gd_y1, gd_y2;
2795 int id = scrollbutton_info[i].gadget_id;
2797 x = scrollbutton_info[i].x;
2798 y = scrollbutton_info[i].y;
2800 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2804 width = SC_SCROLLBUTTON_XSIZE;
2805 height = SC_SCROLLBUTTON_YSIZE;
2807 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
2808 gfx_pressed = scrollbutton_info[i].gfx_pressed;
2809 gd_bitmap_unpressed = new_graphic_info[gfx_unpressed].bitmap;
2810 gd_bitmap_pressed = new_graphic_info[gfx_pressed].bitmap;
2811 gd_x1 = new_graphic_info[gfx_unpressed].src_x;
2812 gd_y1 = new_graphic_info[gfx_unpressed].src_y;
2813 gd_x2 = new_graphic_info[gfx_pressed].src_x;
2814 gd_y2 = new_graphic_info[gfx_pressed].src_y;
2816 gi = CreateGadget(GDI_CUSTOM_ID, id,
2817 GDI_CUSTOM_TYPE_ID, i,
2818 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2823 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2824 GDI_STATE, GD_BUTTON_UNPRESSED,
2825 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
2826 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
2827 GDI_EVENT_MASK, event_mask,
2828 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2832 Error(ERR_EXIT, "cannot create gadget");
2834 screen_gadget[id] = gi;
2838 static void CreateScreenScrollbars()
2842 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2844 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
2845 int gfx_unpressed, gfx_pressed;
2846 int gd_x1, gd_x2, gd_y1, gd_y2;
2847 struct GadgetInfo *gi;
2848 int items_max, items_visible, item_position;
2849 unsigned long event_mask;
2850 int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
2851 int id = scrollbar_info[i].gadget_id;
2853 items_max = num_page_entries;
2854 items_visible = num_page_entries;
2857 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2859 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
2860 gfx_pressed = scrollbar_info[i].gfx_pressed;
2861 gd_bitmap_unpressed = new_graphic_info[gfx_unpressed].bitmap;
2862 gd_bitmap_pressed = new_graphic_info[gfx_pressed].bitmap;
2863 gd_x1 = new_graphic_info[gfx_unpressed].src_x;
2864 gd_y1 = new_graphic_info[gfx_unpressed].src_y;
2865 gd_x2 = new_graphic_info[gfx_pressed].src_x;
2866 gd_y2 = new_graphic_info[gfx_pressed].src_y;
2868 gi = CreateGadget(GDI_CUSTOM_ID, id,
2869 GDI_CUSTOM_TYPE_ID, i,
2870 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2871 GDI_X, scrollbar_info[i].x,
2872 GDI_Y, scrollbar_info[i].y,
2873 GDI_WIDTH, scrollbar_info[i].width,
2874 GDI_HEIGHT, scrollbar_info[i].height,
2875 GDI_TYPE, scrollbar_info[i].type,
2876 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2877 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2878 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2879 GDI_STATE, GD_BUTTON_UNPRESSED,
2880 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
2881 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
2882 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2883 GDI_EVENT_MASK, event_mask,
2884 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2888 Error(ERR_EXIT, "cannot create gadget");
2890 screen_gadget[id] = gi;
2894 void CreateScreenGadgets()
2896 CreateScreenScrollbuttons();
2897 CreateScreenScrollbars();
2900 void FreeScreenGadgets()
2904 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2905 FreeGadget(screen_gadget[i]);
2908 void MapChooseTreeGadgets(TreeInfo *ti)
2910 int num_entries = numTreeInfoInGroup(ti);
2913 if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
2916 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2917 MapGadget(screen_gadget[i]);
2920 void UnmapChooseTreeGadgets()
2924 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2925 UnmapGadget(screen_gadget[i]);
2928 static void HandleScreenGadgets(struct GadgetInfo *gi)
2930 int id = gi->custom_id;
2932 if (game_status != CHOOSELEVEL && game_status != SETUP)
2937 case SCREEN_CTRL_ID_SCROLL_UP:
2938 if (game_status == CHOOSELEVEL)
2939 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2940 else if (game_status == SETUP)
2941 HandleSetupScreen(SX,SY + 32, 0,0, MB_MENU_MARK);
2944 case SCREEN_CTRL_ID_SCROLL_DOWN:
2945 if (game_status == CHOOSELEVEL)
2946 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2947 else if (game_status == SETUP)
2948 HandleSetupScreen(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2951 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2952 if (game_status == CHOOSELEVEL)
2953 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
2954 else if (game_status == SETUP)
2955 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);