+#if 0
+ DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
+ DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
+ DrawText(SX + 12 * 32, SY + 64 + i * 32,
+ int2str(highscore[i].Score, 5), FS_BIG, color);
+#else
+ DrawText(SX, SY + 64 + i * 32, "..................................",
+ FS_MEDIUM, FC_YELLOW);
+ DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
+ FS_MEDIUM, FC_YELLOW);
+ DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
+ DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
+ int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
+#endif
+ }
+}
+
+void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
+{
+ static int first_entry = 0;
+ static int highlight_position = 0;
+ int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
+ int button_released = !button;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ first_entry = 0;
+ highlight_position = mx;
+ drawHallOfFameList(first_entry, highlight_position);
+ return;
+ }
+
+ if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
+ step = MAX_MENU_ENTRIES_ON_SCREEN - 1;
+
+ if (dy < 0)
+ {
+ if (first_entry > 0)
+ {
+ first_entry -= step;
+ if (first_entry < 0)
+ first_entry = 0;
+
+ drawHallOfFameList(first_entry, highlight_position);
+ return;
+ }
+ }
+ else if (dy > 0)
+ {
+ if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
+ {
+ first_entry += step;
+ if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
+ first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN);
+
+ drawHallOfFameList(first_entry, highlight_position);
+ return;
+ }
+ }
+
+ if (button_released)
+ {
+ FadeSound(SND_HALLOFFAME);
+ game_status = MAINMENU;
+ DrawMainMenu();
+ }
+
+ BackToFront();
+
+ if (game_status == HALLOFFAME)
+ DoAnimation();
+}
+
+
+/* ========================================================================= */
+/* setup screen functions */
+/* ========================================================================= */
+
+static struct TokenInfo *setup_info;
+static int num_setup_info;
+static int setup_mode = SETUP_MODE_MAIN;
+
+static void execSetupMain()
+{
+ setup_mode = SETUP_MODE_MAIN;
+ DrawSetupScreen();
+}
+
+static void execSetupSound()
+{
+ setup_mode = SETUP_MODE_SOUND;
+ DrawSetupScreen();
+}
+
+static void execSetupInput()
+{
+ setup_mode = SETUP_MODE_INPUT;
+ DrawSetupScreen();
+}
+
+static void execSetupShortcut()
+{
+ setup_mode = SETUP_MODE_SHORTCUT;
+ DrawSetupScreen();
+}
+
+static void execExitSetup()
+{
+ game_status = MAINMENU;
+ DrawMainMenu();
+}
+
+static void execSaveAndExitSetup()
+{
+ SaveSetup();
+ execExitSetup();
+}
+
+static struct TokenInfo setup_info_main[] =
+{
+ { TYPE_ENTER_MENU, execSetupSound, "Sound Setup" },
+ { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
+ { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" },
+#if 0
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_SWITCH, &setup.sound, "Sound:", },
+ { TYPE_SWITCH, &setup.sound_loops, " Sound Loops:" },
+ { TYPE_SWITCH, &setup.sound_music, " Game Music:" },
+#endif
+ { TYPE_SWITCH, &setup.toons, "Toons:" },
+#if 0
+ { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" },
+#endif
+ { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
+ { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" },
+#if 0
+ { TYPE_SWITCH, &setup.fading, "Fading:" },
+#endif
+ { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
+ { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" },
+ { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" },
+ { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" },
+ { TYPE_SWITCH, &setup.handicap, "Handicap:" },
+ { TYPE_SWITCH, &setup.time_limit, "Timelimit:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
+ { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and exit" },
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_sound[] =
+{
+ { TYPE_SWITCH, &setup.sound, "Sound:", },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" },
+ { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" },
+ { TYPE_SWITCH, &setup.sound_music, "Game Music:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcut[] =
+{
+ { TYPE_KEYTEXT, NULL, "Quick Save Game:", },
+ { TYPE_KEY, &setup.shortcut.save_game, "" },
+ { TYPE_KEYTEXT, NULL, "Quick Load Game:", },
+ { TYPE_KEY, &setup.shortcut.load_game, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
+ { 0, NULL, NULL }
+};
+
+static Key getSetupKey()
+{
+ Key key = KSYM_UNDEFINED;
+ boolean got_key_event = FALSE;
+
+ while (!got_key_event)
+ {
+ if (PendingEvent()) /* got event */
+ {
+ Event event;
+
+ NextEvent(&event);
+
+ switch(event.type)
+ {
+ case EVENT_KEYPRESS:
+ {
+ key = GetEventKey((KeyEvent *)&event, TRUE);
+
+ /* press 'Escape' or 'Enter' to keep the existing key binding */
+ if (key == KSYM_Escape || key == KSYM_Return)
+ key = KSYM_UNDEFINED; /* keep old value */
+
+ got_key_event = TRUE;
+ }
+ break;
+
+ case EVENT_KEYRELEASE:
+ key_joystick_mapping = 0;
+ break;
+
+ default:
+ HandleOtherEvents(&event);
+ break;
+ }
+ }
+
+ BackToFront();
+ DoAnimation();
+
+ /* don't eat all CPU time */
+ Delay(10);
+ }
+
+ return key;
+}
+
+static void drawSetupValue(int pos)
+{
+ int xpos = MENU_SCREEN_VALUE_XPOS;
+ int ypos = MENU_SCREEN_START_YPOS + pos;
+ int value_color = FC_YELLOW;
+ char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED,
+ setup_info[pos].value);
+
+ if (setup_info[pos].type & TYPE_KEY)
+ {
+ xpos = 3;
+
+ if (setup_info[pos].type & TYPE_QUERY)
+ {
+ value_string = "<press key>";
+ value_color = FC_RED;
+ }
+ }
+
+ if (setup_info[pos].type & TYPE_BOOLEAN_STYLE &&
+ !*(boolean *)(setup_info[pos].value))
+ value_color = FC_BLUE;
+
+ DrawText(SX + xpos * 32, SY + ypos * 32,
+ (xpos == 3 ? " " : " "), FS_BIG, FC_YELLOW);
+ DrawText(SX + xpos * 32, SY + ypos * 32, value_string, FS_BIG, value_color);
+}
+
+static void changeSetupValue(int pos)
+{
+ if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
+ {
+ *(boolean *)setup_info[pos].value ^= TRUE;
+ }
+ else if (setup_info[pos].type & TYPE_KEY)
+ {
+ Key key;
+
+ setup_info[pos].type |= TYPE_QUERY;
+ drawSetupValue(pos);
+ setup_info[pos].type &= ~TYPE_QUERY;
+
+ key = getSetupKey();
+ if (key != KSYM_UNDEFINED)
+ *(Key *)setup_info[pos].value = key;
+ }
+
+ drawSetupValue(pos);
+}
+
+static void DrawSetupScreen_Generic()
+{
+ char *title_string = NULL;
+ int i;
+
+ UnmapAllGadgets();
+ CloseDoor(DOOR_CLOSE_2);
+ ClearWindow();
+
+ if (setup_mode == SETUP_MODE_MAIN)
+ {
+ setup_info = setup_info_main;
+ title_string = "Setup";
+ }
+ else if (setup_mode == SETUP_MODE_SOUND)
+ {
+ setup_info = setup_info_sound;
+ title_string = "Setup Sound";
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUT)
+ {
+ setup_info = setup_info_shortcut;
+ title_string = "Setup Shortcuts";
+ }
+
+ DrawText(SX + 16, SY + 16, title_string, FS_BIG, FC_YELLOW);
+
+ num_setup_info = 0;
+ for(i=0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
+ {
+ void *value_ptr = setup_info[i].value;
+ int ypos = MENU_SCREEN_START_YPOS + i;
+
+ /* set some entries to "unchangeable" according to other variables */
+ if ((value_ptr == &setup.sound && !audio.sound_available) ||
+ (value_ptr == &setup.sound_loops && !audio.loops_available) ||
+ (value_ptr == &setup.sound_music && !audio.music_available) ||
+ (value_ptr == &setup.sound_music && !audio.music_available) ||
+ (value_ptr == &setup.fullscreen && !video.fullscreen_available))
+ setup_info[i].type |= TYPE_GHOSTED;
+
+ DrawText(SX + 32, SY + ypos * 32, setup_info[i].text, FS_BIG, FC_GREEN);
+
+ if (setup_info[i].type & TYPE_ENTER_MENU)
+ initCursor(i, GFX_ARROW_BLUE_RIGHT);
+ else if (setup_info[i].type & TYPE_LEAVE_MENU)
+ initCursor(i, GFX_ARROW_BLUE_LEFT);
+ else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
+ initCursor(i, GFX_KUGEL_BLAU);
+
+ if (setup_info[i].type & TYPE_VALUE)
+ drawSetupValue(i);
+
+ num_setup_info++;
+ }