Jump to content

Emoji in TextLine


Recommended Posts

  • 2 weeks later...
  • 3 weeks later...
  • 3 weeks later...
  • 3 weeks later...
  • 6 months later...
  • 1 month later...

How to fix?

0308 16:03:34483 :: Traceback (most recent call last):

0308 16:03:34484 ::   File "ui.py", line 1827, in OnOverInItem

0308 16:03:34484 ::   File "ui.py", line 102, in __call__

0308 16:03:34484 ::   File "ui.py", line 93, in __call__

0308 16:03:34485 ::   File "uiInventory.py", line 2033, in OverInItem

0308 16:03:34485 ::   File "uiInventory.py", line 2254, in ShowToolTip

0308 16:03:34486 ::   File "uiToolTip.py", line 773, in SetInventoryItem

0308 16:03:34486 ::   File "uiToolTip.py", line 1962, in AddItemData

0308 16:03:34487 :: AttributeError
0308 16:03:34487 :: : 
0308 16:03:34487 :: 'ItemToolTip' object has no attribute 'emojiTextLine'
0308 16:03:34487 :: 

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...
  • 3 weeks later...
  • 2 weeks later...
  • 3 weeks later...
  • 3 months later...
  • 3 weeks later...
  • 2 weeks later...

Error (active)    E0020    identifier "emoji" is undefined    UserInterface  
Error    C2065    'emoji': undeclared identifier   
Error    C2672    'boost::algorithm::replace_all': no matching overloaded function found  
Error    C2780    'void boost::algorithm::replace_all(SequenceT &,const Range1T &,const Range2T &)': expects 3 arguments - 2 provided
 

Some help please..? 

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
On 1/11/2019 at 4:32 PM, xP3NG3Rx said:

M2 Download Center

This is the hidden content, please
( Internal )

Hi, folks!

With this guide you will be able to combine textlines with images, like rubinum does.

 

 

202002Photoshop-2019-01-11-10-48-05.png

 

Usage is simple:


emojiTextLine.SetText("|Eemoji/key_ctrl|e + |Eemoji/key_x|e + |Eemoji/key_rclick|e - Direct sell")

 

The files are located in the icon pack, so basically the code will load from icon/{GIVEN_PATH}.tga - in the sample the path for the X  is: icon/emoji/key_x.tga
Here are the images from rubinum client: 

  Reveal hidden contents

This is the hidden content, please

 

Howto:

  Reveal hidden contents

1.) Open EterLib/TextTag.h and add the new tags into the enum there:



	TEXT_TAG_EMOJI_START, // |E
	TEXT_TAG_EMOJI_END, // |e ex) |Epath/filename|h

2.1.) Open the EterLib/TextTag.cpp and extend the GetTextTag function with the following statements:



    else if (*cur == L'E') // emoji |Epath/emo|e
    {
        tagLen = 2;
        return TEXT_TAG_EMOJI_START;
    }
    else if (*cur == L'e') // end of emoji
    {
        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();

4.3.) This is a bit complicated, so first of all look for this line:



else    // ľĆ¶řżÜ ´Ů¸Ą ÁöżŞ.

This is the else for the Arabic codepage, I could not test 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"";
                        }

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();
            }
        }
    }

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();

 

 

Have fun :)
Sorry for arab players :P, for sure they have also developers, so let's go guys, finish it ?
If you have problem, maybe I made a mistake in the guide of missed out something, just leave a comment below.

PS.: Sometimes the code tag of the board puts an extra invisible character mostly the end of the lines, if your IDE cries for syntax error, but it seems correct, check that part of the file with notepad++, it will show a ?(question mark) where the problem is.

 

so for arab rtl we cannot add this system ?

  • Metin2 Dev 2
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.