Jump to content

Emoji in TextLine


Recommended Posts

  • Honorable Member

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: 

Spoiler

This is the hidden content, please

 

Howto:

Spoiler

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.

 

  • Metin2 Dev 327
  • kekw 2
  • Eyes 5
  • Dislove 5
  • Angry 3
  • Not Good 2
  • Sad 2
  • Cry 1
  • Smile Tear 2
  • Think 3
  • Confused 4
  • Scream 6
  • Lmao 2
  • Good 118
  • Love 25
  • Love 256
Link to comment
Share on other sites

  • Honorable Member

2826032HAQzFQ.png
 

I prepared other buttons for this system, which I think are holding a better climate. I put it here, maybe it will be useful to someone ;)
PS: I also put a project save in the package, so that you can more conveniently edit each button if necessary.


Download: 

This is the hidden content, please
 (
This is the hidden content, please
)

  • Metin2 Dev 187
  • kekw 2
  • Eyes 4
  • Dislove 4
  • Angry 1
  • Not Good 3
  • Sad 2
  • Cry 1
  • Scream 3
  • Lmao 2
  • Good 48
  • Love 7
  • Love 115

GhwYizE.gif

Link to comment
Share on other sites

  • Gold

@xP3NG3Rx Basically you must have added some system which will support these keyboard and mouse shortcuts. But I just need to see these image shortcuts under some item in item description so here must be something like:

Spoiler

if self.itemVnum >= 29101 and self.itemVnum <= 29109:
  self.emojiTextLine.SetText("|Eemoji/key_ctrl|e + |Eemoji/key_x|e + |Eemoji/key_rclick|e - Direct sell")
  self.emojiTextLine.Show()

 

Like you can see it on Tatsumaru image. 

  • Good 1

I'll be always helpful! 👊 

Link to comment
Share on other sites

6 hours ago, attila1995 said:

@xP3NG3Rx

I have an interesting question.

So, how can i break the emotion's image to a new line, like private chat?

Can you make and show a code to it?

Have a good day.

You can edit the code for the privat Chat 

 

The idea is :

Hello friend :) 

To 

Hello friend 

You can make a replace or a find script for this I mean 

Find in text : ) -> replace to the emoji 

Link to comment
Share on other sites

17 hours ago, Kori said:

You can edit the code for the privat Chat 

 

The idea is :


Hello friend :) 

To 


Hello friend 

You can make a replace or a find script for this I mean 

Find in text : ) -> replace to the emoji 

 

Hi!

I think you didnt understand what i have written.

So when somebody writes a long message in private chat (in game), the message's line will be broken at chat's border of board (because the chat board is resizable, and his contents are following his size, so the chat line will be resied too) and the broken line will be in a next line, so when im using a smiley code in the long message and the line has been broken, the smiley's image will not be there in the broken line, that is just there at over of board in the first line, not in next line...

Thank you for answers.

Link to comment
Share on other sites

  • 2 weeks later...
  • Premium
2 hours ago, evils666 said:

I have this error:
 


15>GrpTextInstance.cpp(452): error C2065: 'kEmoji' : undeclared identifier
15>GrpTextInstance.cpp(452): error C2228: left of '.x' must have class/struct/union
15>          type is 'unknown-type'
15>GrpTextInstance.cpp(472): error C2065: 'emojiStep' : undeclared identifier

Please help.

Check symbols in code "?" open notepad++


 

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
On 1/12/2019 at 5:30 AM, Tatsumaru said:

2HAQzFQ.png
I prepared other buttons for this system, which I think are holding a better climate. I put it here, maybe it will be useful to someone ;)
PS: I also put a project save in the package, so that you can more conveniently edit each button if necessary.

Download: 

This is the hidden content, please

Reupload?

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 8
  • Not Good 1
  • Good 2
  • Love 1
  • Love 5
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.