summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/browserbox.cpp26
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp15
2 files changed, 33 insertions, 8 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 14dd95ba3..9ffead378 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/browserbox.h"
+#include "itemcolormanager.h"
#include "settings.h"
#include "input/inputmanager.h"
@@ -235,13 +236,30 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
bLink.y2 = bLink.y1 + font->getHeight();
if (bLink.caption.empty())
{
+ bLink.caption = bLink.link;
#ifndef DYECMD
- const int id = atoi(bLink.link.c_str());
- if (id)
- bLink.caption = ItemDB::get(id).getName();
+ size_t idx = bLink.link.find(",");
+ if (idx != std::string::npos)
+ {
+ const int id = atoi(bLink.link.substr(0, idx).c_str());
+ if (id)
+ {
+ std::vector<int> parts;
+ splitToIntVector(parts, bLink.link.substr(idx), ',');
+ while (parts.size() < 4)
+ parts.push_back(0);
+ const ItemColor itemColor =
+ ItemColorManager::getColorFromCards(&parts[0]);
+ bLink.caption = ItemDB::get(id).getName(itemColor);
+ }
+ }
else
+ {
+ const int id = atoi(bLink.link.c_str());
+ if (id)
+ bLink.caption = ItemDB::get(id).getName();
+ }
#endif
- bLink.caption = bLink.link;
if (translator)
bLink.caption = translator->getStr(bLink.caption);
}
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 3b31ea553..1f30c5da6 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -22,6 +22,8 @@
#include "gui/widgets/itemlinkhandler.h"
+#include "itemcolormanager.h"
+
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
@@ -111,14 +113,19 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
splitToIntVector(str, link, ',');
if (str.empty())
return;
- ItemColor color = ItemColor_one;
- if (str.size() > 1)
- color = fromInt(str[1], ItemColor);
+
const int id = str[0];
+
if (id > 0)
{
+ str.erase(str.begin());
+ while (str.size() < 4)
+ str.push_back(0);
+ const ItemColor color =
+ ItemColorManager::getColorFromCards(&str[0]);
+
const ItemInfo &itemInfo = ItemDB::get(id);
- itemPopup->setItem(itemInfo, color, true, -1, nullptr);
+ itemPopup->setItem(itemInfo, color, true, -1, &str[0]);
if (itemPopup->isPopupVisible())
{
itemPopup->setVisible(Visible_false);