added using narrow fonts for setup values on setup screens with scrollbar
authorHolger Schemel <info@artsoft.org>
Tue, 5 Apr 2016 21:09:45 +0000 (23:09 +0200)
committerHolger Schemel <info@artsoft.org>
Tue, 5 Apr 2016 21:09:45 +0000 (23:09 +0200)
src/conf_gfx.c
src/main.c
src/main.h
src/screens.c

index 04db35adef9073cfda0039f78a6e027e51e5a43c..45b4298bb2e1a67b196b27344a7a6b04ffe4a91b 100644 (file)
@@ -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"                     },
index e820719ad9886b1ea9bc24f608a5b7164dc0dfff..665504da737c031a13d00298ee2d54f59f828b03 100644 (file)
@@ -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"       },
index 75399360ece932e2a5cd8df4e0b09837baa59fd9..496bfaabea1defccddf5b650ef291fcfe961124a 100644 (file)
 #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 */
index de42525a6ab33fc43a651a0c94a4ae00bd7546f3..3bcb01c4b532ac3ee7ebb89491e15e21ad0501f1 100644 (file)
@@ -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)
   {