1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
29 /* for DrawSetupScreen(), HandleSetupScreen() */
30 #define SETUP_SCREEN_POS_START 2
31 #define SETUP_SCREEN_POS_END (SCR_FIELDY - 1)
32 #define SETUP_SCREEN_POS_EMPTY1 (SETUP_SCREEN_POS_END - 2)
33 #define SETUP_SCREEN_POS_EMPTY2 (SETUP_SCREEN_POS_END - 2)
35 /* for HandleSetupInputScreen() */
36 #define SETUPINPUT_SCREEN_POS_START 2
37 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 2)
38 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
39 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
41 /* for HandleChooseLevel() */
42 #define MAX_LEVEL_SERIES_ON_SCREEN (SCR_FIELDY - 2)
44 /* buttons and scrollbars identifiers */
45 #define SCREEN_CTRL_ID_SCROLL_UP 0
46 #define SCREEN_CTRL_ID_SCROLL_DOWN 1
47 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 2
49 #define NUM_SCREEN_SCROLLBUTTONS 2
50 #define NUM_SCREEN_SCROLLBARS 1
51 #define NUM_SCREEN_GADGETS 3
53 /* forward declaration for internal use */
54 static void HandleScreenGadgets(struct GadgetInfo *);
56 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
60 int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
62 DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
63 DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING);
68 static struct LevelDirInfo *leveldir_last_valid = NULL;
70 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
74 KeyboardAutoRepeatOn();
76 /* needed if last screen was the playing screen, invoked from level editor */
77 if (level_editor_test_game)
79 game_status = LEVELED;
84 /* needed if last screen was the editor screen */
85 UndrawSpecialEditorDoor();
87 /* map gadgets for main menu screen */
90 /* leveldir_current may be invalid (level group, parent link) */
91 if (!validLevelSeries(leveldir_current))
92 leveldir_current = getFirstValidLevelSeries(leveldir_last_valid);
94 /* store valid level series information */
95 leveldir_last_valid = leveldir_current;
97 /* level_nr may have been set to value over handicap with level editor */
98 if (setup.handicap && level_nr > leveldir_current->handicap_level)
99 level_nr = leveldir_current->handicap_level;
106 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
107 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
108 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
109 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
110 (leveldir_current->readonly ? FC_RED : FC_YELLOW));
111 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
112 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
113 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
114 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
115 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
116 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
118 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
120 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
121 leveldir_current->first_level,
122 leveldir_current->last_level);
124 if (leveldir_current->readonly)
126 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
127 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
131 DrawGraphic(0, i, GFX_KUGEL_BLAU);
132 DrawGraphic(10, 3, GFX_ARROW_BLUE_LEFT);
133 DrawGraphic(14, 3, GFX_ARROW_BLUE_RIGHT);
135 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
138 if (leveldir_current->name)
140 int len = strlen(leveldir_current->name);
141 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
142 int lypos = SY + 352;
144 DrawText(lxpos, lypos, leveldir_current->name, FS_SMALL, FC_SPECIAL2);
149 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
152 if (TAPE_IS_EMPTY(tape))
154 DrawCompleteVideoDisplay();
156 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
164 static void gotoTopLevelDir()
166 /* move upwards to top level directory */
167 while (leveldir_current->node_parent)
169 /* write a "path" into level tree for easy navigation to last level */
170 if (leveldir_current->node_parent->node_group->cl_first == -1)
172 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
173 int leveldir_pos = posLevelDirInfo(leveldir_current);
174 int num_page_entries;
175 int cl_first, cl_cursor;
177 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
178 num_page_entries = num_leveldirs;
180 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
182 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
183 cl_cursor = leveldir_pos - cl_first + 3;
185 leveldir_current->node_parent->node_group->cl_first = cl_first;
186 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
189 leveldir_current = leveldir_current->node_parent;
193 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
195 static int choice = 3;
196 static int redraw = TRUE;
197 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
199 if (redraw || button == MB_MENU_INITIALIZE)
201 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
205 if (button == MB_MENU_INITIALIZE)
210 if (dx && choice == 4)
212 x = (dx < 0 ? 11 : 15);
229 if (!mx && !my && !dx && !dy)
235 if (y == 4 && ((x == 11 && level_nr > leveldir_current->first_level) ||
236 (x == 15 && level_nr < leveldir_current->last_level)) &&
239 static unsigned long level_delay = 0;
240 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
241 int new_level_nr, old_level_nr = level_nr;
242 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
244 new_level_nr = level_nr + (x == 11 ? -step : +step);
245 if (new_level_nr < leveldir_current->first_level)
246 new_level_nr = leveldir_current->first_level;
247 if (new_level_nr > leveldir_current->last_level)
248 new_level_nr = leveldir_current->last_level;
250 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
251 new_level_nr = leveldir_current->handicap_level;
253 if (old_level_nr == new_level_nr ||
254 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
257 level_nr = new_level_nr;
259 DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
260 int2str(level_nr, 3), FS_BIG, font_color);
261 DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
262 int2str(level_nr, 3), FS_BIG, font_color);
265 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
269 DrawCompleteVideoDisplay();
271 /* needed because DrawMicroLevel() takes some time */
274 DelayReached(&level_delay, 0); /* reset delay counter */
276 else if (x == 1 && y >= 3 && y <= 10)
282 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
283 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
291 game_status = TYPENAME;
292 HandleTypeName(strlen(setup.player_name), 0);
298 game_status = CHOOSELEVEL;
299 SaveLevelSetup_LastSeries();
300 SaveLevelSetup_SeriesInfo();
309 game_status = HALLOFFAME;
314 if (leveldir_current->readonly &&
315 strcmp(setup.player_name, "Artsoft") != 0)
316 Request("This level is read only !", REQ_CONFIRM);
317 game_status = LEVELED;
322 game_status = HELPSCREEN;
327 if (setup.autorecord)
328 TapeStartRecording();
332 SendToServer_StartPlaying();
336 game_status = PLAYING;
348 SaveLevelSetup_LastSeries();
349 SaveLevelSetup_SeriesInfo();
350 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
351 game_status = EXITGAME;
361 if (game_status == MAINMENU)
363 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
368 #define MAX_HELPSCREEN_ELS 10
372 static long helpscreen_state;
373 static int helpscreen_step[MAX_HELPSCREEN_ELS];
374 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
375 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
376 static int helpscreen_action[] =
378 GFX_SPIELER1_DOWN,4,2,
380 GFX_SPIELER1_LEFT,4,2,
381 GFX_SPIELER1_RIGHT,4,2,
382 GFX_SPIELER1_PUSH_LEFT,4,2,
383 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
384 GFX_ERDREICH,1,100, HA_NEXT,
385 GFX_LEERRAUM,1,100, HA_NEXT,
386 GFX_MORAST_LEER,1,100, HA_NEXT,
387 GFX_BETON,1,100, HA_NEXT,
388 GFX_MAUERWERK,1,100, HA_NEXT,
389 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
390 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
391 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
392 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
393 GFX_UNSICHTBAR,1,100, HA_NEXT,
394 GFX_FELSBODEN,1,100, HA_NEXT,
395 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
396 GFX_EDELSTEIN,2,5, HA_NEXT,
397 GFX_DIAMANT,2,5, HA_NEXT,
398 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
399 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
400 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
401 GFX_FELSBROCKEN,4,5, HA_NEXT,
402 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
403 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
404 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
405 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
406 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
407 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
408 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
409 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
410 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
411 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
412 GFX_GEBLUBBER,4,4, HA_NEXT,
413 GFX_SCHLUESSEL1,4,25, HA_NEXT,
414 GFX_PFORTE1,4,25, HA_NEXT,
415 GFX_PFORTE1X,4,25, HA_NEXT,
416 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
417 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
418 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
419 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
420 GFX_LEERRAUM,1,10, HA_NEXT,
421 GFX_DYNABOMB_NR,1,100, HA_NEXT,
422 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
423 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
424 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
425 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
426 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
427 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
428 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
429 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
430 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
431 GFX_BUTTERFLY,2,2, HA_NEXT,
432 GFX_FIREFLY,2,2, HA_NEXT,
433 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
434 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
435 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
436 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
437 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
438 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
439 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
440 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
441 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
442 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
446 GFX_MOLE_RIGHT,4,2, HA_NEXT,
447 GFX_PINGUIN_DOWN,4,2,
449 GFX_PINGUIN_LEFT,4,2,
450 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
451 GFX_SCHWEIN_DOWN,4,2,
453 GFX_SCHWEIN_LEFT,4,2,
454 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
458 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
459 GFX_SONDE_START,8,1, HA_NEXT,
460 GFX_ABLENK,4,1, HA_NEXT,
461 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
462 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
463 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
464 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
465 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
466 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
467 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
468 GFX_DIAMANT,1,10, HA_NEXT,
469 GFX_LIFE,1,100, HA_NEXT,
470 GFX_LIFE_ASYNC,1,100, HA_NEXT,
471 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
472 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
473 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
474 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
475 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
476 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
477 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
478 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
479 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
480 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
481 GFX_SPEED_PILL,1,100, HA_NEXT,
484 static char *helpscreen_eltext[][2] =
486 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
487 {"Normal sand:", "You can dig through it"},
488 {"Empty field:", "You can walk through it"},
489 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
490 {"Massive Wall:", "Nothing can go through it"},
491 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
492 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
493 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
494 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
495 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
496 {"Emerald: You must collect enough of","them to finish a level"},
497 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
498 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
499 {"Colorful Gems:", "Seem to behave like Emeralds"},
500 {"Rock: Smashes several things;", "Can be moved by the player"},
501 {"Bomb: You can move it, but be", "careful when dropping it"},
502 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
503 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
504 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
505 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
506 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
507 {"Acid: Things that fall in are gone", "forever (including our hero)"},
508 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
509 {"Door: Can be opened by the key", "with the same color"},
510 {"Door: You have to find out the", "right color of the key for it"},
511 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
512 {"Dynamite: This one explodes after", "a few seconds"},
513 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
514 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
515 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
516 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
517 {"Bug: Moves at the right side", "of walls; don't touch it!"},
518 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
519 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
520 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
521 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
522 {"Cruncher (BD style):", "Eats almost everything"},
523 {"Robot: Tries to kill the player", ""},
524 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
525 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
526 {"The Pig: Harmless, but eats all", "gems it can get"},
527 {"The Dragon: Breathes fire,", "especially to some monsters"},
528 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
529 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
530 {"Light Bulb: All of them must be", "switched on to finish a level"},
531 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
532 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
533 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
534 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
535 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
536 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
537 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
538 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
539 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
540 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
541 {"Exit door: Opens if you have enough","emeralds to finish the level"},
542 {"Open exit door: Enter here to leave","the level and exit the actual game"},
543 {"Sokoban element: Object which must", "be pushed to an empty field"},
544 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
545 {"Sokoban element: Field with object", "which can be pushed away"},
546 {"Speed pill: Lets the player run", "twice as fast as normally"},
548 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
550 static char *helpscreen_music[][3] =
552 { "Alchemy", "Ian Boddy", "Drive" },
553 { "The Chase", "Propaganda", "A Secret Wish" },
554 { "Network 23", "Tangerine Dream", "Exit" },
555 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
556 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
557 { "Voyager", "The Alan Parsons Project","Pyramid" },
558 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
560 static int helpscreen_musicpos;
562 void DrawHelpScreenElAction(int start)
566 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
568 while(helpscreen_action[j] != HA_END)
570 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
572 else if (i<start || helpscreen_delay[i-start])
574 if (i>=start && helpscreen_delay[i-start])
575 helpscreen_delay[i-start]--;
577 while(helpscreen_action[j] != HA_NEXT)
584 j += 3*helpscreen_step[i-start];
585 graphic = helpscreen_action[j++];
587 if (helpscreen_frame[i-start])
589 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
590 helpscreen_frame[i-start]--;
595 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
598 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
600 if (helpscreen_action[j] == HA_NEXT)
602 if (!helpscreen_frame[i-start])
603 helpscreen_step[i-start] = 0;
607 if (!helpscreen_frame[i-start])
608 helpscreen_step[i-start]++;
609 while(helpscreen_action[j] != HA_NEXT)
614 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
625 void DrawHelpScreenElText(int start)
628 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
629 int ybottom = SYSIZE - 20;
634 DrawTextFCentered(100, FC_GREEN, "The game elements:");
636 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
639 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
640 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
641 DrawText(xstart, ystart + (i - start) * ystep + 16,
642 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
645 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
648 void DrawHelpScreenMusicText(int num)
650 int ystart = 150, ystep = 30;
651 int ybottom = SYSIZE - 20;
657 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
659 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
661 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
662 helpscreen_music[num][0]);
663 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
665 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
666 "%s", helpscreen_music[num][1]);
667 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
669 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
670 helpscreen_music[num][2]);
672 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
674 PlaySoundLoop(background_loop[num]);
677 void DrawHelpScreenCreditsText()
679 int ystart = 150, ystep = 30;
680 int ybottom = SYSIZE - 20;
686 DrawTextFCentered(100, FC_GREEN,
688 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
689 "DOS/Windows port of the game:");
690 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
692 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
693 "Additional toons:");
694 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
696 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
697 "...and many thanks to all contributors");
698 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
701 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
704 void DrawHelpScreenContactText()
706 int ystart = 150, ystep = 30;
707 int ybottom = SYSIZE - 20;
712 DrawTextFCentered(100, FC_GREEN, "Program information:");
714 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
715 "This game is Freeware!");
716 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
717 "If you like it, send e-mail to:");
718 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
719 "aeglos@valinor.owl.de");
720 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
722 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
724 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
726 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
728 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
731 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
732 "If you have created new levels,");
733 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
734 "send them to me to include them!");
735 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
738 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
741 void DrawHelpScreen()
746 CloseDoor(DOOR_CLOSE_2);
748 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
749 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
750 helpscreen_musicpos = 0;
751 helpscreen_state = 0;
752 DrawHelpScreenElText(0);
753 DrawHelpScreenElAction(0);
757 PlaySoundLoop(SND_RHYTHMLOOP);
760 void HandleHelpScreen(int button)
762 static unsigned long hs_delay = 0;
763 int num_helpscreen_els_pages =
764 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
765 int button_released = !button;
770 if (helpscreen_state < num_helpscreen_els_pages - 1)
772 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
773 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
775 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
776 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
778 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
781 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
783 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
786 DrawHelpScreenCreditsText();
788 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
791 DrawHelpScreenContactText();
797 game_status = MAINMENU;
802 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
804 if (helpscreen_state<num_helpscreen_els_pages)
805 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
813 void HandleTypeName(int newxpos, Key key)
815 static int xpos = 0, ypos = 2;
820 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
821 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
825 if (((key >= KEY_A && key <= KEY_Z) || (key >= KEY_a && key <= KEY_z)) &&
826 xpos < MAX_PLAYER_NAME_LEN)
830 if (key >= KEY_A && key <= KEY_Z)
831 ascii = 'A' + (char)(key - KEY_A);
833 ascii = 'a' + (char)(key - KEY_a);
835 setup.player_name[xpos] = ascii;
836 setup.player_name[xpos + 1] = 0;
838 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
839 setup.player_name, FS_BIG, FC_YELLOW);
840 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
841 setup.player_name, FS_BIG, FC_YELLOW);
842 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
844 else if ((key == KEY_Delete || key == KEY_BackSpace) && xpos > 0)
847 setup.player_name[xpos] = 0;
848 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
849 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
851 else if (key == KEY_Return && xpos > 0)
853 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
854 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
857 game_status = MAINMENU;
863 static void drawCursorExt(int ypos, int color, int graphic)
865 static int cursor_array[SCR_FIELDY];
868 cursor_array[ypos] = graphic;
870 graphic = cursor_array[ypos];
873 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
874 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
877 DrawGraphic(0, ypos, graphic);
880 static void initCursor(int ypos, int graphic)
882 drawCursorExt(ypos, FC_BLUE, graphic);
885 static void drawCursor(int ypos, int color)
887 drawCursorExt(ypos, color, 0);
890 void DrawChooseLevel()
893 CloseDoor(DOOR_CLOSE_2);
896 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
897 MapChooseLevelGadgets();
903 static void AdjustChooseLevelScrollbar(int id, int first_entry)
905 struct GadgetInfo *gi = screen_gadget[id];
906 int items_max, items_visible, item_position;
908 items_max = numLevelDirInfoInGroup(leveldir_current);
909 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
910 item_position = first_entry;
912 if (item_position > items_max - items_visible)
913 item_position = items_max - items_visible;
915 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
916 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
919 static void drawChooseLevelList(int first_entry, int num_page_entries)
922 char buffer[SCR_FIELDX * 2];
923 int max_buffer_len = (SCR_FIELDX - 2) * 2;
924 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
926 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
927 redraw_mask |= REDRAW_FIELD;
929 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
931 for(i=0; i<num_page_entries; i++)
933 struct LevelDirInfo *node, *node_first;
934 int leveldir_pos = first_entry + i;
937 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
938 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
940 strncpy(buffer, node->name , max_buffer_len);
941 buffer[max_buffer_len] = '\0';
943 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
945 if (node->parent_link)
946 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
947 else if (node->level_group)
948 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
950 initCursor(ypos, GFX_KUGEL_BLAU);
954 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
956 if (first_entry + num_page_entries < num_leveldirs)
957 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
960 static void drawChooseLevelInfo(int leveldir_pos)
962 struct LevelDirInfo *node, *node_first;
963 int x, last_redraw_mask = redraw_mask;
965 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
966 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
968 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
970 if (node->parent_link)
971 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
972 else if (node->level_group)
973 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
975 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
976 node->levels, node->class_desc);
978 /* let BackToFront() redraw only what is needed */
979 redraw_mask = last_redraw_mask | REDRAW_TILES;
980 for (x=0; x<SCR_FIELDX; x++)
984 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
986 static unsigned long choose_delay = 0;
987 static int redraw = TRUE;
988 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
989 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
990 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
991 int num_page_entries;
993 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
994 num_page_entries = num_leveldirs;
996 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
998 if (button == MB_MENU_INITIALIZE)
1000 int leveldir_pos = posLevelDirInfo(leveldir_current);
1002 if (leveldir_current->cl_first == -1)
1004 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1005 leveldir_current->cl_cursor =
1006 leveldir_pos - leveldir_current->cl_first + 3;
1009 if (dx == 999) /* first entry is set by scrollbar position */
1010 leveldir_current->cl_first = dy;
1012 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1013 leveldir_current->cl_first);
1015 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1016 drawChooseLevelInfo(leveldir_pos);
1022 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1026 if (button == MB_MENU_INITIALIZE)
1034 y = leveldir_current->cl_cursor + dy;
1037 x = y = 0; /* no action */
1039 if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */
1042 step = num_page_entries - 1;
1044 y = (dy < 0 ? 2 : num_page_entries + 3);
1048 if (x == 1 && y == 2)
1050 if (leveldir_current->cl_first > 0 &&
1051 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1053 leveldir_current->cl_first -= step;
1054 if (leveldir_current->cl_first < 0)
1055 leveldir_current->cl_first = 0;
1057 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1058 drawChooseLevelInfo(leveldir_current->cl_first +
1059 leveldir_current->cl_cursor - 3);
1060 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1061 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1062 leveldir_current->cl_first);
1066 else if (x == 1 && y > num_page_entries + 2)
1068 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1069 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1071 leveldir_current->cl_first += step;
1072 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1073 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1075 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1076 drawChooseLevelInfo(leveldir_current->cl_first +
1077 leveldir_current->cl_cursor - 3);
1078 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1079 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1080 leveldir_current->cl_first);
1085 if (!mx && !my && !dx && !dy)
1088 y = leveldir_current->cl_cursor;
1093 struct LevelDirInfo *node_first, *node_cursor;
1095 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1097 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1098 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1100 if (node_cursor->node_group)
1102 node_cursor->cl_first = leveldir_current->cl_first;
1103 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1104 leveldir_current = node_cursor->node_group;
1108 else if (dx == -1 && leveldir_current->node_parent)
1110 leveldir_current = leveldir_current->node_parent;
1114 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1118 if (y != leveldir_current->cl_cursor)
1120 drawCursor(y - 1, FC_RED);
1121 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1122 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1123 leveldir_current->cl_cursor = y;
1128 struct LevelDirInfo *node_first, *node_cursor;
1129 int leveldir_pos = leveldir_current->cl_first + y - 3;
1131 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1132 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1134 if (node_cursor->node_group)
1136 node_cursor->cl_first = leveldir_current->cl_first;
1137 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1138 leveldir_current = node_cursor->node_group;
1141 else if (node_cursor->parent_link)
1143 leveldir_current = node_cursor->node_parent;
1148 leveldir_current = node_cursor;
1150 LoadLevelSetup_SeriesInfo();
1152 SaveLevelSetup_LastSeries();
1153 SaveLevelSetup_SeriesInfo();
1156 game_status = MAINMENU;
1164 if (game_status == CHOOSELEVEL)
1168 void DrawHallOfFame(int highlight_position)
1171 CloseDoor(DOOR_CLOSE_2);
1173 if (highlight_position < 0)
1174 LoadScore(level_nr);
1178 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1179 PlaySound(SND_HALLOFFAME);
1182 static void drawHallOfFameList(int first_entry, int highlight_position)
1187 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1188 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1190 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1192 int entry = first_entry + i;
1193 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1196 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1197 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1198 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1199 int2str(highscore[i].Score, 5), FS_BIG, color);
1201 DrawText(SX, SY + 64 + i * 32, "..................................",
1202 FS_MEDIUM, FC_YELLOW);
1203 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1204 FS_MEDIUM, FC_YELLOW);
1205 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1206 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1207 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1212 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1214 static int first_entry = 0;
1215 static int highlight_position = 0;
1216 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1217 int button_released = !button;
1219 if (button == MB_MENU_INITIALIZE)
1222 highlight_position = mx;
1223 drawHallOfFameList(first_entry, highlight_position);
1227 if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */
1228 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1232 if (first_entry > 0)
1234 first_entry -= step;
1235 if (first_entry < 0)
1238 drawHallOfFameList(first_entry, highlight_position);
1244 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1246 first_entry += step;
1247 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1248 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1250 drawHallOfFameList(first_entry, highlight_position);
1255 if (button_released)
1257 FadeSound(SND_HALLOFFAME);
1258 game_status = MAINMENU;
1264 if (game_status == HALLOFFAME)
1268 void DrawSetupScreen()
1277 { &setup.sound, "Sound:", },
1278 { &setup.sound_loops, " Sound Loops:" },
1279 { &setup.sound_music, " Game Music:" },
1281 { &setup.toons, "Toons:" },
1282 { &setup.double_buffering, "Buffered gfx:" },
1284 { &setup.scroll_delay, "Scroll Delay:" },
1285 { &setup.soft_scrolling, "Soft Scroll.:" },
1286 { &setup.fading, "Fading:" },
1287 { &setup.quick_doors, "Quick Doors:" },
1288 { &setup.autorecord, "Auto-Record:" },
1289 { &setup.team_mode, "Team-Mode:" },
1290 { &setup.handicap, "Handicap:" },
1291 { &setup.time_limit, "Timelimit:" },
1292 { NULL, "Input Devices" },
1295 { NULL, "Save and exit" }
1299 CloseDoor(DOOR_CLOSE_2);
1302 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1304 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1306 int base = i - SETUP_SCREEN_POS_START;
1308 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1310 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1312 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1313 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1315 initCursor(i, GFX_KUGEL_BLAU);
1318 if (setup_info[base].value)
1320 int setting_value = *setup_info[base].value;
1322 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1323 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1329 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1332 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1334 static int choice = 3;
1335 static int redraw = TRUE;
1336 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1337 int pos_start = SETUP_SCREEN_POS_START + 1;
1338 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1339 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1340 int pos_end = SETUP_SCREEN_POS_END + 1;
1342 if (button == MB_MENU_INITIALIZE)
1347 drawCursor(choice - 1, FC_RED);
1351 if (button == MB_MENU_INITIALIZE)
1364 if (y >= pos_empty1 && y <= pos_empty2)
1365 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1369 else if (y > pos_end)
1373 if (!mx && !my && !dx && !dy)
1379 if (dx == 1 && choice == 14)
1381 game_status = SETUPINPUT;
1382 DrawSetupInputScreen();
1386 if (x==1 && y >= pos_start && y <= pos_end &&
1387 !(y >= pos_empty1 && y <= pos_empty2))
1393 drawCursor(y - 1, FC_RED);
1394 drawCursor(choice - 1, FC_BLUE);
1402 if (y==3 && sound_status==SOUND_AVAILABLE)
1406 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1407 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1408 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1409 setup.sound_loops = FALSE;
1410 setup.sound_music = FALSE;
1413 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1414 setup.sound = !setup.sound;
1416 else if (y==4 && sound_loops_allowed)
1418 if (setup.sound_loops)
1419 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1422 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1423 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1426 setup.sound_loops = !setup.sound_loops;
1428 else if (y==5 && sound_loops_allowed)
1430 if (setup.sound_music)
1431 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1434 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1435 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1438 setup.sound_music = !setup.sound_music;
1445 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1447 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1448 setup.toons = !setup.toons;
1453 if (setup.double_buffering)
1454 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1456 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1457 setup.double_buffering = !setup.double_buffering;
1458 setup.direct_draw = !setup.double_buffering;
1460 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1461 setup.double_buffering = TRUE;
1462 setup.direct_draw = !setup.double_buffering;
1469 if (setup.scroll_delay)
1470 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1472 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1473 setup.scroll_delay = !setup.scroll_delay;
1477 if (setup.soft_scrolling)
1478 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1480 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1481 setup.soft_scrolling = !setup.soft_scrolling;
1486 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1488 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1489 setup.fading = !setup.fading;
1493 if (setup.quick_doors)
1494 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1496 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1497 setup.quick_doors = !setup.quick_doors;
1501 if (setup.autorecord)
1502 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1504 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1505 setup.autorecord = !setup.autorecord;
1509 if (setup.team_mode)
1510 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1512 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1513 setup.team_mode = !setup.team_mode;
1518 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1520 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1521 setup.handicap = !setup.handicap;
1525 if (setup.time_limit)
1526 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1528 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1529 setup.time_limit = !setup.time_limit;
1533 game_status = SETUPINPUT;
1534 DrawSetupInputScreen();
1537 else if (y==pos_end-1 || y==pos_end)
1548 save_joystick_data(JOYSTICK_FILENAME);
1554 game_status = MAINMENU;
1562 if (game_status==SETUP)
1566 void DrawSetupInputScreen()
1569 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1571 initCursor(2, GFX_KUGEL_BLAU);
1572 initCursor(3, GFX_KUGEL_BLAU);
1573 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1574 initCursor(15, GFX_KUGEL_BLAU);
1576 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1577 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1579 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1580 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1581 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1583 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1584 "Joysticks deactivated on this screen");
1586 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1591 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1593 if (device_name == NULL)
1596 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1599 if (strlen(device_name) > 1)
1601 char c1 = device_name[strlen(device_name) - 1];
1602 char c2 = device_name[strlen(device_name) - 2];
1604 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1605 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1608 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1611 static void drawPlayerSetupInputInfo(int player_nr)
1614 static struct SetupKeyboardInfo custom_key;
1621 { &custom_key.left, "Joystick Left" },
1622 { &custom_key.right, "Joystick Right" },
1623 { &custom_key.up, "Joystick Up" },
1624 { &custom_key.down, "Joystick Down" },
1625 { &custom_key.snap, "Button 1" },
1626 { &custom_key.bomb, "Button 2" }
1628 static char *joystick_name[MAX_PLAYERS] =
1636 custom_key = setup.input[player_nr].key;
1638 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1639 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1641 if (setup.input[player_nr].use_joystick)
1643 char *device_name = setup.input[player_nr].joy.device_name;
1645 DrawText(SX+8*32, SY+3*32,
1646 joystick_name[getJoystickNrFromDeviceName(device_name)],
1648 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1652 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1653 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1656 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1657 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1658 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1659 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1660 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1661 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1662 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1663 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1664 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1665 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1666 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1670 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1672 DrawText(SX + 3*32, SY + ypos*32,
1673 " ", FS_BIG, FC_YELLOW);
1674 DrawText(SX + 3*32, SY + ypos*32,
1675 (setup.input[player_nr].use_joystick ?
1677 getKeyNameFromKey(*custom[i].key)),
1682 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1684 static int choice = 3;
1685 static int player_nr = 0;
1686 static int redraw = TRUE;
1687 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1688 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1689 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1690 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1691 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1693 if (button == MB_MENU_INITIALIZE)
1695 drawPlayerSetupInputInfo(player_nr);
1701 drawCursor(choice - 1, FC_RED);
1705 if (button == MB_MENU_INITIALIZE)
1710 if (dx && choice == 3)
1712 x = (dx < 0 ? 11 : 13);
1715 else if (dx && choice == 4)
1717 button = MB_MENU_CHOICE;
1729 if (y >= pos_empty1 && y <= pos_empty2)
1730 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1734 else if (y > pos_end)
1738 if (!mx && !my && !dx && !dy)
1744 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1746 static unsigned long delay = 0;
1748 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1751 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1753 drawPlayerSetupInputInfo(player_nr);
1755 else if (x==1 && y >= pos_start && y <= pos_end &&
1756 !(y >= pos_empty1 && y <= pos_empty2))
1762 drawCursor(y - 1, FC_RED);
1763 drawCursor(choice - 1, FC_BLUE);
1771 char *device_name = setup.input[player_nr].joy.device_name;
1773 if (!setup.input[player_nr].use_joystick)
1775 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1777 setJoystickDeviceToNr(device_name, new_device_nr);
1778 setup.input[player_nr].use_joystick = TRUE;
1782 int device_nr = getJoystickNrFromDeviceName(device_name);
1783 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1785 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1786 setup.input[player_nr].use_joystick = FALSE;
1788 setJoystickDeviceToNr(device_name, new_device_nr);
1798 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1799 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1801 if (setup.input[player_nr].use_joystick)
1803 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1804 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1806 setup.input[player_nr].use_joystick = FALSE;
1810 setup.input[player_nr].use_joystick = TRUE;
1811 setup.input[player_nr].joystick_nr = one_joystick_nr;
1815 drawPlayerSetupInputInfo(player_nr);
1819 if (setup.input[player_nr].use_joystick)
1822 game_status = CALIBRATION;
1823 CalibrateJoystick(player_nr);
1824 game_status = SETUPINPUT;
1827 CustomizeKeyboard(player_nr);
1831 else if (y == pos_end)
1835 game_status = SETUP;
1845 if (game_status == SETUPINPUT)
1849 void CustomizeKeyboard(int player_nr)
1853 boolean finished = FALSE;
1854 static struct SetupKeyboardInfo custom_key;
1859 } customize_step[] =
1861 { &custom_key.left, "Move Left" },
1862 { &custom_key.right, "Move Right" },
1863 { &custom_key.up, "Move Up" },
1864 { &custom_key.down, "Move Down" },
1865 { &custom_key.snap, "Snap Field" },
1866 { &custom_key.bomb, "Place Bomb" }
1869 /* read existing key bindings from player setup */
1870 custom_key = setup.input[player_nr].key;
1873 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1879 DrawText(SX, SY + (2+2*step_nr)*32,
1880 customize_step[step_nr].text, FS_BIG, FC_RED);
1881 DrawText(SX, SY + (2+2*step_nr+1)*32,
1882 "Key:", FS_BIG, FC_RED);
1883 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1884 getKeyNameFromKey(*customize_step[step_nr].key),
1889 if (PendingEvent()) /* got event */
1897 case EVENT_KEYPRESS:
1899 Key key = GetEventKey((KeyEvent *)&event, TRUE);
1901 if (key == KEY_Escape || (key == KEY_Return && step_nr == 6))
1907 /* press 'Enter' to keep the existing key binding */
1908 if (key == KEY_Return || step_nr == 6)
1909 key = *customize_step[step_nr].key;
1911 /* check if key already used */
1912 for (i=0; i<step_nr; i++)
1913 if (*customize_step[i].key == key)
1918 /* got new key binding */
1919 *customize_step[step_nr].key = key;
1920 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1921 " ", FS_BIG, FC_YELLOW);
1922 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1923 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
1926 /* un-highlight last query */
1927 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1928 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1929 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1930 "Key:", FS_BIG, FC_GREEN);
1932 /* press 'Enter' to leave */
1935 DrawText(SX + 16, SY + 15*32+16,
1936 "Press Enter", FS_BIG, FC_YELLOW);
1940 /* query next key binding */
1941 DrawText(SX, SY+(2+2*step_nr)*32,
1942 customize_step[step_nr].text, FS_BIG, FC_RED);
1943 DrawText(SX, SY+(2+2*step_nr+1)*32,
1944 "Key:", FS_BIG, FC_RED);
1945 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1946 getKeyNameFromKey(*customize_step[step_nr].key),
1951 case EVENT_KEYRELEASE:
1952 key_joystick_mapping = 0;
1956 HandleOtherEvents(&event);
1964 /* don't eat all CPU time */
1968 /* write new key bindings back to player setup */
1969 setup.input[player_nr].key = custom_key;
1972 DrawSetupInputScreen();
1975 void CalibrateJoystick(int player_nr)
1978 struct joystick joy_ctrl;
1980 struct joystick_control
1989 int new_joystick_xleft = 128, new_joystick_xright = 128;
1990 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1991 int new_joystick_xmiddle, new_joystick_ymiddle;
1993 int calibration_step = 1;
1996 int joystick_fd = stored_player[player_nr].joystick_fd;
1997 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1998 boolean check[3][3];
1999 int check_remaining;
2003 if (joystick_status == JOYSTICK_OFF ||
2005 !setup.input[player_nr].use_joystick)
2011 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2012 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2013 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2014 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2015 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2016 check_remaining = 3 * 3;
2018 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2019 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2020 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2021 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2022 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2023 check_remaining = 0;
2030 check[x][y] = FALSE;
2031 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2035 joy_value = Joystick(player_nr);
2036 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2037 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2038 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2043 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2045 joy_ctrl.buttons = 0;
2048 while(Joystick(player_nr) & JOY_BUTTON);
2054 if (PendingEvent()) /* got event */
2062 case EVENT_KEYPRESS:
2063 switch(GetEventKey((KeyEvent *)&event, TRUE))
2066 if (check_remaining == 0)
2079 case EVENT_KEYRELEASE:
2080 key_joystick_mapping = 0;
2084 HandleOtherEvents(&event);
2090 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2092 joystick_status = JOYSTICK_OFF;
2096 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2097 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2098 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2099 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2101 new_joystick_xmiddle =
2102 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2103 new_joystick_ymiddle =
2104 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2106 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2107 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2108 setup.input[player_nr].joy.xright = new_joystick_xright;
2109 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2110 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2111 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2113 CheckJoystickData();
2116 joy_value = Joystick(player_nr);
2118 if (joy_value & JOY_BUTTON && check_remaining == 0)
2123 if (calibration_step == 1)
2128 else if (calibrate_joystick(joystick_fd) != 0)
2130 joystick_status = JOYSTICK_OFF;
2134 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2139 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2140 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2142 if (calibration_step == 2)
2143 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2145 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2147 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2148 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2152 while(Joystick(player_nr) & JOY_BUTTON)
2158 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2159 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2161 if (x != last_x || y != last_y)
2164 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2166 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2168 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2173 if (check_remaining > 0 && !check[x+1][y+1])
2175 check[x+1][y+1] = TRUE;
2180 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2181 setup.input[player_nr].joy.xleft,
2182 setup.input[player_nr].joy.xmiddle,
2183 setup.input[player_nr].joy.xright);
2184 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2185 setup.input[player_nr].joy.yupper,
2186 setup.input[player_nr].joy.ymiddle,
2187 setup.input[player_nr].joy.ylower);
2195 /* don't eat all CPU time */
2201 DrawSetupInputScreen();
2202 while(Joystick(player_nr) & JOY_BUTTON);
2208 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2209 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2212 DrawSetupInputScreen();
2215 void HandleGameActions()
2217 if (game_status != PLAYING)
2220 if (local_player->LevelSolved)
2223 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2231 /* ---------- new screen button stuff -------------------------------------- */
2233 /* graphic position and size values for buttons and scrollbars */
2234 #define SC_SCROLLBUTTON_XPOS 64
2235 #define SC_SCROLLBUTTON_YPOS 0
2236 #define SC_SCROLLBAR_XPOS 0
2237 #define SC_SCROLLBAR_YPOS 64
2239 #define SC_SCROLLBUTTON_XSIZE 32
2240 #define SC_SCROLLBUTTON_YSIZE 32
2242 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2243 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2244 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2245 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2246 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2247 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2248 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2249 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2251 #define SC_BORDER_SIZE 14
2259 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2262 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2263 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2264 SCREEN_CTRL_ID_SCROLL_UP,
2265 "scroll level series up"
2268 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2269 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2270 SCREEN_CTRL_ID_SCROLL_DOWN,
2271 "scroll level series down"
2283 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2286 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2287 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2288 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2289 GD_TYPE_SCROLLBAR_VERTICAL,
2290 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2291 "scroll level series vertically"
2295 static void CreateScreenScrollbuttons()
2297 Bitmap gd_bitmap = pix[PIX_MORE];
2298 struct GadgetInfo *gi;
2299 unsigned long event_mask;
2302 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2304 int id = scrollbutton_info[i].gadget_id;
2305 int x, y, width, height;
2306 int gd_x1, gd_x2, gd_y1, gd_y2;
2308 x = scrollbutton_info[i].x;
2309 y = scrollbutton_info[i].y;
2311 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2315 width = SC_SCROLLBUTTON_XSIZE;
2316 height = SC_SCROLLBUTTON_YSIZE;
2317 gd_x1 = scrollbutton_info[i].xpos;
2318 gd_y1 = scrollbutton_info[i].ypos;
2320 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2322 gi = CreateGadget(GDI_CUSTOM_ID, id,
2323 GDI_CUSTOM_TYPE_ID, i,
2324 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2329 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2330 GDI_STATE, GD_BUTTON_UNPRESSED,
2331 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2332 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2333 GDI_EVENT_MASK, event_mask,
2334 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2338 Error(ERR_EXIT, "cannot create gadget");
2340 screen_gadget[id] = gi;
2344 static void CreateScreenScrollbars()
2348 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2350 int id = scrollbar_info[i].gadget_id;
2351 Bitmap gd_bitmap = pix[PIX_MORE];
2352 int gd_x1, gd_x2, gd_y1, gd_y2;
2353 struct GadgetInfo *gi;
2354 int items_max, items_visible, item_position;
2355 unsigned long event_mask;
2356 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2359 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2360 num_page_entries = num_leveldirs;
2362 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2364 items_max = MAX(num_leveldirs, num_page_entries);
2365 items_visible = num_page_entries;
2368 items_max = num_page_entries;
2369 items_visible = num_page_entries;
2373 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2375 gd_x1 = scrollbar_info[i].xpos;
2376 gd_x2 = gd_x1 + scrollbar_info[i].width;
2377 gd_y1 = scrollbar_info[i].ypos;
2378 gd_y2 = scrollbar_info[i].ypos;
2380 gi = CreateGadget(GDI_CUSTOM_ID, id,
2381 GDI_CUSTOM_TYPE_ID, i,
2382 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2383 GDI_X, scrollbar_info[i].x,
2384 GDI_Y, scrollbar_info[i].y,
2385 GDI_WIDTH, scrollbar_info[i].width,
2386 GDI_HEIGHT, scrollbar_info[i].height,
2387 GDI_TYPE, scrollbar_info[i].type,
2388 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2389 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2390 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2391 GDI_STATE, GD_BUTTON_UNPRESSED,
2392 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2393 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2394 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2395 GDI_EVENT_MASK, event_mask,
2396 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2400 Error(ERR_EXIT, "cannot create gadget");
2402 screen_gadget[id] = gi;
2406 void CreateScreenGadgets()
2408 CreateScreenScrollbuttons();
2409 CreateScreenScrollbars();
2412 void MapChooseLevelGadgets()
2414 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2417 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2420 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2421 MapGadget(screen_gadget[i]);
2424 void UnmapChooseLevelGadgets()
2428 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2429 UnmapGadget(screen_gadget[i]);
2432 static void HandleScreenGadgets(struct GadgetInfo *gi)
2434 int id = gi->custom_id;
2436 if (game_status != CHOOSELEVEL)
2441 case SCREEN_CTRL_ID_SCROLL_UP:
2442 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2445 case SCREEN_CTRL_ID_SCROLL_DOWN:
2446 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2449 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2450 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);