diff --git a/src/console.c b/src/console.c index 6f9579bef..e9f4c80ff 100644 --- a/src/console.c +++ b/src/console.c @@ -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<= con_width) break; + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<data1 != gamecontrol[0][gc_talkkey][1])) return false; - M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete); - - if (c == KEY_ENTER) + if (M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete)) + ; // Do nothing + else if (c == KEY_ENTER) { chat_on = false; chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) @@ -1427,6 +1427,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. @@ -1917,7 +1918,7 @@ static void HU_DrawChat(void) } } - if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 0)) + if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) { emote_t *suggest; int skip = 0; @@ -2106,15 +2107,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)<= 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); @@ -2126,6 +2127,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) { diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index c4dc05ba1..3e55ef788 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -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; diff --git a/src/m_emotes.h b/src/m_emotes.h index 9921e4444..efe3d69a2 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -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)<cursor == 0) - return; + return false; // If we're in "autocomplete" state, delete ':' for latest autocompleted emote if (autocomplete->complete[0]) @@ -457,8 +457,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a int emotestart = autocomplete->emotestart; // No emote - no autocomplete - if (emotestart == -1 || (size_t)emotestart == input->cursor) - return; + if (emotestart == -1 || input->cursor - emotestart < 2) + return false; strlcpy(autocomplete->complete, &input->buffer[emotestart], input->cursor-emotestart+1); } @@ -476,7 +476,7 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a { // Clear autocompletion state autocomplete->complete[0] = 0; - return; + return false; } } @@ -488,6 +488,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a M_TextInputAddString(input, completed->name); M_TextInputAddChar(input, ':'); + + return true; } boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete) @@ -503,7 +505,8 @@ boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplet if (key == '\t' || (autocomplete->complete[0] == 0 && key == KEY_ENTER)) { - M_TextInputCompleteEmote(input, autocomplete); + if (M_TextInputCompleteEmote(input, autocomplete) && key == KEY_ENTER) // Don't send message if we've autocompleted an emote + ret = true; } else {