From f3fecdc627d366f2a146a9f2961d989574c5529e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 21 Apr 2011 11:05:49 +0200 Subject: [PATCH] quest entries are added to main journal now --- apps/openmw/mwdialogue/journal.cpp | 2 ++ apps/openmw/mwdialogue/journalentry.cpp | 18 ++++++++++++++++++ apps/openmw/mwdialogue/journalentry.hpp | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 545e2f3ee4..8f84edabc8 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 8e3aeb93bb..6cfee7cf45 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 8506b9dbcf..f19e9c52c9 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); }; }