1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-18 13:12:50 +00:00
OpenMW/apps/openmw/mwdialogue/dialoguemanagerimp.hpp

133 lines
4.7 KiB
C++
Raw Normal View History

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