Jump to content

Emoji in TextLine


Recommended Posts

  • Honorable Member

M2 Download Center

Hidden Content

    Give reaction to this post to see the hidden content.
( 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

Hidden Content

    Give reaction to this post to see the hidden content.

 

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 6
  • Love 63
  • Love 7
  • Good 8
Link to comment
  • 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: 

Hidden Content

    Give reaction to this post to see the hidden content.
 (

Hidden Content

    Give reaction to this post to see the hidden content.
)

  • Metin2 Dev 3
  • Love 34
  • Love 3
  • Good 3

dKMsrOV.png

Link to comment

If someone getting this error or something like this:

Spoiler
'snprintf': identifier not found

 

Just add at the top of the file this:

Spoiler
#include <stdio.h>

 

And change sprintf to:

Spoiler
_snprintf

 

 

  • Love 6
  • Good 1
Link to comment

@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. 

Link to comment
  • Honorable Member

If you mean you need a function which shows the correct keyboard combination with text and also make it to work like what does it say, just hire a dev who can code it to you.

Link to comment
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
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
  • 2 weeks later...

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.

Link to comment
  • VIP
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++

If code.isTurkisch:
    self.suicide();
elif code.isPoland:
   self.giveHate()

 

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

Hidden Content

    Give reaction to this post to see the hidden content.

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: 

Hidden Content

    Give reaction to this post to see the hidden content.

Reupload?

  • Metin2 Dev 1
  • Love 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.