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:
parent
1979568959
commit
945b5da5a3
2 changed files with 13 additions and 10 deletions
|
|
@ -1229,9 +1229,9 @@ boolean HU_Responder(event_t *ev)
|
|||
&& !G_ControlBoundToKey(0, gc_talkkey, ev->data1, false))
|
||||
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)
|
||||
{
|
||||
if (!CHAT_MUTE)
|
||||
HU_sendChatMessage();
|
||||
|
|
@ -1776,7 +1776,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;
|
||||
|
|
|
|||
|
|
@ -425,10 +425,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])
|
||||
|
|
@ -447,8 +447,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);
|
||||
}
|
||||
|
|
@ -466,7 +466,7 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a
|
|||
{
|
||||
// Clear autocompletion state
|
||||
autocomplete->complete[0] = 0;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -478,6 +478,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)
|
||||
|
|
@ -493,7 +495,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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue