Client: Some minor work towards making the textmenu/game_text code respect

actual font data handled by Nuclide via external fontdef files.
This commit is contained in:
Marco Cawthorne 2022-01-31 13:57:30 -08:00
parent 7ce222007c
commit 419e89e861
Signed by: eukara
GPG Key ID: C196CD8BA993248A
5 changed files with 26 additions and 13 deletions

View File

@ -45,6 +45,7 @@ typedef struct
void(int, vector, float) hudpic;
} weapon_t;
void Weapons_Holster(void);
void Weapons_Primary(void);
void Weapons_Secondary(void);
void Weapons_Reload(void);

View File

@ -34,7 +34,10 @@ typedef struct
void Font_Load(string strFile, font_s &fntNew);
void Font_DrawText(vector vecOrigin, string strText, font_s fnt);
void Font_DrawText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt);
void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, int iAlignFlags);
string Font_RGBtoHex(vector vecColor);
int Font_GetHeight(font_s);
float Font_GetStringWidth(string strText, float flColors, font_s fnt);
float Font_GetID(font_s fnt);
float Font_GetID(font_s fnt);

View File

@ -146,3 +146,18 @@ Font_RGBtoHex(vector vecColor)
return sprintf("^x%s%s%s", numtohex(vecColor[0]), numtohex(vecColor[1]), numtohex(vecColor[2]));
}
int
Font_GetHeight(font_s fnt)
{
return (float)fnt.iScaleY;
}
float
Font_GetStringWidth(string strText, float flColors, font_s fnt)
{
drawfont = (float)fnt.iID;
stringwidth(strText, flColors, [(float)fnt.iScaleX,(float)fnt.iScaleY]);
drawfont = 0;
drawfontscale = [1,1,0];
}

View File

@ -50,7 +50,7 @@ GameText_DrawString(vector pos, string msg, vector col, float alpha)
int c = tokenizebyseparator(msg, "\n");
for (int i = 0; i < c; i++) {
float strwidth = stringwidth(argv(i), TRUE, [20,20]);
float strwidth = Font_GetStringWidth(argv(i), TRUE, FONT_20);
if (pos[0] == -1) {
rpos[0] = g_hudmins[0] + (g_hudres[0] / 2) - (strwidth/2);
@ -67,10 +67,10 @@ GameText_DrawString(vector pos, string msg, vector col, float alpha)
} else {
rpos[1] = g_hudmins[1] + ((g_hudres[1] - 12) * pos[1]);
}
rpos[1] += 20 * i;
rpos[1] -= (20 * c) / 2;
drawstring(rpos, argv(i), '20 20', col, alpha,
DRAWFLAG_ADDITIVE);
rpos[1] += Font_GetHeight(FONT_20) * i;
rpos[1] -= (Font_GetHeight(FONT_20) * c) / 2;
Font_DrawText(rpos, argv(i), FONT_20);
}
}
@ -132,15 +132,11 @@ GameText_DrawMessage(int i, float timer, int highlight)
void
GameText_Draw(void)
{
drawfont = Font_GetID(FONT_20);
for (int i = 0i; i < 6; i++) {
GameText_DrawMessage(i, g_textchannels[i].m_flTime - g_textchannels[i].m_flFXTime, 0);
GameText_DrawMessage(i, g_textchannels[i].m_flTime, 1);
g_textchannels[i].m_flTime += clframetime;
}
drawfont = Font_GetID(FONT_CON);
}
void

View File

@ -15,7 +15,6 @@
*/
#ifdef SERVER
int
NSMonster::GetTriggerCondition(void)
{
@ -42,6 +41,7 @@ NSMonster::Save(float handle)
SaveInt(handle, "iFlags", m_iFlags);
super::Save(handle);
}
void
NSMonster::Restore(string strKey, string strValue)
{
@ -169,7 +169,6 @@ NSMonster::AlertNearby(void)
}
}
void
NSMonster::SeeThink(void)
{
@ -240,7 +239,6 @@ NSMonster::GetRunSpeed(void)
return 140;
}
void
NSMonster::AttackThink(void)
{