mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-16 04:52:40 +00:00
Cleanup chat event handling
# Conflicts: # src/hu_stuff.c
This commit is contained in:
parent
5d406375a8
commit
cf6dfecc6a
1 changed files with 23 additions and 30 deletions
|
|
@ -1067,31 +1067,6 @@ static void HU_sendChatMessage(void)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handles key input and string input
|
||||
//
|
||||
static inline void HU_keyInChatString(char *s, char ch)
|
||||
{
|
||||
if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART])
|
||||
|| ch == ' ') // Allow spaces, of course
|
||||
{
|
||||
if (strlen(s) >= HU_MAXMSGLEN)
|
||||
return;
|
||||
|
||||
memmove(&s[c_input + 1], &s[c_input], strlen(s) - c_input + 1);
|
||||
s[c_input] = ch;
|
||||
c_input++;
|
||||
}
|
||||
else if (ch == KEY_BACKSPACE)
|
||||
{
|
||||
if (c_input <= 0)
|
||||
return;
|
||||
|
||||
memmove(&s[c_input - 1], &s[c_input], strlen(s) - c_input + 1);
|
||||
c_input--;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HU_clearChatChars(void)
|
||||
|
|
@ -1179,12 +1154,15 @@ boolean HU_Responder(event_t *ev)
|
|||
c = CON_ShiftChar(c);
|
||||
|
||||
// pasting. pasting is cool. chat is a bit limited, though :(
|
||||
if (((c == 'v' || c == 'V') && ctrldown) && !CHAT_MUTE)
|
||||
if ((c == 'v' || c == 'V') && ctrldown)
|
||||
{
|
||||
const char *paste;
|
||||
size_t chatlen;
|
||||
size_t pastelen;
|
||||
|
||||
if (CHAT_MUTE)
|
||||
return true;
|
||||
|
||||
paste = I_ClipboardPaste();
|
||||
if (paste == NULL)
|
||||
return true;
|
||||
|
|
@ -1199,8 +1177,7 @@ boolean HU_Responder(event_t *ev)
|
|||
c_input += pastelen;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (c == KEY_ENTER)
|
||||
else if (c == KEY_ENTER)
|
||||
{
|
||||
if (!CHAT_MUTE)
|
||||
HU_sendChatMessage();
|
||||
|
|
@ -1245,8 +1222,24 @@ boolean HU_Responder(event_t *ev)
|
|||
else
|
||||
c_input++;
|
||||
}
|
||||
else if (!CHAT_MUTE)
|
||||
HU_keyInChatString(w_chat, c);
|
||||
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font[c-HU_FONTSTART])
|
||||
|| c == ' ') // Allow spaces, of course
|
||||
{
|
||||
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)
|
||||
return true;
|
||||
|
||||
memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
|
||||
w_chat[c_input] = c;
|
||||
c_input++;
|
||||
}
|
||||
else if (c == KEY_BACKSPACE)
|
||||
{
|
||||
if (CHAT_MUTE || c_input <= 0)
|
||||
return true;
|
||||
|
||||
memmove(&w_chat[c_input - 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
|
||||
c_input--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue