diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index b1d85f729b..42cce5cf55 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -43,6 +43,21 @@ namespace MWDialogue quest.setIndex (index, *mEnvironment.mWorld); } + void Journal::addTopic (const std::string& topicId, const std::string& infoId) + { + TTopicContainer::iterator iter = mTopics.find (topicId); + + if (iter==mTopics.end()) + { + std::pair result + = mTopics.insert (std::make_pair (topicId, Topic (topicId))); + + iter = result.first; + } + + iter->second.addEntry (JournalEntry (topicId, infoId), *mEnvironment.mWorld); + } + int Journal::getJournalIndex (const std::string& id) const { return 0; @@ -67,4 +82,14 @@ namespace MWDialogue { return mQuests.end(); } + + Journal::TTopicIter Journal::topicBegin() const + { + return mTopics.begin(); + } + + Journal::TTopicIter Journal::topicEnd() const + { + return mTopics.end(); + } } diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index 5477ae5a53..ff1343945d 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -24,12 +24,15 @@ namespace MWDialogue typedef TEntryContainer::const_iterator TEntryIter; typedef std::map TQuestContainer; // topc, quest typedef TQuestContainer::const_iterator TQuestIter; + typedef std::map TTopicContainer; // topic-id, topic-content + typedef TTopicContainer::const_iterator TTopicIter; private: MWWorld::Environment& mEnvironment; TEntryContainer mJournal; TQuestContainer mQuests; + TTopicContainer mTopics; Quest& getQuest (const std::string& id); @@ -46,6 +49,8 @@ namespace MWDialogue int getJournalIndex (const std::string& id) const; ///< Get the journal index. + void addTopic (const std::string& topicId, const std::string& infoId); + TEntryIter begin() const; ///< Iterator pointing to the begin of the main journal. /// @@ -59,6 +64,14 @@ namespace MWDialogue TQuestIter questEnd() const; ///< Iterator pointing past the last quest. + + TTopicIter topicBegin() const; + ///< Iterator pointing to the first topic (sorted by topic ID) + /// + /// \note The topic ID is identical with the user-visible topic string. + + TTopicIter topicEnd() const; + ///< Iterator pointing past the last topic. }; }