only decline offered quests if the player explicitly pressed the decline button
This commit is contained in:
parent
da8e6d1aa8
commit
4458d2e85e
@ -293,7 +293,7 @@ void QuestPane::commonSetup(Json config, String bodyText, String const& portrait
|
|||||||
GuiReader reader;
|
GuiReader reader;
|
||||||
|
|
||||||
reader.registerCallback("close", [=](Widget*) { close(); });
|
reader.registerCallback("close", [=](Widget*) { close(); });
|
||||||
reader.registerCallback("btnDecline", [=](Widget*) { close(); });
|
reader.registerCallback("btnDecline", [=](Widget*) { decline(); });
|
||||||
reader.registerCallback("btnAccept", [=](Widget*) { accept(); });
|
reader.registerCallback("btnAccept", [=](Widget*) { accept(); });
|
||||||
reader.construct(config.get("paneLayout"), this);
|
reader.construct(config.get("paneLayout"), this);
|
||||||
|
|
||||||
@ -330,6 +330,10 @@ void QuestPane::close() {
|
|||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuestPane::decline() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
void QuestPane::accept() {
|
void QuestPane::accept() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@ -348,7 +352,7 @@ PanePtr QuestPane::createTooltip(Vec2I const& screenPosition) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NewQuestInterface::NewQuestInterface(QuestManagerPtr const& manager, QuestPtr const& quest, PlayerPtr player)
|
NewQuestInterface::NewQuestInterface(QuestManagerPtr const& manager, QuestPtr const& quest, PlayerPtr player)
|
||||||
: QuestPane(quest, std::move(player)), m_manager(manager), m_declined(false) {
|
: QuestPane(quest, std::move(player)), m_manager(manager), m_decision(QuestDecision::Cancelled) {
|
||||||
auto assets = Root::singleton().assets();
|
auto assets = Root::singleton().assets();
|
||||||
|
|
||||||
List<Drawable> objectivePortrait = m_quest->portrait("Objective").value({});
|
List<Drawable> objectivePortrait = m_quest->portrait("Objective").value({});
|
||||||
@ -364,8 +368,7 @@ NewQuestInterface::NewQuestInterface(QuestManagerPtr const& manager, QuestPtr co
|
|||||||
|
|
||||||
commonSetup(config, m_quest->text(), "QuestStarted");
|
commonSetup(config, m_quest->text(), "QuestStarted");
|
||||||
|
|
||||||
m_declined = m_quest->canBeAbandoned();
|
if (!m_quest->canBeAbandoned()) {
|
||||||
if (!m_declined) {
|
|
||||||
if (auto declineButton = fetchChild<ButtonWidget>("btnDecline"))
|
if (auto declineButton = fetchChild<ButtonWidget>("btnDecline"))
|
||||||
declineButton->disable();
|
declineButton->disable();
|
||||||
}
|
}
|
||||||
@ -392,21 +395,28 @@ NewQuestInterface::NewQuestInterface(QuestManagerPtr const& manager, QuestPtr co
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NewQuestInterface::close() {
|
void NewQuestInterface::close() {
|
||||||
m_declined = true;
|
m_decision = QuestDecision::Cancelled;
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewQuestInterface::decline() {
|
||||||
|
m_decision = QuestDecision::Declined;
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewQuestInterface::accept() {
|
void NewQuestInterface::accept() {
|
||||||
m_declined = false;
|
m_decision = QuestDecision::Accepted;
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewQuestInterface::dismissed() {
|
void NewQuestInterface::dismissed() {
|
||||||
QuestPane::dismissed();
|
QuestPane::dismissed();
|
||||||
if (m_declined && m_quest->canBeAbandoned()) {
|
if (m_decision == QuestDecision::Declined && m_quest->canBeAbandoned()) {
|
||||||
m_manager->getQuest(m_quest->questId())->declineOffer();
|
m_manager->getQuest(m_quest->questId())->declineOffer();
|
||||||
} else {
|
} else if (m_decision == QuestDecision::Accepted) {
|
||||||
m_manager->getQuest(m_quest->questId())->start();
|
m_manager->getQuest(m_quest->questId())->start();
|
||||||
|
} else {
|
||||||
|
m_manager->getQuest(m_quest->questId())->cancelOffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ protected:
|
|||||||
|
|
||||||
void commonSetup(Json config, String bodyText, String const& portraitName);
|
void commonSetup(Json config, String bodyText, String const& portraitName);
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
virtual void decline();
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
virtual PanePtr createTooltip(Vec2I const& screenPosition) override;
|
virtual PanePtr createTooltip(Vec2I const& screenPosition) override;
|
||||||
|
|
||||||
@ -60,16 +61,23 @@ protected:
|
|||||||
|
|
||||||
class NewQuestInterface : public QuestPane {
|
class NewQuestInterface : public QuestPane {
|
||||||
public:
|
public:
|
||||||
|
enum class QuestDecision {
|
||||||
|
Declined,
|
||||||
|
Accepted,
|
||||||
|
Cancelled
|
||||||
|
};
|
||||||
|
|
||||||
NewQuestInterface(QuestManagerPtr const& manager, QuestPtr const& quest, PlayerPtr player);
|
NewQuestInterface(QuestManagerPtr const& manager, QuestPtr const& quest, PlayerPtr player);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void close() override;
|
void close() override;
|
||||||
|
void decline() override;
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void dismissed() override;
|
void dismissed() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QuestManagerPtr m_manager;
|
QuestManagerPtr m_manager;
|
||||||
bool m_declined;
|
QuestDecision m_decision;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QuestCompleteInterface : public QuestPane {
|
class QuestCompleteInterface : public QuestPane {
|
||||||
|
@ -240,6 +240,12 @@ void Quest::declineOffer() {
|
|||||||
uninitScript();
|
uninitScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Quest::cancelOffer() {
|
||||||
|
setState(QuestState::New);
|
||||||
|
m_scriptComponent.invoke("questCancel");
|
||||||
|
uninitScript();
|
||||||
|
}
|
||||||
|
|
||||||
void Quest::start() {
|
void Quest::start() {
|
||||||
setState(QuestState::Active);
|
setState(QuestState::Active);
|
||||||
initScript();
|
initScript();
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
|
|
||||||
void offer();
|
void offer();
|
||||||
void declineOffer();
|
void declineOffer();
|
||||||
|
void cancelOffer();
|
||||||
void start();
|
void start();
|
||||||
void complete(Maybe<size_t> followupIndex = {});
|
void complete(Maybe<size_t> followupIndex = {});
|
||||||
void fail();
|
void fail();
|
||||||
|
Loading…
Reference in New Issue
Block a user