EOSERV Forum > Programming > New lines in info box
Topic is locked.
Page: << 1 >>
New lines in info box
Author Message
Post #186975 New lines in info box

I thought the info box was missing an important thing to show information in a more orderly way, so I decided to fix that and add the ability to put new lines in there.

  • Add this in src/character.hpp within the character class:

void ShowInfoBox(std::string title, std::string content);

  • And add this in character.cpp:

void Character::ShowInfoBox(std::string title, std::string content)

{

    if(content.find("/n") != std::string::npos)

    {

        std::string buf = "";

        std::vector<std::string> lines = util::explode("/n", content);

        UTIL_FOREACH(lines, line)

        {

            line.insert(0, buf);

            buf.clear();

            if(line[line.size() - 1] == '/')

            {

                buf = line + "n";

                line.clear();

                continue;

            }

            line.resize(line.length() + 67, ' ');

            line = util::text_cap(line, 198);

        }

        content.clear();

        UTIL_FOREACH(lines, line)

        {

            content += line;

        }

    }


    PacketBuilder builder(PACKET_MESSAGE, PACKET_ACCEPT, title.length() + content.length() + 1);

    builder.AddString(title);

    builder.AddByte(255);

    builder.AddString(content);

    this->Send(builder);

}


All you have to do after is use "/n" in the info box content to make a new line and "//n" if you just want it to show as "/n" and not make a new line.

Also, this can be done with dialog boxes as well since they both have the same max text width per line at 200. If anyone even cares, I'll post the one for dialog boxes too.

11 years, 7 weeks ago
Post #187025 Re: New lines in info box

I believe the info box supports 3 lines by default. I have the proper packet for that in my source. I will look at the exact later, but I am positive it is one title and 3 strings for messages. There should be no reason to call a new line like this. 3 paragraphs is really overkill anyway.

11 years, 6 weeks ago
Page: << 1 >>
Topic is locked.
EOSERV Forum > Programming > New lines in info box