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

This commit is contained in:
Indev 2025-11-26 22:44:57 +03:00 committed by NepDisk
parent c56d0c8c73
commit 5c86b7205f
4 changed files with 35 additions and 17 deletions

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"
#include "m_misc.h"
@ -1450,7 +1452,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
{

View file

@ -1272,6 +1272,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.
@ -1965,15 +1966,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, true);
}
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 = (fontv[HU_FONT].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, true);
@ -1985,6 +1986,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, true);
}
c += charwidth;
if (c >= vid.width)
{

View file

@ -237,7 +237,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;
@ -247,13 +247,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;

View file

@ -6,6 +6,7 @@ extern "C" {
#endif
#include "doomdef.h"
#include "m_fixed.h"
#include "command.h"
extern consvar_t cv_emotes;
@ -39,7 +40,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"