1.) Open EterLib/TextTag.h and add the new tags into the enum there:
- TEXT_TAG_EMOJI_START,
- TEXT_TAG_EMOJI_END,
2.1.) Open the EterLib/TextTag.cpp and extend the GetTextTag function with the following statements:
- else if (*cur == L'E')
- {
- tagLen = 2;
- return TEXT_TAG_EMOJI_START;
- }
- else if (*cur == L'e')
- {
- tagLen = 2;
- return TEXT_TAG_EMOJI_END;
- }
2.2.) Extend the GetTextTagOutputString function with the following statements:
- else if (tag == TEXT_TAG_EMOJI_START)
- hyperlinkStep = 1;
- else if (tag == TEXT_TAG_EMOJI_END)
- hyperlinkStep = 0;
2.3.) Repeat the 2.2. in the GetTextTagInternalPosFromRenderPos function:
- else if (tag == TEXT_TAG_EMOJI_START)
- hyperlinkStep = 1;
- else if (tag == TEXT_TAG_EMOJI_END)
- hyperlinkStep = 0;
2.4.) Repeat again in the GetTextTagOutputLen function too:
- else if (tag == TEXT_TAG_EMOJI_START)
- hyperlinkStep = 1;
- else if (tag == TEXT_TAG_EMOJI_END)
- hyperlinkStep = 0;
3.1.) Open EterLib/GrpTextInstance.h and add the following line at the top of the file where the includes are:
- #include "GrpImageInstance.h"
3.2.) Add the following struct below of the SHyperlink struct:
- struct SEmoji
- {
- short x;
- CGraphicImageInstance * pInstance;
- SEmoji() : x(0)
- {
- pInstance = NULL;
- }
- };
3.3.) Below of the m_hyperlinkVector declaration declare a new variable:
- std::vector<SEmoji> m_emojiVector;
4.1.) Open EterLib/GrpTextInstance.cpp and add the following line at the top of the file, where the includes are:
- #include "ResourceManager.h"
4.2.) In the CGraphicTextInstance::Update function add the following below of this line: m_hyperlinkVector.clear();
- if (m_emojiVector.size() != 0)
- {
- for (std::vector<SEmoji>::iterator itor = m_emojiVector.begin(); itor != m_emojiVector.end(); ++itor)
- {
- SEmoji & rEmo = *itor;
- if (rEmo.pInstance)
- {
- CGraphicImageInstance::Delete(rEmo.pInstance);
- rEmo.pInstance = NULL;
- }
- }
- }
- m_emojiVector.clear();
Alles anzeigen
4.3.) This is a bit complicated, so first of all look for this line:
This is the else for the Arabic codepage, I could not test it on it, so I didn't make it to arab rtl style.
4.4.) Add the following below of this line: std::wstring hyperlinkBuffer;
- SEmoji kEmoji;
- int emojiStep = 0;
- std::wstring emojiBuffer;
4.5.) Replace this
- if (hyperlinkStep == 1)
- hyperlinkBuffer.append(1, wText[i]);
With this
- if (hyperlinkStep == 1)
- hyperlinkBuffer.append(1, wText[i]);
- else if (emojiStep == 1)
- emojiBuffer.append(1, wText[i]);
4.6.) Then add the new processor for the new tags:
- else if (ret == TEXT_TAG_EMOJI_START)
- {
- emojiStep = 1;
- emojiBuffer = L"";
- }
- else if (ret == TEXT_TAG_EMOJI_END)
- {
- kEmoji.x = x;
- char retBuf[1024];
- int retLen = Ymir_WideCharToMultiByte(GetDefaultCodePage(), 0, emojiBuffer.c_str(), emojiBuffer.length(), retBuf, sizeof(retBuf) - 1, NULL, NULL);
- retBuf[retLen] = '\0';
- char szPath[255];
- snprintf(szPath, sizeof(szPath), "icon/%s.tga", retBuf);
- if (CResourceManager::Instance().IsFileExist(szPath))
- {
- CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(szPath);
- kEmoji.pInstance = CGraphicImageInstance::New();
- kEmoji.pInstance->SetImagePointer(pImage);
- m_emojiVector.push_back(kEmoji);
- memset(&kEmoji, 0, sizeof(SEmoji));
- for (int i = 0; i < pImage->GetWidth() / (pSpaceInfo->width-1); ++i)
- x += __DrawCharacter(pFontTexture, dataCodePage, ' ', dwColor);
- if (pImage->GetWidth() % (pSpaceInfo->width - 1) > 1)
- x += __DrawCharacter(pFontTexture, dataCodePage, ' ', dwColor);
- }
- emojiStep = 0;
- emojiBuffer = L"";
- }
Alles anzeigen
4.7.) Add the following code to the end of the CGraphicTextInstance::Render function:
- if (m_emojiVector.size() != 0)
- {
- for (std::vector<SEmoji>::iterator itor = m_emojiVector.begin(); itor != m_emojiVector.end(); ++itor)
- {
- SEmoji & rEmo = *itor;
- if (rEmo.pInstance)
- {
- rEmo.pInstance->SetPosition(fStanX + rEmo.x, (fStanY + 7.0) - (rEmo.pInstance->GetHeight() / 2));
- rEmo.pInstance->Render();
- }
- }
- }
Alles anzeigen
4.8.) Add the following into the CGraphicTextInstance::Destroy function:
- if (m_emojiVector.size() != 0)
- {
- for (std::vector<SEmoji>::iterator itor = m_emojiVector.begin(); itor != m_emojiVector.end(); ++itor)
- {
- SEmoji & rEmo = *itor;
- if (rEmo.pInstance)
- {
- CGraphicImageInstance::Delete(rEmo.pInstance);
- rEmo.pInstance = NULL;
- }
- }
- }
- m_emojiVector.clear();
Alles anzeigen