2012-08-11 12:02:51 +02:00
|
|
|
#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
|
2012-08-09 10:35:53 +02:00
|
|
|
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
|
2010-08-06 18:01:34 +02:00
|
|
|
|
2012-08-11 17:30:55 +02:00
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
|
|
|
|
2012-11-10 14:31:58 +01:00
|
|
|
#include <map>
|
2014-10-11 12:30:24 -05:00
|
|
|
#include <set>
|
2019-05-13 22:32:46 +02:00
|
|
|
#include <unordered_map>
|
2010-08-06 18:01:34 +02:00
|
|
|
|
2012-02-18 12:19:42 +01:00
|
|
|
#include <components/compiler/streamerrorhandler.hpp>
|
2012-12-31 04:15:47 +04:00
|
|
|
#include <components/translation/translation.hpp>
|
2017-10-22 19:06:47 +02:00
|
|
|
#include <components/misc/stringops.hpp>
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/loadinfo.hpp>
|
2012-02-17 20:20:23 +01:00
|
|
|
|
2010-08-08 13:21:03 +02:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2012-08-09 10:35:53 +02:00
|
|
|
|
2012-11-10 14:31:58 +01:00
|
|
|
#include "../mwscript/compilercontext.hpp"
|
2010-08-08 11:34:03 +02:00
|
|
|
|
2014-02-23 20:11:05 +01:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct Dialogue;
|
|
|
|
}
|
|
|
|
|
2010-08-06 19:16:44 +02:00
|
|
|
namespace MWDialogue
|
2010-08-06 18:01:34 +02:00
|
|
|
{
|
2012-08-09 10:35:53 +02:00
|
|
|
class DialogueManager : public MWBase::DialogueManager
|
2010-08-06 18:01:34 +02:00
|
|
|
{
|
2021-12-02 08:04:29 +00:00
|
|
|
struct ActorKnownTopicInfo
|
|
|
|
{
|
|
|
|
int mFlags;
|
|
|
|
const ESM::DialInfo* mInfo;
|
|
|
|
};
|
|
|
|
|
2017-10-22 19:06:47 +02:00
|
|
|
std::set<std::string, Misc::StringUtils::CiComp> mKnownTopics;// Those are the topics the player knows.
|
2014-05-27 14:54:29 +02:00
|
|
|
|
|
|
|
// Modified faction reactions. <Faction1, <Faction2, Difference> >
|
|
|
|
typedef std::map<std::string, std::map<std::string, int> > ModFactionReactionMap;
|
2015-01-19 23:55:17 +01:00
|
|
|
ModFactionReactionMap mChangedFactionReaction;
|
2014-05-27 14:54:29 +02:00
|
|
|
|
2021-12-02 08:04:29 +00:00
|
|
|
std::map<std::string, ActorKnownTopicInfo, Misc::StringUtils::CiComp> mActorKnownTopics;
|
2012-02-17 20:20:23 +01:00
|
|
|
|
2012-12-31 04:15:47 +04:00
|
|
|
Translation::Storage& mTranslationDataStorage;
|
2012-02-17 20:20:23 +01:00
|
|
|
MWScript::CompilerContext mCompilerContext;
|
2012-02-18 12:19:42 +01:00
|
|
|
Compiler::StreamErrorHandler mErrorHandler;
|
2012-12-08 14:24:15 +01:00
|
|
|
|
2012-02-17 20:20:23 +01:00
|
|
|
MWWorld::Ptr mActor;
|
2012-11-10 13:31:10 +01:00
|
|
|
bool mTalkedTo;
|
2012-02-17 20:20:23 +01:00
|
|
|
|
2012-03-14 18:47:29 +01:00
|
|
|
int mChoice;
|
2014-06-10 16:36:22 +02:00
|
|
|
std::string mLastTopic; // last topic ID, lowercase
|
2012-03-16 17:30:59 +01:00
|
|
|
bool mIsInChoice;
|
2017-09-25 21:38:38 +02:00
|
|
|
bool mGoodbye;
|
|
|
|
|
|
|
|
std::vector<std::pair<std::string, int> > mChoices;
|
2012-03-14 18:47:29 +01:00
|
|
|
|
2021-06-24 22:02:52 +02:00
|
|
|
int mOriginalDisposition;
|
|
|
|
int mCurrentDisposition;
|
|
|
|
int mPermanentDispositionChange;
|
2012-11-10 00:29:36 +01:00
|
|
|
|
2021-12-02 08:04:29 +00:00
|
|
|
std::vector<std::string> parseTopicIdsFromText (const std::string& text);
|
|
|
|
void addTopicsFromText (const std::string& text);
|
2012-11-10 14:31:58 +01:00
|
|
|
|
2017-09-25 21:38:38 +02:00
|
|
|
void updateActorKnownTopics();
|
2014-01-09 00:40:25 +01:00
|
|
|
void updateGlobals();
|
2012-11-10 14:31:58 +01:00
|
|
|
|
2017-04-21 03:55:28 +09:00
|
|
|
bool compile (const std::string& cmd, std::vector<Interpreter::Type_Code>& code, const MWWorld::Ptr& actor);
|
|
|
|
void executeScript (const std::string& script, const MWWorld::Ptr& actor);
|
2012-11-10 14:31:58 +01:00
|
|
|
|
2017-10-24 00:25:41 +02:00
|
|
|
void executeTopic (const std::string& topic, ResponseCallback* callback);
|
2012-12-08 14:24:15 +01:00
|
|
|
|
2017-09-25 18:50:24 +02:00
|
|
|
const ESM::Dialogue* searchDialogue(const std::string& id);
|
|
|
|
|
2021-06-24 22:02:52 +02:00
|
|
|
void updateOriginalDisposition();
|
|
|
|
|
2010-08-06 18:01:34 +02:00
|
|
|
public:
|
|
|
|
|
2017-02-20 21:09:15 +01:00
|
|
|
DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage);
|
2010-08-06 18:01:34 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void clear() override;
|
2013-05-15 17:54:18 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool isInChoice() const override;
|
2013-03-31 13:13:46 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool startDialogue (const MWWorld::Ptr& actor, ResponseCallback* callback) override;
|
2017-09-25 21:38:38 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
std::list<std::string> getAvailableTopics() override;
|
2020-10-22 23:57:53 +02:00
|
|
|
int getTopicFlag(const std::string& topicId) override;
|
2019-05-13 22:32:46 +02:00
|
|
|
|
2020-10-22 23:57:53 +02:00
|
|
|
bool inJournal (const std::string& topicId, const std::string& infoId) override;
|
2010-08-06 18:01:34 +02:00
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
void addTopic(std::string_view topic) override;
|
2012-02-10 16:09:43 +01:00
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
void addChoice(std::string_view text,int choice) override;
|
2020-10-16 22:18:54 +04:00
|
|
|
const std::vector<std::pair<std::string, int> >& getChoices() override;
|
2017-09-25 21:38:38 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool isGoodbye() override;
|
2012-03-07 18:44:09 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void goodbye() override;
|
2012-05-11 07:18:41 +02:00
|
|
|
|
2020-08-21 17:18:39 +04:00
|
|
|
bool checkServiceRefused (ResponseCallback* callback, ServiceType service = ServiceType::Any) override;
|
2013-03-16 20:32:21 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void say(const MWWorld::Ptr &actor, const std::string &topic) override;
|
2013-07-24 10:02:50 -07:00
|
|
|
|
2012-02-05 12:25:23 +01:00
|
|
|
//calbacks for the GUI
|
2020-10-16 22:18:54 +04:00
|
|
|
void keywordSelected (const std::string& keyword, ResponseCallback* callback) override;
|
|
|
|
void goodbyeSelected() override;
|
|
|
|
void questionAnswered (int answer, ResponseCallback* callback) override;
|
2012-02-05 12:25:23 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void persuade (int type, ResponseCallback* callback) override;
|
2014-05-31 13:57:07 +02:00
|
|
|
|
2018-08-01 17:31:35 +03:00
|
|
|
/// @note Controlled by an option, gets discarded when dialogue ends by default
|
2020-10-16 22:18:54 +04:00
|
|
|
void applyBarterDispositionChange (int delta) override;
|
2014-02-16 12:54:27 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
int countSavedGameRecords() const override;
|
2014-02-16 12:54:27 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const override;
|
2014-02-16 12:54:27 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void readRecord (ESM::ESMReader& reader, uint32_t type) override;
|
2014-05-27 14:54:29 +02:00
|
|
|
|
|
|
|
/// Changes faction1's opinion of faction2 by \a diff.
|
2022-05-21 01:21:55 +02:00
|
|
|
void modFactionReaction (std::string_view faction1, std::string_view faction2, int diff) override;
|
2014-05-27 14:54:29 +02:00
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
void setFactionReaction (std::string_view faction1, std::string_view faction2, int absolute) override;
|
2015-01-19 23:55:17 +01:00
|
|
|
|
2014-05-27 14:54:29 +02:00
|
|
|
/// @return faction1's opinion of faction2
|
2022-05-21 01:21:55 +02:00
|
|
|
int getFactionReaction (std::string_view faction1, std::string_view faction2) const override;
|
2014-06-10 16:36:22 +02:00
|
|
|
|
|
|
|
/// Removes the last added topic response for the given actor from the journal
|
2020-10-16 22:18:54 +04:00
|
|
|
void clearInfoActor (const MWWorld::Ptr& actor) const override;
|
2010-08-06 18:01:34 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|