From d3e8bd2ac9c04820d21ea6e256db1c49aaa28125 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 5 Apr 2016 23:09:45 +0200 Subject: [PATCH] added using narrow fonts for setup values on setup screens with scrollbar --- src/conf_gfx.c | 6 ++++++ src/main.c | 3 +++ src/main.h | 29 ++++++++++++++++------------- src/screens.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 04db35ad..45b4298b 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5211,11 +5211,15 @@ struct ConfigInfo image_config[] = { "font.option_off.y", "160" }, { "font.option_off.width", "32" }, { "font.option_off.height", "32" }, + { "font.option_off_narrow", UNDEFINED_FILENAME }, + { "font.option_off_narrow.clone_from", "font.text_2.LEVELS" }, { "font.option_on", "RocksFontBig.png" }, { "font.option_on.x", "0" }, { "font.option_on.y", "480" }, { "font.option_on.width", "32" }, { "font.option_on.height", "32" }, + { "font.option_on_narrow", UNDEFINED_FILENAME }, + { "font.option_on_narrow.clone_from", "font.text_4.LEVELS" }, { "font.value_1", "RocksFontBig.png" }, { "font.value_1.x", "0" }, @@ -5232,6 +5236,8 @@ struct ConfigInfo image_config[] = { "font.value_old.y", "160" }, { "font.value_old.width", "32" }, { "font.value_old.height", "32" }, + { "font.value_narrow", UNDEFINED_FILENAME }, + { "font.value_narrow.clone_from", "font.text_4.LEVELS" }, { "font.level_number", "RocksFontSmall.png" }, { "font.level_number.x", "0" }, diff --git a/src/main.c b/src/main.c index e820719a..665504da 100644 --- a/src/main.c +++ b/src/main.c @@ -5542,11 +5542,14 @@ struct FontInfo font_info[NUM_FONTS + 1] = { "font.input_2.active" }, { "font.input_1" }, { "font.input_2" }, + { "font.option_off_narrow" }, { "font.option_off" }, + { "font.option_on_narrow" }, { "font.option_on" }, { "font.value_1" }, { "font.value_2" }, { "font.value_old" }, + { "font.value_narrow" }, { "font.level_number.active" }, { "font.level_number" }, { "font.tape_recorder" }, diff --git a/src/main.h b/src/main.h index 75399360..496bfaab 100644 --- a/src/main.h +++ b/src/main.h @@ -1948,19 +1948,22 @@ #define FONT_INPUT_2_ACTIVE 24 #define FONT_INPUT_1 25 #define FONT_INPUT_2 26 -#define FONT_OPTION_OFF 27 -#define FONT_OPTION_ON 28 -#define FONT_VALUE_1 29 -#define FONT_VALUE_2 30 -#define FONT_VALUE_OLD 31 -#define FONT_LEVEL_NUMBER_ACTIVE 32 -#define FONT_LEVEL_NUMBER 33 -#define FONT_TAPE_RECORDER 34 -#define FONT_GAME_INFO 35 -#define FONT_INFO_ELEMENTS 36 -#define FONT_INFO_LEVELSET 37 - -#define NUM_FONTS 38 +#define FONT_OPTION_OFF_NARROW 27 +#define FONT_OPTION_OFF 28 +#define FONT_OPTION_ON_NARROW 29 +#define FONT_OPTION_ON 30 +#define FONT_VALUE_1 31 +#define FONT_VALUE_2 32 +#define FONT_VALUE_OLD 33 +#define FONT_VALUE_NARROW 34 +#define FONT_LEVEL_NUMBER_ACTIVE 35 +#define FONT_LEVEL_NUMBER 36 +#define FONT_TAPE_RECORDER 37 +#define FONT_GAME_INFO 38 +#define FONT_INFO_ELEMENTS 39 +#define FONT_INFO_LEVELSET 40 + +#define NUM_FONTS 41 #define NUM_INITIAL_FONTS 4 /* values for toon animation configuration */ diff --git a/src/screens.c b/src/screens.c index de42525a..3bcb01c4 100644 --- a/src/screens.c +++ b/src/screens.c @@ -5616,13 +5616,22 @@ static int getSetupValueFont(int type, void *value) return FONT_VALUE_1; } +static int getSetupValueFontNarrow(int type, int font_nr) +{ + return (font_nr == FONT_VALUE_1 ? FONT_VALUE_NARROW : + font_nr == FONT_OPTION_ON ? FONT_OPTION_ON_NARROW : + font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW : + font_nr); +} + static void drawSetupValue(int screen_pos, int setup_info_pos_raw) { int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw); struct TokenInfo *si = &setup_info[si_pos]; boolean font_draw_xoffset_modified = FALSE; + boolean scrollbar_needed = (num_setup_info < max_setup_info); int font_draw_xoffset_old = -1; - int xoffset = (num_setup_info < max_setup_info ? -1 : 0); + int xoffset = (scrollbar_needed ? -1 : 0); int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset; int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset; int xpos = menu_screen_value_xpos; @@ -5664,6 +5673,26 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) font_nr = getSetupValueFont(type, value); font_width = getFontWidth(font_nr); + // special check if right-side setup values moved left due to scrollbar + if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS) + { + int max_menu_text_length = 26; // maximum text length for classic menu + int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset; + int text_startx = mSX + MENU_SCREEN_START_XPOS * 32; + int text_font_nr = getMenuTextFont(FONT_MENU_2); + int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset; + int text_width = max_menu_text_length * getFontWidth(text_font_nr); + + if (startx + font_xoffset < text_startx + text_width + text_font_xoffset) + { + xpos += 1; + startx = mSX + xpos * 32; + + font_nr = getSetupValueFontNarrow(type, font_nr); + font_width = getFontWidth(font_nr); + } + } + /* downward compatibility correction for Juergen Bonhagen's menu settings */ if (setup_mode != SETUP_MODE_INPUT) { -- 2.34.1