OpenMW
|
00001 #ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H 00002 #define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H 00003 00004 #include "../mwbase/dialoguemanager.hpp" 00005 00006 #include <map> 00007 #include <list> 00008 00009 #include <components/compiler/streamerrorhandler.hpp> 00010 #include <components/translation/translation.hpp> 00011 00012 #include "../mwworld/ptr.hpp" 00013 00014 #include "../mwscript/compilercontext.hpp" 00015 00016 namespace MWDialogue 00017 { 00018 class DialogueManager : public MWBase::DialogueManager 00019 { 00020 std::map<std::string, ESM::Dialogue> mDialogueMap; 00021 std::map<std::string, bool> mKnownTopics;// Those are the topics the player knows. 00022 std::list<std::string> mActorKnownTopics; 00023 00024 Translation::Storage& mTranslationDataStorage; 00025 MWScript::CompilerContext mCompilerContext; 00026 std::ostream mErrorStream; 00027 Compiler::StreamErrorHandler mErrorHandler; 00028 00029 MWWorld::Ptr mActor; 00030 bool mTalkedTo; 00031 00032 int mChoice; 00033 std::string mLastTopic; 00034 bool mIsInChoice; 00035 00036 float mTemporaryDispositionChange; 00037 float mPermanentDispositionChange; 00038 bool mScriptVerbose; 00039 00040 void parseText (const std::string& text); 00041 00042 void updateTopics(); 00043 00044 bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code); 00045 void executeScript (const std::string& script); 00046 00047 void executeTopic (const std::string& topic, bool randomResponse=false); 00048 00049 public: 00050 00051 DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage); 00052 00053 virtual void clear(); 00054 00055 virtual bool isInChoice() const; 00056 00057 virtual void startDialogue (const MWWorld::Ptr& actor); 00058 00059 virtual void addTopic (const std::string& topic); 00060 00061 virtual void askQuestion (const std::string& question,int choice); 00062 00063 virtual void goodbye(); 00064 00065 virtual MWWorld::Ptr getActor() const; 00067 00068 virtual bool checkServiceRefused (); 00069 00070 virtual void say(const MWWorld::Ptr &actor, const std::string &topic) const; 00071 00072 //calbacks for the GUI 00073 virtual void keywordSelected (const std::string& keyword); 00074 virtual void goodbyeSelected(); 00075 virtual void questionAnswered (int answer); 00076 00077 virtual void persuade (int type); 00078 virtual int getTemporaryDispositionChange () const; 00079 virtual void applyTemporaryDispositionChange (int delta); 00080 }; 00081 00082 00083 struct HyperTextToken 00084 { 00085 HyperTextToken(const std::string& text, bool link) : mText(text), mLink(link) {} 00086 00087 std::string mText; 00088 bool mLink; 00089 }; 00090 00091 // In translations (at least Russian) the links are marked with @#, so 00092 // it should be a function to parse it 00093 std::vector<HyperTextToken> ParseHyperText(const std::string& text); 00094 00095 size_t RemovePseudoAsterisks(std::string& phrase); 00096 } 00097 00098 #endif