From: Holger Schemel Date: Sat, 4 Jan 2025 16:25:03 +0000 (+0100) Subject: added support for narrow font if game panel text too large X-Git-Tag: 4.4.0.1~57 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=47050d911d9d02de93608345dd510b60a70f5f51;p=rocksndiamonds.git added support for narrow font if game panel text too large If player name, level set name, level name or level author to be drawn on game panel is larger than a specified size (using ".chars" option) or larger than the game panel width, an alternative (less wide) font (using ".font_narrow" option) will be used. --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 034873ae..a1f56f9b 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -11012,6 +11012,7 @@ struct ConfigInfo image_config[] = { "game.panel.player_name.valign", "top" }, { "game.panel.player_name.chars", "-1" }, { "game.panel.player_name.font", "font.text_2" }, + { "game.panel.player_name.font_narrow", "font.text_1" }, { "game.panel.player_name.draw_masked", "true" }, { "game.panel.player_name.draw_order", "0" }, { "game.panel.player_name.class", "none" }, @@ -11023,6 +11024,7 @@ struct ConfigInfo image_config[] = { "game.panel.levelset_name.valign", "top" }, { "game.panel.levelset_name.chars", "-1" }, { "game.panel.levelset_name.font", "font.text_2" }, + { "game.panel.levelset_name.font_narrow", "font.text_1" }, { "game.panel.levelset_name.draw_masked", "true" }, { "game.panel.levelset_name.draw_order", "0" }, { "game.panel.levelset_name.class", "none" }, @@ -11034,6 +11036,7 @@ struct ConfigInfo image_config[] = { "game.panel.level_name.valign", "top" }, { "game.panel.level_name.chars", "-1" }, { "game.panel.level_name.font", "font.text_2" }, + { "game.panel.level_name.font_narrow", "font.text_1" }, { "game.panel.level_name.draw_masked", "true" }, { "game.panel.level_name.draw_order", "0" }, { "game.panel.level_name.class", "none" }, @@ -11045,6 +11048,7 @@ struct ConfigInfo image_config[] = { "game.panel.level_author.valign", "top" }, { "game.panel.level_author.chars", "-1" }, { "game.panel.level_author.font", "font.text_2" }, + { "game.panel.level_author.font_narrow", "font.text_1" }, { "game.panel.level_author.draw_masked", "true" }, { "game.panel.level_author.draw_order", "0" }, { "game.panel.level_author.class", "none" }, diff --git a/src/game.c b/src/game.c index 66935e7f..27bc34bd 100644 --- a/src/game.c +++ b/src/game.c @@ -2973,6 +2973,15 @@ static void DisplayGameControlValues(void) font = (active ? font2 : font1); } + else if (nr == GAME_PANEL_PLAYER_NAME || + nr == GAME_PANEL_LEVELSET_NAME || + nr == GAME_PANEL_LEVEL_NAME || + nr == GAME_PANEL_LEVEL_AUTHOR) + { + // use alternative (narrow) font if text larger than specified size or game panel width + if ((size > 0 && strlen(s) > size) || strlen(s) * getFontWidth(font) > DXSIZE) + font = pos->font_alt; + } if (s != NULL) {