quest entries are added to main journal now

This commit is contained in:
Marc Zinnschlag 2011-04-21 11:05:49 +02:00
parent 792de880cf
commit f3fecdc627
3 changed files with 28 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#include "journal.hpp"
#include "../mwworld/environment.hpp"
#include <iostream>
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;
}

View file

@ -5,6 +5,8 @@
#include <components/esm_store/store.hpp>
#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<ESM::DialInfo>::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);
}
}

View file

@ -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);
};
}