summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-09 00:05:38 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-09 00:05:38 +0300
commitb28730a1ecf54cd50b09e5e93dfb454fc46c2300 (patch)
tree4fd9c679b026eea8c05c308a04187852b5199200 /src/gui
parent86cb4a51351b8217ede6672703a1b39b91ddb572 (diff)
downloadplus-b28730a1ecf54cd50b09e5e93dfb454fc46c2300.tar.gz
plus-b28730a1ecf54cd50b09e5e93dfb454fc46c2300.tar.bz2
plus-b28730a1ecf54cd50b09e5e93dfb454fc46c2300.tar.xz
plus-b28730a1ecf54cd50b09e5e93dfb454fc46c2300.zip
Open quest in quests window if quest link was clicked.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp12
-rw-r--r--src/gui/windows/questswindow.cpp19
-rw-r--r--src/gui/windows/questswindow.h3
3 files changed, 32 insertions, 2 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 983129a3f..b2e4a89c9 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -34,6 +34,7 @@
#include "gui/windows/confirmdialog.h"
#include "gui/windows/helpwindow.h"
+#include "gui/windows/questswindow.h"
#include "input/inputmanager.h"
@@ -178,11 +179,14 @@ void ItemLinkHandler::handleSearchLink(const std::string &link)
void ItemLinkHandler::handleLink(const std::string &link,
MouseEvent *const event)
{
+ if (link.empty())
+ return;
+
if (strStartWith(link, "http://") || strStartWith(link, "https://"))
{
handleHttpLink(link, event);
}
- else if (!link.empty() && link[0] == '?')
+ else if (link[0] == '?')
{
handleSearchLink(link);
}
@@ -203,10 +207,14 @@ void ItemLinkHandler::handleLink(const std::string &link,
if (helpWindow)
helpWindow->loadHelpSimple("news");
}
- if (link == "copyright")
+ else if (link == "copyright")
{
inputManager.executeAction(InputAction::WINDOW_ABOUT);
}
+ else if (link[0] == 'q')
+ {
+ questsWindow->selectQuest(atoi(link.substr(1).c_str()));
+ }
else
{
handleItemLink(link);
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index ab204d1f8..5ffb2fc2f 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -142,6 +142,7 @@ QuestsWindow::~QuestsWindow()
delete2(mItemLinkHandler);
mQuestLinks.clear();
+ mQuestReverseLinks.clear();
if (mCompleteIcon)
{
mCompleteIcon->decRef();
@@ -183,6 +184,7 @@ void QuestsWindow::rebuild(const bool playSound)
{
mQuestsModel->clear();
mQuestLinks.clear();
+ mQuestReverseLinks.clear();
StringVect &names = mQuestsModel->getNames();
std::vector<Image*> &images = mQuestsModel->getImages();
std::vector<QuestItem*> complete;
@@ -234,6 +236,7 @@ void QuestsWindow::rebuild(const bool playSound)
}
quest->completeFlag = 1;
mQuestLinks.push_back(quest);
+ mQuestReverseLinks[quest->var] = k;
names.push_back(quest->name);
if (mCompleteIcon)
{
@@ -257,6 +260,7 @@ void QuestsWindow::rebuild(const bool playSound)
}
quest->completeFlag = 0;
mQuestLinks.push_back(quest);
+ mQuestReverseLinks[quest->var] = k;
names.push_back(quest->name);
if (mIncompleteIcon)
{
@@ -460,3 +464,18 @@ void QuestsWindow::addEffect(Being *const being)
being->addSpecialEffect(effect->effectId);
}
}
+
+void QuestsWindow::selectQuest(const int varId)
+{
+ std::map<int, int>::const_iterator it = mQuestReverseLinks.find(varId);
+ if (it == mQuestReverseLinks.end())
+ return;
+ if (mVisible == Visible_false)
+ setVisible(Visible_true);
+ const int listPos = (*it).second;
+ if (listPos < 0)
+ return;
+ showQuest(mQuestLinks[listPos]);
+ mQuestsListBox->setSelected(listPos);
+ requestMoveToTop();
+}
diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h
index dd3464fae..f4f00f429 100644
--- a/src/gui/windows/questswindow.h
+++ b/src/gui/windows/questswindow.h
@@ -76,6 +76,8 @@ class QuestsWindow final : public Window,
void addEffect(Being *const being);
+ void selectQuest(const int varId);
+
private:
QuestsModel *mQuestsModel A_NONNULLPOINTER;
ExtendedListBox *mQuestsListBox A_NONNULLPOINTER;
@@ -94,6 +96,7 @@ class QuestsWindow final : public Window,
// npc effects for current map and values: npc, effect
NpcQuestEffectMap mNpcEffects;
std::vector<QuestItem*> mQuestLinks;
+ std::map<int, int> mQuestReverseLinks;
int mNewQuestEffectId;
int mCompleteQuestEffectId;
const Map *mMap;