From 836459705f715f882b287b06b0e3c02af7dfbf8d Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Tue, 4 Jun 2013 21:25:12 +0300
Subject: Improve itemlinkhandler.

add support for colored item links.
---
 src/gui/widgets/itemlinkhandler.cpp | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

(limited to 'src')

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);
-- 
cgit v1.2.3-70-g09d2