diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-04 21:25:12 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-04 21:25:12 +0300 |
commit | 836459705f715f882b287b06b0e3c02af7dfbf8d (patch) | |
tree | 23a5eebccd060d6967a1c5d2cfee00a7b21deeee | |
parent | 4e23bae304a273e990b066313d78a09c9fc38bb2 (diff) | |
download | manaplus-836459705f715f882b287b06b0e3c02af7dfbf8d.tar.gz manaplus-836459705f715f882b287b06b0e3c02af7dfbf8d.tar.bz2 manaplus-836459705f715f882b287b06b0e3c02af7dfbf8d.tar.xz manaplus-836459705f715f882b287b06b0e3c02af7dfbf8d.zip |
Improve itemlinkhandler.
add support for colored item links.
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index d1fbcb5e9..fefaae428 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -49,7 +49,7 @@ struct OpenUrlListener : public gcn::ActionListener A_DELETE_COPY(OpenUrlListener) - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "yes") openBrowser(url); @@ -111,20 +111,25 @@ void ItemLinkHandler::handleLink(const std::string &link, } else { - if (!mItemPopup) + if (!mItemPopup || link.empty()) return; - int id = 0; - std::stringstream stream; - stream << link; - stream >> id; + char ch = link[0]; + if (ch < '0' || ch > '9') + return; + std::vector<int> str; + splitToIntVector(str, link, ','); + if (str.empty()) + return; + int color = 1; + if (str.size() > 1) + color = str[1]; + int id = str[0]; if (id > 0) { const ItemInfo &itemInfo = ItemDB::get(id); - // +++ need add color to links? - mItemPopup->setItem(itemInfo, 1, true); - + mItemPopup->setItem(itemInfo, color, true); if (mItemPopup->isPopupVisible()) { mItemPopup->setVisible(false); |