From 86cb4a51351b8217ede6672703a1b39b91ddb572 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 8 Feb 2017 23:14:24 +0300 Subject: Add support for quest links in browserbox. --- src/resources/db/questdb.cpp | 18 ++++++++++++++++++ src/resources/db/questdb.h | 2 ++ src/utils/browserboxtools.cpp | 8 +++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/resources/db/questdb.cpp b/src/resources/db/questdb.cpp index 9df240f92..93bcada6e 100644 --- a/src/resources/db/questdb.cpp +++ b/src/resources/db/questdb.cpp @@ -241,3 +241,21 @@ std::vector *QuestDb::getAllEffects() { return &mAllEffects; } + +std::string QuestDb::getName(const int id) +{ + std::map >::const_iterator it = + mQuests.find(id); + if (it == mQuests.end()) + { + // TRANSLATORS: quests window quest name + return _("unknown"); + } + const std::vector &items = (*it).second; + if (items.empty()) + { + // TRANSLATORS: quests window quest name + return _("unknown"); + } + return items[0]->name; +} diff --git a/src/resources/db/questdb.h b/src/resources/db/questdb.h index 3b9fa2ef1..5a172573c 100644 --- a/src/resources/db/questdb.h +++ b/src/resources/db/questdb.h @@ -48,6 +48,8 @@ namespace QuestDb std::map > *getQuests(); std::vector *getAllEffects(); + + std::string getName(const int id); } // namespace QuestDb #endif // RESOURCES_DB_QUESTDB_H diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp index e049e220d..8a1fb42bb 100644 --- a/src/utils/browserboxtools.cpp +++ b/src/utils/browserboxtools.cpp @@ -38,6 +38,7 @@ #include "resources/db/itemdb.h" #include "resources/db/mercenarydb.h" #include "resources/db/monsterdb.h" +#include "resources/db/questdb.h" #include "resources/db/petdb.h" #endif // DYECMD @@ -99,13 +100,18 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link) data = info->getName(); } else if (!link.empty() && link[0] == 'M') - { // homunculus link + { // mercenary link const BeingTypeId id = static_cast( atoi(link.substr(1).c_str())); BeingInfo *info = MercenaryDB::get(id); if (info) data = info->getName(); } + else if (!link.empty() && link[0] == 'q') + { // quest link + data = QuestDb::getName( + atoi(link.substr(1).c_str())); + } else { // item link size_t idx = link.find(','); -- cgit v1.2.3-70-g09d2