Discordify emotes a bit more :chonkbunckle:

- When autocompleting emote with enter, don't send it immediately
- Don't autocomplete after typing 1 character after : (allows text emotes like ":c")
This commit is contained in:
indev committed 2025-11-26 22:56:04 +03:00
1 parent 4d9c345202
commit 45ba69a45a
2 files changed
+13 -10

No files matched your search

+4 -4
View File
@@ -1380,9 +1380,9 @@ boolean HU_Responder(event_t *ev)
&& ev->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. :)
@@ -1911,7 +1911,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;
+9 -6
View File
@@ -435,10 +435,10 @@ static int M_TextInputEmoteStart(textinput_t *input)
return emotestart;
}
static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete)
static boolean M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete)
{
if (input->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
{