2012-08-11 10:02:51 +00:00
|
|
|
#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
|
2012-08-09 08:35:53 +00:00
|
|
|
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
|
2010-08-06 16:01:34 +00:00
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
|
|
|
|
2012-11-10 13:31:58 +00:00
|
|
|
#include <map>
|
|
|
|
#include <list>
|
2010-08-06 16:01:34 +00:00
|
|
|
|
2012-02-18 11:19:42 +00:00
|
|
|
#include <components/compiler/streamerrorhandler.hpp>
|
2012-12-31 00:15:47 +00:00
|
|
|
#include <components/translation/translation.hpp>
|
2012-02-17 19:20:23 +00:00
|
|
|
|
2010-08-08 11:21:03 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2012-08-09 08:35:53 +00:00
|
|
|
|
2012-11-10 13:31:58 +00:00
|
|
|
#include "../mwscript/compilercontext.hpp"
|
2010-08-08 09:34:03 +00:00
|
|
|
|
2014-02-23 19:11:05 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct Dialogue;
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:16:44 +00:00
|
|
|
namespace MWDialogue
|
2010-08-06 16:01:34 +00:00
|
|
|
{
|
2012-08-09 08:35:53 +00:00
|
|
|
class DialogueManager : public MWBase::DialogueManager
|
2010-08-06 16:01:34 +00:00
|
|
|
{
|
2012-11-10 13:31:58 +00:00
|
|
|
std::map<std::string, ESM::Dialogue> mDialogueMap;
|
|
|
|
std::map<std::string, bool> mKnownTopics;// Those are the topics the player knows.
|
2014-05-27 12:54:29 +00:00
|
|
|
|
|
|
|
// Modified faction reactions. <Faction1, <Faction2, Difference> >
|
|
|
|
typedef std::map<std::string, std::map<std::string, int> > ModFactionReactionMap;
|
|
|
|
ModFactionReactionMap mModFactionReaction;
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
std::list<std::string> mActorKnownTopics;
|
2012-02-17 19:20:23 +00:00
|
|
|
|
2012-12-31 00:15:47 +00:00
|
|
|
Translation::Storage& mTranslationDataStorage;
|
2012-02-17 19:20:23 +00:00
|
|
|
MWScript::CompilerContext mCompilerContext;
|
2012-02-18 11:19:42 +00:00
|
|
|
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;
|
2012-11-10 12:31:10 +00:00
|
|
|
bool mTalkedTo;
|
2012-02-17 19:20:23 +00:00
|
|
|
|
2012-03-14 17:47:29 +00:00
|
|
|
int mChoice;
|
2014-06-10 14:36:22 +00:00
|
|
|
std::string mLastTopic; // last topic ID, lowercase
|
2012-03-16 16:30:59 +00:00
|
|
|
bool mIsInChoice;
|
2012-03-14 17:47:29 +00:00
|
|
|
|
2012-11-09 23:29:36 +00:00
|
|
|
float mTemporaryDispositionChange;
|
|
|
|
float mPermanentDispositionChange;
|
2012-11-13 14:35:46 +00:00
|
|
|
bool mScriptVerbose;
|
2012-11-09 23:29:36 +00:00
|
|
|
|
2012-11-10 13:31:58 +00:00
|
|
|
void parseText (const std::string& text);
|
|
|
|
|
|
|
|
void updateTopics();
|
2014-01-08 23:40:25 +00:00
|
|
|
void updateGlobals();
|
2012-11-10 13:31:58 +00:00
|
|
|
|
|
|
|
bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code);
|
|
|
|
void executeScript (const std::string& script);
|
|
|
|
|
2014-01-04 01:49:10 +00:00
|
|
|
void executeTopic (const std::string& topic);
|
2012-12-08 13:24:15 +00:00
|
|
|
|
2010-08-06 16:01:34 +00:00
|
|
|
public:
|
|
|
|
|
2012-12-31 00:15:47 +00:00
|
|
|
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, 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;
|
|
|
|
|
2012-08-09 08:35:53 +00:00
|
|
|
virtual void startDialogue (const MWWorld::Ptr& actor);
|
2010-08-06 16:01:34 +00:00
|
|
|
|
2012-08-09 08:35:53 +00:00
|
|
|
virtual void addTopic (const std::string& topic);
|
2012-02-10 15:09:43 +00:00
|
|
|
|
2012-08-09 08:35:53 +00:00
|
|
|
virtual void askQuestion (const std::string& question,int choice);
|
2012-03-07 17:44:09 +00:00
|
|
|
|
2012-08-09 08:35:53 +00:00
|
|
|
virtual void goodbye();
|
2012-05-11 05:18:41 +00:00
|
|
|
|
2013-03-16 19:32:21 +00:00
|
|
|
virtual bool checkServiceRefused ();
|
|
|
|
|
2013-07-24 17:02:50 +00:00
|
|
|
virtual void say(const MWWorld::Ptr &actor, const std::string &topic) const;
|
|
|
|
|
2012-02-05 11:25:23 +00:00
|
|
|
//calbacks for the GUI
|
2012-08-09 08:35:53 +00:00
|
|
|
virtual void keywordSelected (const std::string& keyword);
|
|
|
|
virtual void goodbyeSelected();
|
2013-05-04 12:15:47 +00:00
|
|
|
virtual void questionAnswered (int answer);
|
2012-02-05 11:25:23 +00:00
|
|
|
|
2012-11-09 23:29:36 +00:00
|
|
|
virtual void persuade (int type);
|
|
|
|
virtual int getTemporaryDispositionChange () const;
|
2014-05-31 11:57:07 +00:00
|
|
|
|
|
|
|
/// @note This change is temporary and gets discarded when dialogue ends.
|
2014-01-08 00:24:06 +00:00
|
|
|
virtual void applyDispositionChange (int delta);
|
2014-02-16 11:54:27 +00:00
|
|
|
|
|
|
|
virtual int countSavedGameRecords() const;
|
|
|
|
|
2014-04-28 09:29:57 +00:00
|
|
|
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
|
2014-02-16 11:54:27 +00:00
|
|
|
|
|
|
|
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
|
2014-05-27 12:54:29 +00:00
|
|
|
|
|
|
|
/// Changes faction1's opinion of faction2 by \a diff.
|
|
|
|
virtual void modFactionReaction (const std::string& faction1, const std::string& faction2, int diff);
|
|
|
|
|
|
|
|
/// @return faction1's opinion of faction2
|
|
|
|
virtual int getFactionReaction (const std::string& faction1, const std::string& faction2) const;
|
2014-06-10 14:36:22 +00:00
|
|
|
|
|
|
|
/// 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
|
|
|
};
|
2012-12-31 00:15:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct HyperTextToken
|
|
|
|
{
|
|
|
|
HyperTextToken(const std::string& text, bool link) : mText(text), mLink(link) {}
|
|
|
|
|
|
|
|
std::string mText;
|
|
|
|
bool mLink;
|
|
|
|
};
|
|
|
|
|
|
|
|
// In translations (at least Russian) the links are marked with @#, so
|
|
|
|
// it should be a function to parse it
|
|
|
|
std::vector<HyperTextToken> ParseHyperText(const std::string& text);
|
|
|
|
|
|
|
|
size_t RemovePseudoAsterisks(std::string& phrase);
|
2010-08-06 16:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|