autocomplete last player that highlighted you or got highlighted in chat

This commit is contained in:
oy 2016-06-14 18:32:09 +02:00
parent f9368007b1
commit 8447152b0a
2 changed files with 12 additions and 3 deletions

View file

@ -40,6 +40,7 @@ void CChat::OnReset()
m_InputUpdate = false; m_InputUpdate = false;
m_ChatStringOffset = 0; m_ChatStringOffset = 0;
m_CompletionChosen = -1; m_CompletionChosen = -1;
m_CompletionFav = -1;
m_aCompletionBuffer[0] = 0; m_aCompletionBuffer[0] = 0;
m_PlaceholderOffset = 0; m_PlaceholderOffset = 0;
m_PlaceholderLength = 0; m_PlaceholderLength = 0;
@ -156,10 +157,15 @@ bool CChat::OnInput(IInput::CEvent Event)
// find next possible name // find next possible name
const char *pCompletionString = 0; const char *pCompletionString = 0;
if(m_ReverseCompletion) if(m_CompletionChosen < 0 && m_CompletionFav >= 0)
m_CompletionChosen = (m_CompletionChosen-1 + 2*MAX_CLIENTS)%(2*MAX_CLIENTS); m_CompletionChosen = m_CompletionFav;
else 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) 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; pCompletionString = m_pClient->m_aClients[Index].m_aName;
m_CompletionChosen = Index+SearchType*MAX_CLIENTS; m_CompletionChosen = Index+SearchType*MAX_CLIENTS;
m_CompletionFav = m_CompletionChosen;
break; 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); 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] == ' '))) if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || (pHL[Length] == ':' && pHL[Length+1] == ' ')))
Highlighted = true; Highlighted = true;
m_CompletionFav = ClientID;
} }
m_aLines[m_CurrentLine].m_Highlighted = Highlighted; m_aLines[m_CurrentLine].m_Highlighted = Highlighted;

View file

@ -49,6 +49,7 @@ class CChat : public CComponent
int m_ChatStringOffset; int m_ChatStringOffset;
int m_OldChatStringLength; int m_OldChatStringLength;
int m_CompletionChosen; int m_CompletionChosen;
int m_CompletionFav;
char m_aCompletionBuffer[256]; char m_aCompletionBuffer[256];
int m_PlaceholderOffset; int m_PlaceholderOffset;
int m_PlaceholderLength; int m_PlaceholderLength;