- if (xpos == MENU_SCREEN_VALUE_XPOS &&
- startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
- correct_font_draw_xoffset = TRUE;
-
- /* check if setup value would overlap with setup text when printed */
- /* (this can happen for extreme/wrong values for font draw offset) */
- if (correct_font_draw_xoffset)
- {
- font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset;
- font_draw_xoffset_modified = TRUE;
-
- if (type & TYPE_KEY)
- getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
- else if (!(type & TYPE_STRING))
- getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
- MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr));
- }
- }
-
-#if 0
- DrawBackground(startx, starty, SX + SXSIZE - startx, font_height);
-#else
- for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
- DrawText(startx + i * font_width, starty, " ", font_nr);
-#endif
-
- DrawText(startx, starty, value_string, font_nr);
-
- if (font_draw_xoffset_modified)
- getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
-}
-#endif
-
-#if 1
-static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
-{
- int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
- struct TokenInfo *si = &setup_info[si_pos];
-
- if (si->type & TYPE_BOOLEAN_STYLE)
- {
- *(boolean *)si->value ^= TRUE;
- }
- else if (si->type & TYPE_YES_NO_AUTO)
- {
- *(int *)si->value =
- (dx == -1 ?
- (*(int *)si->value == AUTO ? TRUE :
- *(int *)si->value == TRUE ? FALSE : AUTO) :
- (*(int *)si->value == TRUE ? AUTO :
- *(int *)si->value == AUTO ? FALSE : TRUE));
- }
- else if (si->type & TYPE_KEY)
- {
- Key key;
-
- si->type |= TYPE_QUERY;
- drawSetupValue(screen_pos, setup_info_pos_raw);
- si->type &= ~TYPE_QUERY;
-
- key = getSetupKey();
- if (key != KSYM_UNDEFINED)
- *(Key *)si->value = key;
- }
-
- drawSetupValue(screen_pos, setup_info_pos_raw);
-
- // fullscreen state may have changed at this point
- if (si->value == &setup.fullscreen)
- ToggleFullscreenOrChangeWindowScalingIfNeeded();
-}
-
-#else
-
-static void changeSetupValue(int pos, int dx)
-{
- if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
- {
- *(boolean *)setup_info[pos].value ^= TRUE;
- }
- else if (setup_info[pos].type & TYPE_YES_NO_AUTO)
- {
- *(int *)setup_info[pos].value =
- (dx == -1 ?
- (*(int *)setup_info[pos].value == AUTO ? TRUE :
- *(int *)setup_info[pos].value == TRUE ? FALSE : AUTO) :
- (*(int *)setup_info[pos].value == TRUE ? AUTO :
- *(int *)setup_info[pos].value == AUTO ? FALSE : TRUE));
- }
- else if (setup_info[pos].type & TYPE_KEY)
- {
- Key key;
-
- setup_info[pos].type |= TYPE_QUERY;
- drawSetupValue(pos, -1);
- setup_info[pos].type &= ~TYPE_QUERY;
-
- key = getSetupKey();
- if (key != KSYM_UNDEFINED)
- *(Key *)setup_info[pos].value = key;
- }
-
- drawSetupValue(pos, -1);
-
- // fullscreen state may have changed at this point
- if (setup_info[pos].value == &setup.fullscreen)
- ToggleFullscreenOrChangeWindowScalingIfNeeded();
-}
-#endif
-
-#if 1
-static void DrawCursorAndText_Setup(int screen_pos, int setup_info_pos_raw,
- boolean active)
-{
- int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
- struct TokenInfo *si = &setup_info[si_pos];
- int xpos = MENU_SCREEN_START_XPOS;
- int ypos = MENU_SCREEN_START_YPOS + screen_pos;
- int font_nr = getSetupTextFont(si->type);
-
- if (setup_info == setup_info_input)
- font_nr = FONT_MENU_1;
-
- if (active)
- font_nr = FONT_ACTIVE(font_nr);
-
- DrawText(mSX + xpos * 32, mSY + ypos * 32, si->text, font_nr);
-
- if (si->type & ~TYPE_SKIP_ENTRY)
- drawCursor(screen_pos, active);
-}
-#else
-static void DrawCursorAndText_Setup(int pos, boolean active)
-{
- int xpos = MENU_SCREEN_START_XPOS;
- int ypos = MENU_SCREEN_START_YPOS + pos;
- int font_nr = getSetupTextFont(setup_info[pos].type);
-
- if (setup_info == setup_info_input)
- font_nr = FONT_MENU_1;
-
- if (active)
- font_nr = FONT_ACTIVE(font_nr);
-
- DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[pos].text, font_nr);
-
- if (setup_info[pos].type & ~TYPE_SKIP_ENTRY)
- drawCursor(pos, active);
-}
-#endif
-
-static void drawSetupInfoList(struct TokenInfo *setup_info,
- int first_entry, int num_page_entries)
-{
- int i;
-
- if (num_page_entries > NUM_MENU_ENTRIES_ON_SCREEN)
- num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
-
- if (num_page_entries > max_setup_info)
- num_page_entries = max_setup_info;
-
- if (first_entry + num_page_entries > max_setup_info)
- first_entry = 0;
-
-#if 1
- /* clear tree list area, but not title or scrollbar */
- DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
- SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
- NUM_MENU_ENTRIES_ON_SCREEN * 32);
-#endif
-
- for (i = 0; i < num_page_entries; i++)
- {
- int setup_info_pos = first_entry + i;
- struct TokenInfo *si = &setup_info[setup_info_pos];
- void *value_ptr = si->value;
-
- /* set some entries to "unchangeable" according to other variables */
- if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
- (value_ptr == &setup.sound_loops && !audio.loops_available) ||
- (value_ptr == &setup.sound_music && !audio.music_available) ||
- (value_ptr == &setup.fullscreen && !video.fullscreen_available) ||
- (value_ptr == &screen_mode_text && !video.fullscreen_available) ||
- (value_ptr == &window_size_text && !video.window_scaling_available) ||
- (value_ptr == &scaling_type_text && !video.window_scaling_available))
- si->type |= TYPE_GHOSTED;
-
- if (si->type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
- initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
- else if (si->type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
- initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
- else if (si->type & ~TYPE_SKIP_ENTRY)
- initCursor(i, IMG_MENU_BUTTON);
-
- DrawCursorAndText_Setup(i, setup_info_pos, FALSE);
-
- if (si->type & TYPE_VALUE)
- drawSetupValue(i, setup_info_pos);
- }
-}
-
-static void DrawSetupScreen_Generic()
-{
- boolean redraw_all = FALSE;
- char *title_string = NULL;
- int i;