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.