mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-16 13:02: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
|
#endif
|
||||||
|
|
||||||
void HU_clearChatChars(void)
|
void HU_clearChatChars(void)
|
||||||
|
|
@ -1179,12 +1154,15 @@ boolean HU_Responder(event_t *ev)
|
||||||
c = CON_ShiftChar(c);
|
c = CON_ShiftChar(c);
|
||||||
|
|
||||||
// pasting. pasting is cool. chat is a bit limited, though :(
|
// 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;
|
const char *paste;
|
||||||
size_t chatlen;
|
size_t chatlen;
|
||||||
size_t pastelen;
|
size_t pastelen;
|
||||||
|
|
||||||
|
if (CHAT_MUTE)
|
||||||
|
return true;
|
||||||
|
|
||||||
paste = I_ClipboardPaste();
|
paste = I_ClipboardPaste();
|
||||||
if (paste == NULL)
|
if (paste == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1199,8 +1177,7 @@ boolean HU_Responder(event_t *ev)
|
||||||
c_input += pastelen;
|
c_input += pastelen;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (c == KEY_ENTER)
|
||||||
if (c == KEY_ENTER)
|
|
||||||
{
|
{
|
||||||
if (!CHAT_MUTE)
|
if (!CHAT_MUTE)
|
||||||
HU_sendChatMessage();
|
HU_sendChatMessage();
|
||||||
|
|
@ -1245,8 +1222,24 @@ boolean HU_Responder(event_t *ev)
|
||||||
else
|
else
|
||||||
c_input++;
|
c_input++;
|
||||||
}
|
}
|
||||||
else if (!CHAT_MUTE)
|
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font[c-HU_FONTSTART])
|
||||||
HU_keyInChatString(w_chat, c);
|
|| 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue