summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-27 01:35:58 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-27 01:35:58 +0300
commit5f5cba799299df65d74a99e7d37800b90c91b538 (patch)
tree34d653cc8144fe0f6581c5d2b5db4f52d23bff9a /src/gui
parenta4fb19cf0333c4ed46ba07c5f25a2524c2ef6a11 (diff)
downloadmanaverse-5f5cba799299df65d74a99e7d37800b90c91b538.tar.gz
manaverse-5f5cba799299df65d74a99e7d37800b90c91b538.tar.bz2
manaverse-5f5cba799299df65d74a99e7d37800b90c91b538.tar.xz
manaverse-5f5cba799299df65d74a99e7d37800b90c91b538.zip
Add support for links to monsters.
Format is: @@mID|@@ Example: [@@m1002|@@]
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/browserbox.cpp55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index a229cb10f..098ee0d64 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -40,10 +40,15 @@
#include "render/graphics.h"
-#include "resources/imageset.h"
+#ifndef DYECMD
+#include "resources/beinginfo.h"
#include "resources/iteminfo.h"
#include "resources/db/itemdb.h"
+#include "resources/db/monsterdb.h"
+#endif // DYECMD
+
+#include "resources/imageset.h"
#include "resources/image/image.h"
@@ -247,26 +252,38 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
{
bLink.caption = bLink.link;
#ifndef DYECMD
- 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() < maxCards)
- parts.push_back(0);
- const ItemColor itemColor =
- ItemColorManager::getColorFromCards(&parts[0]);
- bLink.caption = ItemDB::get(id).getName(itemColor);
- }
+ const std::string link = bLink.link;
+ if (!link.empty() && link[0] == 'm')
+ { // monster link
+ const BeingTypeId id = static_cast<BeingTypeId>(
+ atoi(bLink.link.substr(1).c_str()));
+ BeingInfo *info = MonsterDB::get(id);
+ if (info)
+ bLink.caption = info->getName();
}
else
- {
- const int id = atoi(bLink.link.c_str());
- if (id)
- bLink.caption = ItemDB::get(id).getName();
+ { // item link
+ 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() < maxCards)
+ 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 // DYECMD