diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-21 00:33:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-21 00:33:29 +0300 |
commit | ad465929229a928d418c68b7786c18f95f170eba (patch) | |
tree | ffc9fe3337948eaa871e00225830dd7a9a0631c8 | |
parent | 37deb731372da40bb9ce5bc4b8d8e19bfc750163 (diff) | |
download | manaplus-ad465929229a928d418c68b7786c18f95f170eba.tar.gz manaplus-ad465929229a928d418c68b7786c18f95f170eba.tar.bz2 manaplus-ad465929229a928d418c68b7786c18f95f170eba.tar.xz manaplus-ad465929229a928d418c68b7786c18f95f170eba.zip |
Fix some incorrect chars in browserbox links.
-rw-r--r-- | src/gui/whoisonline.cpp | 21 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 3 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 10 | ||||
-rw-r--r-- | src/utils/stringutils.h | 4 |
4 files changed, 28 insertions, 10 deletions
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index a194b2ccb..3a03eec13 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -154,10 +154,11 @@ void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event) { if (chatWindow) { + std::string text = decodeLinkText(link); if (config.getBoolValue("whispertab")) - chatWindow->localChatInput("/q " + link); + chatWindow->localChatInput("/q " + text); else - chatWindow->addInputText("/w \"" + link + "\" "); + chatWindow->addInputText("/w \"" + text + "\" "); } } else if (event->getButton() == gcn::MouseEvent::RIGHT) @@ -169,8 +170,9 @@ void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event) { if (actorSpriteManager) { + std::string text = decodeLinkText(link); Being* being = actorSpriteManager->findBeingByName( - link, Being::PLAYER); + text, Being::PLAYER); if (being && viewport) { @@ -706,15 +708,15 @@ void WhoIsOnline::updateSize() const std::string WhoIsOnline::prepareNick(std::string nick, int level, std::string color) const { + const char *const text = encodeLinkText(nick).c_str(); if (mShowLevel && level > 1) { - return strprintf("@@%s|##%s%s (%d)@@", nick.c_str(), - color.c_str(), nick.c_str(), level); + return strprintf("@@%s|##%s%s (%d)@@", text, + color.c_str(), text, level); } else { - return strprintf("@@%s|##%s%s@@", nick.c_str(), - color.c_str(), nick.c_str()); + return strprintf("@@%s|##%s%s@@", text, color.c_str(), text); } } @@ -839,6 +841,7 @@ void OnlinePlayer::setText(std::string color) if (mVersion > 0) mText += strprintf(" - %d", mVersion); - mText = strprintf("@@%s|##%s%s %s@@", mNick.c_str(), - color.c_str(), mNick.c_str(), mText.c_str()); + const char *const text = encodeLinkText(mNick).c_str(); + mText = strprintf("@@%s|##%s%s %s@@", text, color.c_str(), + text, mText.c_str()); } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index ddd21f5dd..51b977bbc 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -306,7 +306,8 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) void BrowserBox::addRow(const std::string &cmd, const char *const text) { - addRow(strprintf("@@%s|%s@@", cmd.c_str(), text)); + addRow(strprintf("@@%s|%s@@", encodeLinkText(cmd).c_str(), + encodeLinkText(text).c_str())); } void BrowserBox::addImage(const std::string &path) diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 74e5d9f58..d4585a26d 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -668,3 +668,13 @@ signed char parseBoolean(const std::string &value) else return -1; } + +std::string encodeLinkText(std::string data) +{ + return replaceAll(data, "|", "\342\235\230"); +} + +std::string decodeLinkText(std::string data) +{ + return replaceAll(data, "\342\235\230", "|"); +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 612486cb2..8b3ae0563 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -223,4 +223,8 @@ std::string getDateString() A_WARN_UNUSED; signed char parseBoolean(const std::string &value); +std::string encodeLinkText(std::string data); + +std::string decodeLinkText(std::string data); + #endif // UTILS_STRINGUTILS_H |