Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: MTA10/core/CChat.cpp
- ===================================================================
- --- MTA10/core/CChat.cpp (revision 6832)
- +++ MTA10/core/CChat.cpp (working copy)
- @@ -596,9 +596,103 @@
- m_fSmoothScrollResetTime = GetSecondCount ();
- break;
- }
- + case VK_TAB:
- + {
- + if (m_strInputText.size() > 0)
- + {
- + bool bSuccess = false;
- +
- + SString strCurrentInput = GetInputText();
- +
- + std::vector<SString> vChatParts;
- + strCurrentInput.Split( " ", vChatParts );
- + SString strPlayerNamePart = vChatParts.back( );
- + if (strPlayerNamePart.size() == 0)
- + break;
- +
- + CModManager* pModManager = CModManager::GetSingletonPtr();
- + if (pModManager && pModManager->GetCurrentMod( ))
- + {
- + //Create vector and get playernames from deathmatch module
- + std::vector<SString> vPlayerNames;
- + pModManager->GetCurrentMod( )->GetPlayerNames( vPlayerNames );
- +
- + for (std::vector<SString>::iterator iter = vPlayerNames.begin( );
- + iter != vPlayerNames.end( );
- + ++iter)
- + {
- + SString strPlayerName = *iter;
- +
- + // Check if there is another player after our last result
- + if (m_strLastPlayerName.size() != 0)
- + {
- + if (strPlayerName.CompareI( m_strLastPlayerName )) {
- + m_strLastPlayerName.clear( );
- + if (*iter == vPlayerNames.back( ))
- + {
- + CharacterKeyHandler( KeyboardArgs );
- + return true;
- + }
- + }
- + continue;
- + }
- +
- + // Already a part?
- + if (m_strLastPlayerNamePart.size( ) != 0)
- + {
- + strPlayerNamePart = m_strLastPlayerNamePart;
- + }
- +
- + // Check namepart
- + if (!strPlayerName.BeginsWith( strPlayerNamePart ))
- + continue;
- + else
- + {
- + //Remove last part
- + vChatParts.pop_back( );
- +
- + //Turn back into string
- + SString strTmp;
- + for (std::vector<SString>::iterator _iter = vChatParts.begin( );
- + _iter != vChatParts.end( );
- + _iter++)
- + {
- + strTmp += *_iter + " ";
- + }
- +
- + //Check size if it's ok, then output
- + SString strOutput = strTmp + strPlayerName;
- + if (MbUTF8ToUTF16( strOutput ).size() < CHAT_MAX_CHAT_LENGTH)
- + {
- + bSuccess = true;
- + m_strLastPlayerNamePart = strPlayerNamePart;
- + m_strLastPlayerName = strPlayerName;
- + SetInputText( strOutput );
- + }
- +
- + break;
- + }
- + }
- +
- + // No success? Try again!
- + if (!bSuccess)
- + m_strLastPlayerName.clear( );
- + }
- +
- + }
- + break;
- + }
- default:
- {
- + // Clear last namepart when pressing letter
- + if (m_strLastPlayerNamePart.size() != 0)
- + m_strLastPlayerNamePart.clear();
- +
- + // Clear last name when pressing letter
- + if (m_strLastPlayerName.size() != 0)
- + m_strLastPlayerName.clear();
- +
- // If we haven't exceeded the maximum number of characters per chat message, append the char to the message and update the input control
- if ( MbUTF8ToUTF16(m_strInputText).size () < CHAT_MAX_CHAT_LENGTH )
- {
- Index: MTA10/core/CChat.h
- ===================================================================
- --- MTA10/core/CChat.h (revision 6832)
- +++ MTA10/core/CChat.h (working copy)
- @@ -246,6 +246,8 @@
- float m_fSmoothScrollResetTime;
- float m_fSmoothRepeatTimer;
- CChatInputLine m_InputLine;
- + SString m_strLastPlayerNamePart;
- + SString m_strLastPlayerName;
- CGUI* m_pManager;
- CGUIFont* m_pFont;
- Index: MTA10/mods/deathmatch/CClient.cpp
- ===================================================================
- --- MTA10/mods/deathmatch/CClient.cpp (revision 6832)
- +++ MTA10/mods/deathmatch/CClient.cpp (working copy)
- @@ -288,3 +288,18 @@
- return true;
- #endif
- }
- +
- +void CClient::GetPlayerNames( std::vector<SString> &vPlayerNames )
- +{
- + if (g_pClientGame) {
- + vPlayerNames.clear( );
- + for ( std::vector<CClientPlayer*>::const_iterator iter = g_pClientGame->GetPlayerManager( )->IterBegin( );
- + iter != g_pClientGame->GetPlayerManager( )->IterEnd( );
- + ++iter )
- + {
- + CClientPlayer* pClient = *iter;
- + SString strPlayerName = pClient->GetNametagText( );
- + vPlayerNames.push_back( strPlayerName );
- + }
- + }
- +};
- \ No newline at end of file
- Index: MTA10/mods/deathmatch/CClient.h
- ===================================================================
- --- MTA10/mods/deathmatch/CClient.h (revision 6832)
- +++ MTA10/mods/deathmatch/CClient.h (working copy)
- @@ -35,6 +35,7 @@
- //bool ProcessInput ( CInputMessage* pInputMessage );
- bool HandleException ( CExceptionInformation* pExceptionInformation );
- + void GetPlayerNames ( std::vector<SString> &vPlayerNames );
- };
- #endif
- \ No newline at end of file
- Index: MTA10/mods/shared_logic/CClientEntity.h
- ===================================================================
- --- MTA10/mods/shared_logic/CClientEntity.h (revision 6832)
- +++ MTA10/mods/shared_logic/CClientEntity.h (working copy)
- @@ -183,7 +183,7 @@
- };
- bool CanUpdateSync ( unsigned char ucRemote );
- - inline const char* GetName ( void ) { return m_strName; }
- + inline SString GetName ( void ) { return m_strName; }
- inline void SetName ( const char* szName ) { m_strName.AssignLeft ( szName, MAX_ELEMENT_NAME_LENGTH ); }
- inline const char* GetTypeName ( void ) { return m_strTypeName; };
- Index: MTA10/sdk/core/CClientBase.h
- ===================================================================
- --- MTA10/sdk/core/CClientBase.h (revision 6832)
- +++ MTA10/sdk/core/CClientBase.h (working copy)
- @@ -30,6 +30,7 @@
- //virtual bool ProcessInput ( CInputMessage* pInputMessage ) = 0 *TODO*
- virtual bool HandleException ( CExceptionInformation* pExceptionInformation ) = 0;
- + virtual void GetPlayerNames ( std::vector<SString> &vPlayerNames ) = 0;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement