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];
59 extern unsigned char get_ascii(KeySym);
64 int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
66 DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
67 DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING);
72 static struct LevelDirInfo *leveldir_last_valid = NULL;
74 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
78 KeyboardAutoRepeatOn();
80 /* needed if last screen was the playing screen, invoked from level editor */
81 if (level_editor_test_game)
83 game_status = LEVELED;
88 /* needed if last screen was the editor screen */
89 UndrawSpecialEditorDoor();
91 /* map gadgets for main menu screen */
94 /* leveldir_current may be invalid (level group, parent link) */
95 if (!validLevelSeries(leveldir_current))
96 leveldir_current = getFirstValidLevelSeries(leveldir_last_valid);
98 /* store valid level series information */
99 leveldir_last_valid = leveldir_current;
101 /* level_nr may have been set to value over handicap with level editor */
102 if (setup.handicap && level_nr > leveldir_current->handicap_level)
103 level_nr = leveldir_current->handicap_level;
110 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
111 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
112 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
113 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
114 (leveldir_current->readonly ? FC_RED : FC_YELLOW));
115 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
116 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
117 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
118 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
119 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
120 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
122 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
124 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
125 leveldir_current->first_level,
126 leveldir_current->last_level);
128 if (leveldir_current->readonly)
130 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
131 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
135 DrawGraphic(0, i, GFX_KUGEL_BLAU);
136 DrawGraphic(10, 3, GFX_ARROW_BLUE_LEFT);
137 DrawGraphic(14, 3, GFX_ARROW_BLUE_RIGHT);
139 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
142 if (leveldir_current->name)
144 int len = strlen(leveldir_current->name);
145 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
146 int lypos = SY + 352;
148 DrawText(lxpos, lypos, leveldir_current->name, FS_SMALL, FC_SPECIAL2);
153 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
156 if (TAPE_IS_EMPTY(tape))
158 DrawCompleteVideoDisplay();
160 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
168 static void gotoTopLevelDir()
170 /* move upwards to top level directory */
171 while (leveldir_current->node_parent)
173 /* write a "path" into level tree for easy navigation to last level */
174 if (leveldir_current->node_parent->node_group->cl_first == -1)
176 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
177 int leveldir_pos = posLevelDirInfo(leveldir_current);
178 int num_page_entries;
179 int cl_first, cl_cursor;
181 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
182 num_page_entries = num_leveldirs;
184 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
186 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
187 cl_cursor = leveldir_pos - cl_first + 3;
189 leveldir_current->node_parent->node_group->cl_first = cl_first;
190 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
193 leveldir_current = leveldir_current->node_parent;
197 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
199 static int choice = 3;
200 static int redraw = TRUE;
201 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
203 if (redraw || button == MB_MENU_INITIALIZE)
205 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
209 if (button == MB_MENU_INITIALIZE)
214 if (dx && choice == 4)
216 x = (dx < 0 ? 11 : 15);
233 if (!mx && !my && !dx && !dy)
239 if (y == 4 && ((x == 11 && level_nr > leveldir_current->first_level) ||
240 (x == 15 && level_nr < leveldir_current->last_level)) &&
243 static unsigned long level_delay = 0;
244 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
245 int new_level_nr, old_level_nr = level_nr;
246 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
248 new_level_nr = level_nr + (x == 11 ? -step : +step);
249 if (new_level_nr < leveldir_current->first_level)
250 new_level_nr = leveldir_current->first_level;
251 if (new_level_nr > leveldir_current->last_level)
252 new_level_nr = leveldir_current->last_level;
254 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
255 new_level_nr = leveldir_current->handicap_level;
257 if (old_level_nr == new_level_nr ||
258 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
261 level_nr = new_level_nr;
263 DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
264 int2str(level_nr, 3), FS_BIG, font_color);
265 DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
266 int2str(level_nr, 3), FS_BIG, font_color);
269 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
273 DrawCompleteVideoDisplay();
275 /* needed because DrawMicroLevel() takes some time */
278 DelayReached(&level_delay, 0); /* reset delay counter */
280 else if (x == 1 && y >= 3 && y <= 10)
286 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
287 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
295 game_status = TYPENAME;
296 HandleTypeName(strlen(setup.player_name), 0);
302 game_status = CHOOSELEVEL;
303 SaveLevelSetup_LastSeries();
304 SaveLevelSetup_SeriesInfo();
313 game_status = HALLOFFAME;
318 if (leveldir_current->readonly &&
319 strcmp(setup.player_name, "Artsoft") != 0)
320 Request("This level is read only !", REQ_CONFIRM);
321 game_status = LEVELED;
326 game_status = HELPSCREEN;
331 if (setup.autorecord)
332 TapeStartRecording();
336 SendToServer_StartPlaying();
340 game_status = PLAYING;
352 SaveLevelSetup_LastSeries();
353 SaveLevelSetup_SeriesInfo();
354 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
355 game_status = EXITGAME;
365 if (game_status == MAINMENU)
367 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
372 #define MAX_HELPSCREEN_ELS 10
376 static long helpscreen_state;
377 static int helpscreen_step[MAX_HELPSCREEN_ELS];
378 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
379 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
380 static int helpscreen_action[] =
382 GFX_SPIELER1_DOWN,4,2,
384 GFX_SPIELER1_LEFT,4,2,
385 GFX_SPIELER1_RIGHT,4,2,
386 GFX_SPIELER1_PUSH_LEFT,4,2,
387 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
388 GFX_ERDREICH,1,100, HA_NEXT,
389 GFX_LEERRAUM,1,100, HA_NEXT,
390 GFX_MORAST_LEER,1,100, HA_NEXT,
391 GFX_BETON,1,100, HA_NEXT,
392 GFX_MAUERWERK,1,100, HA_NEXT,
393 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
394 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
395 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
396 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
397 GFX_UNSICHTBAR,1,100, HA_NEXT,
398 GFX_FELSBODEN,1,100, HA_NEXT,
399 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
400 GFX_EDELSTEIN,2,5, HA_NEXT,
401 GFX_DIAMANT,2,5, HA_NEXT,
402 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
403 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
404 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
405 GFX_FELSBROCKEN,4,5, HA_NEXT,
406 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
407 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
408 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
409 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
410 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
411 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
412 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
413 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
414 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
415 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
416 GFX_GEBLUBBER,4,4, HA_NEXT,
417 GFX_SCHLUESSEL1,4,25, HA_NEXT,
418 GFX_PFORTE1,4,25, HA_NEXT,
419 GFX_PFORTE1X,4,25, HA_NEXT,
420 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
421 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
422 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
423 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
424 GFX_LEERRAUM,1,10, HA_NEXT,
425 GFX_DYNABOMB_NR,1,100, HA_NEXT,
426 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
427 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
428 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
429 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
430 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
431 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
432 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
433 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
434 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
435 GFX_BUTTERFLY,2,2, HA_NEXT,
436 GFX_FIREFLY,2,2, HA_NEXT,
437 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
438 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
439 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
440 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
441 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
442 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
443 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
444 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
445 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
446 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
450 GFX_MOLE_RIGHT,4,2, HA_NEXT,
451 GFX_PINGUIN_DOWN,4,2,
453 GFX_PINGUIN_LEFT,4,2,
454 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
455 GFX_SCHWEIN_DOWN,4,2,
457 GFX_SCHWEIN_LEFT,4,2,
458 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
462 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
463 GFX_SONDE_START,8,1, HA_NEXT,
464 GFX_ABLENK,4,1, HA_NEXT,
465 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
466 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
467 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
468 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
469 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
470 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
471 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
472 GFX_DIAMANT,1,10, HA_NEXT,
473 GFX_LIFE,1,100, HA_NEXT,
474 GFX_LIFE_ASYNC,1,100, HA_NEXT,
475 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
476 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
477 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
478 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
479 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
480 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
481 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
482 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
483 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
484 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
485 GFX_SPEED_PILL,1,100, HA_NEXT,
488 static char *helpscreen_eltext[][2] =
490 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
491 {"Normal sand:", "You can dig through it"},
492 {"Empty field:", "You can walk through it"},
493 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
494 {"Massive Wall:", "Nothing can go through it"},
495 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
496 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
497 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
498 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
499 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
500 {"Emerald: You must collect enough of","them to finish a level"},
501 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
502 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
503 {"Colorful Gems:", "Seem to behave like Emeralds"},
504 {"Rock: Smashes several things;", "Can be moved by the player"},
505 {"Bomb: You can move it, but be", "careful when dropping it"},
506 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
507 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
508 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
509 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
510 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
511 {"Acid: Things that fall in are gone", "forever (including our hero)"},
512 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
513 {"Door: Can be opened by the key", "with the same color"},
514 {"Door: You have to find out the", "right color of the key for it"},
515 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
516 {"Dynamite: This one explodes after", "a few seconds"},
517 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
518 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
519 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
520 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
521 {"Bug: Moves at the right side", "of walls; don't touch it!"},
522 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
523 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
524 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
525 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
526 {"Cruncher (BD style):", "Eats almost everything"},
527 {"Robot: Tries to kill the player", ""},
528 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
529 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
530 {"The Pig: Harmless, but eats all", "gems it can get"},
531 {"The Dragon: Breathes fire,", "especially to some monsters"},
532 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
533 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
534 {"Light Bulb: All of them must be", "switched on to finish a level"},
535 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
536 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
537 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
538 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
539 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
540 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
541 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
542 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
543 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
544 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
545 {"Exit door: Opens if you have enough","emeralds to finish the level"},
546 {"Open exit door: Enter here to leave","the level and exit the actual game"},
547 {"Sokoban element: Object which must", "be pushed to an empty field"},
548 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
549 {"Sokoban element: Field with object", "which can be pushed away"},
550 {"Speed pill: Lets the player run", "twice as fast as normally"},
552 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
554 static char *helpscreen_music[][3] =
556 { "Alchemy", "Ian Boddy", "Drive" },
557 { "The Chase", "Propaganda", "A Secret Wish" },
558 { "Network 23", "Tangerine Dream", "Exit" },
559 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
560 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
561 { "Voyager", "The Alan Parsons Project","Pyramid" },
562 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
564 static int helpscreen_musicpos;
566 void DrawHelpScreenElAction(int start)
570 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
572 while(helpscreen_action[j] != HA_END)
574 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
576 else if (i<start || helpscreen_delay[i-start])
578 if (i>=start && helpscreen_delay[i-start])
579 helpscreen_delay[i-start]--;
581 while(helpscreen_action[j] != HA_NEXT)
588 j += 3*helpscreen_step[i-start];
589 graphic = helpscreen_action[j++];
591 if (helpscreen_frame[i-start])
593 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
594 helpscreen_frame[i-start]--;
599 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
602 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
604 if (helpscreen_action[j] == HA_NEXT)
606 if (!helpscreen_frame[i-start])
607 helpscreen_step[i-start] = 0;
611 if (!helpscreen_frame[i-start])
612 helpscreen_step[i-start]++;
613 while(helpscreen_action[j] != HA_NEXT)
618 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
629 void DrawHelpScreenElText(int start)
632 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
633 int ybottom = SYSIZE - 20;
638 DrawTextFCentered(100, FC_GREEN, "The game elements:");
640 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
643 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
644 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
645 DrawText(xstart, ystart + (i - start) * ystep + 16,
646 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
649 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
652 void DrawHelpScreenMusicText(int num)
654 int ystart = 150, ystep = 30;
655 int ybottom = SYSIZE - 20;
661 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
663 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
665 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
666 helpscreen_music[num][0]);
667 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
669 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
670 "%s", helpscreen_music[num][1]);
671 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
673 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
674 helpscreen_music[num][2]);
676 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
678 PlaySoundLoop(background_loop[num]);
681 void DrawHelpScreenCreditsText()
683 int ystart = 150, ystep = 30;
684 int ybottom = SYSIZE - 20;
690 DrawTextFCentered(100, FC_GREEN,
692 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
693 "DOS/Windows port of the game:");
694 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
696 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
697 "Additional toons:");
698 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
700 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
701 "...and many thanks to all contributors");
702 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
705 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
708 void DrawHelpScreenContactText()
710 int ystart = 150, ystep = 30;
711 int ybottom = SYSIZE - 20;
716 DrawTextFCentered(100, FC_GREEN, "Program information:");
718 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
719 "This game is Freeware!");
720 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
721 "If you like it, send e-mail to:");
722 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
723 "aeglos@valinor.owl.de");
724 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
726 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
728 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
730 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
732 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
735 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
736 "If you have created new levels,");
737 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
738 "send them to me to include them!");
739 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
742 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
745 void DrawHelpScreen()
750 CloseDoor(DOOR_CLOSE_2);
752 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
753 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
754 helpscreen_musicpos = 0;
755 helpscreen_state = 0;
756 DrawHelpScreenElText(0);
757 DrawHelpScreenElAction(0);
761 PlaySoundLoop(SND_RHYTHMLOOP);
764 void HandleHelpScreen(int button)
766 static unsigned long hs_delay = 0;
767 int num_helpscreen_els_pages =
768 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
769 int button_released = !button;
774 if (helpscreen_state < num_helpscreen_els_pages - 1)
776 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
777 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
779 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
780 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
782 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
785 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
787 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
790 DrawHelpScreenCreditsText();
792 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
795 DrawHelpScreenContactText();
801 game_status = MAINMENU;
806 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
808 if (helpscreen_state<num_helpscreen_els_pages)
809 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
817 void HandleTypeName(int newxpos, KeySym key)
819 static int xpos = 0, ypos = 2;
824 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
825 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
829 if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
830 xpos < MAX_PLAYER_NAME_LEN)
834 if (key >= XK_A && key <= XK_Z)
835 ascii = 'A' + (char)(key - XK_A);
837 ascii = 'a' + (char)(key - XK_a);
839 setup.player_name[xpos] = ascii;
840 setup.player_name[xpos + 1] = 0;
842 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
843 setup.player_name, FS_BIG, FC_YELLOW);
844 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
845 setup.player_name, FS_BIG, FC_YELLOW);
846 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
848 else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0)
851 setup.player_name[xpos] = 0;
852 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
853 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
855 else if (key == XK_Return && xpos > 0)
857 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
858 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
861 game_status = MAINMENU;
867 static void drawCursorExt(int ypos, int color, int graphic)
869 static int cursor_array[SCR_FIELDY];
872 cursor_array[ypos] = graphic;
874 graphic = cursor_array[ypos];
877 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
878 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
881 DrawGraphic(0, ypos, graphic);
884 static void initCursor(int ypos, int graphic)
886 drawCursorExt(ypos, FC_BLUE, graphic);
889 static void drawCursor(int ypos, int color)
891 drawCursorExt(ypos, color, 0);
894 void DrawChooseLevel()
897 CloseDoor(DOOR_CLOSE_2);
900 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
901 MapChooseLevelGadgets();
907 static void AdjustChooseLevelScrollbar(int id, int first_entry)
909 struct GadgetInfo *gi = screen_gadget[id];
910 int items_max, items_visible, item_position;
912 items_max = numLevelDirInfoInGroup(leveldir_current);
913 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
914 item_position = first_entry;
916 if (item_position > items_max - items_visible)
917 item_position = items_max - items_visible;
919 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
920 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
923 static void drawChooseLevelList(int first_entry, int num_page_entries)
926 char buffer[SCR_FIELDX * 2];
927 int max_buffer_len = (SCR_FIELDX - 2) * 2;
928 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
930 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
931 redraw_mask |= REDRAW_FIELD;
933 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
935 for(i=0; i<num_page_entries; i++)
937 struct LevelDirInfo *node, *node_first;
938 int leveldir_pos = first_entry + i;
941 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
942 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
944 strncpy(buffer, node->name , max_buffer_len);
945 buffer[max_buffer_len] = '\0';
947 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
949 if (node->parent_link)
950 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
951 else if (node->level_group)
952 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
954 initCursor(ypos, GFX_KUGEL_BLAU);
958 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
960 if (first_entry + num_page_entries < num_leveldirs)
961 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
964 static void drawChooseLevelInfo(int leveldir_pos)
966 struct LevelDirInfo *node, *node_first;
967 int x, last_redraw_mask = redraw_mask;
969 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
970 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
972 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
974 if (node->parent_link)
975 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
976 else if (node->level_group)
977 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
979 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
980 node->levels, node->class_desc);
982 /* let BackToFront() redraw only what is needed */
983 redraw_mask = last_redraw_mask | REDRAW_TILES;
984 for (x=0; x<SCR_FIELDX; x++)
988 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
990 static unsigned long choose_delay = 0;
991 static int redraw = TRUE;
992 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
993 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
994 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
995 int num_page_entries;
997 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
998 num_page_entries = num_leveldirs;
1000 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1002 if (button == MB_MENU_INITIALIZE)
1004 int leveldir_pos = posLevelDirInfo(leveldir_current);
1006 if (leveldir_current->cl_first == -1)
1008 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1009 leveldir_current->cl_cursor =
1010 leveldir_pos - leveldir_current->cl_first + 3;
1013 if (dx == 999) /* first entry is set by scrollbar position */
1014 leveldir_current->cl_first = dy;
1016 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1017 leveldir_current->cl_first);
1019 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1020 drawChooseLevelInfo(leveldir_pos);
1026 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1030 if (button == MB_MENU_INITIALIZE)
1038 y = leveldir_current->cl_cursor + dy;
1041 x = y = 0; /* no action */
1043 if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */
1046 step = num_page_entries - 1;
1048 y = (dy < 0 ? 2 : num_page_entries + 3);
1052 if (x == 1 && y == 2)
1054 if (leveldir_current->cl_first > 0 &&
1055 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1057 leveldir_current->cl_first -= step;
1058 if (leveldir_current->cl_first < 0)
1059 leveldir_current->cl_first = 0;
1061 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1062 drawChooseLevelInfo(leveldir_current->cl_first +
1063 leveldir_current->cl_cursor - 3);
1064 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1065 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1066 leveldir_current->cl_first);
1070 else if (x == 1 && y > num_page_entries + 2)
1072 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1073 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1075 leveldir_current->cl_first += step;
1076 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1077 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1079 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1080 drawChooseLevelInfo(leveldir_current->cl_first +
1081 leveldir_current->cl_cursor - 3);
1082 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1083 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1084 leveldir_current->cl_first);
1089 if (!mx && !my && !dx && !dy)
1092 y = leveldir_current->cl_cursor;
1097 struct LevelDirInfo *node_first, *node_cursor;
1099 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1101 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1102 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1104 if (node_cursor->node_group)
1106 node_cursor->cl_first = leveldir_current->cl_first;
1107 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1108 leveldir_current = node_cursor->node_group;
1112 else if (dx == -1 && leveldir_current->node_parent)
1114 leveldir_current = leveldir_current->node_parent;
1118 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1122 if (y != leveldir_current->cl_cursor)
1124 drawCursor(y - 1, FC_RED);
1125 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1126 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1127 leveldir_current->cl_cursor = y;
1132 struct LevelDirInfo *node_first, *node_cursor;
1133 int leveldir_pos = leveldir_current->cl_first + y - 3;
1135 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1136 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1138 if (node_cursor->node_group)
1140 node_cursor->cl_first = leveldir_current->cl_first;
1141 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1142 leveldir_current = node_cursor->node_group;
1145 else if (node_cursor->parent_link)
1147 leveldir_current = node_cursor->node_parent;
1152 leveldir_current = node_cursor;
1154 LoadLevelSetup_SeriesInfo();
1156 SaveLevelSetup_LastSeries();
1157 SaveLevelSetup_SeriesInfo();
1160 game_status = MAINMENU;
1168 if (game_status == CHOOSELEVEL)
1172 void DrawHallOfFame(int highlight_position)
1175 CloseDoor(DOOR_CLOSE_2);
1177 if (highlight_position < 0)
1178 LoadScore(level_nr);
1182 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1183 PlaySound(SND_HALLOFFAME);
1186 static void drawHallOfFameList(int first_entry, int highlight_position)
1191 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1192 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1194 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1196 int entry = first_entry + i;
1197 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1200 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1201 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1202 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1203 int2str(highscore[i].Score, 5), FS_BIG, color);
1205 DrawText(SX, SY + 64 + i * 32, "..................................",
1206 FS_MEDIUM, FC_YELLOW);
1207 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1208 FS_MEDIUM, FC_YELLOW);
1209 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1210 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1211 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1216 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1218 static int first_entry = 0;
1219 static int highlight_position = 0;
1220 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1221 int button_released = !button;
1223 if (button == MB_MENU_INITIALIZE)
1226 highlight_position = mx;
1227 drawHallOfFameList(first_entry, highlight_position);
1231 if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */
1232 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1236 if (first_entry > 0)
1238 first_entry -= step;
1239 if (first_entry < 0)
1242 drawHallOfFameList(first_entry, highlight_position);
1248 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1250 first_entry += step;
1251 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1252 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1254 drawHallOfFameList(first_entry, highlight_position);
1259 if (button_released)
1261 FadeSound(SND_HALLOFFAME);
1262 game_status = MAINMENU;
1268 if (game_status == HALLOFFAME)
1272 void DrawSetupScreen()
1281 { &setup.sound, "Sound:", },
1282 { &setup.sound_loops, " Sound Loops:" },
1283 { &setup.sound_music, " Game Music:" },
1285 { &setup.toons, "Toons:" },
1286 { &setup.double_buffering, "Buffered gfx:" },
1288 { &setup.scroll_delay, "Scroll Delay:" },
1289 { &setup.soft_scrolling, "Soft Scroll.:" },
1290 { &setup.fading, "Fading:" },
1291 { &setup.quick_doors, "Quick Doors:" },
1292 { &setup.autorecord, "Auto-Record:" },
1293 { &setup.team_mode, "Team-Mode:" },
1294 { &setup.handicap, "Handicap:" },
1295 { &setup.time_limit, "Timelimit:" },
1296 { NULL, "Input Devices" },
1299 { NULL, "Save and exit" }
1303 CloseDoor(DOOR_CLOSE_2);
1306 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1308 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1310 int base = i - SETUP_SCREEN_POS_START;
1312 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1314 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1316 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1317 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1319 initCursor(i, GFX_KUGEL_BLAU);
1322 if (setup_info[base].value)
1324 int setting_value = *setup_info[base].value;
1326 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1327 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1333 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1336 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1338 static int choice = 3;
1339 static int redraw = TRUE;
1340 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1341 int pos_start = SETUP_SCREEN_POS_START + 1;
1342 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1343 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1344 int pos_end = SETUP_SCREEN_POS_END + 1;
1346 if (button == MB_MENU_INITIALIZE)
1351 drawCursor(choice - 1, FC_RED);
1355 if (button == MB_MENU_INITIALIZE)
1368 if (y >= pos_empty1 && y <= pos_empty2)
1369 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1373 else if (y > pos_end)
1377 if (!mx && !my && !dx && !dy)
1383 if (dx == 1 && choice == 14)
1385 game_status = SETUPINPUT;
1386 DrawSetupInputScreen();
1390 if (x==1 && y >= pos_start && y <= pos_end &&
1391 !(y >= pos_empty1 && y <= pos_empty2))
1397 drawCursor(y - 1, FC_RED);
1398 drawCursor(choice - 1, FC_BLUE);
1406 if (y==3 && sound_status==SOUND_AVAILABLE)
1410 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1411 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1412 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1413 setup.sound_loops = FALSE;
1414 setup.sound_music = FALSE;
1417 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1418 setup.sound = !setup.sound;
1420 else if (y==4 && sound_loops_allowed)
1422 if (setup.sound_loops)
1423 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1426 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1427 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1430 setup.sound_loops = !setup.sound_loops;
1432 else if (y==5 && sound_loops_allowed)
1434 if (setup.sound_music)
1435 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1438 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1439 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1442 setup.sound_music = !setup.sound_music;
1449 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1451 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1452 setup.toons = !setup.toons;
1457 if (setup.double_buffering)
1458 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1460 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1461 setup.double_buffering = !setup.double_buffering;
1462 setup.direct_draw = !setup.double_buffering;
1464 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1465 setup.double_buffering = TRUE;
1466 setup.direct_draw = !setup.double_buffering;
1473 if (setup.scroll_delay)
1474 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1476 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1477 setup.scroll_delay = !setup.scroll_delay;
1481 if (setup.soft_scrolling)
1482 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1484 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1485 setup.soft_scrolling = !setup.soft_scrolling;
1490 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1492 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1493 setup.fading = !setup.fading;
1497 if (setup.quick_doors)
1498 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1500 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1501 setup.quick_doors = !setup.quick_doors;
1505 if (setup.autorecord)
1506 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1508 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1509 setup.autorecord = !setup.autorecord;
1513 if (setup.team_mode)
1514 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1516 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1517 setup.team_mode = !setup.team_mode;
1522 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1524 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1525 setup.handicap = !setup.handicap;
1529 if (setup.time_limit)
1530 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1532 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1533 setup.time_limit = !setup.time_limit;
1537 game_status = SETUPINPUT;
1538 DrawSetupInputScreen();
1541 else if (y==pos_end-1 || y==pos_end)
1552 save_joystick_data(JOYSTICK_FILENAME);
1558 game_status = MAINMENU;
1566 if (game_status==SETUP)
1570 void DrawSetupInputScreen()
1573 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1575 initCursor(2, GFX_KUGEL_BLAU);
1576 initCursor(3, GFX_KUGEL_BLAU);
1577 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1578 initCursor(15, GFX_KUGEL_BLAU);
1580 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1581 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1583 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1584 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1585 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1587 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1588 "Joysticks deactivated on this screen");
1590 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1595 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1597 if (device_name == NULL)
1600 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1603 if (strlen(device_name) > 1)
1605 char c1 = device_name[strlen(device_name) - 1];
1606 char c2 = device_name[strlen(device_name) - 2];
1608 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1609 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1612 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1615 static void drawPlayerSetupInputInfo(int player_nr)
1618 static struct SetupKeyboardInfo custom_key;
1625 { &custom_key.left, "Joystick Left" },
1626 { &custom_key.right, "Joystick Right" },
1627 { &custom_key.up, "Joystick Up" },
1628 { &custom_key.down, "Joystick Down" },
1629 { &custom_key.snap, "Button 1" },
1630 { &custom_key.bomb, "Button 2" }
1632 static char *joystick_name[MAX_PLAYERS] =
1640 custom_key = setup.input[player_nr].key;
1642 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1643 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1645 if (setup.input[player_nr].use_joystick)
1647 char *device_name = setup.input[player_nr].joy.device_name;
1649 DrawText(SX+8*32, SY+3*32,
1650 joystick_name[getJoystickNrFromDeviceName(device_name)],
1652 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1656 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1657 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1660 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1661 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1662 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1663 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1664 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1665 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1666 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1667 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1668 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1669 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1670 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1674 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1676 DrawText(SX + 3*32, SY + ypos*32,
1677 " ", FS_BIG, FC_YELLOW);
1678 DrawText(SX + 3*32, SY + ypos*32,
1679 (setup.input[player_nr].use_joystick ?
1681 getKeyNameFromKeySym(*custom[i].keysym)),
1686 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1688 static int choice = 3;
1689 static int player_nr = 0;
1690 static int redraw = TRUE;
1691 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1692 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1693 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1694 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1695 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1697 if (button == MB_MENU_INITIALIZE)
1699 drawPlayerSetupInputInfo(player_nr);
1705 drawCursor(choice - 1, FC_RED);
1709 if (button == MB_MENU_INITIALIZE)
1714 if (dx && choice == 3)
1716 x = (dx < 0 ? 11 : 13);
1719 else if (dx && choice == 4)
1721 button = MB_MENU_CHOICE;
1733 if (y >= pos_empty1 && y <= pos_empty2)
1734 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1738 else if (y > pos_end)
1742 if (!mx && !my && !dx && !dy)
1748 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1750 static unsigned long delay = 0;
1752 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1755 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1757 drawPlayerSetupInputInfo(player_nr);
1759 else if (x==1 && y >= pos_start && y <= pos_end &&
1760 !(y >= pos_empty1 && y <= pos_empty2))
1766 drawCursor(y - 1, FC_RED);
1767 drawCursor(choice - 1, FC_BLUE);
1775 char *device_name = setup.input[player_nr].joy.device_name;
1777 if (!setup.input[player_nr].use_joystick)
1779 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1781 setJoystickDeviceToNr(device_name, new_device_nr);
1782 setup.input[player_nr].use_joystick = TRUE;
1786 int device_nr = getJoystickNrFromDeviceName(device_name);
1787 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1789 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1790 setup.input[player_nr].use_joystick = FALSE;
1792 setJoystickDeviceToNr(device_name, new_device_nr);
1802 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1803 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1805 if (setup.input[player_nr].use_joystick)
1807 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1808 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1810 setup.input[player_nr].use_joystick = FALSE;
1814 setup.input[player_nr].use_joystick = TRUE;
1815 setup.input[player_nr].joystick_nr = one_joystick_nr;
1819 drawPlayerSetupInputInfo(player_nr);
1823 if (setup.input[player_nr].use_joystick)
1826 game_status = CALIBRATION;
1827 CalibrateJoystick(player_nr);
1828 game_status = SETUPINPUT;
1831 CustomizeKeyboard(player_nr);
1835 else if (y == pos_end)
1839 game_status = SETUP;
1849 if (game_status == SETUPINPUT)
1853 void CustomizeKeyboard(int player_nr)
1857 boolean finished = FALSE;
1858 static struct SetupKeyboardInfo custom_key;
1863 } customize_step[] =
1865 { &custom_key.left, "Move Left" },
1866 { &custom_key.right, "Move Right" },
1867 { &custom_key.up, "Move Up" },
1868 { &custom_key.down, "Move Down" },
1869 { &custom_key.snap, "Snap Field" },
1870 { &custom_key.bomb, "Place Bomb" }
1873 /* read existing key bindings from player setup */
1874 custom_key = setup.input[player_nr].key;
1877 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1883 DrawText(SX, SY + (2+2*step_nr)*32,
1884 customize_step[step_nr].text, FS_BIG, FC_RED);
1885 DrawText(SX, SY + (2+2*step_nr+1)*32,
1886 "Key:", FS_BIG, FC_RED);
1887 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1888 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1893 if (PendingEvent()) /* got event */
1901 case EVENT_KEYPRESS:
1903 KeySym key = XLookupKeysym((KeyEvent *)&event,
1904 ((KeyEvent *)&event)->state);
1906 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1912 /* press 'Enter' to keep the existing key binding */
1913 if (key == XK_Return || step_nr == 6)
1914 key = *customize_step[step_nr].keysym;
1916 /* check if key already used */
1917 for (i=0; i<step_nr; i++)
1918 if (*customize_step[i].keysym == key)
1923 /* got new key binding */
1924 *customize_step[step_nr].keysym = key;
1925 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1926 " ", FS_BIG, FC_YELLOW);
1927 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1928 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1931 /* un-highlight last query */
1932 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1933 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1934 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1935 "Key:", FS_BIG, FC_GREEN);
1937 /* press 'Enter' to leave */
1940 DrawText(SX + 16, SY + 15*32+16,
1941 "Press Enter", FS_BIG, FC_YELLOW);
1945 /* query next key binding */
1946 DrawText(SX, SY+(2+2*step_nr)*32,
1947 customize_step[step_nr].text, FS_BIG, FC_RED);
1948 DrawText(SX, SY+(2+2*step_nr+1)*32,
1949 "Key:", FS_BIG, FC_RED);
1950 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1951 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1956 case EVENT_KEYRELEASE:
1957 key_joystick_mapping = 0;
1961 HandleOtherEvents(&event);
1969 /* don't eat all CPU time */
1973 /* write new key bindings back to player setup */
1974 setup.input[player_nr].key = custom_key;
1977 DrawSetupInputScreen();
1980 void CalibrateJoystick(int player_nr)
1983 struct joystick joy_ctrl;
1985 struct joystick_control
1994 int new_joystick_xleft = 128, new_joystick_xright = 128;
1995 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1996 int new_joystick_xmiddle, new_joystick_ymiddle;
1998 int calibration_step = 1;
2001 int joystick_fd = stored_player[player_nr].joystick_fd;
2002 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2003 boolean check[3][3];
2004 int check_remaining;
2008 if (joystick_status == JOYSTICK_OFF ||
2010 !setup.input[player_nr].use_joystick)
2016 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2017 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2018 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2019 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2020 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2021 check_remaining = 3 * 3;
2023 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2024 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2025 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2026 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2027 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2028 check_remaining = 0;
2035 check[x][y] = FALSE;
2036 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2040 joy_value = Joystick(player_nr);
2041 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2042 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2043 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2048 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2050 joy_ctrl.buttons = 0;
2053 while(Joystick(player_nr) & JOY_BUTTON);
2059 if (PendingEvent()) /* got event */
2067 case EVENT_KEYPRESS:
2068 switch(XLookupKeysym((KeyEvent *)&event,
2069 ((KeyEvent *)&event)->state))
2072 if (check_remaining == 0)
2085 case EVENT_KEYRELEASE:
2086 key_joystick_mapping = 0;
2090 HandleOtherEvents(&event);
2096 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2098 joystick_status = JOYSTICK_OFF;
2102 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2103 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2104 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2105 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2107 new_joystick_xmiddle =
2108 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2109 new_joystick_ymiddle =
2110 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2112 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2113 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2114 setup.input[player_nr].joy.xright = new_joystick_xright;
2115 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2116 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2117 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2119 CheckJoystickData();
2122 joy_value = Joystick(player_nr);
2124 if (joy_value & JOY_BUTTON && check_remaining == 0)
2129 if (calibration_step == 1)
2134 else if (calibrate_joystick(joystick_fd) != 0)
2136 joystick_status = JOYSTICK_OFF;
2140 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2145 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2146 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2148 if (calibration_step == 2)
2149 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2151 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2153 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2154 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2158 while(Joystick(player_nr) & JOY_BUTTON)
2164 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2165 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2167 if (x != last_x || y != last_y)
2170 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2172 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2174 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2179 if (check_remaining > 0 && !check[x+1][y+1])
2181 check[x+1][y+1] = TRUE;
2186 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2187 setup.input[player_nr].joy.xleft,
2188 setup.input[player_nr].joy.xmiddle,
2189 setup.input[player_nr].joy.xright);
2190 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2191 setup.input[player_nr].joy.yupper,
2192 setup.input[player_nr].joy.ymiddle,
2193 setup.input[player_nr].joy.ylower);
2201 /* don't eat all CPU time */
2207 DrawSetupInputScreen();
2208 while(Joystick(player_nr) & JOY_BUTTON);
2214 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2215 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2218 DrawSetupInputScreen();
2221 void HandleGameActions()
2223 if (game_status != PLAYING)
2226 if (local_player->LevelSolved)
2229 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2237 /* ---------- new screen button stuff -------------------------------------- */
2239 /* graphic position and size values for buttons and scrollbars */
2240 #define SC_SCROLLBUTTON_XPOS 64
2241 #define SC_SCROLLBUTTON_YPOS 0
2242 #define SC_SCROLLBAR_XPOS 0
2243 #define SC_SCROLLBAR_YPOS 64
2245 #define SC_SCROLLBUTTON_XSIZE 32
2246 #define SC_SCROLLBUTTON_YSIZE 32
2248 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2249 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2250 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2251 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2252 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2253 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2254 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2255 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2257 #define SC_BORDER_SIZE 14
2265 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2268 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2269 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2270 SCREEN_CTRL_ID_SCROLL_UP,
2271 "scroll level series up"
2274 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2275 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2276 SCREEN_CTRL_ID_SCROLL_DOWN,
2277 "scroll level series down"
2289 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2292 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2293 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2294 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2295 GD_TYPE_SCROLLBAR_VERTICAL,
2296 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2297 "scroll level series vertically"
2301 static void CreateScreenScrollbuttons()
2303 Bitmap gd_bitmap = pix[PIX_MORE];
2304 struct GadgetInfo *gi;
2305 unsigned long event_mask;
2308 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2310 int id = scrollbutton_info[i].gadget_id;
2311 int x, y, width, height;
2312 int gd_x1, gd_x2, gd_y1, gd_y2;
2314 x = scrollbutton_info[i].x;
2315 y = scrollbutton_info[i].y;
2317 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2321 width = SC_SCROLLBUTTON_XSIZE;
2322 height = SC_SCROLLBUTTON_YSIZE;
2323 gd_x1 = scrollbutton_info[i].xpos;
2324 gd_y1 = scrollbutton_info[i].ypos;
2326 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2328 gi = CreateGadget(GDI_CUSTOM_ID, id,
2329 GDI_CUSTOM_TYPE_ID, i,
2330 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2335 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2336 GDI_STATE, GD_BUTTON_UNPRESSED,
2337 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2338 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2339 GDI_EVENT_MASK, event_mask,
2340 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2344 Error(ERR_EXIT, "cannot create gadget");
2346 screen_gadget[id] = gi;
2350 static void CreateScreenScrollbars()
2354 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2356 int id = scrollbar_info[i].gadget_id;
2357 Bitmap gd_bitmap = pix[PIX_MORE];
2358 int gd_x1, gd_x2, gd_y1, gd_y2;
2359 struct GadgetInfo *gi;
2360 int items_max, items_visible, item_position;
2361 unsigned long event_mask;
2362 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2365 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2366 num_page_entries = num_leveldirs;
2368 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2370 items_max = MAX(num_leveldirs, num_page_entries);
2371 items_visible = num_page_entries;
2374 items_max = num_page_entries;
2375 items_visible = num_page_entries;
2379 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2381 gd_x1 = scrollbar_info[i].xpos;
2382 gd_x2 = gd_x1 + scrollbar_info[i].width;
2383 gd_y1 = scrollbar_info[i].ypos;
2384 gd_y2 = scrollbar_info[i].ypos;
2386 gi = CreateGadget(GDI_CUSTOM_ID, id,
2387 GDI_CUSTOM_TYPE_ID, i,
2388 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2389 GDI_X, scrollbar_info[i].x,
2390 GDI_Y, scrollbar_info[i].y,
2391 GDI_WIDTH, scrollbar_info[i].width,
2392 GDI_HEIGHT, scrollbar_info[i].height,
2393 GDI_TYPE, scrollbar_info[i].type,
2394 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2395 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2396 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2397 GDI_STATE, GD_BUTTON_UNPRESSED,
2398 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2399 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2400 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2401 GDI_EVENT_MASK, event_mask,
2402 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2406 Error(ERR_EXIT, "cannot create gadget");
2408 screen_gadget[id] = gi;
2412 void CreateScreenGadgets()
2414 CreateScreenScrollbuttons();
2415 CreateScreenScrollbars();
2418 void MapChooseLevelGadgets()
2420 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2423 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2426 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2427 MapGadget(screen_gadget[i]);
2430 void UnmapChooseLevelGadgets()
2434 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2435 UnmapGadget(screen_gadget[i]);
2438 static void HandleScreenGadgets(struct GadgetInfo *gi)
2440 int id = gi->custom_id;
2442 if (game_status != CHOOSELEVEL)
2447 case SCREEN_CTRL_ID_SCROLL_UP:
2448 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2451 case SCREEN_CTRL_ID_SCROLL_DOWN:
2452 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2455 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2456 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);