mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
autocomplete last player that highlighted you or got highlighted in chat
This commit is contained in:
parent
f9368007b1
commit
8447152b0a
|
@ -40,6 +40,7 @@ void CChat::OnReset()
|
|||
m_InputUpdate = false;
|
||||
m_ChatStringOffset = 0;
|
||||
m_CompletionChosen = -1;
|
||||
m_CompletionFav = -1;
|
||||
m_aCompletionBuffer[0] = 0;
|
||||
m_PlaceholderOffset = 0;
|
||||
m_PlaceholderLength = 0;
|
||||
|
@ -156,10 +157,15 @@ bool CChat::OnInput(IInput::CEvent Event)
|
|||
|
||||
// find next possible name
|
||||
const char *pCompletionString = 0;
|
||||
if(m_ReverseCompletion)
|
||||
m_CompletionChosen = (m_CompletionChosen-1 + 2*MAX_CLIENTS)%(2*MAX_CLIENTS);
|
||||
if(m_CompletionChosen < 0 && m_CompletionFav >= 0)
|
||||
m_CompletionChosen = m_CompletionFav;
|
||||
else
|
||||
m_CompletionChosen = (m_CompletionChosen+1)%(2*MAX_CLIENTS);
|
||||
{
|
||||
if (m_ReverseCompletion)
|
||||
m_CompletionChosen = (m_CompletionChosen - 1 + 2 * MAX_CLIENTS) % (2 * MAX_CLIENTS);
|
||||
else
|
||||
m_CompletionChosen = (m_CompletionChosen + 1) % (2 * MAX_CLIENTS);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 2*MAX_CLIENTS; ++i)
|
||||
{
|
||||
|
@ -194,6 +200,7 @@ bool CChat::OnInput(IInput::CEvent Event)
|
|||
{
|
||||
pCompletionString = m_pClient->m_aClients[Index].m_aName;
|
||||
m_CompletionChosen = Index+SearchType*MAX_CLIENTS;
|
||||
m_CompletionFav = m_CompletionChosen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -367,6 +374,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
|
|||
int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName);
|
||||
if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || (pHL[Length] == ':' && pHL[Length+1] == ' ')))
|
||||
Highlighted = true;
|
||||
m_CompletionFav = ClientID;
|
||||
}
|
||||
m_aLines[m_CurrentLine].m_Highlighted = Highlighted;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ class CChat : public CComponent
|
|||
int m_ChatStringOffset;
|
||||
int m_OldChatStringLength;
|
||||
int m_CompletionChosen;
|
||||
int m_CompletionFav;
|
||||
char m_aCompletionBuffer[256];
|
||||
int m_PlaceholderOffset;
|
||||
int m_PlaceholderLength;
|
||||
|
|
Loading…
Reference in a new issue