Add support for emotes in console chat mode (and support for emotes in console in general)

This commit is contained in:
indev committed 2025-11-26 22:45:03 +03:00
1 parent 0437952027
commit 4d9c345202
4 files changed
+47 -17

No files matched your search

+26 -1
View File
@@ -33,6 +33,8 @@
#include "d_main.h"
#include "m_menu.h"
#include "m_textinput.h"
#include "m_emotes.h"
#include "i_time.h"
#include "filesrch.h"
#ifdef HWRENDER
@@ -1453,7 +1455,18 @@ static void CON_DrawHudlines(void)
}
if (c >= con_width)
break;
if (*p < HU_FONTSTART)
int emotelen;
emote_t *emote;
if ((emote = M_VerifyEmote((const char *)p, &emotelen)))
{
M_DrawScaledEmote(x<<FRACBITS, (y+2*con_scalefactor)<<FRACBITS, charwidth*FRACUNIT/EMOTEWIDTH, emote, I_GetTime(), V_NOSCALESTART|V_NOSCALEPATCH);
p += emotelen-1;
c += emotelen-1;
continue;
}
else if (*p < HU_FONTSTART)
;//charwidth = 4 * con_scalefactor;
else
{
@@ -1527,8 +1540,20 @@ static void CON_DrawConsole(void)
p++;
c++;
}
if (c >= con_width)
break;
int emotelen;
emote_t *emote;
if ((emote = M_VerifyEmote((const char *)p, &emotelen)))
{
M_DrawScaledEmote(x<<FRACBITS, (y+2*con_scalefactor)<<FRACBITS, charwidth*FRACUNIT/EMOTEWIDTH, emote, I_GetTime(), V_NOSCALESTART|V_NOSCALEPATCH);
p += emotelen-1;
c += emotelen-1;
continue;
}
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
}
}
+16 -8
View File
@@ -1420,6 +1420,7 @@ boolean HU_Responder(event_t *ev)
//======================================================================
#define HU_DrawEmote(x, y, emote, flags) M_DrawEmote((x), (y), (emote), hu_emoteanim, (flags))
#define HU_DrawScaledEmote(x, y, scale, emote, flags) M_DrawScaledEmote((x), (y), (scale), (emote), hu_emoteanim, (flags))
// Precompile a wordwrapped string to any given width.
// This is a muuuch better method than V_WORDWRAP.
@@ -2099,15 +2100,15 @@ static void HU_DrawChat_Old(void)
i = 0;
while (w_chat_buf[i])
{
if (w_chat.cursor == (i+1) && hu_tick < 4)
{
INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down.
INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight);
V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
}
int emotelen;
emote_t *emote;
//Hurdler: isn't it better like that?
if (w_chat_buf[i] >= HU_FONTSTART)
if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen)))
{
HU_DrawScaledEmote((HU_INPUTX + c)<<FRACBITS, (y+con_scalefactor*2)<<FRACBITS, charwidth*FRACUNIT/EMOTEWIDTH, emote, V_NOSCALESTART | V_NOSCALEPATCH | t);
i += emotelen-1;
}
else if (w_chat_buf[i] >= HU_FONTSTART) //Hurdler: isn't it better like that?
{
//charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor;
V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value);
@@ -2119,6 +2120,13 @@ static void HU_DrawChat_Old(void)
++i;
if (w_chat.cursor == i && hu_tick < 4)
{
INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down.
INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight);
V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
}
c += charwidth;
if (c >= vid.width)
{
+2 -7
View File
@@ -248,7 +248,7 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen)
return match;
}
void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags)
void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, tic_t anim, INT32 flags)
{
if (emote->numframes == 0)
return;
@@ -258,13 +258,8 @@ void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags)
const int CHARHEIGHT = 6;
fixed_t scale = FRACUNIT;
x *= FRACUNIT;
y *= FRACUNIT;
if (emotepatch->width > EMOTEWIDTH)
scale = (FRACUNIT/emotepatch->width)*EMOTEWIDTH;
scale = FixedMul(scale, (FRACUNIT/emotepatch->width)*EMOTEWIDTH);
else if (emotepatch->width < EMOTEWIDTH)
x += (EMOTEWIDTH-emotepatch->width)*FRACUNIT/2;
+3 -1
View File
@@ -17,6 +17,7 @@ extern "C" {
#endif
#include "doomdef.h"
#include "m_fixed.h"
#include "command.h"
extern consvar_t cv_emotes;
@@ -50,7 +51,8 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen);
// Draw the emote, anim should be some kind of timer ticking every game tic
// for animated emotes
void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags);
#define M_DrawEmote(x, y, emote, anim, flags) M_DrawScaledEmote((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, emote, anim, flags)
void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, tic_t anim, INT32 flags);
#ifdef __cplusplus
} // extern "C"