From: Holger Schemel Date: Tue, 7 Feb 2023 14:07:35 +0000 (+0100) Subject: added debug output showing which font token is used for which screen text X-Git-Tag: 4.3.5.0~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0b49aff192cd5aead79fd70c2b427754ad8df796;p=rocksndiamonds.git added debug output showing which font token is used for which screen text --- diff --git a/src/init.c b/src/init.c index bdcff368..0f8e16e5 100644 --- a/src/init.c +++ b/src/init.c @@ -381,7 +381,7 @@ void InitImageTextures(void) CreateImageTextures(texture_graphics[i]); } -static int getFontBitmapID(int font_nr) +static int getFontSpecialSuffix(void) { int special = -1; @@ -394,6 +394,13 @@ static int getFontBitmapID(int font_nr) else if (game_status == GAME_MODE_PSEUDO_TYPENAMES) special = GFX_SPECIAL_ARG_NAMES; + return special; +} + +static int getFontBitmapID(int font_nr) +{ + int special = getFontSpecialSuffix(); + if (special != -1) return font_info[font_nr].special_bitmap_id[special]; else @@ -411,6 +418,22 @@ static int getFontFromToken(char *token) return FONT_INITIAL_1; } +static char *getTokenFromFont(int font_nr) +{ + static char *token = NULL; + int special = getFontSpecialSuffix(); + + checked_free(token); + + if (special != -1) + token = getStringCat2(font_info[font_nr].token_name, + special_suffix_info[special].suffix); + else + token = getStringCopy(font_info[font_nr].token_name); + + return token; +} + static void InitFontGraphicInfo(void) { static struct FontBitmapInfo *font_bitmap_info = NULL; @@ -422,7 +445,7 @@ static void InitFontGraphicInfo(void) if (graphic_info == NULL) // still at startup phase { InitFontInfo(font_initial, NUM_INITIAL_FONTS, - getFontBitmapID, getFontFromToken); + getFontBitmapID, getFontFromToken, getTokenFromFont); return; } @@ -647,7 +670,7 @@ static void InitFontGraphicInfo(void) } InitFontInfo(font_bitmap_info, num_font_bitmaps, - getFontBitmapID, getFontFromToken); + getFontBitmapID, getFontFromToken, getTokenFromFont); } static void InitGlobalAnimGraphicInfo(void) diff --git a/src/libgame/system.h b/src/libgame/system.h index 5c131b97..6bd13456 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1228,6 +1228,7 @@ struct GfxInfo struct FontBitmapInfo *font_bitmap_info; int (*select_font_function)(int); int (*get_font_from_token_function)(char *); + char * (*get_token_from_font_function)(int); int anim_random_frame; diff --git a/src/libgame/text.c b/src/libgame/text.c index 4de7319a..0d73df43 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -22,12 +22,14 @@ void InitFontInfo(struct FontBitmapInfo *font_bitmap_info, int num_fonts, int (*select_font_function)(int), - int (*get_font_from_token_function)(char *)) + int (*get_font_from_token_function)(char *), + char * (*get_token_from_font_function)(int)) { gfx.num_fonts = num_fonts; gfx.font_bitmap_info = font_bitmap_info; gfx.select_font_function = select_font_function; gfx.get_font_from_token_function = get_font_from_token_function; + gfx.get_token_from_font_function = get_token_from_font_function; } void FreeFontInfo(struct FontBitmapInfo *font_bitmap_info) @@ -254,6 +256,11 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, int src_x, src_y; char *text_ptr = text; +#if DEBUG + Debug("font:token", "'%s' / '%s'", + gfx.get_token_from_font_function(font_nr), text); +#endif + if (font->bitmap == NULL) return; diff --git a/src/libgame/text.h b/src/libgame/text.h index 840bf368..b8c9c15f 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -76,7 +76,9 @@ // font structure definitions void InitFontInfo(struct FontBitmapInfo *, int, - int (*function1)(int), int (*function2)(char *)); + int (*function1)(int), + int (*function2)(char *), + char * (*function3)(int)); void FreeFontInfo(struct FontBitmapInfo *); struct FontBitmapInfo *getFontBitmapInfo(int);