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, WINDOW_SUBTITLE_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 /* needed if last screen was the setup screen and fullscreen state changed */
88 ChangeVideoModeIfNeeded();
90 /* map gadgets for main menu screen */
93 /* leveldir_current may be invalid (level group, parent link) */
94 if (!validLevelSeries(leveldir_current))
95 leveldir_current = getFirstValidLevelSeries(leveldir_last_valid);
97 /* store valid level series information */
98 leveldir_last_valid = leveldir_current;
100 /* level_nr may have been set to value over handicap with level editor */
101 if (setup.handicap && level_nr > leveldir_current->handicap_level)
102 level_nr = leveldir_current->handicap_level;
109 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
110 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
111 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
112 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
113 (leveldir_current->readonly ? FC_RED : FC_YELLOW));
114 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
115 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
116 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
117 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
118 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
119 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
121 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
123 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
124 leveldir_current->first_level,
125 leveldir_current->last_level);
127 if (leveldir_current->readonly)
129 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
130 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
134 DrawGraphic(0, i, GFX_KUGEL_BLAU);
135 DrawGraphic(10, 3, GFX_ARROW_BLUE_LEFT);
136 DrawGraphic(14, 3, GFX_ARROW_BLUE_RIGHT);
138 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
141 if (leveldir_current->name)
143 int len = strlen(leveldir_current->name);
144 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
145 int lypos = SY + 352;
147 DrawText(lxpos, lypos, leveldir_current->name, FS_SMALL, FC_SPECIAL2);
152 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
155 if (TAPE_IS_EMPTY(tape))
157 DrawCompleteVideoDisplay();
159 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
167 static void gotoTopLevelDir()
169 /* move upwards to top level directory */
170 while (leveldir_current->node_parent)
172 /* write a "path" into level tree for easy navigation to last level */
173 if (leveldir_current->node_parent->node_group->cl_first == -1)
175 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
176 int leveldir_pos = posLevelDirInfo(leveldir_current);
177 int num_page_entries;
178 int cl_first, cl_cursor;
180 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
181 num_page_entries = num_leveldirs;
183 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
185 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
186 cl_cursor = leveldir_pos - cl_first + 3;
188 leveldir_current->node_parent->node_group->cl_first = cl_first;
189 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
192 leveldir_current = leveldir_current->node_parent;
196 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
198 static int choice = 3;
199 static int redraw = TRUE;
200 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
202 if (redraw || button == MB_MENU_INITIALIZE)
204 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
208 if (button == MB_MENU_INITIALIZE)
213 if (dx && choice == 4)
215 x = (dx < 0 ? 11 : 15);
232 if (!mx && !my && !dx && !dy)
238 if (y == 4 && ((x == 11 && level_nr > leveldir_current->first_level) ||
239 (x == 15 && level_nr < leveldir_current->last_level)) &&
242 static unsigned long level_delay = 0;
243 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
244 int new_level_nr, old_level_nr = level_nr;
245 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
247 new_level_nr = level_nr + (x == 11 ? -step : +step);
248 if (new_level_nr < leveldir_current->first_level)
249 new_level_nr = leveldir_current->first_level;
250 if (new_level_nr > leveldir_current->last_level)
251 new_level_nr = leveldir_current->last_level;
253 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
254 new_level_nr = leveldir_current->handicap_level;
256 if (old_level_nr == new_level_nr ||
257 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
260 level_nr = new_level_nr;
262 DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
263 int2str(level_nr, 3), FS_BIG, font_color);
264 DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
265 int2str(level_nr, 3), FS_BIG, font_color);
268 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
272 DrawCompleteVideoDisplay();
274 /* needed because DrawMicroLevel() takes some time */
277 DelayReached(&level_delay, 0); /* reset delay counter */
279 else if (x == 1 && y >= 3 && y <= 10)
285 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
286 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
294 game_status = TYPENAME;
295 HandleTypeName(strlen(setup.player_name), 0);
301 game_status = CHOOSELEVEL;
302 SaveLevelSetup_LastSeries();
303 SaveLevelSetup_SeriesInfo();
312 game_status = HALLOFFAME;
317 if (leveldir_current->readonly &&
318 strcmp(setup.player_name, "Artsoft") != 0)
319 Request("This level is read only !", REQ_CONFIRM);
320 game_status = LEVELED;
325 game_status = HELPSCREEN;
330 if (setup.autorecord)
331 TapeStartRecording();
333 #if !defined(MSDOS) && !defined(WIN32)
335 SendToServer_StartPlaying();
339 game_status = PLAYING;
351 SaveLevelSetup_LastSeries();
352 SaveLevelSetup_SeriesInfo();
353 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
354 game_status = EXITGAME;
364 if (game_status == MAINMENU)
366 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
371 #define MAX_HELPSCREEN_ELS 10
375 static long helpscreen_state;
376 static int helpscreen_step[MAX_HELPSCREEN_ELS];
377 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
378 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
379 static int helpscreen_action[] =
381 GFX_SPIELER1_DOWN,4,2,
383 GFX_SPIELER1_LEFT,4,2,
384 GFX_SPIELER1_RIGHT,4,2,
385 GFX_SPIELER1_PUSH_LEFT,4,2,
386 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
387 GFX_ERDREICH,1,100, HA_NEXT,
388 GFX_LEERRAUM,1,100, HA_NEXT,
389 GFX_MORAST_LEER,1,100, HA_NEXT,
390 GFX_BETON,1,100, HA_NEXT,
391 GFX_MAUERWERK,1,100, HA_NEXT,
392 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
393 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
394 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
395 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
396 GFX_UNSICHTBAR,1,100, HA_NEXT,
397 GFX_FELSBODEN,1,100, HA_NEXT,
398 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
399 GFX_EDELSTEIN,2,5, HA_NEXT,
400 GFX_DIAMANT,2,5, HA_NEXT,
401 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
402 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
403 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
404 GFX_FELSBROCKEN,4,5, HA_NEXT,
405 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
406 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
407 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
408 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
409 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
410 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
411 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
412 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
413 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
414 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
415 GFX_GEBLUBBER,4,4, HA_NEXT,
416 GFX_SCHLUESSEL1,4,25, HA_NEXT,
417 GFX_PFORTE1,4,25, HA_NEXT,
418 GFX_PFORTE1X,4,25, HA_NEXT,
419 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
420 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
421 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
422 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
423 GFX_LEERRAUM,1,10, HA_NEXT,
424 GFX_DYNABOMB_NR,1,100, HA_NEXT,
425 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
426 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
427 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
428 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
429 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
430 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
431 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
432 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
433 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
434 GFX_BUTTERFLY,2,2, HA_NEXT,
435 GFX_FIREFLY,2,2, HA_NEXT,
436 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
437 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
438 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
439 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
440 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
441 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
442 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
443 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
444 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
445 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
449 GFX_MOLE_RIGHT,4,2, HA_NEXT,
450 GFX_PINGUIN_DOWN,4,2,
452 GFX_PINGUIN_LEFT,4,2,
453 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
454 GFX_SCHWEIN_DOWN,4,2,
456 GFX_SCHWEIN_LEFT,4,2,
457 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
461 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
462 GFX_SONDE_START,8,1, HA_NEXT,
463 GFX_ABLENK,4,1, HA_NEXT,
464 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
465 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
466 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
467 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
468 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
469 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
470 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
471 GFX_DIAMANT,1,10, HA_NEXT,
472 GFX_LIFE,1,100, HA_NEXT,
473 GFX_LIFE_ASYNC,1,100, HA_NEXT,
474 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
475 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
476 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
477 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
478 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
479 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
480 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
481 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
482 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
483 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
484 GFX_SPEED_PILL,1,100, HA_NEXT,
487 static char *helpscreen_eltext[][2] =
489 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
490 {"Normal sand:", "You can dig through it"},
491 {"Empty field:", "You can walk through it"},
492 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
493 {"Massive Wall:", "Nothing can go through it"},
494 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
495 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
496 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
497 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
498 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
499 {"Emerald: You must collect enough of","them to finish a level"},
500 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
501 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
502 {"Colorful Gems:", "Seem to behave like Emeralds"},
503 {"Rock: Smashes several things;", "Can be moved by the player"},
504 {"Bomb: You can move it, but be", "careful when dropping it"},
505 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
506 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
507 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
508 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
509 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
510 {"Acid: Things that fall in are gone", "forever (including our hero)"},
511 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
512 {"Door: Can be opened by the key", "with the same color"},
513 {"Door: You have to find out the", "right color of the key for it"},
514 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
515 {"Dynamite: This one explodes after", "a few seconds"},
516 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
517 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
518 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
519 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
520 {"Bug: Moves at the right side", "of walls; don't touch it!"},
521 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
522 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
523 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
524 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
525 {"Cruncher (BD style):", "Eats almost everything"},
526 {"Robot: Tries to kill the player", ""},
527 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
528 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
529 {"The Pig: Harmless, but eats all", "gems it can get"},
530 {"The Dragon: Breathes fire,", "especially to some monsters"},
531 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
532 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
533 {"Light Bulb: All of them must be", "switched on to finish a level"},
534 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
535 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
536 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
537 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
538 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
539 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
540 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
541 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
542 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
543 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
544 {"Exit door: Opens if you have enough","emeralds to finish the level"},
545 {"Open exit door: Enter here to leave","the level and exit the actual game"},
546 {"Sokoban element: Object which must", "be pushed to an empty field"},
547 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
548 {"Sokoban element: Field with object", "which can be pushed away"},
549 {"Speed pill: Lets the player run", "twice as fast as normally"},
551 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
553 static char *helpscreen_music[][3] =
555 { "Alchemy", "Ian Boddy", "Drive" },
556 { "The Chase", "Propaganda", "A Secret Wish" },
557 { "Network 23", "Tangerine Dream", "Exit" },
558 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
559 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
560 { "Voyager", "The Alan Parsons Project","Pyramid" },
561 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
563 static int helpscreen_musicpos;
565 void DrawHelpScreenElAction(int start)
569 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
571 while(helpscreen_action[j] != HA_END)
573 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
575 else if (i<start || helpscreen_delay[i-start])
577 if (i>=start && helpscreen_delay[i-start])
578 helpscreen_delay[i-start]--;
580 while(helpscreen_action[j] != HA_NEXT)
587 j += 3*helpscreen_step[i-start];
588 graphic = helpscreen_action[j++];
590 if (helpscreen_frame[i-start])
592 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
593 helpscreen_frame[i-start]--;
598 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
601 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
603 if (helpscreen_action[j] == HA_NEXT)
605 if (!helpscreen_frame[i-start])
606 helpscreen_step[i-start] = 0;
610 if (!helpscreen_frame[i-start])
611 helpscreen_step[i-start]++;
612 while(helpscreen_action[j] != HA_NEXT)
617 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
628 void DrawHelpScreenElText(int start)
631 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
632 int ybottom = SYSIZE - 20;
637 DrawTextFCentered(100, FC_GREEN, "The game elements:");
639 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
642 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
643 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
644 DrawText(xstart, ystart + (i - start) * ystep + 16,
645 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
648 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
651 void DrawHelpScreenMusicText(int num)
653 int ystart = 150, ystep = 30;
654 int ybottom = SYSIZE - 20;
660 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
662 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
664 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
665 helpscreen_music[num][0]);
666 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
668 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
669 "%s", helpscreen_music[num][1]);
670 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
672 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
673 helpscreen_music[num][2]);
675 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
677 PlaySoundLoop(background_loop[num]);
680 void DrawHelpScreenCreditsText()
682 int ystart = 150, ystep = 30;
683 int ybottom = SYSIZE - 20;
689 DrawTextFCentered(100, FC_GREEN,
691 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
692 "DOS port of the game:");
693 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
695 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
696 "Additional toons:");
697 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
699 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
700 "...and many thanks to all contributors");
701 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
704 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
707 void DrawHelpScreenContactText()
709 int ystart = 150, ystep = 30;
710 int ybottom = SYSIZE - 20;
715 DrawTextFCentered(100, FC_GREEN, "Program information:");
717 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
718 "This game is Freeware!");
719 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
720 "If you like it, send e-mail to:");
721 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
723 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
725 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
727 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
728 "Detmolder Strasse 189");
729 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
731 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
734 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
735 "If you have created new levels,");
736 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
737 "send them to me to include them!");
738 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
741 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
744 void DrawHelpScreen()
749 CloseDoor(DOOR_CLOSE_2);
751 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
752 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
753 helpscreen_musicpos = 0;
754 helpscreen_state = 0;
755 DrawHelpScreenElText(0);
756 DrawHelpScreenElAction(0);
760 PlaySoundLoop(SND_RHYTHMLOOP);
763 void HandleHelpScreen(int button)
765 static unsigned long hs_delay = 0;
766 int num_helpscreen_els_pages =
767 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
768 int button_released = !button;
773 if (helpscreen_state < num_helpscreen_els_pages - 1)
775 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
776 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
778 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
779 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
781 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
784 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
786 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
789 DrawHelpScreenCreditsText();
791 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
794 DrawHelpScreenContactText();
800 game_status = MAINMENU;
805 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
807 if (helpscreen_state<num_helpscreen_els_pages)
808 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
816 void HandleTypeName(int newxpos, Key key)
818 static int xpos = 0, ypos = 2;
823 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
824 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
828 if (((key >= KEY_A && key <= KEY_Z) || (key >= KEY_a && key <= KEY_z)) &&
829 xpos < MAX_PLAYER_NAME_LEN)
833 if (key >= KEY_A && key <= KEY_Z)
834 ascii = 'A' + (char)(key - KEY_A);
836 ascii = 'a' + (char)(key - KEY_a);
838 setup.player_name[xpos] = ascii;
839 setup.player_name[xpos + 1] = 0;
841 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
842 setup.player_name, FS_BIG, FC_YELLOW);
843 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
844 setup.player_name, FS_BIG, FC_YELLOW);
845 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
847 else if ((key == KEY_Delete || key == KEY_BackSpace) && xpos > 0)
850 setup.player_name[xpos] = 0;
851 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
852 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
854 else if (key == KEY_Return && xpos > 0)
856 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
857 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
860 game_status = MAINMENU;
866 static void drawCursorExt(int ypos, int color, int graphic)
868 static int cursor_array[SCR_FIELDY];
871 cursor_array[ypos] = graphic;
873 graphic = cursor_array[ypos];
876 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
877 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
880 DrawGraphic(0, ypos, graphic);
883 static void initCursor(int ypos, int graphic)
885 drawCursorExt(ypos, FC_BLUE, graphic);
888 static void drawCursor(int ypos, int color)
890 drawCursorExt(ypos, color, 0);
893 void DrawChooseLevel()
896 CloseDoor(DOOR_CLOSE_2);
899 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
900 MapChooseLevelGadgets();
906 static void AdjustChooseLevelScrollbar(int id, int first_entry)
908 struct GadgetInfo *gi = screen_gadget[id];
909 int items_max, items_visible, item_position;
911 items_max = numLevelDirInfoInGroup(leveldir_current);
912 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
913 item_position = first_entry;
915 if (item_position > items_max - items_visible)
916 item_position = items_max - items_visible;
918 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
919 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
922 static void drawChooseLevelList(int first_entry, int num_page_entries)
925 char buffer[SCR_FIELDX * 2];
926 int max_buffer_len = (SCR_FIELDX - 2) * 2;
927 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
929 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
930 redraw_mask |= REDRAW_FIELD;
932 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
934 for(i=0; i<num_page_entries; i++)
936 struct LevelDirInfo *node, *node_first;
937 int leveldir_pos = first_entry + i;
940 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
941 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
943 strncpy(buffer, node->name , max_buffer_len);
944 buffer[max_buffer_len] = '\0';
946 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
948 if (node->parent_link)
949 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
950 else if (node->level_group)
951 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
953 initCursor(ypos, GFX_KUGEL_BLAU);
957 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
959 if (first_entry + num_page_entries < num_leveldirs)
960 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
963 static void drawChooseLevelInfo(int leveldir_pos)
965 struct LevelDirInfo *node, *node_first;
966 int x, last_redraw_mask = redraw_mask;
968 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
969 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
971 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
973 if (node->parent_link)
974 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
975 else if (node->level_group)
976 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
978 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
979 node->levels, node->class_desc);
981 /* let BackToFront() redraw only what is needed */
982 redraw_mask = last_redraw_mask | REDRAW_TILES;
983 for (x=0; x<SCR_FIELDX; x++)
987 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
989 static unsigned long choose_delay = 0;
990 static int redraw = TRUE;
991 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
992 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
993 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
994 int num_page_entries;
996 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
997 num_page_entries = num_leveldirs;
999 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1001 if (button == MB_MENU_INITIALIZE)
1003 int leveldir_pos = posLevelDirInfo(leveldir_current);
1005 if (leveldir_current->cl_first == -1)
1007 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1008 leveldir_current->cl_cursor =
1009 leveldir_pos - leveldir_current->cl_first + 3;
1012 if (dx == 999) /* first entry is set by scrollbar position */
1013 leveldir_current->cl_first = dy;
1015 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1016 leveldir_current->cl_first);
1018 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1019 drawChooseLevelInfo(leveldir_pos);
1025 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1029 if (button == MB_MENU_INITIALIZE)
1037 y = leveldir_current->cl_cursor + dy;
1040 x = y = 0; /* no action */
1042 if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */
1045 step = num_page_entries - 1;
1047 y = (dy < 0 ? 2 : num_page_entries + 3);
1051 if (x == 1 && y == 2)
1053 if (leveldir_current->cl_first > 0 &&
1054 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1056 leveldir_current->cl_first -= step;
1057 if (leveldir_current->cl_first < 0)
1058 leveldir_current->cl_first = 0;
1060 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1061 drawChooseLevelInfo(leveldir_current->cl_first +
1062 leveldir_current->cl_cursor - 3);
1063 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1064 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1065 leveldir_current->cl_first);
1069 else if (x == 1 && y > num_page_entries + 2)
1071 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1072 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1074 leveldir_current->cl_first += step;
1075 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1076 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1078 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1079 drawChooseLevelInfo(leveldir_current->cl_first +
1080 leveldir_current->cl_cursor - 3);
1081 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1082 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1083 leveldir_current->cl_first);
1088 if (!mx && !my && !dx && !dy)
1091 y = leveldir_current->cl_cursor;
1096 struct LevelDirInfo *node_first, *node_cursor;
1098 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1100 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1101 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1103 if (node_cursor->node_group)
1105 node_cursor->cl_first = leveldir_current->cl_first;
1106 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1107 leveldir_current = node_cursor->node_group;
1111 else if (dx == -1 && leveldir_current->node_parent)
1113 leveldir_current = leveldir_current->node_parent;
1117 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1121 if (y != leveldir_current->cl_cursor)
1123 drawCursor(y - 1, FC_RED);
1124 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1125 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1126 leveldir_current->cl_cursor = y;
1131 struct LevelDirInfo *node_first, *node_cursor;
1132 int leveldir_pos = leveldir_current->cl_first + y - 3;
1134 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1135 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1137 if (node_cursor->node_group)
1139 node_cursor->cl_first = leveldir_current->cl_first;
1140 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1141 leveldir_current = node_cursor->node_group;
1144 else if (node_cursor->parent_link)
1146 leveldir_current = node_cursor->node_parent;
1151 leveldir_current = node_cursor;
1153 LoadLevelSetup_SeriesInfo();
1155 SaveLevelSetup_LastSeries();
1156 SaveLevelSetup_SeriesInfo();
1159 game_status = MAINMENU;
1167 if (game_status == CHOOSELEVEL)
1171 void DrawHallOfFame(int highlight_position)
1174 CloseDoor(DOOR_CLOSE_2);
1176 if (highlight_position < 0)
1177 LoadScore(level_nr);
1181 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1182 PlaySound(SND_HALLOFFAME);
1185 static void drawHallOfFameList(int first_entry, int highlight_position)
1190 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1191 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1193 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1195 int entry = first_entry + i;
1196 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1199 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1200 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1201 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1202 int2str(highscore[i].Score, 5), FS_BIG, color);
1204 DrawText(SX, SY + 64 + i * 32, "..................................",
1205 FS_MEDIUM, FC_YELLOW);
1206 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1207 FS_MEDIUM, FC_YELLOW);
1208 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1209 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1210 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1215 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1217 static int first_entry = 0;
1218 static int highlight_position = 0;
1219 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1220 int button_released = !button;
1222 if (button == MB_MENU_INITIALIZE)
1225 highlight_position = mx;
1226 drawHallOfFameList(first_entry, highlight_position);
1230 if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */
1231 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1235 if (first_entry > 0)
1237 first_entry -= step;
1238 if (first_entry < 0)
1241 drawHallOfFameList(first_entry, highlight_position);
1247 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1249 first_entry += step;
1250 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1251 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1253 drawHallOfFameList(first_entry, highlight_position);
1258 if (button_released)
1260 FadeSound(SND_HALLOFFAME);
1261 game_status = MAINMENU;
1267 if (game_status == HALLOFFAME)
1271 void DrawSetupScreen()
1280 { &setup.sound, "Sound:", },
1281 { &setup.sound_loops, " Sound Loops:" },
1282 { &setup.sound_music, " Game Music:" },
1284 { &setup.toons, "Toons:" },
1285 { &setup.double_buffering, "Buffered gfx:" },
1287 { &setup.scroll_delay, "Scroll Delay:" },
1288 { &setup.soft_scrolling, "Soft Scroll.:" },
1290 { &setup.fading, "Fading:" },
1292 { &setup.fullscreen, "Fullscreen:" },
1293 { &setup.quick_doors, "Quick Doors:" },
1294 { &setup.autorecord, "Auto-Record:" },
1295 { &setup.team_mode, "Team-Mode:" },
1296 { &setup.handicap, "Handicap:" },
1297 { &setup.time_limit, "Timelimit:" },
1298 { NULL, "Input Devices" },
1301 { NULL, "Save and exit" }
1305 CloseDoor(DOOR_CLOSE_2);
1308 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1310 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1312 int base = i - SETUP_SCREEN_POS_START;
1314 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1316 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1318 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1319 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1321 initCursor(i, GFX_KUGEL_BLAU);
1324 if (setup_info[base].value)
1326 int setting_value = *setup_info[base].value;
1328 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1329 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1335 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1338 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1340 static int choice = 3;
1341 static int redraw = TRUE;
1342 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1343 int pos_start = SETUP_SCREEN_POS_START + 1;
1344 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1345 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1346 int pos_end = SETUP_SCREEN_POS_END + 1;
1348 if (button == MB_MENU_INITIALIZE)
1353 drawCursor(choice - 1, FC_RED);
1357 if (button == MB_MENU_INITIALIZE)
1370 if (y >= pos_empty1 && y <= pos_empty2)
1371 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1375 else if (y > pos_end)
1379 if (!mx && !my && !dx && !dy)
1385 if (dx == 1 && choice == 14)
1387 game_status = SETUPINPUT;
1388 DrawSetupInputScreen();
1392 if (x==1 && y >= pos_start && y <= pos_end &&
1393 !(y >= pos_empty1 && y <= pos_empty2))
1399 drawCursor(y - 1, FC_RED);
1400 drawCursor(choice - 1, FC_BLUE);
1408 if (y==3 && sound_status==SOUND_AVAILABLE)
1412 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1413 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1414 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1415 setup.sound_loops = FALSE;
1416 setup.sound_music = FALSE;
1419 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1420 setup.sound = !setup.sound;
1422 else if (y==4 && sound_loops_allowed)
1424 if (setup.sound_loops)
1425 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1428 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1429 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1432 setup.sound_loops = !setup.sound_loops;
1434 else if (y==5 && sound_loops_allowed)
1436 if (setup.sound_music)
1437 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1440 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1441 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1444 setup.sound_music = !setup.sound_music;
1451 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1453 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1454 setup.toons = !setup.toons;
1459 if (setup.double_buffering)
1460 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1462 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1463 setup.double_buffering = !setup.double_buffering;
1464 setup.direct_draw = !setup.double_buffering;
1466 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1467 setup.double_buffering = TRUE;
1468 setup.direct_draw = !setup.double_buffering;
1475 if (setup.scroll_delay)
1476 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1478 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1479 setup.scroll_delay = !setup.scroll_delay;
1483 if (setup.soft_scrolling)
1484 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1486 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1487 setup.soft_scrolling = !setup.soft_scrolling;
1493 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1495 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1496 setup.fading = !setup.fading;
1499 else if (y==8 && fullscreen_available)
1501 if (setup.fullscreen)
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.fullscreen = !setup.fullscreen;
1509 if (setup.quick_doors)
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.quick_doors = !setup.quick_doors;
1517 if (setup.autorecord)
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.autorecord = !setup.autorecord;
1525 if (setup.team_mode)
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.team_mode = !setup.team_mode;
1534 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1536 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1537 setup.handicap = !setup.handicap;
1541 if (setup.time_limit)
1542 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1544 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1545 setup.time_limit = !setup.time_limit;
1549 game_status = SETUPINPUT;
1550 DrawSetupInputScreen();
1553 else if (y==pos_end-1 || y==pos_end)
1564 save_joystick_data(JOYSTICK_FILENAME);
1570 game_status = MAINMENU;
1578 if (game_status==SETUP)
1582 void DrawSetupInputScreen()
1585 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1587 initCursor(2, GFX_KUGEL_BLAU);
1588 initCursor(3, GFX_KUGEL_BLAU);
1589 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1590 initCursor(15, GFX_KUGEL_BLAU);
1592 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1593 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1595 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1596 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1597 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1599 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1600 "Joysticks deactivated on this screen");
1602 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1607 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1609 if (device_name == NULL)
1612 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1615 if (strlen(device_name) > 1)
1617 char c1 = device_name[strlen(device_name) - 1];
1618 char c2 = device_name[strlen(device_name) - 2];
1620 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1621 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1624 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1627 static void drawPlayerSetupInputInfo(int player_nr)
1630 static struct SetupKeyboardInfo custom_key;
1637 { &custom_key.left, "Joystick Left" },
1638 { &custom_key.right, "Joystick Right" },
1639 { &custom_key.up, "Joystick Up" },
1640 { &custom_key.down, "Joystick Down" },
1641 { &custom_key.snap, "Button 1" },
1642 { &custom_key.bomb, "Button 2" }
1644 static char *joystick_name[MAX_PLAYERS] =
1652 custom_key = setup.input[player_nr].key;
1654 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1655 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1657 if (setup.input[player_nr].use_joystick)
1659 char *device_name = setup.input[player_nr].joy.device_name;
1661 DrawText(SX+8*32, SY+3*32,
1662 joystick_name[getJoystickNrFromDeviceName(device_name)],
1664 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1668 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1669 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1672 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1673 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1674 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1675 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1676 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1677 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1678 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1679 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1680 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1681 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1682 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1686 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1688 DrawText(SX + 3*32, SY + ypos*32,
1689 " ", FS_BIG, FC_YELLOW);
1690 DrawText(SX + 3*32, SY + ypos*32,
1691 (setup.input[player_nr].use_joystick ?
1693 getKeyNameFromKey(*custom[i].key)),
1698 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1700 static int choice = 3;
1701 static int player_nr = 0;
1702 static int redraw = TRUE;
1703 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1704 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1705 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1706 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1707 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1709 if (button == MB_MENU_INITIALIZE)
1711 drawPlayerSetupInputInfo(player_nr);
1717 drawCursor(choice - 1, FC_RED);
1721 if (button == MB_MENU_INITIALIZE)
1726 if (dx && choice == 3)
1728 x = (dx < 0 ? 11 : 13);
1731 else if (dx && choice == 4)
1733 button = MB_MENU_CHOICE;
1745 if (y >= pos_empty1 && y <= pos_empty2)
1746 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1750 else if (y > pos_end)
1754 if (!mx && !my && !dx && !dy)
1760 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1762 static unsigned long delay = 0;
1764 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1767 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1769 drawPlayerSetupInputInfo(player_nr);
1771 else if (x==1 && y >= pos_start && y <= pos_end &&
1772 !(y >= pos_empty1 && y <= pos_empty2))
1778 drawCursor(y - 1, FC_RED);
1779 drawCursor(choice - 1, FC_BLUE);
1787 char *device_name = setup.input[player_nr].joy.device_name;
1789 if (!setup.input[player_nr].use_joystick)
1791 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1793 setJoystickDeviceToNr(device_name, new_device_nr);
1794 setup.input[player_nr].use_joystick = TRUE;
1798 int device_nr = getJoystickNrFromDeviceName(device_name);
1799 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1801 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1802 setup.input[player_nr].use_joystick = FALSE;
1804 setJoystickDeviceToNr(device_name, new_device_nr);
1814 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1815 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1817 if (setup.input[player_nr].use_joystick)
1819 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1820 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1822 setup.input[player_nr].use_joystick = FALSE;
1826 setup.input[player_nr].use_joystick = TRUE;
1827 setup.input[player_nr].joystick_nr = one_joystick_nr;
1831 drawPlayerSetupInputInfo(player_nr);
1835 if (setup.input[player_nr].use_joystick)
1838 game_status = CALIBRATION;
1839 CalibrateJoystick(player_nr);
1840 game_status = SETUPINPUT;
1843 CustomizeKeyboard(player_nr);
1847 else if (y == pos_end)
1851 game_status = SETUP;
1861 if (game_status == SETUPINPUT)
1865 void CustomizeKeyboard(int player_nr)
1869 boolean finished = FALSE;
1870 static struct SetupKeyboardInfo custom_key;
1875 } customize_step[] =
1877 { &custom_key.left, "Move Left" },
1878 { &custom_key.right, "Move Right" },
1879 { &custom_key.up, "Move Up" },
1880 { &custom_key.down, "Move Down" },
1881 { &custom_key.snap, "Snap Field" },
1882 { &custom_key.bomb, "Place Bomb" }
1885 /* read existing key bindings from player setup */
1886 custom_key = setup.input[player_nr].key;
1889 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1895 DrawText(SX, SY + (2+2*step_nr)*32,
1896 customize_step[step_nr].text, FS_BIG, FC_RED);
1897 DrawText(SX, SY + (2+2*step_nr+1)*32,
1898 "Key:", FS_BIG, FC_RED);
1899 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1900 getKeyNameFromKey(*customize_step[step_nr].key),
1905 if (PendingEvent()) /* got event */
1913 case EVENT_KEYPRESS:
1915 Key key = GetEventKey((KeyEvent *)&event, TRUE);
1917 if (key == KEY_Escape || (key == KEY_Return && step_nr == 6))
1923 /* all keys configured -- wait for "Escape" or "Return" key */
1927 /* press 'Enter' to keep the existing key binding */
1928 if (key == KEY_Return)
1929 key = *customize_step[step_nr].key;
1931 /* check if key already used */
1932 for (i=0; i<step_nr; i++)
1933 if (*customize_step[i].key == key)
1938 /* got new key binding */
1939 *customize_step[step_nr].key = key;
1940 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1941 " ", FS_BIG, FC_YELLOW);
1942 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1943 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
1946 /* un-highlight last query */
1947 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1948 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1949 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1950 "Key:", FS_BIG, FC_GREEN);
1952 /* press 'Enter' to leave */
1955 DrawText(SX + 16, SY + 15*32+16,
1956 "Press Enter", FS_BIG, FC_YELLOW);
1960 /* query next key binding */
1961 DrawText(SX, SY+(2+2*step_nr)*32,
1962 customize_step[step_nr].text, FS_BIG, FC_RED);
1963 DrawText(SX, SY+(2+2*step_nr+1)*32,
1964 "Key:", FS_BIG, FC_RED);
1965 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1966 getKeyNameFromKey(*customize_step[step_nr].key),
1971 case EVENT_KEYRELEASE:
1972 key_joystick_mapping = 0;
1976 HandleOtherEvents(&event);
1984 /* don't eat all CPU time */
1988 /* write new key bindings back to player setup */
1989 setup.input[player_nr].key = custom_key;
1992 DrawSetupInputScreen();
1995 void CalibrateJoystick(int player_nr)
1998 struct joystick joy_ctrl;
2000 struct joystick_control
2009 int new_joystick_xleft = 128, new_joystick_xright = 128;
2010 int new_joystick_yupper = 128, new_joystick_ylower = 128;
2011 int new_joystick_xmiddle, new_joystick_ymiddle;
2013 int calibration_step = 1;
2016 int joystick_fd = stored_player[player_nr].joystick_fd;
2017 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2018 boolean check[3][3];
2019 int check_remaining;
2023 if (joystick_status == JOYSTICK_OFF ||
2025 !setup.input[player_nr].use_joystick)
2031 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2032 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2033 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2034 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2035 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2036 check_remaining = 3 * 3;
2038 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2039 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2040 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2041 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2042 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2043 check_remaining = 0;
2050 check[x][y] = FALSE;
2051 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2055 joy_value = Joystick(player_nr);
2056 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2057 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2058 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2063 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2065 joy_ctrl.buttons = 0;
2068 while(Joystick(player_nr) & JOY_BUTTON);
2074 if (PendingEvent()) /* got event */
2082 case EVENT_KEYPRESS:
2083 switch(GetEventKey((KeyEvent *)&event, TRUE))
2086 if (check_remaining == 0)
2099 case EVENT_KEYRELEASE:
2100 key_joystick_mapping = 0;
2104 HandleOtherEvents(&event);
2111 #ifdef USE_SDL_JOYSTICK
2112 joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0);
2113 joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1);
2115 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2117 joystick_status = JOYSTICK_OFF;
2122 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2123 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2124 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2125 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2127 new_joystick_xmiddle =
2128 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2129 new_joystick_ymiddle =
2130 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2132 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2133 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2134 setup.input[player_nr].joy.xright = new_joystick_xright;
2135 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2136 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2137 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2139 CheckJoystickData();
2142 joy_value = Joystick(player_nr);
2144 if (joy_value & JOY_BUTTON && check_remaining == 0)
2149 if (calibration_step == 1)
2154 else if (calibrate_joystick(joystick_fd) != 0)
2156 joystick_status = JOYSTICK_OFF;
2160 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2165 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2166 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2168 if (calibration_step == 2)
2169 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2171 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2173 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2174 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2178 while(Joystick(player_nr) & JOY_BUTTON)
2184 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2185 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2187 if (x != last_x || y != last_y)
2190 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2192 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2194 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2199 if (check_remaining > 0 && !check[x+1][y+1])
2201 check[x+1][y+1] = TRUE;
2206 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2207 setup.input[player_nr].joy.xleft,
2208 setup.input[player_nr].joy.xmiddle,
2209 setup.input[player_nr].joy.xright);
2210 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2211 setup.input[player_nr].joy.yupper,
2212 setup.input[player_nr].joy.ymiddle,
2213 setup.input[player_nr].joy.ylower);
2221 /* don't eat all CPU time */
2227 DrawSetupInputScreen();
2229 /* wait until the last pressed button was released */
2230 while(Joystick(player_nr) & JOY_BUTTON)
2232 if (PendingEvent()) /* got event */
2237 HandleOtherEvents(&event);
2247 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2248 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2251 DrawSetupInputScreen();
2254 void HandleGameActions()
2256 if (game_status != PLAYING)
2259 if (local_player->LevelSolved)
2262 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2270 /* ---------- new screen button stuff -------------------------------------- */
2272 /* graphic position and size values for buttons and scrollbars */
2273 #define SC_SCROLLBUTTON_XPOS 64
2274 #define SC_SCROLLBUTTON_YPOS 0
2275 #define SC_SCROLLBAR_XPOS 0
2276 #define SC_SCROLLBAR_YPOS 64
2278 #define SC_SCROLLBUTTON_XSIZE 32
2279 #define SC_SCROLLBUTTON_YSIZE 32
2281 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2282 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2283 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2284 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2285 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2286 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2287 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2288 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2290 #define SC_BORDER_SIZE 14
2298 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2301 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2302 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2303 SCREEN_CTRL_ID_SCROLL_UP,
2304 "scroll level series up"
2307 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2308 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2309 SCREEN_CTRL_ID_SCROLL_DOWN,
2310 "scroll level series down"
2322 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2325 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2326 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2327 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2328 GD_TYPE_SCROLLBAR_VERTICAL,
2329 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2330 "scroll level series vertically"
2334 static void CreateScreenScrollbuttons()
2336 Bitmap gd_bitmap = pix[PIX_MORE];
2337 struct GadgetInfo *gi;
2338 unsigned long event_mask;
2341 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2343 int id = scrollbutton_info[i].gadget_id;
2344 int x, y, width, height;
2345 int gd_x1, gd_x2, gd_y1, gd_y2;
2347 x = scrollbutton_info[i].x;
2348 y = scrollbutton_info[i].y;
2350 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2354 width = SC_SCROLLBUTTON_XSIZE;
2355 height = SC_SCROLLBUTTON_YSIZE;
2356 gd_x1 = scrollbutton_info[i].xpos;
2357 gd_y1 = scrollbutton_info[i].ypos;
2359 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2361 gi = CreateGadget(GDI_CUSTOM_ID, id,
2362 GDI_CUSTOM_TYPE_ID, i,
2363 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2368 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2369 GDI_STATE, GD_BUTTON_UNPRESSED,
2370 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2371 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2372 GDI_EVENT_MASK, event_mask,
2373 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2377 Error(ERR_EXIT, "cannot create gadget");
2379 screen_gadget[id] = gi;
2383 static void CreateScreenScrollbars()
2387 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2389 int id = scrollbar_info[i].gadget_id;
2390 Bitmap gd_bitmap = pix[PIX_MORE];
2391 int gd_x1, gd_x2, gd_y1, gd_y2;
2392 struct GadgetInfo *gi;
2393 int items_max, items_visible, item_position;
2394 unsigned long event_mask;
2395 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2398 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2399 num_page_entries = num_leveldirs;
2401 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2403 items_max = MAX(num_leveldirs, num_page_entries);
2404 items_visible = num_page_entries;
2407 items_max = num_page_entries;
2408 items_visible = num_page_entries;
2412 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2414 gd_x1 = scrollbar_info[i].xpos;
2415 gd_x2 = gd_x1 + scrollbar_info[i].width;
2416 gd_y1 = scrollbar_info[i].ypos;
2417 gd_y2 = scrollbar_info[i].ypos;
2419 gi = CreateGadget(GDI_CUSTOM_ID, id,
2420 GDI_CUSTOM_TYPE_ID, i,
2421 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2422 GDI_X, scrollbar_info[i].x,
2423 GDI_Y, scrollbar_info[i].y,
2424 GDI_WIDTH, scrollbar_info[i].width,
2425 GDI_HEIGHT, scrollbar_info[i].height,
2426 GDI_TYPE, scrollbar_info[i].type,
2427 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2428 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2429 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2430 GDI_STATE, GD_BUTTON_UNPRESSED,
2431 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2432 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2433 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2434 GDI_EVENT_MASK, event_mask,
2435 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2439 Error(ERR_EXIT, "cannot create gadget");
2441 screen_gadget[id] = gi;
2445 void CreateScreenGadgets()
2447 CreateScreenScrollbuttons();
2448 CreateScreenScrollbars();
2451 void MapChooseLevelGadgets()
2453 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2456 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2459 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2460 MapGadget(screen_gadget[i]);
2463 void UnmapChooseLevelGadgets()
2467 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2468 UnmapGadget(screen_gadget[i]);
2471 static void HandleScreenGadgets(struct GadgetInfo *gi)
2473 int id = gi->custom_id;
2475 if (game_status != CHOOSELEVEL)
2480 case SCREEN_CTRL_ID_SCROLL_UP:
2481 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2484 case SCREEN_CTRL_ID_SCROLL_DOWN:
2485 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2488 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2489 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);