diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 545e2f3ee..8f84edabc 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -1,6 +1,7 @@ #include "journal.hpp" +#include "../mwworld/environment.hpp" #include namespace MWDialogue @@ -11,6 +12,7 @@ namespace MWDialogue void Journal::addEntry (const std::string& id, int index) { + mJournal.push_back (JournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); std::cout << "journal: " << id << " at " << index << std::endl; } diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 8e3aeb93b..6cfee7cf4 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -5,6 +5,8 @@ #include +#include "../mwworld/world.hpp" + namespace MWDialogue { JournalEntry::JournalEntry() {} @@ -24,4 +26,20 @@ namespace MWDialogue throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); } + + JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index, + const MWWorld::World& world) + { + const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic); + + for (std::vector::const_iterator iter (dialogue->mInfo.begin()); + iter!=dialogue->mInfo.end(); ++iter) + if (iter->data.disposition==index) /// \todo cleanup info structure + { + int day = world.getGlobalVariable ("dayspassed").mLong; + return JournalEntry (day, topic, iter->id); + } + + throw std::runtime_error ("unknown journal index for topic " + topic); + } } diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index 8506b9dbc..f19e9c52c 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -8,6 +8,11 @@ namespace ESMS struct ESMStore; } +namespace MWWorld +{ + class World; +} + namespace MWDialogue { /// \brief a quest or dialogue entry with a timestamp @@ -22,6 +27,9 @@ namespace MWDialogue JournalEntry (int day, const std::string& topic, const std::string& infoId); std::string getText (const ESMS::ESMStore& store) const; + + static JournalEntry makeFromQuest (const std::string& topic, int index, + const MWWorld::World& world); }; }