From 4056c5bde64e9f8a404b1da738812fdd699436a6 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 3 Jun 2019 14:28:51 -0700 Subject: [PATCH 01/10] Prepare a font system --- src/font.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/font.h | 49 +++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 src/font.c create mode 100644 src/font.h diff --git a/src/font.c b/src/font.c new file mode 100644 index 000000000..7207def62 --- /dev/null +++ b/src/font.c @@ -0,0 +1,76 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2019 by Kart Krew. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file font.c +/// \brief Font setup + +#include "doomdef.h" +#include "hu_stuff.h" +#include "font.h" + +font_t fontv[MAX_FONTS]; +int fontc; + +static void +FontCache (font_t *fnt) +{ + int i; + int c; + + c = fnt->start; + for (i = 0; i < fnt->size; ++i, ++c) + { + fnt->font[i] = HU_CachePatch( + "%s%.*d", + fnt->digits, + fnt->prefix, + c); + } +} + +void +Font_Load (void) +{ + int i; + for (i = 0; i < fontc; ++i) + { + FontCache(&fontv[i]); + } +} + +int +Font_DumbRegister (const font_t *sfnt) +{ + font_t *fnt; + + if (fontc == MAX_FONTS) + return -1; + + fnt = &fontv[fontc]; + + if (!( fnt->font = ZZ_Alloc(sfnt->size * sizeof (patch_t *)) )) + return -1; + + memcpy(fnt, sfnt, sizeof (font_t)); + + return fontc++; +} + +int +Font_Register (const font_t *sfnt) +{ + int d; + + d = Font_DumbRegister(sfnt); + + if (d >= 0) + FontCache(&fontv[d]); + + return d; +} diff --git a/src/font.h b/src/font.h new file mode 100644 index 000000000..c2ef5cf34 --- /dev/null +++ b/src/font.h @@ -0,0 +1,49 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2019 by Kart Krew. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file font.h +/// \brief Font setup + +#ifndef __FONT_H_ +#define __FONT_H__ + +#define MAX_FONTS 32 + +typedef struct font font_t; + +struct font +{ + patch_t **font; + + UINT8 start; + UINT8 size; + + char prefix[8];/* 7 used at most */ + unsigned digits : 2; +}; + +extern font_t fontv[MAX_FONTS]; +extern int fontc; + +/* +Reloads already registered fonts. +*/ +void Font_Load (void); + +/* +Registers and loads a new font. +*/ +int Font_Register (const font_t *); + +/* +Register a new font, but do not load it yet. +*/ +int Font_DumbRegister (const font_t *); + +#endif From 0b0b7c480bbcd9845b829157ffb99318ec11a0f3 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 3 Jun 2019 14:38:45 -0700 Subject: [PATCH 02/10] Set up with the font system --- src/hu_stuff.c | 213 ++++++++++++++++++++++--------------------------- src/hu_stuff.h | 27 +++++-- 2 files changed, 117 insertions(+), 123 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index f343f12b7..36ecb1101 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -14,6 +14,7 @@ #include "doomdef.h" #include "byteptr.h" #include "hu_stuff.h" +#include "font.h" #include "m_menu.h" // gametype_cons_t #include "m_cond.h" // emblems @@ -64,19 +65,9 @@ //------------------------------------------- // heads up font //------------------------------------------- -patch_t *hu_font[HU_FONTSIZE]; -patch_t *kart_font[KART_FONTSIZE]; // SRB2kart -patch_t *tny_font[HU_FONTSIZE]; -patch_t *tallnum[10]; // 0-9 -patch_t *nightsnum[10]; // 0-9 - -// Level title and credits fonts -patch_t *lt_font[LT_FONTSIZE]; -patch_t *cred_font[CRED_FONTSIZE]; // ping font // Note: I'd like to adress that at this point we might *REALLY* want to work towards a common drawString function that can take any font we want because this is really turning into a MESS. :V -Lat' -patch_t *pingnum[10]; patch_t *pinggfx[5]; // small ping graphic patch_t *framecounter; @@ -187,135 +178,52 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum); void HU_LoadGraphics(void) { - char buffer[9]; - INT32 i, j; + INT32 i; if (dedicated) return; - j = HU_FONTSTART; - for (i = 0; i < HU_FONTSIZE; i++, j++) - { - // cache the heads-up font for entire game execution - sprintf(buffer, "STCFN%.3d", j); - if (W_CheckNumForName(buffer) == LUMPERROR) - hu_font[i] = NULL; - else - hu_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - - // tiny version of the heads-up font - sprintf(buffer, "TNYFN%.3d", j); - if (W_CheckNumForName(buffer) == LUMPERROR) - tny_font[i] = NULL; - else - tny_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - - // cache the level title font for entire game execution - lt_font[0] = (patch_t *)W_CachePatchName("LTFNT039", PU_HUDGFX); /// \note fake start hack - - // Number support - lt_font[9] = (patch_t *)W_CachePatchName("LTFNT048", PU_HUDGFX); - lt_font[10] = (patch_t *)W_CachePatchName("LTFNT049", PU_HUDGFX); - lt_font[11] = (patch_t *)W_CachePatchName("LTFNT050", PU_HUDGFX); - lt_font[12] = (patch_t *)W_CachePatchName("LTFNT051", PU_HUDGFX); - lt_font[13] = (patch_t *)W_CachePatchName("LTFNT052", PU_HUDGFX); - lt_font[14] = (patch_t *)W_CachePatchName("LTFNT053", PU_HUDGFX); - lt_font[15] = (patch_t *)W_CachePatchName("LTFNT054", PU_HUDGFX); - lt_font[16] = (patch_t *)W_CachePatchName("LTFNT055", PU_HUDGFX); - lt_font[17] = (patch_t *)W_CachePatchName("LTFNT056", PU_HUDGFX); - lt_font[18] = (patch_t *)W_CachePatchName("LTFNT057", PU_HUDGFX); - - // SRB2kart - j = KART_FONTSTART; - for (i = 0; i < KART_FONTSIZE; i++, j++) - { - // cache the heads-up font for entire game execution - sprintf(buffer, "MKFNT%.3d", j); - if (W_CheckNumForName(buffer) == LUMPERROR) - kart_font[i] = NULL; - else - kart_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - // - - j = LT_FONTSTART; - for (i = 0; i < LT_FONTSIZE; i++) - { - sprintf(buffer, "LTFNT%.3d", j); - j++; - - if (W_CheckNumForName(buffer) == LUMPERROR) - lt_font[i] = NULL; - else - lt_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - - // cache the credits font for entire game execution (why not?) - j = CRED_FONTSTART; - for (i = 0; i < CRED_FONTSIZE; i++) - { - sprintf(buffer, "CRFNT%.3d", j); - j++; - - if (W_CheckNumForName(buffer) == LUMPERROR) - cred_font[i] = NULL; - else - cred_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - - //cache numbers too! - for (i = 0; i < 10; i++) - { - sprintf(buffer, "STTNUM%d", i); - tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - sprintf(buffer, "NGTNUM%d", i); - nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - sprintf(buffer, "PINGN%d", i); - pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } + Font_Load(); // minus for negative tallnums - tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX); + tallminus = HU_CachePatch("STTMINUS"); // cache the crosshairs, don't bother to know which one is being used, // just cache all 3, they're so small anyway. for (i = 0; i < HU_CROSSHAIRS; i++) { - sprintf(buffer, "CROSHAI%c", '1'+i); - crosshair[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + crosshair[i] = HU_CachePatch("CROSHAI%c", '1'+i); } - emblemicon = W_CachePatchName("EMBLICON", PU_HUDGFX); - tokenicon = W_CachePatchName("TOKNICON", PU_HUDGFX); + emblemicon = HU_CachePatch("EMBLICON"); + tokenicon = HU_CachePatch("TOKNICON"); - emeraldpics[0] = W_CachePatchName("CHAOS1", PU_HUDGFX); - emeraldpics[1] = W_CachePatchName("CHAOS2", PU_HUDGFX); - emeraldpics[2] = W_CachePatchName("CHAOS3", PU_HUDGFX); - emeraldpics[3] = W_CachePatchName("CHAOS4", PU_HUDGFX); - emeraldpics[4] = W_CachePatchName("CHAOS5", PU_HUDGFX); - emeraldpics[5] = W_CachePatchName("CHAOS6", PU_HUDGFX); - emeraldpics[6] = W_CachePatchName("CHAOS7", PU_HUDGFX); - tinyemeraldpics[0] = W_CachePatchName("TEMER1", PU_HUDGFX); - tinyemeraldpics[1] = W_CachePatchName("TEMER2", PU_HUDGFX); - tinyemeraldpics[2] = W_CachePatchName("TEMER3", PU_HUDGFX); - tinyemeraldpics[3] = W_CachePatchName("TEMER4", PU_HUDGFX); - tinyemeraldpics[4] = W_CachePatchName("TEMER5", PU_HUDGFX); - tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX); - tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); + emeraldpics[0] = HU_CachePatch("CHAOS1"); + emeraldpics[1] = HU_CachePatch("CHAOS2"); + emeraldpics[2] = HU_CachePatch("CHAOS3"); + emeraldpics[3] = HU_CachePatch("CHAOS4"); + emeraldpics[4] = HU_CachePatch("CHAOS5"); + emeraldpics[5] = HU_CachePatch("CHAOS6"); + emeraldpics[6] = HU_CachePatch("CHAOS7"); + tinyemeraldpics[0] = HU_CachePatch("TEMER1"); + tinyemeraldpics[1] = HU_CachePatch("TEMER2"); + tinyemeraldpics[2] = HU_CachePatch("TEMER3"); + tinyemeraldpics[3] = HU_CachePatch("TEMER4"); + tinyemeraldpics[4] = HU_CachePatch("TEMER5"); + tinyemeraldpics[5] = HU_CachePatch("TEMER6"); + tinyemeraldpics[6] = HU_CachePatch("TEMER7"); - songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX); + songcreditbg = HU_CachePatch("K_SONGCR"); // cache ping gfx: for (i = 0; i < 5; i++) { - sprintf(buffer, "PINGGFX%d", i+1); - pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + pinggfx[i] = HU_CachePatch("PINGGFX%d", i+1); } // fps stuff - framecounter = W_CachePatchName("FRAMER", PU_HUDGFX); - frameslash = W_CachePatchName("FRAMESL", PU_HUDGFX);; + framecounter = HU_CachePatch("FRAMER"); + frameslash = HU_CachePatch("FRAMESL");; } // Initialise Heads up @@ -323,6 +231,8 @@ void HU_LoadGraphics(void) // void HU_Init(void) { + font_t font; + #ifndef NONET COM_AddCommand("say", Command_Say_f); COM_AddCommand("sayto", Command_Sayto_f); @@ -334,9 +244,78 @@ void HU_Init(void) // set shift translation table shiftxform = english_shiftxform; + /* + Setup fonts + */ + + if (!dedicated) + { +#define DIM( start, size ) ( font.start = start, font.size = size ) +#define ADIM( name ) DIM (name ## _FONTSTART, name ## _FONTSIZE) +#define PR( s ) strcpy(font.prefix, s) +#define DIG( n ) ( font.digits = n ) +#define REG Font_DumbRegister(&font) + + DIG (3); + + ADIM (HU); + + PR ("STCFN"); + REG; + + PR ("TNYFN"); + REG; + + ADIM (KART); + PR ("MKFNT"); + REG; + + ADIM (LT); + PR ("LTFNT"); + REG; + + ADIM (CRED); + PR ("CRFNT"); + REG; + + DIG (1); + + DIM (0, 10); + + PR ("STTNUM"); + REG; + + PR ("NGTNUM"); + REG; + + PR ("PINGN"); + REG; + +#undef REG +#undef DIG +#undef PR +#undef ADMIN +#undef DIM + } + HU_LoadGraphics(); } +patch_t *HU_CachePatch(const char *format, ...) +{ + va_list ap; + char buffer[9]; + + va_start (ap, format); + vsprintf(buffer, format, ap); + va_end (ap); + + if (W_CheckNumForName(buffer) == LUMPERROR) + return NULL; + else + return (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); +} + static inline void HU_Stop(void) { headsupactive = false; diff --git a/src/hu_stuff.h b/src/hu_stuff.h index be6798a82..3b412e76a 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -17,6 +17,7 @@ #include "d_event.h" #include "w_wad.h" #include "r_defs.h" +#include "font.h" //------------------------------------ // heads up font @@ -42,6 +43,23 @@ #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) +#define X( name ) name ## _FONT +/* fonts */ +enum +{ + X (HU), + X (TINY), + X (KART), + + X (LT), + X (CRED), + + X (TALLNUM), + X (NIGHTSNUM), + X (PINGNUM), +}; +#undef X + #define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init(); extern char *shiftxform; // english translation shift table @@ -78,15 +96,9 @@ void HU_AddChatText(const char *text, boolean playsound); // set true when entering a chat message extern boolean chat_on; -extern patch_t *hu_font[HU_FONTSIZE], *kart_font[KART_FONTSIZE], *tny_font[HU_FONTSIZE]; // SRB2kart -extern patch_t *tallnum[10]; -extern patch_t *pingnum[10]; extern patch_t *pinggfx[5]; -extern patch_t *nightsnum[10]; extern patch_t *framecounter; extern patch_t *frameslash; -extern patch_t *lt_font[LT_FONTSIZE]; -extern patch_t *cred_font[CRED_FONTSIZE]; extern patch_t *emeraldpics[7]; extern patch_t *tinyemeraldpics[7]; extern patch_t *rflagico; @@ -104,6 +116,9 @@ void HU_Init(void); void HU_LoadGraphics(void); +// Load a HUDGFX patch or NULL. +patch_t *HU_CachePatch(const char *format, ...); + // reset heads up when consoleplayer respawns. void HU_Start(void); From 8ee25a7c8ab2f632d24583952bc0a6ba3c767c57 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 3 Jun 2019 14:57:58 -0700 Subject: [PATCH 03/10] Begin using the font system --- src/d_clisrv.c | 2 +- src/g_game.c | 2 +- src/hu_stuff.c | 4 ++-- src/k_kart.c | 2 +- src/st_stuff.h | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1dc2c1420..0149b8d30 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2212,7 +2212,7 @@ boolean CL_Responder(event_t *ev) if (cl_mode != CL_CHALLENGE) return false; - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) + if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && fontv[HU_FONT].font[ch-HU_FONTSTART]) || ch == ' ') // Allow spaces, of course { len = strlen(cl_challengepassword); diff --git a/src/g_game.c b/src/g_game.c index 10bd76acc..6f602661b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8273,7 +8273,7 @@ boolean G_DemoTitleResponder(event_t *ev) return true; } - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) + if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && fontv[HU_FONT].font[ch-HU_FONTSTART]) || ch == ' ') // Allow spaces, of course { len = strlen(demo.titlename); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 36ecb1101..ad3f1967d 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -975,7 +975,7 @@ static inline boolean HU_keyInChatString(char *s, char ch) { size_t l; - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) + if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && fontv[HU_FONT].font[ch-HU_FONTSTART]) || ch == ' ') // Allow spaces, of course { l = strlen(s); @@ -1409,7 +1409,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) c = toupper(c); c -= HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[HU_FONT].font[c]) { chw = spacewidth; lastusablespace = i; diff --git a/src/k_kart.c b/src/k_kart.c index 10d772ba0..d68a44e1c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8495,7 +8495,7 @@ static void K_drawInput(void) V_DrawFill(x+(xoffs), y+BUTTH, BUTTW-1, 2, splitflags|31);\ }\ V_DrawFill(x+(xoffs), y+offs, BUTTW-1, BUTTH, col);\ - V_DrawFixedPatch((x+1+(xoffs))< Date: Sun, 23 Jun 2019 16:33:53 -0700 Subject: [PATCH 04/10] Fix minor errors --- src/font.h | 2 +- src/hu_stuff.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/font.h b/src/font.h index c2ef5cf34..88bedb44f 100644 --- a/src/font.h +++ b/src/font.h @@ -10,7 +10,7 @@ /// \file font.h /// \brief Font setup -#ifndef __FONT_H_ +#ifndef __FONT_H__ #define __FONT_H__ #define MAX_FONTS 32 diff --git a/src/hu_stuff.c b/src/hu_stuff.c index ad3f1967d..6b83a5896 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -250,7 +250,7 @@ void HU_Init(void) if (!dedicated) { -#define DIM( start, size ) ( font.start = start, font.size = size ) +#define DIM( s, n ) ( font.start = s, font.size = n ) #define ADIM( name ) DIM (name ## _FONTSTART, name ## _FONTSIZE) #define PR( s ) strcpy(font.prefix, s) #define DIG( n ) ( font.digits = n ) From 8063cc6c2f2a0907d2ae877abc091cbf58bb065e Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 26 Jun 2019 00:31:20 -0700 Subject: [PATCH 05/10] Order correctly and include z_zone.h --- src/font.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/font.c b/src/font.c index 7207def62..aeaabd018 100644 --- a/src/font.c +++ b/src/font.c @@ -13,6 +13,7 @@ #include "doomdef.h" #include "hu_stuff.h" #include "font.h" +#include "z_zone.h" font_t fontv[MAX_FONTS]; int fontc; @@ -28,8 +29,8 @@ FontCache (font_t *fnt) { fnt->font[i] = HU_CachePatch( "%s%.*d", - fnt->digits, fnt->prefix, + fnt->digits, c); } } @@ -54,11 +55,11 @@ Font_DumbRegister (const font_t *sfnt) fnt = &fontv[fontc]; + memcpy(fnt, sfnt, sizeof (font_t)); + if (!( fnt->font = ZZ_Alloc(sfnt->size * sizeof (patch_t *)) )) return -1; - memcpy(fnt, sfnt, sizeof (font_t)); - return fontc++; } From 9579f6ea9e2dbd8c25a6f6a8d6ad7e90e3ac0834 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 26 Jun 2019 16:33:59 -0700 Subject: [PATCH 06/10] Add font system to Makefile and Visual Studio project files --- src/CMakeLists.txt | 2 ++ src/Makefile | 3 ++- src/sdl/Srb2SDL-vc10.vcxproj | 4 +++- src/sdl/Srb2SDL-vc9.vcproj | 44 ++++++++++++++++++++++++++++++++++ src/sdl12/Srb2SDL-vc10.vcxproj | 11 +++++++++ src/sdl12/Srb2SDL-vc9.vcproj | 44 ++++++++++++++++++++++++++++++++++ src/win32/Srb2win-vc10.vcxproj | 4 +++- src/win32/Srb2win-vc9.vcproj | 44 ++++++++++++++++++++++++++++++++++ 8 files changed, 153 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f97c173c..d8bb3956f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ set(SRB2_CORE_SOURCES filesrch.c g_game.c g_input.c + font.c hu_stuff.c i_tcp.c info.c @@ -74,6 +75,7 @@ set(SRB2_CORE_HEADERS g_game.h g_input.h g_state.h + font.h hu_stuff.h i_joy.h i_net.h diff --git a/src/Makefile b/src/Makefile index 214c2bf7a..adac06b2b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -487,6 +487,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/am_map.o \ $(OBJDIR)/command.o \ $(OBJDIR)/console.o \ + $(OBJDIR)/font.o \ $(OBJDIR)/hu_stuff.o \ $(OBJDIR)/y_inter.o \ $(OBJDIR)/st_stuff.o \ @@ -788,7 +789,7 @@ $(OBJDIR)/v_video.o: v_video.c doomdef.h doomtype.h g_state.h m_swap.h r_local.h tables.h m_fixed.h screen.h command.h m_bbox.h r_main.h d_player.h \ p_pspr.h info.h d_think.h sounds.h p_mobj.h doomdata.h d_ticcmd.h \ r_data.h r_defs.h r_state.h r_bsp.h r_segs.h r_plane.h r_sky.h \ - r_things.h r_draw.h v_video.h hu_stuff.h d_event.h w_wad.h console.h \ + r_things.h r_draw.h v_video.h font.h hu_stuff.h d_event.h w_wad.h console.h \ i_video.h z_zone.h doomstat.h d_clisrv.h d_netcmd.h $(CC) $(CFLAGS) -fno-omit-frame-pointer $(WFLAGS) -c $< -o $@ endif diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 45b1faab7..b5e897e62 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -231,6 +231,7 @@ + @@ -376,6 +377,7 @@ + @@ -488,4 +490,4 @@ - \ No newline at end of file + diff --git a/src/sdl/Srb2SDL-vc9.vcproj b/src/sdl/Srb2SDL-vc9.vcproj index 3898aeba4..6709ccd5e 100644 --- a/src/sdl/Srb2SDL-vc9.vcproj +++ b/src/sdl/Srb2SDL-vc9.vcproj @@ -2090,6 +2090,50 @@ RelativePath="..\console.h" > + + + + + + + + + + + + + + + + diff --git a/src/sdl12/Srb2SDL-vc10.vcxproj b/src/sdl12/Srb2SDL-vc10.vcxproj index 0ac7e9e55..5514f3eb4 100644 --- a/src/sdl12/Srb2SDL-vc10.vcxproj +++ b/src/sdl12/Srb2SDL-vc10.vcxproj @@ -655,6 +655,16 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) @@ -1366,6 +1376,7 @@ + diff --git a/src/sdl12/Srb2SDL-vc9.vcproj b/src/sdl12/Srb2SDL-vc9.vcproj index fa386e381..bf6cfb36d 100644 --- a/src/sdl12/Srb2SDL-vc9.vcproj +++ b/src/sdl12/Srb2SDL-vc9.vcproj @@ -2090,6 +2090,50 @@ RelativePath="..\console.h" > + + + + + + + + + + + + + + + + diff --git a/src/win32/Srb2win-vc10.vcxproj b/src/win32/Srb2win-vc10.vcxproj index ced3d128e..f494aed1e 100644 --- a/src/win32/Srb2win-vc10.vcxproj +++ b/src/win32/Srb2win-vc10.vcxproj @@ -235,6 +235,7 @@ + @@ -402,6 +403,7 @@ + @@ -502,4 +504,4 @@ - \ No newline at end of file + diff --git a/src/win32/Srb2win-vc9.vcproj b/src/win32/Srb2win-vc9.vcproj index a64b8638c..7fa9f52ad 100644 --- a/src/win32/Srb2win-vc9.vcproj +++ b/src/win32/Srb2win-vc9.vcproj @@ -1831,6 +1831,50 @@ RelativePath="..\console.h" > + + + + + + + + + + + + + + + + From 5e1d110ed55a3e550e216c58e26d1d643cbd59a5 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 26 Jun 2019 16:45:26 -0700 Subject: [PATCH 07/10] Add V_DrawStringScaled --- src/v_video.c | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 11 ++ 2 files changed, 298 insertions(+) diff --git a/src/v_video.c b/src/v_video.c index 9233eda42..76dc95d4a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1499,6 +1499,293 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) return newstring; } +static inline fixed_t FixedCharacterDim( + fixed_t scale, + fixed_t chw, + INT32 hchw, + INT32 dupx, + fixed_t * cwp) +{ + (void)hchw; + (void)dupx; + (*cwp) = chw; + return 0; +} + +static inline fixed_t VariableCharacterDim( + fixed_t scale, + fixed_t chw, + INT32 hchw, + INT32 dupx, + fixed_t * cwp) +{ + (void)chw; + (void)hchw; + (void)dupx; + (*cwp) = FixedMul ((*cwp) << FRACBITS, scale); + return 0; +} + +static inline fixed_t CenteredCharacterDim( + fixed_t scale, + fixed_t chw, + INT32 hchw, + INT32 dupx, + fixed_t * cwp) +{ + INT32 cxoff; + /* + For example, center a 4 wide patch to 8 width: + 4/2 = 2 + 8/2 = 4 + 4 - 2 = 2 (our offset) + 2 + 4 = 6 = 8 - 2 (equal space on either side) + */ + cxoff = hchw -((*cwp) >> 1 ); + (*cwp) = chw; + return FixedMul (( cxoff * dupx )<< FRACBITS, scale); +} + +static inline fixed_t BunchedCharacterDim( + fixed_t scale, + fixed_t chw, + INT32 hchw, + INT32 dupx, + fixed_t * cwp) +{ + (void)chw; + (void)hchw; + (void)dupx; + (*cwp) = FixedMul (max (1, (*cwp) - 1) << FRACBITS, scale); + return 0; +} + +void V_DrawStringScaled( + fixed_t x, + fixed_t y, + fixed_t scale, + fixed_t spacescale, + fixed_t lfscale, + INT32 flags, + int fontno, + const char *s) +{ + fixed_t chw; + INT32 hchw;/* half-width for centering */ + fixed_t spacew; + fixed_t lfh; + + INT32 dupx; + + fixed_t right; + fixed_t bot; + + fixed_t (*dim_fn)(fixed_t,fixed_t,INT32,INT32,fixed_t *); + + font_t *font; + + boolean uppercase; + boolean notcolored; + + const UINT8 *colormap; + + fixed_t cx, cy; + + fixed_t cxoff; + fixed_t cw; + + INT32 spacing; + fixed_t left; + + int c; + + uppercase = !( flags & V_ALLOWLOWERCASE ); + flags &= ~(V_FLIP);/* These two (V_ALLOWLOWERCASE) share a bit. */ + + colormap = V_GetStringColormap(( flags & V_CHARCOLORMASK )); + notcolored = !colormap; + + font = &fontv[fontno]; + + chw = 0; + + spacing = ( flags & V_SPACINGMASK ); + + /* + Hardcoded until a better system can be implemented + for determining how fonts space. + */ + switch (fontno) + { + default: + case HU_FONT: + spacew = 4; + switch (spacing) + { + case V_MONOSPACE: + spacew = 8; + /* FALLTHRU */ + case V_OLDSPACING: + chw = 8; + break; + case V_6WIDTHSPACE: + spacew = 6; + } + break; + case TINY_FONT: + spacew = 2; + switch (spacing) + { + case V_MONOSPACE: + spacew = 5; + /* FALLTHRU */ + case V_OLDSPACING: + chw = 5; + break; + // Out of video flags, so we're reusing this for alternate charwidth instead + /*case V_6WIDTHSPACE: + spacewidth = 3;*/ + } + break; + case KART_FONT: + spacew = 12; + switch (spacing) + { + case V_MONOSPACE: + spacew = 12; + /* FALLTHRU */ + case V_OLDSPACING: + chw = 12; + break; + case V_6WIDTHSPACE: + spacew = 6; + } + break; + } + switch (fontno) + { + default: + case HU_FONT: + case TINY_FONT: + case KART_FONT: + if (( flags & V_RETURN8 )) + lfh = 8; + else + lfh = 12; + break; + case LT_FONT: + case CRED_FONT: + lfh = 12; + break; + } + + hchw = chw >> 1; + + chw <<= FRACBITS; + spacew <<= FRACBITS; + +#define Mul( id, scale ) ( id = FixedMul (scale, id) ) + Mul (chw, scale); + Mul (spacew, scale); + Mul (lfh, scale); + + Mul (spacew, spacescale); + Mul (lfh, lfscale); +#undef Mul + + if (( flags & V_NOSCALESTART )) + { + dupx = vid.dupx; + + hchw *= dupx; + + chw *= dupx; + spacew *= dupx; + lfh *= vid.dupy; + + right = vid.width; + } + else + { + dupx = 1; + + right = ( vid.width / vid.dupx ); + if (!( flags & V_SNAPTOLEFT )) + { + left = ( right - BASEVIDWIDTH )/ 2;/* left edge of drawable area */ + x = ( left << FRACBITS )+ x; + right -= left; + } + } + + right <<= FRACBITS; + bot = vid.height << FRACBITS; + + if (fontno == TINY_FONT) + { + if (chw) + dim_fn = FixedCharacterDim; + else + { + /* Reuse this flag for the alternate bunched-up spacing. */ + if (( flags & V_6WIDTHSPACE )) + dim_fn = BunchedCharacterDim; + else + dim_fn = VariableCharacterDim; + } + } + else + { + if (chw) + dim_fn = CenteredCharacterDim; + else + dim_fn = VariableCharacterDim; + } + + cx = x; + cy = y; + + for (; ( c = *s ); ++s) + { + switch (c) + { + case '\n': + cy += lfh; + if (cy >= bot) + return; + cx = x; + break; + default: + if (( c & 0x80 )) + { + if (notcolored) + { + colormap = V_GetStringColormap( + ( ( c & 0x7f )<< V_CHARCOLORSHIFT )& + V_CHARCOLORMASK); + } + } + else if (cx < right) + { + if (uppercase) + c = toupper(c); + + c -= font->start; + if (c >= 0 && c < font->size && font->font[c]) + { + cw = SHORT (font->font[c]->width) * dupx; + cxoff = (*dim_fn)(scale, chw, hchw, dupx, &cw); + V_DrawFixedPatch(cx + cxoff, cy, scale, + flags, font->font[c], colormap); + cx += cw; + } + else + cx += spacew; + } + } + } +} + // // Write a string using the hu_font // NOTE: the text is centered for screens larger than the base width diff --git a/src/v_video.h b/src/v_video.h index c8485c179..b01f65d06 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -173,6 +173,17 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string); // wordwrap a string using the hu_font char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string); +// draw a string using a font +void V_DrawStringScaled( + fixed_t x, + fixed_t y, + fixed_t scale, + fixed_t space_scale, + fixed_t linefeed_scale, + INT32 flags, + int font, + const char *text); + // draw a string using the hu_font void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string); // SRB2kart From 295631b953ae4d17cd609c5fe9348e50247a8ae8 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 26 Jun 2019 17:02:21 -0700 Subject: [PATCH 08/10] Support Level Title and Credit font in V_DrawStringScaled --- src/v_video.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/v_video.c b/src/v_video.c index 76dc95d4a..0e334dc8b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1661,6 +1661,12 @@ void V_DrawStringScaled( spacew = 6; } break; + case LT_FONT: + spacew = 12; + break; + case CRED_FONT: + spacew = 16; + break; } switch (fontno) { From d8a2d6c7e2ce82375bb7d9184fe245203149fefa Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 26 Jun 2019 17:09:13 -0700 Subject: [PATCH 09/10] Remove old string drawing functions --- src/v_video.c | 615 -------------------------------------------------- src/v_video.h | 27 ++- 2 files changed, 20 insertions(+), 622 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 0e334dc8b..5440cbcdb 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1791,217 +1791,6 @@ void V_DrawStringScaled( } } } - -// -// Write a string using the hu_font -// NOTE: the text is centered for screens larger than the base width -// -void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) -{ - INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0; - const char *ch = string; - INT32 charflags = 0; - const UINT8 *colormap = NULL; - INT32 spacewidth = 4, charwidth = 0; - - INT32 lowercase = (option & V_ALLOWLOWERCASE); - option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... - - if (option & V_NOSCALESTART) - { - dupx = vid.dupx; - dupy = vid.dupy; - scrwidth = vid.width; - } - else - { - dupx = dupy = 1; - scrwidth = vid.width/vid.dupx; - if (!(option & V_SNAPTOLEFT)) - { - left = (scrwidth - BASEVIDWIDTH)/2; - scrwidth -= left; - } - } - - charflags = (option & V_CHARCOLORMASK); - colormap = V_GetStringColormap(charflags); - - switch (option & V_SPACINGMASK) - { - case V_MONOSPACE: - spacewidth = 8; - /* FALLTHRU */ - case V_OLDSPACING: - charwidth = 8; - break; - case V_6WIDTHSPACE: - spacewidth = 6; - default: - break; - } - - for (;;ch++) - { - if (!*ch) - break; - if (*ch & 0x80) //color parsing -x 2.16.09 - { - // manually set flags override color codes - if (!(option & V_CHARCOLORMASK)) - { - charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; - colormap = V_GetStringColormap(charflags); - } - continue; - } - if (*ch == '\n') - { - cx = x; - - if (option & V_RETURN8) - cy += 8*dupy; - else - cy += 12*dupy; - - continue; - } - - c = *ch; - if (!lowercase) - c = toupper(c); - c -= HU_FONTSTART; - - // character does not exist or is a space - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) - { - cx += spacewidth * dupx; - continue; - } - - if (charwidth) - { - w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*dupx/2; - } - else - w = SHORT(hu_font[c]->width) * dupx; - - if (cx > scrwidth) - break; - if (cx+left + w < 0) //left boundary check - { - cx += w; - continue; - } - - V_DrawFixedPatch((cx + center)<= KART_FONTSIZE || !kart_font[c]) - { - cx += spacewidth * dupx; - continue; - } - - if (charwidth) - { - w = charwidth * dupx; - center = w/2 - SHORT(kart_font[c]->width)*dupx/2; - } - else - w = SHORT(kart_font[c]->width) * dupx; - - if (cx > scrwidth) - break; - if (cx+left + w < 0) //left boundary check - { - cx += w; - continue; - } - - V_DrawFixedPatch((cx + center)<= HU_FONTSIZE || !hu_font[c]) - { - cx += spacewidth * dupx; - continue; - } - - if (charwidth) - { - w = charwidth * dupx; - center = w/2 - SHORT(hu_font[c]->width)*dupx/4; - } - else - w = SHORT(hu_font[c]->width) * dupx / 2; - if (cx > scrwidth) - break; - if (cx+left + w < 0) //left boundary check - { - cx += w; - continue; - } - - V_DrawFixedPatch((cx + center)<= HU_FONTSIZE || !tny_font[c]) - { - cx += spacewidth * dupx; - continue; - } - - if (charwidth) - w = charwidth * dupx; - else - w = ((option & V_6WIDTHSPACE ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing - : SHORT(tny_font[c]->width)) * dupx); - - if (cx > scrwidth) - break; - if (cx+left + w < 0) //left boundary check - { - cx += w; - continue; - } - - V_DrawFixedPatch(cx<= HU_FONTSIZE || !hu_font[c]) - { - cx += (spacewidth * dupx)<width)*(dupx/2); - } - else - w = SHORT(hu_font[c]->width) * dupx; - - if ((cx>>FRACBITS) > scrwidth) - break; - if ((cx>>FRACBITS)+left + w < 0) //left boundary check - { - cx += w<= CRED_FONTSIZE) - { - cx += (16*dupx)<width) * dupx; - if ((cx>>FRACBITS) > scrwidth) - break; - - V_DrawSciencePatch(cx, cy, option, cred_font[c], FRACUNIT); - cx += w<= LT_FONTSIZE || !lt_font[c]) - { - cx += 12*dupx; - continue; - } - - w = SHORT(lt_font[c]->width) * dupx; - if (cx > scrwidth) - break; - if (cx+left + w < 0) //left boundary check - { - cx += w; - continue; - } - - V_DrawScaledPatch(cx, cy, option, lt_font[c]); - cx += w; - } -} - // Find string width from lt_font chars // INT32 V_LevelNameWidth(const char *string) diff --git a/src/v_video.h b/src/v_video.h index b01f65d06..d561cea4f 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -161,6 +161,12 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); +/* Convenience macros for leagacy string function macros. */ +#define V__DrawOneScaleString( x,y,scale,option,font,string ) \ + V_DrawStringScaled(x,y,scale,FRACUNIT,FRACUNIT,option,font,string) +#define V__DrawDupxString( x,y,scale,option,font,string )\ + V__DrawOneScaleString ((x)<>1,option,HU_FONT,string) void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string); // draw a string using the tny_font -void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string); +#define V_DrawThinString( x,y,option,string ) \ + V__DrawDupxString (x,y,FRACUNIT,option,TINY_FONT,string) void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); +#define V_DrawStringAtFixed( x,y,option,string ) \ + V__DrawOneScaleString (x,y,FRACUNIT,option,HU_FONT,string) // Draw tall nums, used for menu, HUD, intermission void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); @@ -213,7 +225,8 @@ void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colorm INT32 V_LevelNameWidth(const char *string); INT32 V_LevelNameHeight(const char *string); -void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string); +#define V_DrawCreditString( x,y,option,string ) \ + V__DrawOneScaleString (x,y,FRACUNIT,option,CRED_FONT,string) INT32 V_CreditStringWidth(const char *string); // Find string width from hu_font chars From e04f8b2e53ae3a142f6a1f7b6f855b68e3a8b80f Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 26 Jun 2019 18:25:49 -0700 Subject: [PATCH 10/10] Use font system for other string drawing functions --- src/v_video.c | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 5440cbcdb..146c784b1 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1393,17 +1393,17 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) c -= HU_FONTSTART; else c = toupper(c) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[HU_FONT].font[c]) return; - w = SHORT(hu_font[c]->width); + w = SHORT(fontv[HU_FONT].font[c]->width); if (x + w > vid.width) return; if (colormap != NULL) - V_DrawMappedPatch(x, y, flags, hu_font[c], colormap); + V_DrawMappedPatch(x, y, flags, fontv[HU_FONT].font[c], colormap); else - V_DrawScaledPatch(x, y, flags, hu_font[c]); + V_DrawScaledPatch(x, y, flags, fontv[HU_FONT].font[c]); } // Writes a single character for the chat (half scaled). (draw WHITE if bit 7 set) @@ -1420,14 +1420,14 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UI c -= HU_FONTSTART; else c = toupper(c) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[HU_FONT].font[c]) return; - w = SHORT(hu_font[c]->width)/2; + w = SHORT(fontv[HU_FONT].font[c]->width)/2; if (x + w > vid.width) return; - V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/2, flags, hu_font[c], colormap); + V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/2, flags, fontv[HU_FONT].font[c], colormap); } // Precompile a wordwrapped string to any given width. @@ -1478,13 +1478,13 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) c = toupper(c); c -= HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[HU_FONT].font[c]) { chw = spacewidth; lastusablespace = i; } else - chw = (charwidth ? charwidth : hu_font[c]->width); + chw = (charwidth ? charwidth : fontv[HU_FONT].font[c]->width); x += chw; @@ -1826,7 +1826,7 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = SHORT(fontv[TALLNUM_FONT].font[0]->width); boolean neg; if (flags & V_NOSCALESTART) @@ -1839,7 +1839,7 @@ void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) do { x -= w; - V_DrawScaledPatch(x, y, flags, tallnum[num % 10]); + V_DrawScaledPatch(x, y, flags, fontv[TALLNUM_FONT].font[num % 10]); num /= 10; } while (num); @@ -1852,7 +1852,7 @@ void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) // Does not handle negative numbers in a special way, don't try to feed it any. void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) { - INT32 w = SHORT(tallnum[0]->width); + INT32 w = SHORT(fontv[TALLNUM_FONT].font[0]->width); if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -1864,7 +1864,7 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) do { x -= w; - V_DrawScaledPatch(x, y, flags, tallnum[num % 10]); + V_DrawScaledPatch(x, y, flags, fontv[TALLNUM_FONT].font[num % 10]); num /= 10; } while (--digits); } @@ -1874,7 +1874,7 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colormap) { - INT32 w = SHORT(pingnum[0]->width); // this SHOULD always be 5 but I guess custom graphics exist. + INT32 w = SHORT(fontv[PINGNUM_FONT].font[0]->width); // this SHOULD always be 5 but I guess custom graphics exist. if (flags & V_NOSCALESTART) w *= vid.dupx; @@ -1886,7 +1886,7 @@ void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colorm do { x -= (w-1); // Oni wanted their outline to intersect. - V_DrawFixedPatch(x<= CRED_FONTSIZE) w += 16; else - w += SHORT(cred_font[c]->width); + w += SHORT(fontv[CRED_FONT].font[c]->width); } return w; @@ -1924,10 +1924,10 @@ INT32 V_LevelNameWidth(const char *string) for (i = 0; i < strlen(string); i++) { c = toupper(string[i]) - LT_FONTSTART; - if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) + if (c < 0 || c >= LT_FONTSIZE || !fontv[LT_FONT].font[c]) w += 12; else - w += SHORT(lt_font[c]->width); + w += SHORT(fontv[LT_FONT].font[c]->width); } return w; @@ -1943,11 +1943,11 @@ INT32 V_LevelNameHeight(const char *string) for (i = 0; i < strlen(string); i++) { c = toupper(string[i]) - LT_FONTSTART; - if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) + if (c < 0 || c >= LT_FONTSIZE || !fontv[LT_FONT].font[c]) continue; - if (SHORT(lt_font[c]->height) > w) - w = SHORT(lt_font[c]->height); + if (SHORT(fontv[LT_FONT].font[c]->height) > w) + w = SHORT(fontv[LT_FONT].font[c]->height); } return w; @@ -1983,10 +1983,10 @@ INT32 V_StringWidth(const char *string, INT32 option) continue; c = toupper(c) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[HU_FONT].font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)); + w += (charwidth ? charwidth : SHORT(fontv[HU_FONT].font[c]->width)); } return w; @@ -2022,10 +2022,10 @@ INT32 V_SmallStringWidth(const char *string, INT32 option) continue; c = toupper(c) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[HU_FONT].font[c]) w += spacewidth; else - w += (charwidth ? charwidth : SHORT(hu_font[c]->width)/2); + w += (charwidth ? charwidth : SHORT(fontv[HU_FONT].font[c]->width)/2); } return w; @@ -2062,17 +2062,17 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 continue; - if (!lowercase || !tny_font[c-HU_FONTSTART]) + if (!lowercase || !fontv[TINY_FONT].font[c-HU_FONTSTART]) c = toupper(c); c -= HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !fontv[TINY_FONT].font[c]) w += spacewidth; else { w += (charwidth ? charwidth - : ((option & V_6WIDTHSPACE && i < strlen(string)-1) ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing - : SHORT(tny_font[c]->width))); + : ((option & V_6WIDTHSPACE && i < strlen(string)-1) ? max(1, SHORT(fontv[TINY_FONT].font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing + : SHORT(fontv[TINY_FONT].font[c]->width))); } }