xP3NG3Rx

Emoji in TextLine

29 posts in this topic

Hi, folks!

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

054aa59fb7.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

 

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.

 

  • Like 21
  • Thanks 9
  • Confused 1

Share this post


Link to post
Share on other sites

I did this long time ago for the new item currency in shops with some changes in ExtendedTextLine in ui, seems to working fine in tooltip too :D

download.png

  • Like 2

Share this post


Link to post
Share on other sites
3 hours ago, WeedHex said:

xxx.png.e62956594f6acbc9d28ca62245faa4b4.png

When you use 800x600 it gonna bug? Or you fix in responsive way?

There is not any bug when i use 800x600 you can add 6 buttons without bug at this size.

  • Like 1

Share this post


Link to post
Share on other sites

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

 

 

  • Haha 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Dnia 15.01.2019 o 01:07, ReFresh napisał:

@xP3NG3Rx No. I don't need it. I just want to test the icons of keyboard combination with text on some item which I could define. Separately.

Try itemdesc.txt. I bet it would work

Share this post


Link to post
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 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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++

Share this post


Link to post
Share on other sites
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: https://mega.nz/#!Hxl3kKBA!GnqT6Vno850BpnTiACHyN0q-yGFa4dczKFUK9kbj1Bc

Reupload?

Share this post


Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.