1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 06:39:49 +00:00
OpenMW/apps/openmw/mwdialogue/dialoguemanagerimp.hpp

120 lines
4.2 KiB
C++
Raw Normal View History

2012-08-11 10:02:51 +00:00
#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
2010-08-06 16:01:34 +00:00
#include "../mwbase/dialoguemanager.hpp"
2012-11-10 13:31:58 +00:00
#include <map>
#include <set>
2010-08-06 16:01:34 +00:00
#include <components/compiler/streamerrorhandler.hpp>
#include <components/translation/translation.hpp>
#include <components/misc/stringops.hpp>
2012-02-17 19:20:23 +00:00
2010-08-08 11:21:03 +00:00
#include "../mwworld/ptr.hpp"
2012-11-10 13:31:58 +00:00
#include "../mwscript/compilercontext.hpp"
2014-02-23 19:11:05 +00:00
namespace ESM
{
struct Dialogue;
}
namespace MWDialogue
2010-08-06 16:01:34 +00:00
{
class DialogueManager : public MWBase::DialogueManager
2010-08-06 16:01:34 +00:00
{
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::set<std::string, Misc::StringUtils::CiComp> mActorKnownTopics;
2012-02-17 19:20:23 +00:00
Translation::Storage& mTranslationDataStorage;
2012-02-17 19:20:23 +00:00
MWScript::CompilerContext mCompilerContext;
std::ostream mErrorStream;
Compiler::StreamErrorHandler mErrorHandler;
2012-12-08 13:24:15 +00:00
2012-02-17 19:20:23 +00:00
MWWorld::Ptr mActor;
bool mTalkedTo;
2012-02-17 19:20:23 +00:00
int mChoice;
std::string mLastTopic; // last topic ID, lowercase
bool mIsInChoice;
bool mGoodbye;
std::vector<std::pair<std::string, int> > mChoices;
2012-11-09 23:29:36 +00:00
float mTemporaryDispositionChange;
float mPermanentDispositionChange;
2012-11-10 13:31:58 +00:00
void parseText (const std::string& text);
void updateActorKnownTopics();
void updateGlobals();
2012-11-10 13:31:58 +00: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 13:31:58 +00:00
void executeTopic (const std::string& topic, ResponseCallback* callback);
2012-12-08 13:24:15 +00:00
const ESM::Dialogue* searchDialogue(const std::string& id);
2010-08-06 16:01:34 +00:00
public:
DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage);
2010-08-06 16:01:34 +00:00
2013-05-15 15:54:18 +00:00
virtual void clear();
2013-03-31 11:13:46 +00:00
virtual bool isInChoice() const;
virtual bool startDialogue (const MWWorld::Ptr& actor, ResponseCallback* callback);
std::list<std::string> getAvailableTopics();
2010-08-06 16:01:34 +00:00
virtual void addTopic (const std::string& topic);
2012-02-10 15:09:43 +00:00
virtual void addChoice (const std::string& text,int choice);
const std::vector<std::pair<std::string, int> >& getChoices();
virtual bool isGoodbye();
virtual void goodbye();
virtual bool checkServiceRefused (ResponseCallback* callback);
2013-03-16 19:32:21 +00:00
virtual void say(const MWWorld::Ptr &actor, const std::string &topic);
//calbacks for the GUI
virtual void keywordSelected (const std::string& keyword, ResponseCallback* callback);
virtual void goodbyeSelected();
virtual void questionAnswered (int answer, ResponseCallback* callback);
virtual void persuade (int type, ResponseCallback* callback);
2012-11-09 23:29:36 +00:00
virtual int getTemporaryDispositionChange () const;
/// @note This change is temporary and gets discarded when dialogue ends.
virtual void applyDispositionChange (int delta);
virtual int countSavedGameRecords() const;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
2015-01-22 18:04:59 +00:00
virtual void readRecord (ESM::ESMReader& reader, uint32_t type);
/// Changes faction1's opinion of faction2 by \a diff.
virtual void modFactionReaction (const std::string& faction1, const std::string& faction2, int diff);
virtual void setFactionReaction (const std::string& faction1, const std::string& faction2, int absolute);
/// @return faction1's opinion of faction2
virtual int getFactionReaction (const std::string& faction1, const std::string& faction2) const;
/// Removes the last added topic response for the given actor from the journal
virtual void clearInfoActor (const MWWorld::Ptr& actor) const;
2010-08-06 16:01:34 +00:00
};
}
#endif